* ogg.c : ogg stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: ogg.c,v 1.13 2002/11/26 17:38:33 gbazin Exp $
+ * $Id: ogg.c,v 1.19 2003/01/29 12:59:23 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
if( p_stream->i_fourcc == VLC_FOURCC( 't','a','r','k' ) )
{
/* FIXME: the biggest hack I've ever done */
- msg_Warn( p_input, "tark pts: %lli, granule: %i",
+ msg_Warn( p_input, "tark pts: "I64Fd", granule: "I64Fd,
p_pes->i_pts, p_pes->i_dts );
msleep(10000);
}
p_stream->f_rate = oggpack_read( &opb, 32 );
oggpack_adv( &opb, 32 );
p_stream->i_bitrate = oggpack_read( &opb, 32 );
+ {
+ char title[sizeof("Stream") + 10];
+ input_info_category_t *p_cat;
+ sprintf( title, "Stream %d", p_ogg->i_streams );
+ p_cat = input_InfoCategory( p_input, title );
+ input_AddInfo( p_cat, "Type", "Audio" );
+ input_AddInfo( p_cat, "Codec", "vorbis" );
+ input_AddInfo( p_cat, "Sample Rate", "%f",
+ p_stream->f_rate );
+ input_AddInfo( p_cat, "Bit Rate", "%d",
+ p_stream->i_bitrate );
+ }
}
/* Check for Theora header */
else if( oggpacket.bytes >= 7 &&
msg_Dbg( p_input,
"found theora header, bitrate: %i, rate: %f",
p_stream->i_bitrate, p_stream->f_rate );
+ {
+ char title[sizeof("Stream") + 10];
+ input_info_category_t *p_cat;
+ sprintf( title, "Stream %d", p_ogg->i_streams );
+ p_cat = input_InfoCategory( p_input, title );
+ input_AddInfo( p_cat, "Type", "Video" );
+ input_AddInfo( p_cat, "Codec", "theora" );
+ input_AddInfo( p_cat, "Frame Rate", "%f",
+ p_stream->f_rate );
+ input_AddInfo( p_cat, "Bit Rate", "%d",
+ p_stream->i_bitrate );
+ }
#else /* HAVE_OGGPACKB */
msg_Dbg( p_input, "the ogg demuxer has been compiled "
"without support for the oggpackB extension."
msg_Dbg( p_input,
"found tarkin header, bitrate: %i, rate: %f",
p_stream->i_bitrate, p_stream->f_rate );
+ {
+ char title[sizeof("Stream") + 10];
+ input_info_category_t *p_cat;
+ sprintf( title, "Stream %d", p_ogg->i_streams );
+ p_cat = input_InfoCategory( p_input, title );
+ input_AddInfo( p_cat, "Type", "Video" );
+ input_AddInfo( p_cat, "Codec", "tarkin" );
+ input_AddInfo( p_cat, "Sample Rate", "%f",
+ p_stream->f_rate );
+ input_AddInfo( p_cat, "Bit Rate", "%d",
+ p_stream->i_bitrate );
+ }
+
+ }
+ else if( oggpacket.bytes >= 142 &&
+ !strncmp( &oggpacket.packet[1],
+ "Direct Show Samples embedded in Ogg", 35 ))
+ {
+ /* Old header type */
+
+ /* Check for video header (old format) */
+ if( GetDWLE((oggpacket.packet+96)) == 0x05589f80 &&
+ oggpacket.bytes >= 184 )
+ {
+ p_stream->i_cat = VIDEO_ES;
+
+ p_stream->p_bih = (BITMAPINFOHEADER *)
+ malloc( sizeof(BITMAPINFOHEADER) );
+ if( !p_stream->p_bih )
+ {
+ /* Mem allocation error, just ignore the stream */
+ free( p_stream );
+ p_ogg->i_streams--;
+ continue;
+ }
+ p_stream->p_bih->biSize = sizeof(BITMAPINFOHEADER);
+ p_stream->p_bih->biCompression= p_stream->i_fourcc =
+ VLC_FOURCC( oggpacket.packet[68],
+ oggpacket.packet[69],
+ oggpacket.packet[70],
+ oggpacket.packet[71] );
+ msg_Dbg( p_input, "found video header of type: %.4s",
+ (char *)&p_stream->i_fourcc );
+
+ p_stream->f_rate = 10000000.0 /
+ GetQWLE((oggpacket.packet+164));
+ p_stream->p_bih->biBitCount =
+ GetWLE((oggpacket.packet+182));
+ if( !p_stream->p_bih->biBitCount )
+ p_stream->p_bih->biBitCount=24; // hack, FIXME
+ p_stream->p_bih->biWidth =
+ GetDWLE((oggpacket.packet+176));
+ p_stream->p_bih->biHeight =
+ GetDWLE((oggpacket.packet+180));
+ p_stream->p_bih->biPlanes= 1 ;
+ p_stream->p_bih->biSizeImage =
+ (p_stream->p_bih->biBitCount >> 3) *
+ p_stream->p_bih->biWidth *
+ p_stream->p_bih->biHeight;
+
+ msg_Dbg( p_input,
+ "fps: %f, width:%i; height:%i, bitcount:%i",
+ p_stream->f_rate, p_stream->p_bih->biWidth,
+ p_stream->p_bih->biHeight,
+ p_stream->p_bih->biBitCount);
+ {
+ char title[sizeof("Stream") + 10];
+ input_info_category_t *p_cat;
+ sprintf( title, "Stream %d", p_ogg->i_streams );
+ p_cat = input_InfoCategory( p_input, title );
+ input_AddInfo( p_cat, "Type", "Video" );
+ input_AddInfo( p_cat, "Codec", "%.4s",
+ (char *)&p_stream->i_fourcc );
+ input_AddInfo( p_cat, "Frame Rate", "%f",
+ p_stream->f_rate );
+ input_AddInfo( p_cat, "Bit Count", "%d",
+ p_stream->p_bih->biBitCount );
+ input_AddInfo( p_cat, "Width", "%d",
+ p_stream->p_bih->biWidth );
+ input_AddInfo( p_cat, "Height", "%d",
+ p_stream->p_bih->biHeight );
+ }
+ p_stream->i_bitrate = 0;
+ }
+ /* Check for audio header (old format) */
+ else if( GetDWLE((oggpacket.packet+96)) == 0x05589F81 )
+ {
+ unsigned int i_extra_size;
+
+ p_stream->i_cat = AUDIO_ES;
+
+ i_extra_size = GetWLE((oggpacket.packet+140));
+
+ p_stream->p_wf = (WAVEFORMATEX *)
+ malloc( sizeof(WAVEFORMATEX) + i_extra_size );
+ if( !p_stream->p_wf )
+ {
+ /* Mem allocation error, just ignore the stream */
+ free( p_stream );
+ p_ogg->i_streams--;
+ continue;
+ }
+
+ p_stream->p_wf->wFormatTag =
+ GetWLE((oggpacket.packet+124));
+ p_stream->p_wf->nChannels =
+ GetWLE((oggpacket.packet+126));
+ p_stream->f_rate = p_stream->p_wf->nSamplesPerSec =
+ GetDWLE((oggpacket.packet+128));
+ p_stream->i_bitrate = p_stream->p_wf->nAvgBytesPerSec =
+ GetDWLE((oggpacket.packet+132));
+ p_stream->i_bitrate *= 8;
+ p_stream->p_wf->nBlockAlign =
+ GetWLE((oggpacket.packet+136));
+ p_stream->p_wf->wBitsPerSample =
+ GetWLE((oggpacket.packet+138));
+ p_stream->p_wf->cbSize = i_extra_size;
+
+ if( i_extra_size > 0 )
+ memcpy( p_stream->p_wf+sizeof(WAVEFORMATEX),
+ oggpacket.packet+142, i_extra_size );
+
+ switch( p_stream->p_wf->wFormatTag )
+ {
+ case WAVE_FORMAT_PCM:
+ p_stream->i_fourcc =
+ VLC_FOURCC( 'a', 'r', 'a', 'w' );
+ break;
+ case WAVE_FORMAT_MPEG:
+ case WAVE_FORMAT_MPEGLAYER3:
+ p_stream->i_fourcc =
+ VLC_FOURCC( 'm', 'p', 'g', 'a' );
+ break;
+ case WAVE_FORMAT_A52:
+ p_stream->i_fourcc =
+ VLC_FOURCC( 'a', '5', '2', ' ' );
+ break;
+ case WAVE_FORMAT_WMA1:
+ p_stream->i_fourcc =
+ VLC_FOURCC( 'w', 'm', 'a', '1' );
+ break;
+ case WAVE_FORMAT_WMA2:
+ p_stream->i_fourcc =
+ VLC_FOURCC( 'w', 'm', 'a', '2' );
+ break;
+ default:
+ p_stream->i_fourcc = VLC_FOURCC( 'm', 's',
+ ( p_stream->p_wf->wFormatTag >> 8 ) & 0xff,
+ p_stream->p_wf->wFormatTag & 0xff );
+ }
+
+ msg_Dbg( p_input, "found audio header of type: %.4s",
+ (char *)&p_stream->i_fourcc );
+ msg_Dbg( p_input, "audio:0x%4.4x channels:%d %dHz "
+ "%dbits/sample %dkb/s",
+ p_stream->p_wf->wFormatTag,
+ p_stream->p_wf->nChannels,
+ p_stream->p_wf->nSamplesPerSec,
+ p_stream->p_wf->wBitsPerSample,
+ p_stream->p_wf->nAvgBytesPerSec * 8 / 1024 );
+ {
+ char title[sizeof("Stream") + 10];
+ input_info_category_t *p_cat;
+ sprintf( title, "Stream %d", p_ogg->i_streams );
+ p_cat = input_InfoCategory( p_input, title );
+ input_AddInfo( p_cat, "Type", "Audio" );
+ input_AddInfo( p_cat, "Codec", "%.4s",
+ (char *)&p_stream->i_fourcc );
+ input_AddInfo( p_cat, "Sample Rate", "%d",
+ p_stream->p_wf->nSamplesPerSec );
+ input_AddInfo( p_cat, "Bit Rate", "%d",
+ p_stream->p_wf->nAvgBytesPerSec * 8
+ / 1024 );
+ input_AddInfo( p_cat, "Channels", "%d",
+ p_stream->p_wf->nChannels );
+ input_AddInfo( p_cat, "Bits per Sample", "%d",
+ p_stream->p_wf->wBitsPerSample );
+ }
+
+ }
+ else
+ {
+ msg_Dbg( p_input, "stream %d has an old header "
+ "but is of an unknown type", p_ogg->i_streams-1 );
+ free( p_stream );
+ p_ogg->i_streams--;
+ }
}
else if( (*oggpacket.packet & PACKET_TYPE_BITS )
== PACKET_TYPE_HEADER &&
p_stream->p_bih->biHeight,
p_stream->p_bih->biBitCount);
+ {
+ char title[sizeof("Stream") + 10];
+ input_info_category_t *p_cat;
+ sprintf( title, "Stream %d", p_ogg->i_streams );
+ p_cat = input_InfoCategory( p_input, title );
+ input_AddInfo( p_cat, "Type", "Video" );
+ input_AddInfo( p_cat, "Codec", "%.4s",
+ (char *)&p_stream->i_fourcc );
+ input_AddInfo( p_cat, "Frame Rate", "%f",
+ p_stream->f_rate );
+ input_AddInfo( p_cat, "Bit Count", "%d",
+ p_stream->p_bih->biBitCount );
+ input_AddInfo( p_cat, "Width", "%d",
+ p_stream->p_bih->biWidth );
+ input_AddInfo( p_cat, "Height", "%d",
+ p_stream->p_bih->biHeight );
+ }
p_stream->i_bitrate = 0;
}
/* Check for audio header (new format) */
p_stream->p_wf->nSamplesPerSec,
p_stream->p_wf->wBitsPerSample,
p_stream->p_wf->nAvgBytesPerSec * 8 / 1024 );
+ {
+ char title[sizeof("Stream") + 10];
+ input_info_category_t *p_cat;
+ sprintf( title, "Stream %d", p_ogg->i_streams );
+ p_cat = input_InfoCategory( p_input, title );
+ input_AddInfo( p_cat, "Type", "Audio" );
+ input_AddInfo( p_cat, "Codec", "%.4s",
+ (char *)&p_stream->i_fourcc );
+ input_AddInfo( p_cat, "Sample Rate", "%d",
+ p_stream->p_wf->nSamplesPerSec );
+ input_AddInfo( p_cat, "Bit Rate", "%d",
+ p_stream->p_wf->nAvgBytesPerSec * 8
+ / 1024 );
+ input_AddInfo( p_cat, "Channels", "%d",
+ p_stream->p_wf->nChannels );
+ input_AddInfo( p_cat, "Bits per Sample", "%d",
+ p_stream->p_wf->wBitsPerSample );
+ }
}
/* Check for text (subtitles) header */
else if( !strncmp(st->streamtype, "text", 4) )
p_stream->p_es->i_stream_id = p_stream->p_es->i_id = i_stream;
p_stream->p_es->i_fourcc = p_stream->i_fourcc;
p_stream->p_es->i_cat = p_stream->i_cat;
- p_stream->p_es->p_demux_data = p_stream->p_bih ?
- (void *)p_stream->p_bih : (void *)p_stream->p_wf;
+ p_stream->p_es->p_waveformatex = (void*)p_stream->p_wf;
+ p_stream->p_es->p_bitmapinfoheader = (void*)p_stream->p_bih;
#undef p_stream
}
if( p_stream->i_cat == SPU_ES )
continue;
- if( p_stream->i_interpolated_pcr < p_ogg->i_pcr )
+ if( p_stream->i_interpolated_pcr > 0
+ && p_stream->i_interpolated_pcr < p_ogg->i_pcr )
p_ogg->i_pcr = p_stream->i_interpolated_pcr;
}
#undef p_stream