[vlc-devel] [RFC PATCH 4/4] avocodec: flush buffers in case of mt

Rémi Denis-Courmont remi at remlab.net
Tue Nov 17 16:40:42 CET 2015


Le 2015-11-17 18:16, Thomas Guillem a écrit :
> The NOTE in comment is not good with multi-threading activated.
> Indeed, after a
> flush, when mt was on, pf_decode could return old pictures from 
> before the
> flush.
> ---
>  modules/codec/avcodec/video.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/modules/codec/avcodec/video.c 
> b/modules/codec/avcodec/video.c
> index 1b98c5c..0a7a4b6 100644
> --- a/modules/codec/avcodec/video.c
> +++ b/modules/codec/avcodec/video.c
> @@ -533,17 +533,17 @@ static picture_t *DecodeVideo( decoder_t
> *p_dec, block_t **pp_block )
>              p_sys->i_pts = VLC_TS_INVALID; /* To make sure we
> recover properly */
>
>              p_sys->i_late_frames = 0;
> -#if 0
> -            /* NOTE: data is good only the timeline changed so do
> not flush decoder */
> -            post_mt( p_sys );
> -            if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
> +            /* NOTE: when using one thread, data is good, only the 
> timeline
> +             * changed so do not flush decoder */
> +            if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY
> +             && p_context->thread_count > 1 )

Confusing flush and discontinuity. This may cause terrible results on 
DVB or UDP.

>              {
> +                post_mt( p_sys );
>                  p_sys->b_flushing_buffers = true;
>                  avcodec_flush_buffers( p_context );
>                  p_sys->b_flushing_buffers = false;
> +                wait_mt( p_sys );
>              }
> -            wait_mt( p_sys );
> -#endif
>              if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
>              {
>                  block_Release( p_block );

-- 
Rémi Denis-Courmont
http://www.remlab.net/


More information about the vlc-devel mailing list