[vlc-devel] [PATCH 20/23] filters: chain: set the output vctx from the internal filter chain output vctx

Steve Lhomme robux4 at ycbcr.xyz
Thu Nov 7 10:31:35 CET 2019


---
 modules/video_chroma/chain.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/modules/video_chroma/chain.c b/modules/video_chroma/chain.c
index a6002373c12..27304185609 100644
--- a/modules/video_chroma/chain.c
+++ b/modules/video_chroma/chain.c
@@ -204,6 +204,7 @@ static int Activate( filter_t *p_filter, int (*pf_build)(filter_t *) )
         es_format_Copy( &p_filter->fmt_out,
                         filter_chain_GetFmtOut( p_sys->p_chain ) );
     }
+    assert(p_filter->vctx_out == filter_chain_GetVideoCtxOut( p_sys->p_chain ));
     /* */
     p_filter->pf_video_filter = Chain;
     return VLC_SUCCESS;
@@ -288,7 +289,7 @@ static int BuildTransformChain( filter_t *p_filter )
     /* Lets try resize+chroma first, then transform */
     msg_Dbg( p_filter, "Trying to build chroma+resize" );
     EsFormatMergeSize( &fmt_mid, &p_filter->fmt_out, &p_filter->fmt_in );
-    i_ret = CreateChain( p_filter, &fmt_mid, p_filter->vctx_in );
+    i_ret = CreateChain( p_filter, &fmt_mid, p_filter->vctx_out );
     es_format_Clean( &fmt_mid );
     return i_ret;
 }
@@ -310,7 +311,7 @@ static int BuildChromaResize( filter_t *p_filter )
     /* Lets try it the other way arround (chroma and then resize) */
     msg_Dbg( p_filter, "Trying to build chroma+resize" );
     EsFormatMergeSize( &fmt_mid, &p_filter->fmt_out, &p_filter->fmt_in );
-    i_ret = CreateChain( p_filter, &fmt_mid, p_filter->vctx_in );
+    i_ret = CreateChain( p_filter, &fmt_mid, p_filter->vctx_out );
     es_format_Clean( &fmt_mid );
     if( i_ret == VLC_SUCCESS )
         return VLC_SUCCESS;
@@ -393,10 +394,12 @@ static int BuildFilterChain( filter_t *p_filter )
         if( filter_chain_AppendConverter( p_sys->p_chain,
                                           NULL, NULL, &fmt_mid ) == VLC_SUCCESS )
         {
+            vlc_video_context *mid_ctx = filter_chain_GetVideoCtxOut( p_sys->p_chain );
+
             p_sys->p_video_filter =
                 filter_chain_AppendFilter( p_sys->p_chain,
                                            p_filter->psz_name, p_filter->p_cfg,
-                                           &fmt_mid, NULL, &fmt_mid );
+                                           &fmt_mid, mid_ctx, &fmt_mid );
             if( p_sys->p_video_filter )
             {
                 filter_AddProxyCallbacks( p_filter,
@@ -406,6 +409,7 @@ static int BuildFilterChain( filter_t *p_filter )
                     p_filter->pf_video_mouse = ChainMouse;
                 es_format_Clean( &fmt_mid );
                 i_ret = VLC_SUCCESS;
+                p_filter->vctx_out = filter_chain_GetVideoCtxOut( p_sys->p_chain );
                 break;
             }
         }
@@ -431,8 +435,11 @@ static int CreateChain( filter_t *p_filter, const es_format_t *p_fmt_mid, vlc_vi
         // Check if filter was enough:
         if( p_transform == NULL )
             return VLC_EGENERIC;
-        if( es_format_IsSimilar(&p_transform->fmt_out, &p_filter->fmt_out ))
-           return VLC_SUCCESS;
+        if( es_format_IsSimilar(&p_transform->fmt_out, &p_filter->fmt_out ) )
+        {
+            p_filter->vctx_out = p_transform->vctx_out;
+            return VLC_SUCCESS;
+        }
     }
     else
     {
@@ -453,6 +460,7 @@ static int CreateChain( filter_t *p_filter, const es_format_t *p_fmt_mid, vlc_vi
                                           p_fmt_mid, vctx_mid, &p_filter->fmt_out ) )
             goto error;
     }
+    p_filter->vctx_out = filter_chain_GetVideoCtxOut( p_sys->p_chain );
     return VLC_SUCCESS;
 error:
     //Clean up.
@@ -491,6 +499,9 @@ static int CreateResizeChromaChain( filter_t *p_filter, const es_format_t *p_fmt
 
     if( i_ret != VLC_SUCCESS )
         filter_chain_Clear( p_sys->p_chain );
+    else
+        p_filter->vctx_out = filter_chain_GetVideoCtxOut( p_sys->p_chain );
+
     return i_ret;
 }
 
-- 
2.17.1



More information about the vlc-devel mailing list