[vlc-devel] [PATCH 12/14] filter_chain: add a specific function to clear (empty) a filter chain

Steve Lhomme robux4 at ycbcr.xyz
Wed Sep 18 08:02:40 CEST 2019


On 2019-09-17 17:33, Rémi Denis-Courmont wrote:
> Le tiistaina 17. syyskuuta 2019, 17.22.40 EEST Steve Lhomme a écrit :
>> filter_chain_Reset is reserved for restating new input/output formats and
>> does not allow empty format anymore.
>>
>> filter_chain_Clear doesn't change the input/output formats, only remove all
>> the filters.
>> ---
>>   include/vlc_filter.h                | 11 +++++++++--
>>   modules/video_chroma/chain.c        |  4 ++--
>>   src/libvlccore.sym                  |  1 +
>>   src/misc/filter_chain.c             | 27 +++++++++++++--------------
>>   src/video_output/vout_subpictures.c |  6 +++---
>>   5 files changed, 28 insertions(+), 21 deletions(-)
>>
>> diff --git a/include/vlc_filter.h b/include/vlc_filter.h
>> index 6363ccf3048..f2618cc1e1a 100644
>> --- a/include/vlc_filter.h
>> +++ b/include/vlc_filter.h
>> @@ -350,11 +350,18 @@ VLC_API void filter_chain_Delete( filter_chain_t * );
>>    * reset p_fmt_in and p_fmt_out to the new values.
>>    *
>>    * \param p_chain pointer to filter chain
>> - * \param p_fmt_in new fmt_in params, may be NULL to leave input fmt
>> unchanged - * \param p_fmt_out new fmt_out params, may be NULL to leave
>> output fmt unchanged + * \param p_fmt_in new fmt_in params
>> + * \param p_fmt_out new fmt_out params
>>    */
>>   VLC_API void filter_chain_Reset( filter_chain_t *, const es_format_t *,
>> const es_format_t * );
>>
>> +/**
>> + * Remove all existing filters
>> + *
>> + * \param p_chain pointer to filter chain
>> + */
>> +VLC_API void filter_chain_Clear(filter_chain_t *);
>> +
>>   /**
>>    * Append a filter to the chain.
>>    *
>> diff --git a/modules/video_chroma/chain.c b/modules/video_chroma/chain.c
>> index 52b12d447d3..899081a4fce 100644
>> --- a/modules/video_chroma/chain.c
>> +++ b/modules/video_chroma/chain.c
>> @@ -457,7 +457,7 @@ static int CreateChain( filter_t *p_parent, const
>> es_format_t *p_fmt_mid ) return VLC_SUCCESS;
>>   error:
>>       //Clean up.
>> -    filter_chain_Reset( p_sys->p_chain, NULL, NULL );
>> +    filter_chain_Clear( p_sys->p_chain );
>>       return VLC_EGENERIC;
>>   }
>>
>> @@ -491,7 +491,7 @@ static int CreateResizeChromaChain( filter_t *p_parent,
>> const es_format_t *p_fmt NULL, &p_parent->fmt_out );
>>
>>       if( i_ret != VLC_SUCCESS )
>> -        filter_chain_Reset( p_sys->p_chain, NULL, NULL );
>> +        filter_chain_Clear( p_sys->p_chain );
>>       return i_ret;
>>   }
>>
>> diff --git a/src/libvlccore.sym b/src/libvlccore.sym
>> index f278fe6e9de..e5241c411d0 100644
>> --- a/src/libvlccore.sym
>> +++ b/src/libvlccore.sym
>> @@ -112,6 +112,7 @@ filter_chain_IsEmpty
>>   filter_chain_MouseFilter
>>   filter_chain_NewVideo
>>   filter_chain_Reset
>> +filter_chain_Clear
>>   filter_chain_SubFilter
>>   filter_chain_VideoFilter
>>   filter_chain_VideoFlush
>> diff --git a/src/misc/filter_chain.c b/src/misc/filter_chain.c
>> index d0b08fc69eb..1b61178e24a 100644
>> --- a/src/misc/filter_chain.c
>> +++ b/src/misc/filter_chain.c
>> @@ -149,13 +149,18 @@ filter_chain_t *filter_chain_NewVideo( vlc_object_t
>> *obj, bool allow_change, return chain;
>>   }
>>
>> +void filter_chain_Clear( filter_chain_t *p_chain )
>> +{
>> +    while( p_chain->first != NULL )
>> +        filter_chain_DeleteFilter( p_chain, &p_chain->first->filter );
>> +}
>> +
>>   /**
>>    * Filter chain destruction
>>    */
>>   void filter_chain_Delete( filter_chain_t *p_chain )
>>   {
>> -    while( p_chain->first != NULL )
>> -        filter_chain_DeleteFilter( p_chain, &p_chain->first->filter );
>> +    filter_chain_Clear( p_chain );
>>
>>       es_format_Clean( &p_chain->fmt_in );
>>       es_format_Clean( &p_chain->fmt_out );
>> @@ -168,19 +173,13 @@ void filter_chain_Delete( filter_chain_t *p_chain )
>>   void filter_chain_Reset( filter_chain_t *p_chain, const es_format_t
>> *p_fmt_in, const es_format_t *p_fmt_out )
>>   {
>> -    while( p_chain->first != NULL )
>> -        filter_chain_DeleteFilter( p_chain, &p_chain->first->filter );
>> +    filter_chain_Clear( p_chain );
>>
>> -    if( p_fmt_in )
>> -    {
>> -        es_format_Clean( &p_chain->fmt_in );
>> -        es_format_Copy( &p_chain->fmt_in, p_fmt_in );
>> -    }
>> -    if( p_fmt_out )
>> -    {
>> -        es_format_Clean( &p_chain->fmt_out );
>> -        es_format_Copy( &p_chain->fmt_out, p_fmt_out );
>> -    }
>> +    es_format_Clean( &p_chain->fmt_in );
>> +    es_format_Copy( &p_chain->fmt_in, p_fmt_in );
>> +
>> +    es_format_Clean( &p_chain->fmt_out );
>> +    es_format_Copy( &p_chain->fmt_out, p_fmt_out );
> 
> Missing non-NULL assertions IMO.

Good point.

>>   }
>>
>>   static filter_t *filter_chain_AppendInner( filter_chain_t *chain,
>> diff --git a/src/video_output/vout_subpictures.c
>> b/src/video_output/vout_subpictures.c index d7e7c6fdd87..3e98e9f9766 100644
>> --- a/src/video_output/vout_subpictures.c
>> +++ b/src/video_output/vout_subpictures.c
>> @@ -1806,7 +1806,7 @@ void spu_PutSubpicture(spu_t *spu, subpicture_t
>> *subpic) filter_chain_ForEach(sys->filter_chain,
>>                                        SubFilterDelProxyCallbacks,
>>                                        sys->vout);
>> -            filter_chain_Reset(sys->filter_chain, NULL, NULL);
>> +            filter_chain_Clear(sys->filter_chain);
>>
>>               filter_chain_AppendFromString(spu->p->filter_chain,
>> chain_update); if (sys->vout)
>> @@ -1815,7 +1815,7 @@ void spu_PutSubpicture(spu_t *spu, subpicture_t
>> *subpic) sys->vout);
>>           }
>>           else
>> -            filter_chain_Reset(sys->filter_chain, NULL, NULL);
>> +            filter_chain_Clear(sys->filter_chain);
>>
>>           /* "sub-source"  was formerly "sub-filter", so now the "sub-filter"
>> configuration may contain sub-filters or sub-sources configurations. @@
>> -1913,7 +1913,7 @@ subpicture_t *spu_Render(spu_t *spu,
>>                   filter_chain_ForEach(sys->source_chain,
>>                                        SubSourceDelProxyCallbacks,
>>                                        sys->vout);
>> -        filter_chain_Reset(sys->source_chain, NULL, NULL);
>> +        filter_chain_Clear(sys->source_chain);
>>
>>           filter_chain_AppendFromString(spu->p->source_chain, chain_update);
>>           if (sys->vout)
> 
> 
> -- 
> Rémi Denis-Courmont
> http://www.remlab.net/
> 
> 
> 
> _______________________________________________
> 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