[vlc-devel] [PATCH] video_output: handle the filter change in ThreadDisplayPrerenderNext()

Steve Lhomme robux4 at ycbcr.xyz
Tue Jan 19 12:47:44 UTC 2021


This is a rebased version of a patch sent a few month ago with a branch 
that is mostly merged.

The commit log has changed a bit. In particular it explains how it's not 
equivalent to what was before. We used to drop pending (deinterlacing) 
pictures when applying new filters. Now we drain those pictures using 
the old filters before we apply the new filters.

This is better, in particular when user/dynamic filters are not used. 
The transition from interlaced to non-interlaced would lose the pending 
pictures.

When using user/dynamic filters that may mean these filters are only 
applied 1 or 2 frames later. If we want to be more responsive we will 
need to differentiate the restart or user/filters only from the other 
filters.

On 2021-01-19 13:42, Steve Lhomme wrote:
> If the source format changed we must update the filters. Only decoder format
> change is allowed. Filters cannot change the output format once they are
> settled.
> 
> We keep the displayed.decoded with the next format to update the filters.
> 
> We used to do the filter change before calling ThreadDisplayPrerenderNext(),
> so the filter.chain_static was reset and pending pictures were lost. Now
> We drain it before doing the filter change so no pictures created by these
> filters will be lost, even after a new source format is detected. The downside
> is that dynamic/user filters are not applied to these pending pictures.
> ---
>   src/video_output/video_output.c | 18 ++++++++----------
>   1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
> index d848e2fae1b..7d98ff43575 100644
> --- a/src/video_output/video_output.c
> +++ b/src/video_output/video_output.c
> @@ -1064,6 +1064,13 @@ static bool ThreadDisplayPrerenderNext(vout_thread_sys_t *vout, bool reuse_decod
>       assert(!reuse_decoded || !picture);
>   
>       while (!picture) {
> +        if (sys->filter.changed ||
> +            sys->private.interlacing.has_deint != sys->filter.new_interlaced)
> +        {
> +            sys->private.interlacing.has_deint = sys->filter.new_interlaced;
> +            ThreadChangeFilters(vout);
> +        }
> +
>           picture_t *decoded;
>           if (reuse_decoded && sys->displayed.decoded) {
>               decoded = picture_Hold(sys->displayed.decoded);
> @@ -1132,7 +1139,7 @@ static bool ThreadDisplayPrerenderNext(vout_thread_sys_t *vout, bool reuse_decod
>   
>   
>           if (sys->filter.changed)
> -            ThreadChangeFilters(vout);
> +            continue; // filter+display update needed, keep new displayed.decoded
>   
>           picture_Hold(sys->displayed.decoded);
>           picture = filter_chain_VideoFilter(sys->filter.chain_static, sys->displayed.decoded);
> @@ -1464,15 +1471,6 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
>   
>       assert(sys->clock);
>   
> -    vlc_mutex_lock(&sys->filter.lock);
> -    if (sys->filter.changed ||
> -        sys->private.interlacing.has_deint != sys->filter.new_interlaced)
> -    {
> -        sys->private.interlacing.has_deint = sys->filter.new_interlaced;
> -        ThreadChangeFilters(vout);
> -    }
> -    vlc_mutex_unlock(&sys->filter.lock);
> -
>       if (deadline)
>           *deadline = VLC_TICK_INVALID;
>   
> -- 
> 2.29.2
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
> 


More information about the vlc-devel mailing list