date_t end_date;
mtime_t i_pts;
- int i_frame_size, i_frame_length, i_bits_per_sample;
- unsigned int i_rate, i_channels;
+ int i_frame_length;
+ size_t i_frame_size;
+ unsigned int i_rate, i_channels, i_bits_per_sample;
};
enum
static block_t *Packetize( decoder_t *, block_t ** );
static int SyncInfo( decoder_t *, uint8_t *, unsigned int *,
- unsigned int *,int * );
+ unsigned int *, unsigned int * );
static uint64_t read_utf8( const uint8_t *p_buf, int *pi_read );
static uint8_t flac_crc8( const uint8_t *data, unsigned len );
decoder_t *p_dec = (decoder_t *)p_this;
decoder_sys_t *p_sys = p_dec->p_sys;
+ block_BytestreamRelease( &p_sys->bytestream );
free( p_sys );
}
bs_t bs;
- if( !p_dec->fmt_in.i_extra )
+ if( p_dec->fmt_in.i_extra < 8 + 14 )
return;
- bs_init( &bs, p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra );
+ bs_init( &bs, (uint8_t*)p_dec->fmt_in.p_extra + 8, p_dec->fmt_in.i_extra - 8 );
p_sys->stream_info.min_blocksize = bs_read( &bs, 16 );
p_sys->stream_info.max_blocksize = bs_read( &bs, 16 );
if( !p_sys->b_stream_info )
ProcessHeader( p_dec );
- if( p_sys->stream_info.channels > 6 )
+ if( p_sys->stream_info.channels > 8 )
{
msg_Err( p_dec, "This stream uses too many audio channels" );
return NULL;
if( p_sys->i_rate != p_dec->fmt_out.audio.i_rate )
{
p_dec->fmt_out.audio.i_rate = p_sys->i_rate;
+ const mtime_t i_end_date = date_Get( &p_sys->end_date );
date_Init( &p_sys->end_date, p_sys->i_rate, 1 );
- date_Set( &p_sys->end_date, p_sys->i_pts );
+ date_Set( &p_sys->end_date, i_end_date );
}
p_sys->i_state = STATE_NEXT_SYNC;
- p_sys->i_frame_size = 1;
+ p_sys->i_frame_size = p_sys->b_stream_info && p_sys->stream_info.min_framesize > 0 ?
+ p_sys->stream_info.min_framesize : 1;
case STATE_NEXT_SYNC:
/* TODO: If pp_block == NULL, flush the buffer without checking the
if( p_sys->i_state != STATE_SEND_DATA )
{
+ if( p_sys->b_stream_info && p_sys->stream_info.max_framesize > 0 &&
+ p_sys->i_frame_size > p_sys->stream_info.max_framesize )
+ {
+ block_SkipByte( &p_sys->bytestream );
+ p_sys->i_state = STATE_NOSYNC;
+ return NULL;
+ }
/* Need more data */
return NULL;
}
static int SyncInfo( decoder_t *p_dec, uint8_t *p_buf,
unsigned int * pi_channels,
unsigned int * pi_sample_rate,
- int * pi_bits_per_sample )
+ unsigned int * pi_bits_per_sample )
{
decoder_sys_t *p_sys = p_dec->p_sys;
int i_header, i_temp, i_read;
if( i_blocksize < p_sys->stream_info.min_blocksize ||
i_blocksize > p_sys->stream_info.max_blocksize )
return 0;
+ if( *pi_bits_per_sample != p_sys->stream_info.bits_per_sample )
+ return 0;
+ if( *pi_sample_rate != p_sys->stream_info.sample_rate )
+ return 0;
}
return i_blocksize;
}