⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mpvd.java

📁 优秀的MPEG2-TS流分析软件
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */

/*
 * Disclaimer of Warranty
 *
 * These software programs are available to the user without any license fee or
 * royalty on an "as is" basis.  The MPEG Software Simulation Group disclaims
 * any and all warranties, whether express, implied, or statuary, including any
 * implied warranties or merchantability or of fitness for a particular
 * purpose.  In no event shall the copyright-holder be liable for any
 * incidental, punitive, or consequential damages of any kind whatsoever
 * arising from the use of these programs.
 *
 * This disclaimer of warranty extends to the user of these programs and user's
 * customers, employees, agents, transferees, successors, and assigns.
 *
 * The MPEG Software Simulation Group does not represent or warrant that the
 * programs furnished hereunder are free of infringement of any third-party
 * patents.
 *
 * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware,
 * are subject to royalty fees to patent holders.  Many of these patents are
 * general enough such that they are unavoidable regardless of implementation
 * design.
 *
 */


/*
 * @(#)MPVD.java - still Picture Decoder
 * 
 * Copyright (c) 2003-2005 by dvb.matt, All Rights Reserved. 
 *
 * This file is part of X, a free Java based demux utility.
 * X is intended for educational purposes only, as a non-commercial test project.
 * It may not be used otherwise. Most parts are only experimental.
 * 
 * necessary codes are derived from the MSSG mpeg2dec
 *
 * display modifications: shows I-Frames only
 * 
 *
 * This program is free software; you can redistribute it free of charge
 * and/or modify it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

package net.sourceforge.dvb.projectx.video;


import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.MemoryImageSource;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;

import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;

import net.sourceforge.dvb.projectx.common.Resource;
import net.sourceforge.dvb.projectx.common.X;



public class MPVD extends JFrame {

	public static Picture picture;

	public MPVD()
	{
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		});

		picture = new Picture();
		getContentPane().add("Center", picture);

		setSize(new Dimension(256 + 10, 232 + 30));
		setLocation(100, 100);
		setVisible(false);
	}


public class Picture extends JPanel {

	public Picture()
	{
		//DM08022004 081.6 int16 changed and new
		java.util.Arrays.fill(pixels2, 0xFF505050); //DM24042004 081.7 int02 changed
		source = new MemoryImageSource(512, 288, pixels2, 0, 512); //DM02092004 081.7 int02 changed
		source.setAnimated(true);
		image = createImage(source);

		setBackground(Color.black);
		setVisible(true);

		chooser = new JFileChooser();
		setToolTipText(tooltip1); // <- VORSCHLAG 1 Tooltip! 

		//DM02092003+
		addMouseListener(new MouseAdapter() {
			public void mouseClicked(MouseEvent e) {
				if (e.getClickCount() > 1)
					saveBMP(false,false);
			}
		});
		//DM02092003-

		idct = new IDCTRefNative();
		idctsse = new IDCTSseNative();

		if (IDCTRefNative.isLibraryLoaded())
			idct.init();

		if (IDCTRefNative.isLibraryLoaded() || IDCTSseNative.isLibraryLoaded())
			acceleration = true;
	}

	public boolean isAccelerated()
	{
		return acceleration;
	}

private IDCTRefNative idct;
private IDCTSseNative idctsse;
private boolean acceleration = false;


private JFileChooser chooser;  //DM02092003
private int bmpCount=0; //DM02092003
private int pixels2[] = new int[512 * 288]; //DM02092004 081.7 int02 changed
private Image image;
private MemoryImageSource source;
private boolean FAST=false;
private final String tooltip1 = Resource.getString("mpvdecoder.tip1");

//DM27042004 081.7 int02 add
private long cutfiles_length = 0;
private long cutfiles_points[] = null;
private String info_4 = "";
private String info_3 = "";
private String info_2 = "";
private String info_1 = "";

private String file="";
private int Fault_Flag=0;
private boolean[] Bits=new boolean[0];
private byte[] buf=new byte[0];
private int BitPos=0;
private int BufferPos=0;
private int pixels[] = new int[250];
private boolean PLAY=true, DIRECTION=false, ERROR1=false, ERROR2=false;
private long StartPos=0;
private int SequenceHeader=0; //DM28112003 081.5++
public boolean viewGOP=true;

final int PICTURE_START_CODE=0x100;
final int SLICE_START_CODE_MIN=0x101;
final int SLICE_START_CODE_MAX=0x1AF;
final int USER_DATA_START_CODE=0x1B2;
final int SEQUENCE_HEADER_CODE=0x1B3;
final int EXTENSION_START_CODE=0x1B5;
final int SEQUENCE_END_CODE=0x1B7;
final int GROUP_START_CODE=0x1B8;
final int SYSTEM_END_CODE=0x1B9;
final int PACK_START_CODE=0x1BA;
final int SYSTEM_START_CODE=0x1BB;

private int File_Flag;
private int File_Limit;
private int FO_Flag;
private int IDCT_Flag;
private int Luminance_Flag;
private int Scale_Flag;
private int SystemStream_Flag;
private int ERROR_CODE=0;
private int ERROR_CODE1=0;

/* extension start code IDs */
final int SEQUENCE_EXTENSION_ID=1;
final int SEQUENCE_DISPLAY_EXTENSION_ID=2;
final int QUANT_MATRIX_EXTENSION_ID=3;
final int COPYRIGHT_EXTENSION_ID=4;
final int PICTURE_DISPLAY_EXTENSION_ID=7;
final int PICTURE_CODING_EXTENSION_ID=8;
final int ZIG_ZAG=0;
final int MB_WEIGHT=32;
final int MB_CLASS4=64;
final int MC_FIELD=1;
final int MC_FRAME=2;
final int MC_16X8=2;
final int MC_DMV=3;
final int MV_FIELD=0;
final int MV_FRAME=1;
final int I_TYPE=1;
final int P_TYPE=2;
final int B_TYPE=3;
final int TOP_FIELD=1;
final int BOTTOM_FIELD=2;
final int FRAME_PICTURE=3;
final int MACROBLOCK_INTRA=1;
final int MACROBLOCK_PATTERN=2;
final int MACROBLOCK_MOTION_BACKWARD=4;
final int MACROBLOCK_MOTION_FORWARD=8;
final int MACROBLOCK_QUANT=16;
final int CHROMA420=1;
final int CHROMA422=2;
final int CHROMA444=3;
final int IDCT_CLIP_TABLE_OFFSET=512;

private int q_scale_type=0;  //1
private int quantizer_scale=0, alternate_scan=0;//1
private int Coded_Picture_Width=0, Coded_Picture_Height=0, Chroma_Width=0, Chroma_Height=0;
private int block_count=0, Second_Field=0;
private int horizontal_size=0, vertical_size=0, mb_width=0, mb_height=0;

/* ISO/IEC 13818-2 section 6.2.2.1:  sequence_header() */
private int frame_rate_code=0;
private int aspect_ratio_information=0;

/* ISO/IEC 13818-2 section 6.2.2.3:  sequence_extension() */
private int progressive_sequence=1;  //prog.s std 
private int chroma_format=1;  //4:2:0std 
private int profile_and_level_indication;
private int video_format;
private String video_format_S[] = { "comp","PAL","NTSC","SECAM","MAC","unspec","res","res" };
private String prof[] = { "res","HP","SS","SNR","MP","SP","res","res" };
private String lev[] = { "res","res","res","res","HL","res","HL1440","res","ML","res","LL","res","res","res","res" };

/* ISO/IEC 13818-2 section 6.2.3: picture_header() */
private int picture_coding_type=0;
private int temporal_reference=0;

/* ISO/IEC 13818-2 section 6.2.3.1: picture_coding_extension() header */
private int f_code[][] = new int[2][2];
private int picture_structure=3;  //0
private int frame_pred_frame_dct=1; //0
private int progressive_frame=1;  //0
private int concealment_motion_vectors=0;
private int intra_dc_precision=0; //8bit
private int top_field_first=0;
private int repeat_first_field=0;
private int intra_vlc_format=0; //

private int intra_quantizer_matrix[] = new int[64];
private int non_intra_quantizer_matrix[] = new int[64];
private int chroma_intra_quantizer_matrix[] = new int[64];
private int chroma_non_intra_quantizer_matrix[] = new int[64];
  
private int load_intra_quantizer_matrix=0;
private int load_non_intra_quantizer_matrix=0;
private int load_chroma_intra_quantizer_matrix=0;
private int load_chroma_non_intra_quantizer_matrix=0;

private short block[][]=new short[12][64]; //macroblocks

final String picture_coding_type_string[] = {
	"bad","I","P","B","D"
};

final String progressive_string[] = {
	"i","p"
};

final String aspect_ratio_string[] = {
	"bad","(1:1)","(4:3)","(16:9)","(2.21:1)","(0.8055)","(0.8437)","(0.9375)","(0.9815)","(1.0255)","(1.0695)","(1.1250)","(1.1575)","(1.2015)"
};

/* cosine transform matrix for 8x1 IDCT */
final float ref_dct_matrix[][] = {
	{    /* [0][0-7] */
		 3.5355339059327379e-001f,  3.5355339059327379e-001f,
		 3.5355339059327379e-001f,  3.5355339059327379e-001f,
		 3.5355339059327379e-001f,  3.5355339059327379e-001f,
		 3.5355339059327379e-001f,  3.5355339059327379e-001f,
	}, { /* [1][0-7] */
		 4.9039264020161522e-001f,  4.1573480615127262e-001f,
		 2.7778511650980114e-001f,  9.7545161008064166e-002f,
		-9.7545161008064096e-002f, -2.7778511650980098e-001f,
		-4.1573480615127267e-001f, -4.9039264020161522e-001f,
	}, { /* [2][0-7] */
		 4.6193976625564337e-001f,  1.9134171618254492e-001f,
		-1.9134171618254486e-001f, -4.6193976625564337e-001f,
		-4.6193976625564342e-001f, -1.9134171618254517e-001f,
		 1.9134171618254500e-001f,  4.6193976625564326e-001f,
	}, { /* [3][0-7] */
		 4.1573480615127262e-001f, -9.7545161008064096e-002f,
		-4.9039264020161522e-001f, -2.7778511650980109e-001f,
		 2.7778511650980092e-001f,  4.9039264020161522e-001f,
		 9.7545161008064388e-002f, -4.1573480615127256e-001f,
	}, { /* [4][0-7] */
		 3.5355339059327379e-001f, -3.5355339059327373e-001f,
		-3.5355339059327384e-001f,  3.5355339059327368e-001f,
		 3.5355339059327384e-001f, -3.5355339059327334e-001f,
		-3.5355339059327356e-001f,  3.5355339059327329e-001f,
	}, { /* [5][0-7] */
		 2.7778511650980114e-001f, -4.9039264020161522e-001f,
		 9.7545161008064152e-002f,  4.1573480615127273e-001f,
		-4.1573480615127256e-001f, -9.7545161008064013e-002f,
		 4.9039264020161533e-001f, -2.7778511650980076e-001f,
	}, { /* [6][0-7] */
		 1.9134171618254492e-001f, -4.6193976625564342e-001f,
		 4.6193976625564326e-001f, -1.9134171618254495e-001f,
		-1.9134171618254528e-001f,  4.6193976625564337e-001f,
		-4.6193976625564320e-001f,  1.9134171618254478e-001f,
	}, { /* [7][0-7] */
		 9.7545161008064166e-002f, -2.7778511650980109e-001f,
		 4.1573480615127273e-001f, -4.9039264020161533e-001f,
		 4.9039264020161522e-001f, -4.1573480615127251e-001f,
		 2.7778511650980076e-001f, -9.7545161008064291e-002f,
	},
};

final short idct_clip_table[] = {
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-256,-256,-256,-256,-256,-256,-256,
	-256,-255,-254,-253,-252,-251,-250,-249,
	-248,-247,-246,-245,-244,-243,-242,-241,
	-240,-239,-238,-237,-236,-235,-234,-233,
	-232,-231,-230,-229,-228,-227,-226,-225,
	-224,-223,-222,-221,-220,-219,-218,-217,
	-216,-215,-214,-213,-212,-211,-210,-209,
	-208,-207,-206,-205,-204,-203,-202,-201,
	-200,-199,-198,-197,-196,-195,-194,-193,
	-192,-191,-190,-189,-188,-187,-186,-185,
	-184,-183,-182,-181,-180,-179,-178,-177,
	-176,-175,-174,-173,-172,-171,-170,-169,
	-168,-167,-166,-165,-164,-163,-162,-161,
	-160,-159,-158,-157,-156,-155,-154,-153,
	-152,-151,-150,-149,-148,-147,-146,-145,
	-144,-143,-142,-141,-140,-139,-138,-137,
	-136,-135,-134,-133,-132,-131,-130,-129,
	-128,-127,-126,-125,-124,-123,-122,-121,
	-120,-119,-118,-117,-116,-115,-114,-113,
	-112,-111,-110,-109,-108,-107,-106,-105,
	-104,-103,-102,-101,-100, -99, -98, -97,
	 -96, -95, -94, -93, -92, -91, -90, -89,
	 -88, -87, -86, -85, -84, -83, -82, -81,
	 -80, -79, -78, -77, -76, -75, -74, -73,
	 -72, -71, -70, -69, -68, -67, -66, -65,
	 -64, -63, -62, -61, -60, -59, -58, -57,
	 -56, -55, -54, -53, -52, -51, -50, -49,
	 -48, -47, -46, -45, -44, -43, -42, -41,
	 -40, -39, -38, -37, -36, -35, -34, -33,
	 -32, -31, -30, -29, -28, -27, -26, -25,
	 -24, -23, -22, -21, -20, -19, -18, -17,
	 -16, -15, -14, -13, -12, -11, -10,  -9,
	  -8,  -7,  -6,  -5,  -4,  -3,  -2,  -1,
	   0,   1,   2,   3,   4,   5,   6,   7,
	   8,   9,  10,  11,  12,  13,  14,  15,
	  16,  17,  18,  19,  20,  21,  22,  23,
	  24,  25,  26,  27,  28,  29,  30,  31,
	  32,  33,  34,  35,  36,  37,  38,  39,
	  40,  41,  42,  43,  44,  45,  46,  47,
	  48,  49,  50,  51,  52,  53,  54,  55,
	  56,  57,  58,  59,  60,  61,  62,  63,
	  64,  65,  66,  67,  68,  69,  70,  71,
	  72,  73,  74,  75,  76,  77,  78,  79,
	  80,  81,  82,  83,  84,  85,  86,  87,
	  88,  89,  90,  91,  92,  93,  94,  95,
	  96,  97,  98,  99, 100, 101, 102, 103,
	 104, 105, 106, 107, 108, 109, 110, 111,
	 112, 113, 114, 115, 116, 117, 118, 119,
	 120, 121, 122, 123, 124, 125, 126, 127,
	 128, 129, 130, 131, 132, 133, 134, 135,
	 136, 137, 138, 139, 140, 141, 142, 143,
	 144, 145, 146, 147, 148, 149, 150, 151,
	 152, 153, 154, 155, 156, 157, 158, 159,
	 160, 161, 162, 163, 164, 165, 166, 167,
	 168, 169, 170, 171, 172, 173, 174, 175,
	 176, 177, 178, 179, 180, 181, 182, 183,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -