[vlc-devel] [PATCH 2/6] filter: fps: forward video context and ensure input

Alexandre Janniaux ajanni at videolabs.io
Tue Jun 9 18:43:56 CEST 2020


The FPS filter is resampling the input source into the output source but
it only modifies metadata, so input chroma and input video context must
be used for output.
---
 modules/stream_out/transcode/video.c |  2 +-
 modules/video_filter/fps.c           | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c
index a5ec642175..14282ae864 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -385,7 +385,7 @@ static int transcode_video_filters_init( sout_stream_t *p_stream,
 
     if( b_master_sync )
     {
-        filter_chain_AppendFilter( id->p_f_chain, "fps", NULL, p_dst );
+        filter_chain_AppendFilter( id->p_f_chain, "fps", NULL, p_src );
         p_src = filter_chain_GetFmtOut( id->p_f_chain );
         src_ctx = filter_chain_GetVideoCtxOut( id->p_f_chain );
     }
diff --git a/modules/video_filter/fps.c b/modules/video_filter/fps.c
index 99e13bc009..d2e524154d 100644
--- a/modules/video_filter/fps.c
+++ b/modules/video_filter/fps.c
@@ -138,6 +138,10 @@ static int Open( vlc_object_t *p_this)
     filter_t *p_filter = (filter_t*)p_this;
     filter_sys_t *p_sys;
 
+    /* This filter cannot change the format. */
+    if( p_filter->fmt_out.video.i_chroma != p_filter->fmt_in.video.i_chroma )
+        return VLC_EGENERIC;
+
     p_sys = p_filter->p_sys = malloc( sizeof( *p_sys ) );
 
     if( unlikely( !p_sys ) )
@@ -179,6 +183,11 @@ static int Open( vlc_object_t *p_this)
     p_sys->p_previous_pic = NULL;
 
     p_filter->pf_video_filter = Filter;
+
+    /* We don't change neither the format nor the picture */
+    if ( p_filter->vctx_in )
+        p_filter->vctx_out = vlc_video_context_Hold( p_filter->vctx_in );
+
     return VLC_SUCCESS;
 }
 
@@ -188,5 +197,7 @@ static void Close( vlc_object_t *p_this )
     filter_sys_t *p_sys = p_filter->p_sys;
     if( p_sys->p_previous_pic )
         picture_Release( p_sys->p_previous_pic );
+    if( p_filter->vctx_out )
+        vlc_video_context_Release( p_filter->vctx_out );
     free( p_sys );
 }
-- 
2.27.0



More information about the vlc-devel mailing list