[vlc-devel] [PATCH 09/23] video_output: pass the input video context with the source format

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


Keep it and release it at the same time.
---
 src/video_output/video_output.c  | 29 ++++++++++++++++++++++++-----
 src/video_output/vout_internal.h |  1 +
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index fecdbbe35dd..a67e2fec1ca 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -749,7 +749,7 @@ typedef struct {
 } vout_filter_t;
 
 static void ThreadChangeFilters(vout_thread_t *vout,
-                                const video_format_t *source,
+                                const video_format_t *source, vlc_video_context *src_vctx,
                                 const char *filters,
                                 const bool *new_deinterlace,
                                 bool is_locked)
@@ -867,6 +867,7 @@ static void ThreadChangeFilters(vout_thread_t *vout,
     if (source) {
         video_format_Clean(&vout->p->filter.src_fmt);
         video_format_Copy(&vout->p->filter.src_fmt, source);
+        vout->p->filter.src_vctx = src_vctx ? vlc_video_context_Hold(src_vctx) : NULL;
     }
 
     if (!is_locked)
@@ -926,8 +927,9 @@ static int ThreadDisplayPreparePicture(vout_thread_t *vout, bool reuse,
                         msg_Dbg(vout, "picture might be displayed late (missing %"PRId64" ms)", MS_FROM_VLC_TICK(late));
                     }
                 }
-                if (!VideoFormatIsCropArEqual(&decoded->format, &vout->p->filter.src_fmt))
-                    ThreadChangeFilters(vout, &decoded->format, NULL, NULL, true);
+                if (!VideoFormatIsCropArEqual(&decoded->format, &vout->p->filter.src_fmt) ||
+                    !vlc_video_context_IsSimilar(decoded->vctx, vout->p->filter.src_vctx))
+                    ThreadChangeFilters(vout, &decoded->format, decoded->vctx, NULL, NULL, true);
             }
         }
 
@@ -1518,6 +1520,7 @@ static int vout_Start(vout_thread_t *vout, vlc_video_context *vctx, const vout_c
 
     sys->filter.configuration = NULL;
     video_format_Copy(&sys->filter.src_fmt, &sys->original);
+    sys->filter.src_vctx = vctx ? vlc_video_context_Hold(vctx) : NULL;
 
     static const struct filter_video_callbacks static_cbs = {
         VoutVideoFilterStaticNewPicture,
@@ -1618,6 +1621,11 @@ error:
     if (sys->filter.chain_static != NULL)
         filter_chain_Delete(sys->filter.chain_static);
     video_format_Clean(&sys->filter.src_fmt);
+    if (sys->filter.src_vctx)
+    {
+        vlc_video_context_Release(sys->filter.src_vctx);
+        sys->filter.src_vctx = NULL;
+    }
     if (sys->decoder_fifo != NULL)
     {
         picture_fifo_Delete(sys->decoder_fifo);
@@ -1630,10 +1638,10 @@ static void ThreadControl(vout_thread_t *vout, vout_control_cmd_t cmd)
 {
     switch(cmd.type) {
     case VOUT_CONTROL_CHANGE_FILTERS:
-        ThreadChangeFilters(vout, NULL, cmd.string, NULL, false);
+        ThreadChangeFilters(vout, NULL, NULL, cmd.string, NULL, false);
         break;
     case VOUT_CONTROL_CHANGE_INTERLACE:
-        ThreadChangeFilters(vout, NULL, NULL, &cmd.boolean, false);
+        ThreadChangeFilters(vout, NULL, NULL, NULL, &cmd.boolean, false);
         break;
     case VOUT_CONTROL_MOUSE_STATE:
         ThreadProcessMouseState(vout, &cmd.mouse);
@@ -1714,6 +1722,11 @@ static void vout_ReleaseDisplay(vout_thread_t *vout)
     filter_chain_Delete(sys->filter.chain_interactive);
     filter_chain_Delete(sys->filter.chain_static);
     video_format_Clean(&sys->filter.src_fmt);
+    if (sys->filter.src_vctx)
+    {
+        vlc_video_context_Release(sys->filter.src_vctx);
+        sys->filter.src_vctx = NULL;
+    }
     free(sys->filter.configuration);
 
     if (sys->decoder_fifo != NULL)
@@ -1747,6 +1760,11 @@ static void vout_DisableWindow(vout_thread_t *vout)
 {
     vout_thread_sys_t *sys = vout->p;
     vlc_mutex_lock(&sys->window_lock);
+    if (sys->filter.src_vctx)
+    {
+        vlc_video_context_Release(sys->filter.src_vctx);
+        sys->filter.src_vctx = NULL;
+    }
     if (sys->dec_device)
     {
         vlc_decoder_device_Release(sys->dec_device);
@@ -2055,6 +2073,7 @@ int vout_Request(const vout_configuration_t *cfg, vlc_video_context *vctx, input
         return -1;
     }
 
+    sys->filter.src_vctx = vctx ? vlc_video_context_Hold(vctx) : NULL;
     if (input != NULL && sys->spu)
         spu_Attach(sys->spu, input);
     vout_IntfReinit(vout);
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index 42c00de9809..0ca81871fee 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -163,6 +163,7 @@ struct vout_thread_sys_t
         vlc_mutex_t     lock;
         char            *configuration;
         video_format_t    src_fmt;
+        vlc_video_context *src_vctx;
         struct filter_chain_t *chain_static;
         struct filter_chain_t *chain_interactive;
         bool            has_deint;
-- 
2.17.1



More information about the vlc-devel mailing list