};
enum {
-
STATE_NOSYNC,
STATE_SYNC,
STATE_HEADER,
p_dec->fmt_out.audio.i_channels = p_dec->fmt_in.audio.i_channels;
p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
p_dec->fmt_out.p_extra = malloc( p_dec->fmt_in.i_extra );
+ if( !p_dec->fmt_out.p_extra )
+ {
+ p_dec->fmt_out.i_extra = 0;
+ return VLC_ENOMEM;
+ }
memcpy( p_dec->fmt_out.p_extra, p_dec->fmt_in.p_extra,
p_dec->fmt_in.i_extra );
/* Build the decoder specific info header */
if( !p_dec->fmt_out.i_extra )
{
- p_dec->fmt_out.i_extra = 2;
p_dec->fmt_out.p_extra = malloc( 2 );
+ if( !p_dec->fmt_out.p_extra )
+ {
+ p_dec->fmt_out.i_extra = 0;
+ return 0;
+ }
+ p_dec->fmt_out.i_extra = 2;
((uint8_t *)p_dec->fmt_out.p_extra)[0] =
(i_profile + 1) << 3 | (i_sample_rate_idx >> 1);
((uint8_t *)p_dec->fmt_out.p_extra)[1] =
return i_frame_size - *pi_header_size;
}
+
/****************************************************************************
* LOAS helpers
****************************************************************************/
*pi_header_size = 3;
return ( ( p_header[1] & 0x1f ) << 8 ) + p_header[2];
}
+
static int Mpeg4GAProgramConfigElement( bs_t *s )
{
/* TODO compute channels count ? */
bs_skip( s, i_comment * 8 );
return 0;
}
+
static int Mpeg4GASpecificConfig( mpeg4_cfg_t *p_cfg, bs_t *s )
{
p_cfg->i_frame_length = bs_read1(s) ? 960 : 1024;
}
return 0;
}
+
static int Mpeg4ReadAudioObjectType( bs_t *s )
{
int i_type = bs_read( s, 5 );
i_type += bs_read( s, 6 );
return i_type;
}
+
static int Mpeg4ReadAudioSamplerate( bs_t *s )
{
int i_index = bs_read( s, 4 );
return pi_sample_rates[i_index];
return bs_read( s, 24 );
}
+
static int Mpeg4ReadAudioSpecificInfo( mpeg4_cfg_t *p_cfg, int *pi_extra, uint8_t *p_extra, bs_t *s, int i_max_size )
{
#if 0
memset( p_cfg, 0, sizeof(*p_cfg) );
*pi_extra = 0;
-
+
p_cfg->i_object_type = Mpeg4ReadAudioObjectType( s );
p_cfg->i_samplerate = Mpeg4ReadAudioSamplerate( s );
default:
break;
}
+
if( p_cfg->extension.i_object_type != 5 && i_max_size > 0 && i_max_size - (bs_pos(s) - i_pos_start) >= 16 &&
bs_read( s, 11 ) == 0x2b7 )
{
/* Read the stream mux configuration if present */
if( !bs_read1( &s ) )
{
- if( !LatmReadStreamMuxConfiguration( &p_sys->latm, &s ) && p_sys->latm.i_streams > 0 )
+ if( !LatmReadStreamMuxConfiguration( &p_sys->latm, &s ) &&
+ p_sys->latm.i_streams > 0 )
{
const latm_stream_t *st = &p_sys->latm.stream[0];
{
p_dec->fmt_out.i_extra = st->i_extra;
p_dec->fmt_out.p_extra = malloc( st->i_extra );
+ if( !p_dec->fmt_out.p_extra )
+ {
+ p_dec->fmt_out.i_extra = 0;
+ return 0;
+ }
memcpy( p_dec->fmt_out.p_extra, st->extra, st->i_extra );
}
{
pi_payload[i_program][i_layer] = st->i_frame_length / 8; /* XXX not correct */
}
- else if( st->i_frame_length_type == 3 || st->i_frame_length_type == 5 || st->i_frame_length_type == 7 )
+ else if( ( st->i_frame_length_type == 3 ) ||
+ ( st->i_frame_length_type == 5 ) ||
+ ( st->i_frame_length_type == 7 ) )
{
bs_skip( &s, 2 ); // muxSlotLengthCoded
pi_payload[i_program][i_layer] = 0; /* TODO */
{
pi_payload[i_program][i_layer] = st->i_frame_length / 8; /* XXX not correct */
}
- else if( st->i_frame_length_type == 3 || st->i_frame_length_type == 5 || st->i_frame_length_type == 7 )
+ else if( ( st->i_frame_length_type == 3 ) ||
+ ( st->i_frame_length_type == 5 ) ||
+ ( st->i_frame_length_type == 7 ) )
{
bs_read( &s, 2 ); // muxSlotLengthCoded
}
case STATE_NEXT_SYNC:
/* TODO: If p_block == NULL, flush the buffer without checking the
* next sync word */
+ if( p_sys->bytestream.p_block == NULL )
+ {
+ p_sys->i_state = STATE_NOSYNC;
+ block_BytestreamFlush( &p_sys->bytestream );
+ return NULL;
+ }
/* Check if next expected frame contains the sync word */
if( block_PeekOffsetBytes( &p_sys->bytestream, p_sys->i_frame_size
return NULL;
}
- assert( p_sys->i_type == TYPE_ADTS || p_sys->i_type == TYPE_LOAS );
- if( ( p_sys->i_type == TYPE_ADTS && ( p_header[0] != 0xff || (p_header[1] & 0xf6) != 0xf0 ) ) ||
- ( p_sys->i_type == TYPE_LOAS && ( p_header[0] != 0x56 || (p_header[1] & 0xe0) != 0xe0 ) ) )
+ assert( (p_sys->i_type == TYPE_ADTS) || (p_sys->i_type == TYPE_LOAS) );
+ if( ( ( p_sys->i_type == TYPE_ADTS ) &&
+ ( p_header[0] != 0xff || (p_header[1] & 0xf6) != 0xf0 ) ) ||
+ ( ( p_sys->i_type == TYPE_LOAS ) &&
+ ( p_header[0] != 0x56 || (p_header[1] & 0xe0) != 0xe0 ) ) )
{
msg_Dbg( p_dec, "emulated sync word "
"(no sync on following frame)" );
return NULL;
}
-
/*****************************************************************************
* SetupBuffer:
*****************************************************************************/
free( p_dec->p_sys );
}
-
-