[vlc-devel] [PATCH 18/19] filter: add function to get the output video context

Steve Lhomme robux4 at ycbcr.xyz
Tue Nov 5 16:18:45 CET 2019


Similar to how we get the output video format.
---
 include/vlc_filter.h    |  8 ++++++++
 src/libvlccore.sym      |  1 +
 src/misc/filter_chain.c | 11 +++++++++++
 3 files changed, 20 insertions(+)

diff --git a/include/vlc_filter.h b/include/vlc_filter.h
index 8a3bc6290c2..a3818e8c132 100644
--- a/include/vlc_filter.h
+++ b/include/vlc_filter.h
@@ -433,6 +433,14 @@ VLC_API bool filter_chain_IsEmpty(const filter_chain_t *chain);
  */
 VLC_API const es_format_t *filter_chain_GetFmtOut(const filter_chain_t *chain);
 
+/**
+ * Get last output video context of the last element in the filter chain.
+ * \note doesn't create change the reference count
+ *
+ * \param chain filter chain
+ */
+VLC_API vlc_video_context *filter_chain_GetVideoCtxOut(const filter_chain_t *chain);
+
 /**
  * Apply the filter chain to a video picture.
  *
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 3ea59614722..935cba909a3 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -110,6 +110,7 @@ filter_chain_AppendFromString
 filter_chain_Delete
 filter_chain_DeleteFilter
 filter_chain_GetFmtOut
+filter_chain_GetVideoCtxOut
 filter_chain_IsEmpty
 filter_chain_MouseFilter
 filter_chain_NewVideo
diff --git a/src/misc/filter_chain.c b/src/misc/filter_chain.c
index 210cf4640c3..79e7ee8914d 100644
--- a/src/misc/filter_chain.c
+++ b/src/misc/filter_chain.c
@@ -409,6 +409,17 @@ const es_format_t *filter_chain_GetFmtOut( const filter_chain_t *p_chain )
     return &p_chain->reset_fmt_out;
 }
 
+vlc_video_context *filter_chain_GetVideoCtxOut(const filter_chain_t *p_chain)
+{
+    if( p_chain->last != NULL )
+        return p_chain->last->filter.vctx_out;
+
+    /* No filter was added, the filter chain has no effect, make sure the chromas are compatible */
+    assert(p_chain->fmt_in.video.i_chroma == p_chain->reset_fmt_out.video.i_chroma);
+    assert(p_chain->is_reset);
+    return p_chain->vctx_in;
+}
+
 static picture_t *FilterChainVideoFilter( chained_filter_t *f, picture_t *p_pic )
 {
     for( ; f != NULL; f = f->next )
-- 
2.17.1



More information about the vlc-devel mailing list