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

Steve Lhomme robux4 at ycbcr.xyz
Tue Nov 5 16:18:46 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 0361d9cb18c..ba3c5508c3f 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_input;
-    es_format_InitFromVideo(&fmt_input, source ? source : &vout->p->filter.src_fmt);
+    vlc_video_context *vctx_input;
+    if (source)
+    {
+        es_format_InitFromVideo(&fmt_input, source);
+        vctx_input = src_vctx;
+    }
+    else
+    {
+        es_format_InitFromVideo(&fmt_input, &vout->p->filter.src_fmt);
+        vctx_input = vout->p->filter.src_vctx;
+    }
 
     const es_format_t *p_fmt_current = &fmt_input;
+    vlc_video_context *vctx_current = vctx_input;
 
     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_input)) {
+    if (!es_format_IsSimilar(p_fmt_current, &fmt_input) /*||
+        !vlc_video_context_IsSimilar( vctx_current, vctx_input )*/)
+    {
         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_input) != 0) {
+                                         p_fmt_current, vctx_current, &fmt_input) != 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_input, NULL /* TODO */, &fmt_input);
-            filter_chain_Reset(vout->p->filter.chain_interactive, &fmt_input, NULL /* TODO */, &fmt_input);
+            filter_chain_Reset(vout->p->filter.chain_static,      &fmt_input, vctx_input, &fmt_input);
+            filter_chain_Reset(vout->p->filter.chain_interactive, &fmt_input, vctx_input, &fmt_input);
         }
     }
 
-- 
2.17.1



More information about the vlc-devel mailing list