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 @@
#include <vlc_plugin.h>
#include <vlc_codecs.h>
#include "../../demux/xiph.h"
#include "rtp.h"
......@@ -112,28 +113,20 @@ static ssize_t vorbis_header (void **pextra, const uint8_t *buf, size_t len)
setuplen = len - (idlen + cmtlen);
/* Create the VLC extra format header */
uint8_t *extra = malloc ((size_t)6 + idlen + cmtlen + setuplen);
if (extra == NULL)
return -1;
uint8_t *ptr = *pextra = extra;
/* Identification header */
*ptr++ = idlen >> 8;
*ptr++ = idlen & 0xff;
memcpy (ptr, buf, idlen);
buf += idlen;
ptr += idlen;
/* Comments header */
*ptr++ = cmtlen >> 8;
*ptr++ = cmtlen & 0xff;
memcpy (ptr, buf, cmtlen);
buf += cmtlen;
ptr += cmtlen;
/* Setup header */
*ptr++ = setuplen >> 8;
*ptr++ = setuplen & 0xff;
memcpy (ptr, buf, setuplen);
ptr += setuplen;
return ptr - extra;
unsigned sizes[3] = {
idlen, cmtlen, setuplen
};
void *payloads[3] = {
buf + 0,
buf + idlen,
buf + cmtlen
};
void *extra;
int extra_size;
if (xiph_PackHeaders (&extra_size, &extra, sizes, payloads, 3))
return -1;;
*pextra = extra;
return extra_size;
}
......
......@@ -33,6 +33,7 @@
#include <vlc_input.h>
#include <vlc_codec.h>
#include <vlc_osd.h>
#include "../demux/xiph.h"
#include <kate/kate.h>
#ifdef HAVE_TIGER
......@@ -73,8 +74,7 @@ struct decoder_sys_t
/*
* Input properties
*/
int i_num_headers;
int i_headers;
bool b_has_headers;
/*
* Kate properties
......@@ -377,8 +377,7 @@ static int OpenDecoder( vlc_object_t *p_this )
kate_comment_init( &p_sys->kc );
kate_info_init( &p_sys->ki );
p_sys->i_num_headers = 0;
p_sys->i_headers = 0;
p_sys->b_has_headers = false;
/* retrieve options */
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 )
/* Block to Kate packet */
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 */
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 )
if( ProcessHeaders( p_dec ) )
{
p_sys->i_headers = 0;
p_dec->fmt_in.i_extra = 0;
block_Release( *pp_block );
return NULL;
}
else p_sys->i_headers++;
p_sys->b_has_headers = true;
}
return ProcessPacket( p_dec, &kp, pp_block );
......@@ -540,37 +511,28 @@ static int ProcessHeaders( decoder_t *p_dec )
{
decoder_sys_t *p_sys = p_dec->p_sys;
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 */
kp.nbytes = *(p_extra++) << 8;
kp.nbytes |= (*(p_extra++) & 0xFF);
kp.data = p_extra;
p_extra += kp.nbytes;
i_extra -= (kp.nbytes + 2);
if( i_extra < 0 )
{
msg_Err( p_dec, "header data corrupted");
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;
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 );
if( i_ret < 0 )
{
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",
......@@ -579,24 +541,15 @@ static int ProcessHeaders( decoder_t *p_dec )
p_sys->ki.granule_shift);
/* 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 |= (*(p_extra++) & 0xFF);
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;
}
kp.nbytes = pi_size[i_headeridx];
kp.data = pp_data[i_headeridx];
i_ret = kate_decode_headerin( &p_sys->ki, &p_sys->kc, &kp );
if( i_ret < 0 )
{
msg_Err( p_dec, "Kate header %d is corrupted: %d", i_headeridx, i_ret );
return VLC_EGENERIC;
goto end;
}
/* header 1 is comments */
......@@ -631,7 +584,10 @@ static int ProcessHeaders( decoder_t *p_dec )
}
#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,
else
#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 );
else
p_buf = NULL;
p_buf = DecodePacket( p_dec, p_kp, p_block );
if( p_block ) block_Release( p_block );
if( p_block )
block_Release( p_block );
}
return p_buf;
......
......@@ -33,6 +33,7 @@
#include <vlc_input.h>
#include <vlc_codec.h>
#include <vlc_aout.h>
#include "../demux/xiph.h"
#include <ogg/ogg.h>
#include <speex/speex.h>
......@@ -150,7 +151,7 @@ struct decoder_sys_t
/*
* Input properties
*/
int i_headers;
bool b_has_headers;
int i_frame_in_packet;
/*
......@@ -214,6 +215,7 @@ static int OpenDecoder( vlc_object_t *p_this )
p_dec->p_sys->bits.buf_size = 0;
p_dec->p_sys->b_packetizer = false;
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 );
......@@ -242,7 +244,6 @@ static int OpenDecoder( vlc_object_t *p_this )
p_dec->pf_packetize = (block_t *(*)(decoder_t *, block_t **))
DecodeBlock;
p_sys->i_headers = 0;
p_sys->p_state = NULL;
p_sys->p_header = NULL;
p_sys->i_frame_in_packet = 0;
......@@ -298,38 +299,14 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
oggpacket.packetno = 0;
/* 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;
}
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 )
if( ProcessHeaders( p_dec ) )
{
p_sys->i_headers = 0;
p_dec->fmt_in.i_extra = 0;
block_Release( *pp_block );
return NULL;
}
else p_sys->i_headers++;
p_sys->b_has_headers = true;
}
return ProcessPacket( p_dec, &oggpacket, pp_block );
......@@ -342,50 +319,34 @@ static int ProcessHeaders( decoder_t *p_dec )
{
decoder_sys_t *p_sys = p_dec->p_sys;
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.b_o_s = 1; /* yes this actually is a b_o_s packet :) */
oggpacket.e_o_s = 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 */
oggpacket.bytes = *(p_extra++) << 8;
oggpacket.bytes |= (*(p_extra++) & 0xFF);
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;
}
/* Take care of the initial Speex header */
oggpacket.b_o_s = 1; /* yes this actually is a b_o_s packet :) */
oggpacket.bytes = pi_size[0];
oggpacket.packet = pp_data[0];
if( ProcessInitialHeader( p_dec, &oggpacket ) != VLC_SUCCESS )
{
msg_Err( p_dec, "initial Speex header is corrupted" );
return VLC_EGENERIC;
goto error;
}
/* The next packet in order is the comments header */
oggpacket.b_o_s = 0;
oggpacket.bytes = *(p_extra++) << 8;
oggpacket.bytes |= (*(p_extra++) & 0xFF);
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;
}
oggpacket.bytes = pi_size[1];
oggpacket.packet = pp_data[1];
ParseSpeexComments( p_dec, &oggpacket );
if( p_sys->b_packetizer )
......@@ -397,7 +358,14 @@ static int ProcessHeaders( decoder_t *p_dec )
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;
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,
}
else
{
aout_buffer_t *p_aout_buffer;
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 */
aout_buffer_t *p_aout_buffer = DecodePacket( p_dec, p_oggpacket );
if( p_block ) block_Release( p_block );
if( p_block )
block_Release( p_block );
return p_aout_buffer;
}
}
......@@ -796,15 +760,10 @@ static block_t *SendPacket( decoder_t *p_dec, block_t *p_block )
/* Date management */
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_sys->p_header->frame_size ) -
p_block->i_pts;
}
else
p_block->i_length = 0;
p_block->i_length =
date_Increment( &p_sys->end_date,
p_sys->p_header->frame_size ) -
p_block->i_pts;
return p_block;
}
......
......@@ -33,6 +33,8 @@
#include <vlc_codec.h>
#include <vlc_sout.h>
#include <vlc_input.h>
#include "../demux/xiph.h"
#include <ogg/ogg.h>
#include <theora/theora.h>
......@@ -48,7 +50,7 @@ struct decoder_sys_t
/*
* Input properties
*/
int i_headers;
bool b_has_headers;
/*
* Theora properties
......@@ -143,7 +145,7 @@ static int OpenDecoder( vlc_object_t *p_this )
if( ( p_dec->p_sys = p_sys = malloc(sizeof(*p_sys)) ) == NULL )
return VLC_ENOMEM;
p_dec->p_sys->b_packetizer = false;
p_sys->b_has_headers = false;
p_sys->i_pts = VLC_TS_INVALID;
p_sys->b_decoded_first_keyframe = false;
......@@ -161,8 +163,6 @@ static int OpenDecoder( vlc_object_t *p_this )
theora_comment_init( &p_sys->tc );
theora_info_init( &p_sys->ti );
p_sys->i_headers = 0;
return VLC_SUCCESS;
}
......@@ -205,40 +205,14 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
oggpacket.packetno = 0;
/* Check for headers */
if( p_sys->i_headers == 0 && p_dec->fmt_in.i_extra )
{
/* Headers already available as extra data */
p_sys->i_headers = 3;
}
else if( oggpacket.bytes && p_sys->i_headers < 3 )
if( !p_sys->b_has_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 + 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 )
if( ProcessHeaders( p_dec ) )
{
p_sys->i_headers = 0;
p_dec->fmt_in.i_extra = 0;
block_Release( *pp_block );
return NULL;
}
else p_sys->i_headers++;
p_sys->b_has_headers = true;
}
return ProcessPacket( p_dec, &oggpacket, pp_block );
......@@ -251,34 +225,28 @@ static int ProcessHeaders( decoder_t *p_dec )
{
decoder_sys_t *p_sys = p_dec->p_sys;
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.b_o_s = 1; /* yes this actually is a b_o_s packet :) */
oggpacket.e_o_s = 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 */
oggpacket.bytes = *(p_extra++) << 8;
oggpacket.bytes |= (*(p_extra++) & 0xFF);
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;
}
oggpacket.b_o_s = 1; /* yes this actually is a b_o_s packet :) */
oggpacket.bytes = pi_size[0];
oggpacket.packet = pp_data[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" );
return VLC_EGENERIC;
goto error;
}
/* Set output properties */
......@@ -351,23 +319,13 @@ static int ProcessHeaders( decoder_t *p_dec )
}
/* The next packet in order is the comments header */
oggpacket.b_o_s = 0;
oggpacket.bytes = *(p_extra++) << 8;
oggpacket.bytes |= (*(p_extra++) & 0xFF);
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;
}
/* The next packet in order is the comments header */
oggpacket.b_o_s = 0;
oggpacket.bytes = pi_size[1];
oggpacket.packet = pp_data[1];
if( theora_decode_header( &p_sys->ti, &p_sys->tc, &oggpacket ) < 0 )
{
msg_Err( p_dec, "2nd Theora header is corrupted" );
return VLC_EGENERIC;
goto error;
}
ParseTheoraComments( p_dec );
......@@ -375,23 +333,13 @@ static int ProcessHeaders( decoder_t *p_dec )
/* The next packet in order is the codebooks header
* We need to watch out that this packet is not missing as a
* missing or corrupted header is fatal. */
oggpacket.bytes = *(p_extra++) << 8;
oggpacket.bytes |= (*(p_extra++) & 0xFF);
oggpacket.packet = p_extra;
i_extra -= (oggpacket.bytes + 2);
if( i_extra < 0 )
{
msg_Err( p_dec, "header data corrupted");
return VLC_EGENERIC;
}
/* The next packet in order is the codebooks header
* We need to watch out that this packet is not missing as a
* missing or corrupted header is fatal */
oggpacket.b_o_s = 0;
oggpacket.bytes = pi_size[2];
oggpacket.packet = pp_data[2];
if( theora_decode_header( &p_sys->ti, &p_sys->tc, &oggpacket ) < 0 )
{
msg_Err( p_dec, "3rd Theora header is corrupted" );
return VLC_EGENERIC;
goto error;
}
if( !p_sys->b_packetizer )
......@@ -408,7 +356,14 @@ static int ProcessHeaders( decoder_t *p_dec )
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;
error:
for( unsigned i = 0; i < i_count; i++ )
free( pp_data[i] );
return VLC_EGENERIC;
}
/*****************************************************************************
......@@ -442,21 +397,15 @@ static void *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
/* Date management */
p_block->i_dts = p_block->i_pts = p_sys->i_pts;
if( p_sys->i_headers >= 3 )
p_block->i_length = p_sys->i_pts - p_block->i_pts;
else
p_block->i_length = 0;
p_block->i_length = p_sys->i_pts - p_block->i_pts;
p_buf = p_block;
}
else
{
if( p_sys->i_headers >= 3 )
p_buf = DecodePacket( p_dec, p_oggpacket );
else
p_buf = NULL;
if( p_block ) block_Release( p_block );
p_buf = DecodePacket( p_dec, p_oggpacket );
if( p_block )
block_Release( p_block );
}
/* Date management */
......
......@@ -37,6 +37,7 @@
#include <vlc_aout.h>
#include <vlc_input.h>
#include <vlc_sout.h>
#include "../demux/xiph.h"
#include <ogg/ogg.h>
......@@ -60,10 +61,7 @@ struct decoder_sys_t
/* Module mode */
bool b_packetizer;
/*
* Input properties
*/
int i_headers;
bool b_has_headers;
/*
* Vorbis properties
......@@ -236,7 +234,7 @@ static int OpenDecoder( vlc_object_t *p_this )
date_Set( &p_sys->end_date, 0 );
p_sys->i_last_block_size = 0;
p_sys->b_packetizer = false;
p_sys->i_headers = 0;
p_sys->b_has_headers = false;
/* Take care of vorbis init */
vorbis_info_init( &p_sys->vi );
......@@ -307,41 +305,14 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
oggpacket.packetno = 0;
/* Check for headers */
if( p_sys->i_headers == 0 && p_dec->fmt_in.i_extra )
{
/* Headers already available as extra data */
msg_Dbg( p_dec, "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 */
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( !p_sys->b_has_headers )
{
if( ProcessHeaders( p_dec ) != VLC_SUCCESS )
if( ProcessHeaders( p_dec ) )
{
p_sys->i_headers = 0;
p_dec->fmt_in.i_extra = 0;
block_Release( *pp_block );
return NULL;
}
else p_sys->i_headers++;
p_sys->b_has_headers = true;
}
return ProcessPacket( p_dec, &oggpacket, pp_block );
......@@ -354,34 +325,28 @@ static int ProcessHeaders( decoder_t *p_dec )
{
decoder_sys_t *p_sys = p_dec->p_sys;
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.b_o_s = 1; /* yes this actually is a b_o_s packet :) */
oggpacket.e_o_s = 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 */
oggpacket.bytes = *