Log in

View Full Version : Parse IFO - size of streams in MB


quantum
1st September 2003, 04:13
I can parse an IFO in VB and list the PGCs, but how can I determine how much space in MB the video and audio streams take?

CMatt
4th September 2003, 10:48
Only over the ifo-parsing u can't determine it.
Take a look into the VTSI_MAT table. There is a list with all audio attributes in the track. Now calculate the Substream-ID over this attributes:

// coding_mode u find in the ifo table
// audio_idx is the index of the stream (0 for Aud_1, 1 for Aud_2,..)
int DecodeAudioStreamID(unsigned short coding_mode, const int audio_idx)
{
static unsigned int stream_ofs[] = {0xbd80, 0x0000, 0xc000, 0xc800, 0xbda0, 0xbd88, 0xbd88};
if ((stream_ofs[coding_mode & 7] & 0xff) != 0)
return audio_idx + (stream_ofs[coding_mode & 7] & 0xff);
else
return audio_idx + (stream_ofs[coding_mode & 7] >> 8);
return 0;
}


Now open ur vob files and search the first pack from every of this stream (normaly u can find the offset to the first packs in the navigation-pack at the start of the vob). Next step is to parse the bitrate.
For ac3:

// AC3
static short ac3_bitrates[] = {
32, 32, 40, 40, 48, 48, 56, 56, 64,
64, 80, 80, 96, 96, 112, 112, 128,
128, 160, 160, 192, 192, 224, 224,
256, 256, 320, 320, 384, 384, 448,
448, 512, 512, 576, 576, 640, 640 };

long ac3_rate()
{
short snynch_word = _get_short();
int CRC = _get_short();
char br_code = _get_byte();
if(br_code > 37) return 0;
return ac3_bitrates[br_code];
}

for DTS:

// DTS
static short dts_bitrates[] = {
32, 56, 64, 96, 112, 128, 192, 224, 256, 320,
384, 448, 512, 576, 640, 768, 896, 1024, 1152,
1280, 1344, 1408, 11411, 1472, 1536, 1920, 2048,
3072, 3840, 4096 };

long dts_rate()
{
unsigned char c[10];
for(int i=0;i<10;i++)
c[i] = _get_byte();
int i_bit_rate = (c[8] & 0x03) << 3 | ((c[9] >> 5) & 0x07);
return dts_bitrates[i_bit_rate];
}

for MPEG:

static short mpeg_v1_bitrates[3][16] = {
{0,32,64,96,128,160,192,224,256,288,
320,352,384,416,448,-1},
{0,32,48,56,64,80,96,112,128,160,
192,224,256,320,384,-1},
{0,32,40,48,56,64,80,96,112,128,
160,192,224,256,320,-1}};

static short mpeg_v2_bitrates[3][16] = {
{0,32,48,56,64,80,96,112,128,144,
160,176,192,224,256,-1},
{0,8,16,24,32,40,48,56,64,80,
96,112,128,144,160,-1},
{0,8,16,24,32,40,48,56,64,80,
96,112,128,144,160,-1}};

long mpeg_rate()
{
unsigned char snynch = _get_byte();
unsigned char Layer_version = _get_byte();
unsigned char layer = (Layer_version&0x06)>>1;
unsigned char version_ID = (Layer_version&0x1200)>>3;
char version=0;
switch(version_ID)
{
case 0:
case 2:
version = 2;
case 3:
version = 1;
}
unsigned char rate_code = _get_byte();
rate_code = (rate_code&0xFFFF0000)>>4;
int bitrate=0;
if(version==1)
bitrate = mpeg_v1_bitrates[layer][rate_code];
if(version==2)
bitrate = mpeg_v2_bitrates[layer][rate_code];
return bitrate;
}


For LPCM i have no code.. maybe u can post it if u find something.
The read-commands in this function start with the first byte of the frame, NOT THE PACK! U have to filter out first the PES-header.

The rest should be clear now ;)
U have the bitrate from every audio stream, u have the PGC-tables wich says u wich audio-streams are used and for how long.
Bitrate/playtime = size

i hope my infos helps u..
btw. sorry for the C code, but in never typed a single VB line in my life :D