[vlc-devel] [PATCH v1 07/33] filter: allow using filters with a sink callback to filter into a single picture

Steve Lhomme robux4 at ycbcr.xyz
Sat Sep 26 08:06:28 CEST 2020


On 2020-09-25 17:27, Rémi Denis-Courmont wrote:
> Hi,
> 
> That API is fundamentally incompatible with asynchronous use as the 
> filter would have no sink to output to outside the callback.

Filter users that use filter_FilterSingle() are indeed incompatible with 
an asynchronous system. This was true so far and is still true now. This 
special case exists so they don't have to be rewritten to handle the 
more generic case of having more pictures to handle than they receive.

If you look at the branch, all callers are using an internal converter 
to convert whatever they have into whatever they need. If you make this 
code handle the case where they convert one picture and get two, what 
happens to the second picture ? Which of the two is the one to use ? And 
making this fundamentally asynchronous would make things worse. For 
example the d3d11/dxa9 ones allocate one texture to receive the 
converted result. Now they would have to allocate plenty.

> That's why decoders get an owner callback for this purpose instead.

This does not change anything.

> While I don't expect that asynchronous filters will work quiet yet, I 
> don't want to revector into an API that gets us further from the goal.

Sinks are actually a big step towards asynchronous use. The owner 
pattern is too centralized for that and would need to manage each step 
of the pipeline, maybe with a state machine or something.

> Le 25 septembre 2020 17:46:43 GMT+03:00, Steve Lhomme <robux4 at ycbcr.xyz> 
> a écrit :
> 
>     If a filter sending pictures to a sink send more than one picture to a sink,
>     the code will assert. It means filter_FilterSingle was used with a filter that
>     sends more than one picture. So filter_FilterSingle() should only be used with
>     safe filters, ie not user defined ones bu mostly converters. This is already
>     the case.
>     ------------------------------------------------------------------------
>       include/vlc_filter.h | 15 +++++++++++++++
>       1 file changed, 15 insertions(+)
> 
>     diff --git a/include/vlc_filter.h b/include/vlc_filter.h
>     index 9f8da434fd4..e660e8c6d18 100644
>     --- a/include/vlc_filter.h
>     +++ b/include/vlc_filter.h
>     @@ -219,8 +219,23 @@ static inline picture_t *filter_NewPicture( filter_t *p_filter )
>           return pic;
>       }
>       
>     +static inline int GetSingleResult(struct vlc_video_sink *sink, picture_t *output)
>     +{
>     +    picture_t **single_output = (picture_t **)sink->sys;
>     +    vlc_assert(*single_output == NULL); // called filter_FilterSingle on wrong filter
>     +    *single_output = output;
>     +    return VLC_SUCCESS;
>     +}
>     +
>       static inline picture_t *filter_FilterSingle( filter_t *p_filter, picture_t *pic )
>       {
>     +    if ( p_filter->pf_video_filter_into != NULL )
>     +    {
>     +        picture_t *result = NULL;
>     +        struct vlc_video_sink sink = { &result, GetSingleResult };
>     +        p_filter->pf_video_filter_into( p_filter, pic, &sink );
>     +        return result;
>     +    }
>           return p_filter->pf_video_filter( p_filter, pic );
>       }
>       
> 
> 
> -- 
> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser 
> ma brièveté.
> 
> _______________________________________________
> 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