
 X - a free Java based demux utility
 Copyright (C) 2001-2003 dvb.matt

 It is intended for educational purposes only, as a non-commercial test project.
 It may not be used otherwise. Most parts are only experimental.
 
/==============================================================================/

 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

/==============================================================================/

 This program is completely designed as a test, therefore it mostly 
 implement its own code instead of a derivation of an ISO reference 
 source or any other code. Considerable effort has been expended to 
 ensure an useful implementation, even in cases where the standards 
 are ambiguous or misleading.
 Do not expect any useful output from it, even if that may possible.
 
 For a program compliant to the international standards ISO 11172
 and ISO 13818 it is inevitable to use methods covered by patents
 in various countries. The authors of this program disclaim any
 liability for patent infringement caused by using, modifying or
 redistributing this program.

/==============================================================================/

 This program is provided in sourcecode form only, 
 because it is meant for educational purposes.
 Binaries will not be included.
 
 If you need an executable, you have to compile the package by yourself, 
 or you ask someone to do so for you.
 For compilation, you need a Java SDK, which is available for various platforms.

 All classes should work with Sun's JDK/J2RE 1.2.2 and higher. 

 Extract all files from the received archive to a separate directory.
 the archive contains:

	ac3.bin	- copy to the same place as your compiled version of X
	COPYING
	readme.txt

	src/..
	AUDIO.java
	AudioFrameConstants.java
	BR_MONITOR.java
	D2V.java
	HEXVIEWER.java
	LOGAREA.java
	MPAC.java
	MPAD.java
	MPVD.java
	RIFFHEADER.java
	SCAN.java
	SUBPICTURE.java
	TELETEXT.java
	TS.java
	UISwitchListener.java
	VIDEO.java
	X.java
	MANIFEST.MF	- manifest

	(A) compile the sources:
		your_extract_path/src> [location_of_javac]javac [-O] *.java

	(B) create an .jar archive:
		your_extract_path/src> [location_of_jar]jar cfvm <new archive_name.jar> MANIFEST.MF *.class

	Note:	the .jar archive shall only contain the .class files without any path
		plus the manifest in  META-INF\MANIFEST.MF

	(C) execute the <new archive_name.jar>

	the compiling process doesn't take more than about 30 seconds.

/==============================================================================/

CREDITS

    -  thanx to all the people, who gave hints, files and other things
       to the discontinued "father" of X.
  

/===============================================================================/



history:

--------------------------------------------------------------------------------
- 24.08.2003 X0.81.2 (enhancement)                                    dvb.matt -
--------------------------------------------------------------------------------

show expected export filesize in cut dialog 
   restrictions: 
      - byte pos. cut only
      - secondary streams, ignored IDs/PIDs and streamtype (PES<->ES) may cause different sizes as expected

X.java
internal class COLLECTION
(a)subclass CutListener, method actionPerformed(), line ~2414
(b)method entry(), line ~2750
(c)method loadlist(), line ~2874


change a,b,c to:

getExpectedSize(); //DM24082003 //pointscount.setText(""+comBox[14].getItemCount());


(d)add method getExpectedSize() to this inner class, e.g. line ~2880

//DM24082003+
public void getExpectedSize() {
	//DM24082003+ add fix 081.2a 
	if (previewList.size()==0){ 
		pointscount.setText(""+comBox[14].getItemCount()); 
		return; 
	} 
	//DM24082003- 
	long newSize[] = new long[comBox[14].getItemCount()];
	long start=0, diff=0, end;
	for (int a=0; a<newSize.length; a++)
		newSize[a] = Long.parseLong(comBox[14].getItemAt(a).toString());
	if (newSize.length==0 || (newSize.length&1)==1)
		end = ((long[]) (( (Object[])previewList.get(previewList.size()-1) )[1]) )[1];
	else
		end = newSize[newSize.length-1];

	for (int a=0; a<newSize.length; a+=2){
		diff += newSize[a]-start;
		start = a+1<newSize.length ? newSize[a+1] : start;
	}
	String length = comBox[17].getSelectedIndex()==0 ? (" / exp.Size: "+((end-diff)/1048576L)+"MB") : "";
	pointscount.setText(""+comBox[14].getItemCount() + length);
}
//DM24082003-

-------------------------------------------------------------------------------- 
- 24.08.2003 X0.81.2 (enhancement 2)                                  TheHorse - 
-------------------------------------------------------------------------------- 

Preview slider keyboard key

With shift: 1/10 from >>/<< 
with strg: equal to >>/<< 
with alt: 10x >>/<< 

X.java 
internal class COLLECTION line ~2339 

KeyListener S_keyListener = new KeyAdapter() { 
   public void keyPressed(KeyEvent e) {    
      int offs=1; 
      int keyval=e.getKeyCode(); 
      if (e.isShiftDown()) 
         offs=31250; 
      else if (e.isControlDown()) 
         offs=312500; 
      else if (e.isAltDown()) 
         offs=3125000; 
      if (keyval==KeyEvent.VK_RIGHT) 
         search.setValue(search.getValue()+offs); 
      else if (keyval==KeyEvent.VK_LEFT) 
         search.setValue(search.getValue()-offs); 
      if(keyval != KeyEvent.VK_PAGE_UP && keyval != KeyEvent.VK_PAGE_DOWN) 
         e.setKeyCode(0); 
   } 
}; 
search.addKeyListener(S_keyListener); 

--------------------------------------------------------------------------------
- 16.08.2003 X0.81.1 (Fix 1)                                          dvb.matt -
--------------------------------------------------------------------------------

@fix:
# extendend look-up for usable data in unscrambled marked TS-packets (bad flags in recordings)
# to enable:
- you have to fill the PID list manually with the wanted (but still ignored) PID numbers
# each 'bad' start_packet will be logged

deu:
# manche TS Dateien enthalten wohl verschlsselte Daten obwohl diese als nicht-verschlsselt gekennzeichnet sind.
# bei manueller bernahme der ignorierten PIDs in die PID Liste wird hiermit nun nicht 'abgebrochen' sondern weiterhin nach einem offenen Startcode gesucht.


@X.java
@internal class: WORK
@method: rawparse(), line: ~5939

Code:

	...
	type+=" (0x"+Long.toHexString(count-188).toUpperCase()+" #"+packet+") ";  //pos + packno
	Msg("--> PID 0x"+Integer.toHexString(pid).toUpperCase()+" "+type+" -> ignored");
	//DM16082003+ fix 081.1  //*** replacement
	if (abc.size()==0 || type.indexOf("pay")==-1)
		TSPid.setneeded(false);
	else
		TSPid.setID(-1);
	//DM16082003-
	continue pvaloop;
	...

--------------------------------------------------------------------------------
- 15.08.2003 X081 release                                             dvb.matt -
--------------------------------------------------------------------------------

minor changes in descriptions of buttons etc.
all known fixes (1-5) and extensions (made by java.lang) are implemented
.idd export function now available for all input videotypes

--------------------------------------------------------------------------------
- 14.08.2003                                               extension java.lang -
--------------------------------------------------------------------------------

patch horizontal resolution of the 1st sequence header:
conditional patching added, you can now specify:

  -never, 
  -ever ,
  -if <> 720 or 352
  -if <> 720 or 704 or 352

this feature is useful if you're using dvd-authoring progs like TMPGEncDVDAuthor.

--------------------------------------------------------------------------------
- 06.08.2003                                               extension java.lang -
--------------------------------------------------------------------------------

Modififications are done to export a file readable by the program
Mpeg2Schnitt@Martin Dienert (prog version 0.5, idd-format version 2).
These modifications are are surrounded by inline comments i.E. JLA+ JLA-.
Short usage: select checkbox "Mpeg2Schnitt" in the d2v pane if you want an *.idd file.
known restrictions:

  - file splitting/cutting not implemented yet
  - only a few tests are done
  - works only in demux mode (rawparse)

--------------------------------------------------------------------------------
- ??.08.2003                                             Suggestion / notFix 5 -
--------------------------------------------------------------------------------

@X.java
@method logAlias(), line ~11477

@suggestion: message log if the following nonVideo stream cannot handled by its own PTS data (because it's missing)

	...
	log.close();
	Msg("--> using faked PTS in following data"); // *** add
	}
	...

--------------------------------------------------------------------------------
- 23.07.2003                                                             Fix 4 -
--------------------------------------------------------------------------------

@AUDIO.java
@class: AUDIO
@method: ---, line: ~302

@fix: exception while parsing bad/wrong AC3-frames (bad index)

	int ac3_bitrate_index[] =  {
	...
	320000,384000,448000,512000,576000,640000,
	// 0,0 // *** change to:
	0,0,0,0,0,0,0,0,0,0,0,0,0  // *** new; arraysize should be 0x20
	};

--------------------------------------------------------------------------------
- 29.07.2003                                                            Fix 3a -
--------------------------------------------------------------------------------

@MPVD.java
@internal class: Picture
@method: Add_Block(), line: ~2133, ~2145

@fix: remove a little bit more cross coloured speckles in preview

	if (cc==1){
	...
	g = g<0 ? 0 : (g>255 ? 255 : g); // replacement of  g = (g<0) ? 0 : (0xFF&g);
	b = b<0 ? 0 : (b>255 ? 255 : b); // replacement of  b = (b<0) ? 0 : (0xFF&b);
	...
	}else if (cc==2){
	...
	r = r<0 ? 0 : (r>255 ? 255 : r); // replacement of  r = (r<0) ? 0 : (0xFF&r);
	g = g<0 ? 0 : (g>255 ? 255 : g); // replacement of  g = (g<0) ? 0 : (0xFF&g);
	...
	}

--------------------------------------------------------------------------------
- 20.07.2003                                                             Fix 3 -
--------------------------------------------------------------------------------

@MPVD.java
@internal class: Picture
@method: Add_Block(), line: ~2125++

@fix: remove cross coloured speckles in preview

	if (cc==1){
	for (int y=0;y<16;y++)
	for (int x=0;x<16;x++){
	val = chroma[x+(y*16)];
	luma = pixels[(bx<<1)+x+(((by<<1)+y)*horizontal_size)];
	r = (0xFF&luma>>>16);
	// g = (0xFF&luma>>>8); //*** removed
	// b = (0xFF&luma); // *** removed
	g = (int)((double)(0xFF&luma>>>8) -0.34414*val); // *** changed
	b = (int)((double)(0xFF&luma) +1.722*val); // *** changed
	g = (g<0) ? 0 : (0xFF&g); // *** added
	b = (b<0) ? 0 : (0xFF&b); // *** added
	pixels[(bx<<1)+x+(((by<<1)+y)*horizontal_size)] = r<<16|g<<8|b;
	}
	}else if (cc==2){
	for (int y=0;y<16;y++)
	for (int x=0;x<16;x++){
	val = chroma[x+(y*16)];
	luma = pixels[(bx<<1)+x+(((by<<1)+y)*horizontal_size)];
	b = (0xFF&luma);
	// r = (0xFF&luma>>>16); // *** removed
	// g = (0xFF&luma>>>8); // *** removed
	r = (int)((double)(0xFF&luma>>>16) +1.402*val); // *** changed
	g = (int)((double)(0xFF&luma>>>8) -0.71414*val); // *** changed
	r = (r<0) ? 0 : (0xFF&r); // *** added
	g = (g<0) ? 0 : (0xFF&g); // *** added
	pixels[(bx<<1)+x+(((by<<1)+y)*horizontal_size)] = r<<16|g<<8|b;
	}
	}

--------------------------------------------------------------------------------
- 19.07.2003                                                             Fix 2 -
--------------------------------------------------------------------------------

@X.java
@internal class: WORK
@method: vdrparse(), line: ~5014
@method: rawparse(), line: ~5616
@method: pvaparse(), line: ~6445

@fix: enabled cut- and split- pointer didn't work properly in case of more than 2 inputfiles

	if (startPoint < 0)
	...
	else if (startPoint < count){
	...
	}
	else if (startPoint > count){
	// for (int a=1; a < starts.length; a++){   *** old
	for (int a=FileNumber+1; a < starts.length; a++){  // *** new
	if (starts[a] > startPoint)
	break;
	else
	FileNumber++;
	}
	}

--------------------------------------------------------------------------------
- 19.07.2003                                                             Fix 1 -
--------------------------------------------------------------------------------

@X.java
@internal class: PREVIEW
@method: load(), line: ~2146

@fix: preview didn't jump properly among fileborders in case of more than 2 inputfiles

	for (int a=0;a<previewList.size();a++){
	...
	if (startposition < end){
	...
	if (end-startposition < size && a<previewList.size()-1){
	...
	// }else  *** old
	} // *** new
	break;
	}
	}

--------------------------------------------------------------------------------

0.80  12.07.2003
# collection specials
 + GUI re-arranged, preview scaled to 256*192 
 + load/save external file for cutpoints
# Fix byteposition cut:
 + did not jump effective just to the file before the first cut-in, in case of more than 2 inputfiles
# coming: estimated play time
 + ATM: shows only time of ES MPA/AC3
# preview:
 + in addition to the slider: backward/forward knobs
# now shows the progress percentage in frametitle / taskbar
# new CL-option:
 + load cutpoint list in textform: "-p <file:pointlist>" , interpreted as choosen in the cut type menu (collection specials, p17)

-----------

# Fix TS:
 + stuffing packets (Pid 0x1FFF) will be ignored
 + PMT quickinfo in filemenu: shows the Pids, def. as user private data (0x80..) e.g. AC3 bei NBC(HDTV)
# preview:
 + search for sequenceheader in 2,5MB
 + info while processing/ if error
# ac3.bin
 + silent AC3 2/0 DS 384kbps frame added
# AC3
 + now supports lower bitrates (32..80kbps)
 + extended Loginfos

----------

# collection specials:
 + no more extra pre-skipping (use first cut-in point of "use bytepos. for cuts" instead)
 + global: create a subdirectory for each collection for output files
 + fix preview: NTSC (and other Resol.) should work, (MPEG1 has no Preview)
 + preview + bytepos.-cut works for multiple infiles of the same type (VDR,PVA,MPEG2PS,TS)
# no limitations at output-split, multiple infiles and overlap-output
# mpa decoder:
 + output motorola byte order
 + disable RIFF headers (-> raw PCM, do not have the 2/4GB limitation)
 + downmix to mono
 + split stereo: set in the "conversion" menu
 + amplify by factor

-----------

# collection specials:
 + open with doubleclick (l/r)
# new: preview (i-frame) window for mpeg2 types (PVA,VDR,MPEG2-PS/ES,TS)  (colortype MPEG4:2:0)
 + due to performance, simple scaled to QCIF-resol.
 + "ins" removed -> automatic sort if adding
 + demux only: cut using byteposition (gop aligned) (PVA,VDR,MPEG12,TS)
 + define points with slider or cursors (gop-aligned), "add" oder "del" a point
 + jump to point, if a point is selected from pointlist
 + symbols:   (same info for frame-/gop-number cut)
  * export gop: green arrow
  * ignore gop: red square
# MPA decoder: 
 + now supports MPEG-2.5 layer1,2 (emphasis bit1 detection)
 + resample 48khz to 44.1 or 32khz (linear interpolation)

------------

# collection specials: 
 + context menu (specialsmenu,sendto,add,remove)
# TTX:
 + UT-SUP Hint: do not use odd Pointsizes (bad entry in RLE-Interlace)
# cut hint: 
 + first video cut-in shall not be placed to far from start, if used "PES-Video" with "ES-Audio"
# Fix: patch to interlace/progressive Exception
# neu: video2: 
 + add Sequenceheader to GOPs without
 + GOP-Graph: if a Sequenceheaders exists: a yellow rectangle is shown left to the first cyan I-Frame
# TTX: 
 + 2nd SUP Yoffset per job (alternate UT (e.g. special zoom position)
 + example: one UT-File ("24;8;32;110;520;720;576;-1") , two UT-Files ("24;8;32;110;520;720;576;96")  -> Y 96
# TTX: 
 + Paritycheck (if failed, replaced by "graphic black"/ space), 
# new: 
 + (demux) limit Video-Export to special H-Resolutions
 + cut-Settings re-arranged in "coll. specials" dialog
# CellTimes.txt: 
 + entry also for cut-in points
# Audio: 
 + decode MPEG1+2 Layer1+2 to WAV (std is stereo-pcm output)
# Audio: 
 + "discard every xxx frame", 

------------

# PVA:
 + Fix: crash on process start
 + check for discontinuity in PVA-packs
# TS:
 + shows "useful" PIDs with leading "ok>"
 + pressing "i" fills the pidlist with the useful Pids, if it wasn't empty.
# VDR/MPG: 
 + search area f. VideoPES(packsize0) increased
# TTX: 
 + change chars f. country-code2:  '','' zu '','' (nordisch Ling.., not verified..)
 + decode up to 6 pages per Streamfile and job
 + Fix: if ttx StartPTS arrive later as first VideoPTS, no page were decoded
 + UT-SUP: empty lines will not exported
# GUI - bitrate monitor: 
 + GOPs with more than 15, instead of "..." now a red "Overflow" is set.
# new: PVA/VDR/MPG/TS: 
 + create CellTimes.txt entry on multiple Inputfiles ( Clips) 
  (except: "concatenate diff. recs. " is OFF in case of VDR/PVA )
# GUI: 
 + new: support Drag&Drop, D&D move+copy ( <-  Filenamelist)
 + drop Files into "main" Coll.-area or on all tabs rider
 + D&D-Copymode (hold Ctrl) creates a new coll. for each selected file as with "+<"
# Hint: 
 + d2v file may not suit with NTSC sources
