[vlc-devel] [PATCH 18/23] video output: pass the input video context when creating filters

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


For now we don't enforce similar video context as the chroma differences should
be sufficient to detect source changes. We can only enable this check once all
filters outputting GPU surfaces set the filter->vctx_out.
---
 src/video_output/video_output.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 9c75569d217..378853510f0 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -813,9 +813,20 @@ static void ThreadChangeFilters(vout_thread_t *vout,
         vlc_mutex_lock(&vout->p->filter.lock);
 
     es_format_t fmt_target;
-    es_format_InitFromVideo(&fmt_target, source ? source : &vout->p->filter.src_fmt);
+    vlc_video_context *vctx_target;
+    if (source)
+    {
+        es_format_InitFromVideo(&fmt_target, source);
+        vctx_target = src_vctx;
+    }
+    else
+    {
+        es_format_InitFromVideo(&fmt_target, &vout->p->filter.src_fmt);
+        vctx_target = vout->p->filter.src_vctx;
+    }
 
     const es_format_t *p_fmt_current = &fmt_target;
+    vlc_video_context *vctx_current = vctx_target;
 
     for (int a = 0; a < 2; a++) {
         vlc_array_t    *array = a == 0 ? &array_static :
@@ -823,7 +834,7 @@ static void ThreadChangeFilters(vout_thread_t *vout,
         filter_chain_t *chain = a == 0 ? vout->p->filter.chain_static :
                                          vout->p->filter.chain_interactive;
 
-        filter_chain_Reset(chain, p_fmt_current, NULL /* TODO */, p_fmt_current);
+        filter_chain_Reset(chain, p_fmt_current, vctx_current, p_fmt_current);
         for (size_t i = 0; i < vlc_array_count(array); i++) {
             vout_filter_t *e = vlc_array_item_at_index(array, i);
             msg_Dbg(vout, "Adding '%s' as %s", e->name, a == 0 ? "static" : "interactive");
@@ -843,18 +854,21 @@ static void ThreadChangeFilters(vout_thread_t *vout,
         if (!filter_chain_IsEmpty(chain))
         {
             p_fmt_current = filter_chain_GetFmtOut(chain);
+            vctx_current = filter_chain_GetVideoCtxOut(chain);
         }
         vlc_array_clear(array);
     }
 
-    if (!es_format_IsSimilar(p_fmt_current, &fmt_target)) {
+    if (!es_format_IsSimilar(p_fmt_current, &fmt_target) /*||
+        !vlc_video_context_IsSimilar( vctx_current, vctx_target )*/)
+    {
         msg_Dbg(vout, "Adding a filter to compensate for format changes");
         if (filter_chain_AppendConverter(vout->p->filter.chain_interactive,
-                                         p_fmt_current, NULL /* TODO */, &fmt_target) != 0) {
+                                         p_fmt_current, vctx_current, &fmt_target) != 0) {
             msg_Err(vout, "Failed to compensate for the format changes, removing all filters");
             ThreadDelAllFilterCallbacks(vout);
-            filter_chain_Reset(vout->p->filter.chain_static,      &fmt_target, NULL /* TODO */, &fmt_target);
-            filter_chain_Reset(vout->p->filter.chain_interactive, &fmt_target, NULL /* TODO */, &fmt_target);
+            filter_chain_Reset(vout->p->filter.chain_static,      &fmt_target, vctx_target, &fmt_target);
+            filter_chain_Reset(vout->p->filter.chain_interactive, &fmt_target, vctx_target, &fmt_target);
         }
     }
 
-- 
2.17.1



More information about the vlc-devel mailing list