[vlc-commits] filter_chain: add a specific function to clear (empty) a filter chain
Steve Lhomme
git at videolan.org
Wed Sep 18 09:06:22 CEST 2019
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Sep 17 15:12:05 2019 +0200| [97ac6ec0ced4d816f013a8f036a7579a6d301b27] | committer: Steve Lhomme
filter_chain: add a specific function to clear (empty) a filter chain
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.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=97ac6ec0ced4d816f013a8f036a7579a6d301b27
---
include/vlc_filter.h | 11 +++++++++--
modules/video_chroma/chain.c | 4 ++--
src/libvlccore.sym | 1 +
src/misc/filter_chain.c | 29 +++++++++++++++--------------
src/video_output/vout_subpictures.c | 6 +++---
5 files changed, 30 insertions(+), 21 deletions(-)
diff --git a/include/vlc_filter.h b/include/vlc_filter.h
index 6363ccf304..f2618cc1e1 100644
--- a/include/vlc_filter.h
+++ b/include/vlc_filter.h
@@ -350,12 +350,19 @@ 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.
*
* \param chain filter chain to append a filter to
diff --git a/modules/video_chroma/chain.c b/modules/video_chroma/chain.c
index 52b12d447d..899081a4fc 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 f278fe6e9d..e5241c411d 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 d0b08fc69e..de2b713dfc 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,15 @@ 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 );
- }
+ assert(p_fmt_in != NULL);
+ es_format_Clean( &p_chain->fmt_in );
+ es_format_Copy( &p_chain->fmt_in, p_fmt_in );
+
+ assert(p_fmt_out != NULL);
+ es_format_Clean( &p_chain->fmt_out );
+ es_format_Copy( &p_chain->fmt_out, p_fmt_out );
}
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 d7e7c6fdd8..3e98e9f976 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)
More information about the vlc-commits
mailing list