Commit b5ad5b61 authored by Laurent Aimar's avatar Laurent Aimar

Modified the way xiph codecs headers are transported in VLC.

It makes VLC compatible with FFmpeg vorbis/theora decoder.
It fixes support of big headers (like comments with an art encoded
as a base64 string...).
It simplifies a bit.
parent d61a6d40
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_codecs.h> #include <vlc_codecs.h>
#include "../../demux/xiph.h"
#include "rtp.h" #include "rtp.h"
...@@ -112,28 +113,20 @@ static ssize_t vorbis_header (void **pextra, const uint8_t *buf, size_t len) ...@@ -112,28 +113,20 @@ static ssize_t vorbis_header (void **pextra, const uint8_t *buf, size_t len)
setuplen = len - (idlen + cmtlen); setuplen = len - (idlen + cmtlen);
/* Create the VLC extra format header */ /* Create the VLC extra format header */
uint8_t *extra = malloc ((size_t)6 + idlen + cmtlen + setuplen); unsigned sizes[3] = {
if (extra == NULL) idlen, cmtlen, setuplen
return -1; };
uint8_t *ptr = *pextra = extra; void *payloads[3] = {
/* Identification header */ buf + 0,
*ptr++ = idlen >> 8; buf + idlen,
*ptr++ = idlen & 0xff; buf + cmtlen
memcpy (ptr, buf, idlen); };
buf += idlen; void *extra;
ptr += idlen; int extra_size;
/* Comments header */ if (xiph_PackHeaders (&extra_size, &extra, sizes, payloads, 3))
*ptr++ = cmtlen >> 8; return -1;;
*ptr++ = cmtlen & 0xff; *pextra = extra;
memcpy (ptr, buf, cmtlen); return extra_size;
buf += cmtlen;
ptr += cmtlen;
/* Setup header */
*ptr++ = setuplen >> 8;
*ptr++ = setuplen & 0xff;
memcpy (ptr, buf, setuplen);
ptr += setuplen;
return ptr - extra;
} }
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <vlc_input.h> #include <vlc_input.h>
#include <vlc_codec.h> #include <vlc_codec.h>
#include <vlc_osd.h> #include <vlc_osd.h>
#include "../demux/xiph.h"
#include <kate/kate.h> #include <kate/kate.h>
#ifdef HAVE_TIGER #ifdef HAVE_TIGER
...@@ -73,8 +74,7 @@ struct decoder_sys_t ...@@ -73,8 +74,7 @@ struct decoder_sys_t
/* /*
* Input properties * Input properties
*/ */
int i_num_headers; bool b_has_headers;
int i_headers;
/* /*
* Kate properties * Kate properties
...@@ -377,8 +377,7 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -377,8 +377,7 @@ static int OpenDecoder( vlc_object_t *p_this )
kate_comment_init( &p_sys->kc ); kate_comment_init( &p_sys->kc );
kate_info_init( &p_sys->ki ); kate_info_init( &p_sys->ki );
p_sys->i_num_headers = 0; p_sys->b_has_headers = false;
p_sys->i_headers = 0;
/* retrieve options */ /* retrieve options */
p_sys->b_formatted = var_CreateGetBool( p_dec, "kate-formatted" ); p_sys->b_formatted = var_CreateGetBool( p_dec, "kate-formatted" );
...@@ -492,42 +491,14 @@ static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) ...@@ -492,42 +491,14 @@ static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
/* Block to Kate packet */ /* Block to Kate packet */
kate_packet_wrap(&kp, p_block->i_buffer, p_block->p_buffer); kate_packet_wrap(&kp, p_block->i_buffer, p_block->p_buffer);
if( p_sys->i_headers == 0 && p_dec->fmt_in.i_extra ) if( !p_sys->b_has_headers )
{ {
/* Headers already available as extra data */ if( ProcessHeaders( p_dec ) )
p_sys->i_num_headers = ((unsigned char*)p_dec->fmt_in.p_extra)[0];
p_sys->i_headers = p_sys->i_num_headers;
}
else if( kp.nbytes && (p_sys->i_headers==0 || p_sys->i_headers < p_sys->ki.num_headers ))
{
/* Backup headers as extra data */
uint8_t *p_extra;
p_dec->fmt_in.p_extra = xrealloc( p_dec->fmt_in.p_extra,
p_dec->fmt_in.i_extra + kp.nbytes + 2 );
p_extra = (void*)(((unsigned char*)p_dec->fmt_in.p_extra) + p_dec->fmt_in.i_extra);
*(p_extra++) = kp.nbytes >> 8;
*(p_extra++) = kp.nbytes & 0xFF;
memcpy( p_extra, kp.data, kp.nbytes );
p_dec->fmt_in.i_extra += kp.nbytes + 2;
block_Release( *pp_block );
p_sys->i_num_headers = ((unsigned char*)p_dec->fmt_in.p_extra)[0];
p_sys->i_headers++;
return NULL;
}
if( p_sys->i_headers == p_sys->i_num_headers && p_sys->i_num_headers>0 )
{
if( ProcessHeaders( p_dec ) != VLC_SUCCESS )
{ {
p_sys->i_headers = 0;
p_dec->fmt_in.i_extra = 0;
block_Release( *pp_block ); block_Release( *pp_block );
return NULL; return NULL;
} }
else p_sys->i_headers++; p_sys->b_has_headers = true;
} }
return ProcessPacket( p_dec, &kp, pp_block ); return ProcessPacket( p_dec, &kp, pp_block );
...@@ -540,37 +511,28 @@ static int ProcessHeaders( decoder_t *p_dec ) ...@@ -540,37 +511,28 @@ static int ProcessHeaders( decoder_t *p_dec )
{ {
decoder_sys_t *p_sys = p_dec->p_sys; decoder_sys_t *p_sys = p_dec->p_sys;
kate_packet kp; kate_packet kp;
uint8_t *p_extra;
int i_extra;
int i_headeridx;
int i_ret;
if( !p_dec->fmt_in.i_extra ) return VLC_EGENERIC;
p_extra = p_dec->fmt_in.p_extra;
i_extra = p_dec->fmt_in.i_extra;
/* skip number of headers */
++p_extra;
--i_extra;
/* Take care of the initial Kate header */ unsigned pi_size[XIPH_MAX_HEADER_COUNT];
kp.nbytes = *(p_extra++) << 8; void *pp_data[XIPH_MAX_HEADER_COUNT];
kp.nbytes |= (*(p_extra++) & 0xFF); unsigned i_count;
kp.data = p_extra; if( xiph_SplitHeaders( pi_size, pp_data, &i_count,
p_extra += kp.nbytes; p_dec->fmt_in.i_extra, p_dec->fmt_in.p_extra) )
i_extra -= (kp.nbytes + 2);
if( i_extra < 0 )
{
msg_Err( p_dec, "header data corrupted");
return VLC_EGENERIC; return VLC_EGENERIC;
int i_ret = VLC_SUCCESS;
if( i_count < 1 )
{
i_ret = VLC_EGENERIC;
goto end;
} }
/* Take care of the initial Kate header */
kp.nbytes = pi_size[0];
kp.data = pp_data[0];
i_ret = kate_decode_headerin( &p_sys->ki, &p_sys->kc, &kp ); i_ret = kate_decode_headerin( &p_sys->ki, &p_sys->kc, &kp );
if( i_ret < 0 ) if( i_ret < 0 )
{ {
msg_Err( p_dec, "this bitstream does not contain Kate data (%d)", i_ret ); msg_Err( p_dec, "this bitstream does not contain Kate data (%d)", i_ret );
return VLC_EGENERIC; goto end;
} }
msg_Dbg( p_dec, "%s %s text, granule rate %f, granule shift %d", msg_Dbg( p_dec, "%s %s text, granule rate %f, granule shift %d",
...@@ -579,24 +541,15 @@ static int ProcessHeaders( decoder_t *p_dec ) ...@@ -579,24 +541,15 @@ static int ProcessHeaders( decoder_t *p_dec )
p_sys->ki.granule_shift); p_sys->ki.granule_shift);
/* parse all remaining header packets */ /* parse all remaining header packets */
for( i_headeridx = 1; i_headeridx < p_sys->ki.num_headers; ++i_headeridx ) for( unsigned i_headeridx = 1; i_headeridx < i_count; i_headeridx++ )
{ {
kp.nbytes = *(p_extra++) << 8; kp.nbytes = pi_size[i_headeridx];
kp.nbytes |= (*(p_extra++) & 0xFF); kp.data = pp_data[i_headeridx];
kp.data = p_extra;
p_extra += kp.nbytes;
i_extra -= (kp.nbytes + 2);
if( i_extra < 0 )
{
msg_Err( p_dec, "header %d data corrupted", i_headeridx );
return VLC_EGENERIC;
}
i_ret = kate_decode_headerin( &p_sys->ki, &p_sys->kc, &kp ); i_ret = kate_decode_headerin( &p_sys->ki, &p_sys->kc, &kp );
if( i_ret < 0 ) if( i_ret < 0 )
{ {
msg_Err( p_dec, "Kate header %d is corrupted: %d", i_headeridx, i_ret ); msg_Err( p_dec, "Kate header %d is corrupted: %d", i_headeridx, i_ret );
return VLC_EGENERIC; goto end;
} }
/* header 1 is comments */ /* header 1 is comments */
...@@ -631,7 +584,10 @@ static int ProcessHeaders( decoder_t *p_dec ) ...@@ -631,7 +584,10 @@ static int ProcessHeaders( decoder_t *p_dec )
} }
#endif #endif
return VLC_SUCCESS; end:
for( unsigned i = 0; i < i_count; i++ )
free( pp_data[i] );
return i_ret < 0 ? VLC_EGENERIC : VLC_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
...@@ -668,12 +624,10 @@ static subpicture_t *ProcessPacket( decoder_t *p_dec, kate_packet *p_kp, ...@@ -668,12 +624,10 @@ static subpicture_t *ProcessPacket( decoder_t *p_dec, kate_packet *p_kp,
else else
#endif #endif
{ {
if( p_sys->i_headers >= p_sys->i_num_headers && p_sys->i_num_headers > 0) p_buf = DecodePacket( p_dec, p_kp, p_block );
p_buf = DecodePacket( p_dec, p_kp, p_block );
else
p_buf = NULL;
if( p_block ) block_Release( p_block ); if( p_block )
block_Release( p_block );
} }
return p_buf; return p_buf;
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <vlc_input.h> #include <vlc_input.h>
#include <vlc_codec.h> #include <vlc_codec.h>
#include <vlc_aout.h> #include <vlc_aout.h>
#include "../demux/xiph.h"
#include <ogg/ogg.h> #include <ogg/ogg.h>
#include <speex/speex.h> #include <speex/speex.h>
...@@ -150,7 +151,7 @@ struct decoder_sys_t ...@@ -150,7 +151,7 @@ struct decoder_sys_t
/* /*
* Input properties * Input properties
*/ */
int i_headers; bool b_has_headers;
int i_frame_in_packet; int i_frame_in_packet;
/* /*
...@@ -214,6 +215,7 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -214,6 +215,7 @@ static int OpenDecoder( vlc_object_t *p_this )
p_dec->p_sys->bits.buf_size = 0; p_dec->p_sys->bits.buf_size = 0;
p_dec->p_sys->b_packetizer = false; p_dec->p_sys->b_packetizer = false;
p_dec->p_sys->rtp_rate = p_dec->fmt_in.audio.i_rate; p_dec->p_sys->rtp_rate = p_dec->fmt_in.audio.i_rate;
p_dec->p_sys->b_has_headers = false;
date_Set( &p_sys->end_date, 0 ); date_Set( &p_sys->end_date, 0 );
...@@ -242,7 +244,6 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -242,7 +244,6 @@ static int OpenDecoder( vlc_object_t *p_this )
p_dec->pf_packetize = (block_t *(*)(decoder_t *, block_t **)) p_dec->pf_packetize = (block_t *(*)(decoder_t *, block_t **))
DecodeBlock; DecodeBlock;
p_sys->i_headers = 0;
p_sys->p_state = NULL; p_sys->p_state = NULL;
p_sys->p_header = NULL; p_sys->p_header = NULL;
p_sys->i_frame_in_packet = 0; p_sys->i_frame_in_packet = 0;
...@@ -298,38 +299,14 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) ...@@ -298,38 +299,14 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
oggpacket.packetno = 0; oggpacket.packetno = 0;
/* Check for headers */ /* Check for headers */
if( p_sys->i_headers == 0 && p_dec->fmt_in.i_extra ) if( !p_sys->b_has_headers )
{ {
p_sys->i_headers = 2; if( ProcessHeaders( p_dec ) )
}
else if( oggpacket.bytes && p_sys->i_headers < 2 )
{
uint8_t *p_extra;
p_dec->fmt_in.p_extra = xrealloc( p_dec->fmt_in.p_extra,
p_dec->fmt_in.i_extra + oggpacket.bytes + 2 );
p_extra = ((uint8_t *)p_dec->fmt_in.p_extra) + p_dec->fmt_in.i_extra;
*(p_extra++) = oggpacket.bytes >> 8;
*(p_extra++) = oggpacket.bytes & 0xFF;
memcpy( p_extra, oggpacket.packet, oggpacket.bytes );
p_dec->fmt_in.i_extra += oggpacket.bytes + 2;
block_Release( *pp_block );
p_sys->i_headers++;
return NULL;
}
if( p_sys->i_headers == 2 )
{
if( ProcessHeaders( p_dec ) != VLC_SUCCESS )
{ {
p_sys->i_headers = 0;
p_dec->fmt_in.i_extra = 0;
block_Release( *pp_block ); block_Release( *pp_block );
return NULL; return NULL;
} }
else p_sys->i_headers++; p_sys->b_has_headers = true;
} }
return ProcessPacket( p_dec, &oggpacket, pp_block ); return ProcessPacket( p_dec, &oggpacket, pp_block );
...@@ -342,50 +319,34 @@ static int ProcessHeaders( decoder_t *p_dec ) ...@@ -342,50 +319,34 @@ static int ProcessHeaders( decoder_t *p_dec )
{ {
decoder_sys_t *p_sys = p_dec->p_sys; decoder_sys_t *p_sys = p_dec->p_sys;
ogg_packet oggpacket; ogg_packet oggpacket;
uint8_t *p_extra;
int i_extra;
if( !p_dec->fmt_in.i_extra ) return VLC_EGENERIC; unsigned pi_size[XIPH_MAX_HEADER_COUNT];
void *pp_data[XIPH_MAX_HEADER_COUNT];
unsigned i_count;
if( xiph_SplitHeaders( pi_size, pp_data, &i_count,
p_dec->fmt_in.i_extra, p_dec->fmt_in.p_extra) )
return VLC_EGENERIC;
if( i_count < 2 )
goto error;
oggpacket.granulepos = -1; oggpacket.granulepos = -1;
oggpacket.b_o_s = 1; /* yes this actually is a b_o_s packet :) */
oggpacket.e_o_s = 0; oggpacket.e_o_s = 0;
oggpacket.packetno = 0; oggpacket.packetno = 0;
p_extra = p_dec->fmt_in.p_extra;
i_extra = p_dec->fmt_in.i_extra;
/* Take care of the initial Vorbis header */ /* Take care of the initial Vorbis header */
oggpacket.bytes = *(p_extra++) << 8; oggpacket.b_o_s = 1; /* yes this actually is a b_o_s packet :) */
oggpacket.bytes |= (*(p_extra++) & 0xFF); oggpacket.bytes = pi_size[0];
oggpacket.packet = p_extra; oggpacket.packet = pp_data[0];
p_extra += oggpacket.bytes;
i_extra -= (oggpacket.bytes + 2);
if( i_extra < 0 )
{
msg_Err( p_dec, "header data corrupted");
return VLC_EGENERIC;
}
/* Take care of the initial Speex header */
if( ProcessInitialHeader( p_dec, &oggpacket ) != VLC_SUCCESS ) if( ProcessInitialHeader( p_dec, &oggpacket ) != VLC_SUCCESS )
{ {
msg_Err( p_dec, "initial Speex header is corrupted" ); msg_Err( p_dec, "initial Speex header is corrupted" );
return VLC_EGENERIC; goto error;
} }
/* The next packet in order is the comments header */ /* The next packet in order is the comments header */
oggpacket.b_o_s = 0; oggpacket.b_o_s = 0;
oggpacket.bytes = *(p_extra++) << 8; oggpacket.bytes = pi_size[1];
oggpacket.bytes |= (*(p_extra++) & 0xFF); oggpacket.packet = pp_data[1];
oggpacket.packet = p_extra;
p_extra += oggpacket.bytes;
i_extra -= (oggpacket.bytes + 2);
if( i_extra < 0 )
{
msg_Err( p_dec, "header data corrupted");
return VLC_EGENERIC;
}
ParseSpeexComments( p_dec, &oggpacket ); ParseSpeexComments( p_dec, &oggpacket );
if( p_sys->b_packetizer ) if( p_sys->b_packetizer )
...@@ -397,7 +358,14 @@ static int ProcessHeaders( decoder_t *p_dec ) ...@@ -397,7 +358,14 @@ static int ProcessHeaders( decoder_t *p_dec )
p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra ); p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra );
} }
for( unsigned i = 0; i < i_count; i++ )
free( pp_data[i] );
return VLC_SUCCESS; return VLC_SUCCESS;
error:
for( unsigned i = 0; i < i_count; i++ )
free( pp_data[i] );
return VLC_EGENERIC;
} }
/***************************************************************************** /*****************************************************************************
...@@ -591,14 +559,10 @@ static void *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket, ...@@ -591,14 +559,10 @@ static void *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
} }
else else
{ {
aout_buffer_t *p_aout_buffer; aout_buffer_t *p_aout_buffer = DecodePacket( p_dec, p_oggpacket );
if( p_sys->i_headers >= p_sys->p_header->extra_headers + 2 )
p_aout_buffer = DecodePacket( p_dec, p_oggpacket );
else
p_aout_buffer = NULL; /* Skip headers */
if( p_block ) block_Release( p_block ); if( p_block )
block_Release( p_block );
return p_aout_buffer; return p_aout_buffer;
} }
} }
...@@ -796,15 +760,10 @@ static block_t *SendPacket( decoder_t *p_dec, block_t *p_block ) ...@@ -796,15 +760,10 @@ static block_t *SendPacket( decoder_t *p_dec, block_t *p_block )
/* Date management */ /* Date management */
p_block->i_dts = p_block->i_pts = date_Get( &p_sys->end_date ); p_block->i_dts = p_block->i_pts = date_Get( &p_sys->end_date );
if( p_sys->i_headers >= p_sys->p_header->extra_headers + 2 ) p_block->i_length =
{ date_Increment( &p_sys->end_date,
p_block->i_length = p_sys->p_header->frame_size ) -
date_Increment( &p_sys->end_date, p_block->i_pts;
p_sys->p_header->frame_size ) -
p_block->i_pts;
}
else
p_block->i_length = 0;
return p_block; return p_block;
} }
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#include <vlc_codec.h> #include <vlc_codec.h>
#include <vlc_sout.h> #include <vlc_sout.h>
#include <vlc_input.h> #include <vlc_input.h>
#include "../demux/xiph.h"
#include <ogg/ogg.h> #include <ogg/ogg.h>
#include <theora/theora.h> #include <theora/theora.h>
...@@ -48,7 +50,7 @@ struct decoder_sys_t ...@@ -48,7 +50,7 @@ struct decoder_sys_t
/* /*
* Input properties * Input properties
*/ */
int i_headers; bool b_has_headers;
/* /*
* Theora properties * Theora properties
...@@ -143,7 +145,7 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -143,7 +145,7 @@ static int OpenDecoder( vlc_object_t *p_this )
if( ( p_dec->p_sys = p_sys = malloc(sizeof(*p_sys)) ) == NULL ) if( ( p_dec->p_sys = p_sys = malloc(sizeof(*p_sys)) ) == NULL )
return VLC_ENOMEM; return VLC_ENOMEM;
p_dec->p_sys->b_packetizer = false; p_dec->p_sys->b_packetizer = false;
p_sys->b_has_headers = false;
p_sys->i_pts = VLC_TS_INVALID; p_sys->i_pts = VLC_TS_INVALID;
p_sys->b_decoded_first_keyframe = false; p_sys->b_decoded_first_keyframe = false;
...@@ -161,8 +163,6 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -161,8 +163,6 @@ static int OpenDecoder( vlc_object_t *p_this )
theora_comment_init( &p_sys->tc ); theora_comment_init( &p_sys->tc );
theora_info_init( &p_sys->ti ); theora_info_init( &p_sys->ti );
p_sys->i_headers = 0;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -205,40 +205,14 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) ...@@ -205,40 +205,14 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
oggpacket.packetno = 0; oggpacket.packetno = 0;
/* Check for headers */ /* Check for headers */
if( p_sys->i_headers == 0 && p_dec->fmt_in.i_extra ) if( !p_sys->b_has_headers )
{
/* Headers already available as extra data */
p_sys->i_headers = 3;
}
else if( oggpacket.bytes && p_sys->i_headers < 3 )
{ {
/* Backup headers as extra data */ if( ProcessHeaders( p_dec ) )
uint8_t *p_extra;
p_dec->fmt_in.p_extra = xrealloc( p_dec->fmt_in.p_extra,
p_dec->fmt_in.i_extra + oggpacket.bytes + 2 );
p_extra = ((uint8_t *)p_dec->fmt_in.p_extra) + p_dec->fmt_in.i_extra;
*(p_extra++) = oggpacket.bytes >> 8;
*(p_extra++) = oggpacket.bytes & 0xFF;
memcpy( p_extra, oggpacket.packet, oggpacket.bytes );
p_dec->fmt_in.i_extra += oggpacket.bytes + 2;
block_Release( *pp_block );
p_sys->i_headers++;
return NULL;
}
if( p_sys->i_headers == 3 )
{
if( ProcessHeaders( p_dec ) != VLC_SUCCESS )
{ {
p_sys->i_headers = 0;
p_dec->fmt_in.i_extra = 0;
block_Release( *pp_block ); block_Release( *pp_block );
return NULL; return NULL;
} }
else p_sys->i_headers++; p_sys->b_has_headers = true;
} }
return ProcessPacket( p_dec, &oggpacket, pp_block ); return ProcessPacket( p_dec, &oggpacket, pp_block );
...@@ -251,34 +225,28 @@ static int ProcessHeaders( decoder_t *p_dec ) ...@@ -251,34 +225,28 @@ static int ProcessHeaders( decoder_t *p_dec )
{ {
decoder_sys_t *p_sys = p_dec->p_sys; decoder_sys_t *p_sys = p_dec->p_sys;
ogg_packet oggpacket; ogg_packet oggpacket;
uint8_t *p_extra;
int i_extra;
if( !p_dec->fmt_in.i_extra ) return VLC_EGENERIC; unsigned pi_size[XIPH_MAX_HEADER_COUNT];
void *pp_data[XIPH_MAX_HEADER_COUNT];
unsigned i_count;
if( xiph_SplitHeaders( pi_size, pp_data, &i_count,
p_dec->fmt_in.i_extra, p_dec->fmt_in.p_extra) )
return VLC_EGENERIC;
if( i_count < 3 )
goto error;
oggpacket.granulepos = -1; oggpacket.granulepos = -1;
oggpacket.b_o_s = 1; /* yes this actually is a b_o_s packet :) */
oggpacket.e_o_s = 0; oggpacket.e_o_s = 0;
oggpacket.packetno = 0; oggpacket.packetno = 0;
p_extra = p_dec->fmt_in.p_extra;
i_extra = p_dec->fmt_in.i_extra;
/* Take care of the initial Vorbis header */ /* Take care of the initial Vorbis header */
oggpacket.bytes = *(p_extra++) << 8; oggpacket.b_o_s = 1; /* yes this actually is a b_o_s packet :) */
oggpacket.bytes |= (*(p_extra++) & 0xFF); oggpacket.bytes = pi_size[0];
oggpacket.packet = p_extra; oggpacket.packet = pp_data[0];
p_extra += oggpacket.bytes;
i_extra -= (oggpacket.bytes + 2);
if( i_extra < 0 )
{
msg_Err( p_dec, "header data corrupted");
return VLC_EGENERIC;
}
if( theora_decode_header( &p_sys->ti, &p_sys->tc, &oggpacket ) < 0 ) if( theora_decode_header( &p_sys->ti, &p_sys->tc, &oggpacket ) < 0 )
{ {
msg_Err( p_dec, "this bitstream does not contain Theora video data" ); msg_Err( p_dec, "this bitstream does not contain Theora video data" );
return