Commit a82a5094 authored by Laurent Aimar's avatar Laurent Aimar

video: fixed preroll

audio: use avcodec_decode_audio2
       use block_Realloc to pad buffer.
	   fixed decoding when SplitBuffer is used (flac)
parent 7263355f
...@@ -203,7 +203,14 @@ aout_buffer_t *E_( DecodeAudio )( decoder_t *p_dec, block_t **pp_block ) ...@@ -203,7 +203,14 @@ aout_buffer_t *E_( DecodeAudio )( decoder_t *p_dec, block_t **pp_block )
p_block = *pp_block; p_block = *pp_block;
if( p_block->i_buffer <= 0 && p_sys->i_samples > 0 ) if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
{
block_Release( p_block );
avcodec_flush_buffers( p_sys->p_context );
return NULL;
}
if( p_sys->i_samples > 0 )
{ {
/* More data */ /* More data */
p_buffer = SplitBuffer( p_dec ); p_buffer = SplitBuffer( p_dec );
...@@ -218,20 +225,25 @@ aout_buffer_t *E_( DecodeAudio )( decoder_t *p_dec, block_t **pp_block ) ...@@ -218,20 +225,25 @@ aout_buffer_t *E_( DecodeAudio )( decoder_t *p_dec, block_t **pp_block )
return NULL; return NULL;
} }
if( p_block->i_buffer <= 0 || if( p_block->i_buffer <= 0 )
(p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED)) )
{ {
block_Release( p_block ); block_Release( p_block );
return NULL; return NULL;
} }
if( p_block->i_buffer > AVCODEC_MAX_AUDIO_FRAME_SIZE ) if( p_block->i_buffer > AVCODEC_MAX_AUDIO_FRAME_SIZE )
{ {
/* Grow output buffer if necessary (eg. for PCM data) */ /* Grow output buffer if necessary (eg. for PCM data) */
p_sys->p_output = realloc(p_sys->p_output, p_block->i_buffer); p_sys->p_output = realloc(p_sys->p_output, p_block->i_buffer);
} }
i_used = avcodec_decode_audio( p_sys->p_context, *pp_block = p_block = block_Realloc( p_block, 0, p_block->i_buffer + FF_INPUT_BUFFER_PADDING_SIZE );
if( !p_block )
return NULL;
p_block->i_buffer -= FF_INPUT_BUFFER_PADDING_SIZE;
memset( &p_block->p_buffer[p_block->i_buffer], 0, FF_INPUT_BUFFER_PADDING_SIZE );
i_output = __MAX( AVCODEC_MAX_AUDIO_FRAME_SIZE, p_block->i_buffer );
i_used = avcodec_decode_audio2( p_sys->p_context,
(int16_t*)p_sys->p_output, &i_output, (int16_t*)p_sys->p_output, &i_output,
p_block->p_buffer, p_block->i_buffer ); p_block->p_buffer, p_block->i_buffer );
......
...@@ -376,6 +376,9 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block ) ...@@ -376,6 +376,9 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block )
p_sys->i_late_frames = 0; p_sys->i_late_frames = 0;
block_Release( p_block ); block_Release( p_block );
//if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
//avcodec_flush_buffers( p_sys->p_context );
return NULL; return NULL;
} }
...@@ -433,16 +436,11 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block ) ...@@ -433,16 +436,11 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block )
} }
else else
{ {
if (!(p_block->i_flags & BLOCK_FLAG_PREROLL)) p_sys->p_context->hurry_up = 0;
{ if( !(p_block->i_flags & BLOCK_FLAG_PREROLL) )
b_drawpicture = 1; b_drawpicture = 1;
p_sys->p_context->hurry_up = 0;
}
else else
{
b_drawpicture = 0; b_drawpicture = 0;
p_sys->p_context->hurry_up = 1;
}
} }
...@@ -540,6 +538,9 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block ) ...@@ -540,6 +538,9 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block )
if( !b_drawpicture || !p_sys->p_ff_pic->linesize[0] ) if( !b_drawpicture || !p_sys->p_ff_pic->linesize[0] )
{ {
/* Do not display the picture */ /* Do not display the picture */
p_pic = (picture_t *)p_sys->p_ff_pic->opaque;
if( !b_drawpicture && p_pic )
p_dec->pf_vout_buffer_del( p_dec, p_pic );
continue; continue;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment