========================================================================================
Modifikations for Muxxi:
========================================================================================
Here are all modifications to mpeg2lib, to
1. Get the aspectratio (int) for each decoded frame


File gethdr.c

Replace these lines:
	static char *AspectRatio[5] = {
		"", "1 : 1", "4 : 3", "16 : 9", "2.21 : 1"
	};

With these lines:
	//2004-10-24: Changed to get all possible values (ISO/IEC 13818-2)
	static char *AspectRatio[16] = {
		"res.", "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", "res.", "res."
	};


========================================================================================
File mpeg2lib.h:

struct TVideoFrameInfo {
  int Width, Height;
  double FrameRate;
  int AspectRatio; //2004-10-24: Added to get the aspectratio
};


========================================================================================
File mpeg2lib.cpp:

DLLExport(void) GetMPEG2FrameInfo(TVideoFrameInfo *FrameInfo)
{
  FrameInfo->Width = Coded_Picture_Width;
  FrameInfo->Height = Coded_Picture_Height;
  FrameInfo->FrameRate = frame_rate;
  FrameInfo->AspectRatio= aspect_ratio_information; //2004-10-24: Added to get the aspectratio
}




========================================================================================
Modifikations for MPEG2Schnitt:
========================================================================================
Here are all modifications to mpeg2lib, to ensure that
1. The first frame isn't skipped
2. All frames until the very last at the end can be read
3. The last frame can be read even if it is an I-frame
4. Even a file consisting of just a single I-frame can be read

File DVD2AVI\getbit.c:
in function void Fill_Buffer()

Replace these lines:
	Read = DirectFileRead(VideoFile, Rdbfr, BUFFER_SIZE);
	if (Read < BUFFER_SIZE)
		Next_File();

	if (KeyOp_Flag && (Rdbfr[20] & 0x10))

With these lines:
	Read = DirectFileRead(VideoFile, Rdbfr, BUFFER_SIZE);

	// Mpegschnitt: causes error at end of file, so last ~2 frames not decoded
//	if (Read < BUFFER_SIZE)
//		Next_File();

	if (Read <= 0)
		Next_File();

	if (Read < BUFFER_SIZE)
		memset(Rdbfr+Read,0,BUFFER_SIZE-Read);

	// End Mpegschnitt modifications

	if (KeyOp_Flag && (Rdbfr[20] & 0x10))

========================================================================================
File mpeg2lib.cpp:

After this line:
class EStopPlaying { };

Add this line:
int GetIframe=0;  // Get first frame without advancing pointer!
========================================================================================
File mpeg2lib.cpp:
In function OpenMPEG2File

After this line:
  PrepareDecoder();

Add this line:
  GetIframe=1;
========================================================================================
File mpeg2lib.cpp:
In function OpenMPEG2Disk

After this line:
  PrepareDecoder();

Add this line:
  GetIframe=1;
========================================================================================
File mpeg2lib.cpp:         // note: this ensures that existing programs using this dll work without modifications
In function GetMPEG2FileInfo

Replace this line:
  FileInfo->Frame = Frame_Number;

With this line:
  FileInfo->Frame = Frame_Number+1;
========================================================================================
File mpeg2lib.cpp:
Replace the entire function GetMPEG2Frame

with this one:
DLLExport(pbyte) GetMPEG2Frame()
{
  try {
	  if (GetIframe==1) {
          Write_Frame(backward_reference_frame, d2v_backward, 0);
		  GetIframe=0;
		  try {
			//first P-frame decoding
			while (Get_Hdr() && picture_coding_type==B_TYPE);
			Decode_Picture();
		  } catch(EStopPlaying) { }; // catch end of file exception
          return FrameBuffer;
	  }
	  if(Get_Hdr())
	  {
		  Decode_Picture();
	      return FrameBuffer;
	  }
  }
  catch(EStopPlaying) {
	// No more data -> use last P or I frame!
	if (backward_reference_frame) {
      Write_Frame(backward_reference_frame, d2v_backward, 0);
      return FrameBuffer;
	}
  }
  return NULL;
}
========================================================================================
File mpeg2lib.cpp:
Replace the entire function SkipMPEG2Frames

with this one:

DLLExport(void) SkipMPEG2Frames(int FrameCount)
{
  int Format = Store_Flag;

  if (FrameCount<=0) return;

  if (GetIframe==1) {
      //first P-frame decoding
	  while (Get_Hdr() && picture_coding_type==B_TYPE);
	  Decode_Picture();

	  GetIframe=0;
	  FrameCount--;
  }

  Store_Flag = PixelFormatNone;
  try {
    while(FrameCount-- && Get_Hdr())
          Decode_Picture();
  }
  catch(EStopPlaying) { }
  Store_Flag = Format;
}
========================================================================================
File mpeg2lib.cpp:
In function MPEG2Seek

After this line:
	process.locate = LOCATE_RIP;

Add this line:
	GetIframe=1;
========================================================================================
File mpeg2dec.c:
In function MPEG2Dec

Replace these lines:
	while (Get_Hdr() && picture_coding_type==B_TYPE);

	Decode_Picture();

With these lines:
	// Moved to mpeg2lib.cpp, otherwise the LAST I-Frame cannot
	// be read if the file ends with an I-Frame
========================================================================================

