[vlc-devel] [PATCH v2 3/6] video_output: let the deinterlacing code access vout_thread_t

Steve Lhomme robux4 at ycbcr.xyz
Mon Nov 9 10:32:32 CET 2020


This is still private compared to the rest of the core. deinterlacing.c
contains the video_output logic to switch the deinterlacing mode.

We don't pass the vout_thread_interlacing_t anymore as it can be deduced from
the vout_thread_t pointer.
---
 src/video_output/interlacing.c  | 12 +++--
 src/video_output/video_output.c | 80 ++++++++++++++++-----------------
 src/video_output/vout_private.h | 13 ++++--
 3 files changed, 58 insertions(+), 47 deletions(-)

diff --git a/src/video_output/interlacing.c b/src/video_output/interlacing.c
index bb2f1341eac..e98e76bf7ad 100644
--- a/src/video_output/interlacing.c
+++ b/src/video_output/interlacing.c
@@ -90,8 +90,10 @@ static int DeinterlaceCallback(vlc_object_t *object, char const *cmd,
     return VLC_SUCCESS;
 }
 
-void vout_InitInterlacingSupport(vout_thread_t *vout, vout_thread_interlacing_t *sys)
+void vout_InitInterlacingSupport(vout_thread_t *vout)
 {
+    vout_sys_t *objsys = container_of(vout, vout_sys_t, obj);
+    vout_thread_interlacing_t *sys = &objsys->interlacing;
     vlc_value_t val;
 
     msg_Dbg(vout, "Deinterlacing available");
@@ -157,14 +159,18 @@ void vout_InitInterlacingSupport(vout_thread_t *vout, vout_thread_interlacing_t
     sys->is_interlaced = false;
 }
 
-void vout_ReinitInterlacingSupport(vout_thread_t *vout, vout_thread_interlacing_t *sys)
+void vout_ReinitInterlacingSupport(vout_thread_t *vout)
 {
+    vout_sys_t *objsys = container_of(vout, vout_sys_t, obj);
+    vout_thread_interlacing_t *sys = &objsys->interlacing;
     sys->is_interlaced = false;
     var_SetBool(vout, "deinterlace-needed", false);
 }
 
-void vout_SetInterlacingState(vout_thread_t *vout, vout_thread_interlacing_t *sys, bool is_interlaced)
+void vout_SetInterlacingState(vout_thread_t *vout, bool is_interlaced)
 {
+    vout_sys_t *objsys = container_of(vout, vout_sys_t, obj);
+    vout_thread_interlacing_t *sys = &objsys->interlacing;
     /* Wait 30s before quiting interlacing mode */
     const int interlacing_change = (!!is_interlaced)
                                  - (!!sys->is_interlaced);
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 4f87155225a..8ee65876807 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -64,9 +64,7 @@
 
 typedef struct vout_thread_sys_t
 {
-    struct vout_thread_t obj;
-
-    vout_thread_interlacing_t interlacing;
+    vout_sys_t obj;
 
     vout_thread_private_t private;
 
@@ -188,7 +186,7 @@ typedef struct vout_thread_sys_t
 } vout_thread_sys_t;
 
 #define VOUT_THREAD_TO_SYS(vout) \
-    container_of(vout, vout_thread_sys_t, obj.obj)
+    container_of(vout, vout_thread_sys_t, obj.obj.obj)
 
 
 /* Maximum delay between 2 displayed pictures.
@@ -341,7 +339,7 @@ static void vout_UpdateWindowSizeLocked(vout_thread_sys_t *vout)
         vout_SizeWindow(vout, &sys->original, &width, &height);
         vlc_mutex_unlock(&sys->display_lock);
 
-        msg_Dbg(&vout->obj, "requested window size: %ux%u", width, height);
+        msg_Dbg(&vout->obj.obj, "requested window size: %ux%u", width, height);
         vout_window_SetSize(sys->display_cfg.window, width, height);
     } else
         vlc_mutex_unlock(&sys->display_lock);
@@ -840,7 +838,7 @@ void vout_ChangeViewpoint(vout_thread_t *vout,
 /* */
 static void VoutGetDisplayCfg(vout_thread_sys_t *p_vout, const video_format_t *fmt, vout_display_cfg_t *cfg)
 {
-    vout_thread_t *vout = &p_vout->obj;
+    vout_thread_t *vout = &p_vout->obj.obj;
     /* Load configuration */
     cfg->viewpoint = fmt->pose;
 
@@ -964,7 +962,7 @@ static void ThreadChangeFilters(vout_thread_sys_t *vout)
     vlc_array_init(&array_static);
     vlc_array_init(&array_interactive);
 
-    if (sys->interlacing.has_deint)
+    if (sys->obj.interlacing.has_deint)
     {
         vout_filter_t *e = malloc(sizeof(*e));
 
@@ -1022,16 +1020,16 @@ static void ThreadChangeFilters(vout_thread_sys_t *vout)
         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->obj, "Adding '%s' as %s", e->name, a == 0 ? "static" : "interactive");
+            msg_Dbg(&vout->obj.obj, "Adding '%s' as %s", e->name, a == 0 ? "static" : "interactive");
             filter_t *filter = filter_chain_AppendFilter(chain, e->name, e->cfg,
                                NULL);
             if (!filter)
             {
-                msg_Err(&vout->obj, "Failed to add filter '%s'", e->name);
+                msg_Err(&vout->obj.obj, "Failed to add filter '%s'", e->name);
                 config_ChainDestroy(e->cfg);
             }
             else if (a == 1) /* Add callbacks for interactive filters */
-                filter_AddProxyCallbacks(&vout->obj, filter, FilterRestartCallback);
+                filter_AddProxyCallbacks(&vout->obj.obj, filter, FilterRestartCallback);
 
             free(e->name);
             free(e);
@@ -1045,10 +1043,10 @@ static void ThreadChangeFilters(vout_thread_sys_t *vout)
     }
 
     if (!es_format_IsSimilar(p_fmt_current, &fmt_target)) {
-        msg_Dbg(&vout->obj, "Adding a filter to compensate for format changes");
+        msg_Dbg(&vout->obj.obj, "Adding a filter to compensate for format changes");
         if (filter_chain_AppendConverter(sys->filter.chain_interactive,
                                          &fmt_target) != 0) {
-            msg_Err(&vout->obj, "Failed to compensate for the format changes, removing all filters");
+            msg_Err(&vout->obj.obj, "Failed to compensate for the format changes, removing all filters");
             ThreadDelAllFilterCallbacks(vout);
             filter_chain_Reset(sys->filter.chain_static,      &fmt_target, vctx_target, &fmt_target);
             filter_chain_Reset(sys->filter.chain_interactive, &fmt_target, vctx_target, &fmt_target);
@@ -1120,12 +1118,12 @@ static picture_t *ThreadDisplayPreparePicture(vout_thread_sys_t *vout, bool reus
                     else
                         late_threshold = VOUT_DISPLAY_LATE_THRESHOLD;
                     if (late > late_threshold) {
-                        msg_Warn(&vout->obj, "picture is too late to be displayed (missing %"PRId64" ms)", MS_FROM_VLC_TICK(late));
+                        msg_Warn(&vout->obj.obj, "picture is too late to be displayed (missing %"PRId64" ms)", MS_FROM_VLC_TICK(late));
                         picture_Release(decoded);
                         vout_statistic_AddLost(&sys->statistic, 1);
                         continue;
                     } else if (late > 0) {
-                        msg_Dbg(&vout->obj, "picture might be displayed late (missing %"PRId64" ms)", MS_FROM_VLC_TICK(late));
+                        msg_Dbg(&vout->obj.obj, "picture might be displayed late (missing %"PRId64" ms)", MS_FROM_VLC_TICK(late));
                         vout_statistic_AddLate(&sys->statistic, 1);
                     }
                 }
@@ -1177,7 +1175,7 @@ static picture_t *ConvertRGB32AndBlend(vout_thread_sys_t *vout, picture_t *pic,
         .video = &vout_video_cbs,
         .sys = vout,
     };
-    filter_chain_t *filterc = filter_chain_NewVideo(&vout->obj, false, &owner);
+    filter_chain_t *filterc = filter_chain_NewVideo(&vout->obj.obj, false, &owner);
     if (!filterc)
         return NULL;
 
@@ -1202,7 +1200,7 @@ static picture_t *ConvertRGB32AndBlend(vout_thread_sys_t *vout, picture_t *pic,
 
     if (pic)
     {
-        vlc_blender_t *swblend = filter_NewBlend(VLC_OBJECT(&vout->obj), &dst.video);
+        vlc_blender_t *swblend = filter_NewBlend(VLC_OBJECT(&vout->obj.obj), &dst.video);
         if (swblend)
         {
             bool success = picture_BlendSubpicture(pic, swblend, subpic) > 0;
@@ -1232,7 +1230,7 @@ static int ThreadDisplayRenderPicture(vout_thread_sys_t *vout, bool render_now)
         return VLC_EGENERIC;
 
     if (filtered->date != sys->displayed.current->date)
-        msg_Warn(&vout->obj, "Unsupported timestamp modifications done by chain_interactive");
+        msg_Warn(&vout->obj.obj, "Unsupported timestamp modifications done by chain_interactive");
 
     vout_display_t *vd = sys->display;
 
@@ -1310,9 +1308,9 @@ static int ThreadDisplayRenderPicture(vout_thread_sys_t *vout, bool render_now)
         }
         if (!sys->spu_blend && sys->spu_blend_chroma != fmt_spu.i_chroma) {
             sys->spu_blend_chroma = fmt_spu.i_chroma;
-            sys->spu_blend = filter_NewBlend(VLC_OBJECT(&vout->obj), &fmt_spu);
+            sys->spu_blend = filter_NewBlend(VLC_OBJECT(&vout->obj.obj), &fmt_spu);
             if (!sys->spu_blend)
-                msg_Err(&vout->obj, "Failed to create blending filter, OSD/Subtitles will not work");
+                msg_Err(&vout->obj.obj, "Failed to create blending filter, OSD/Subtitles will not work");
         }
     }
 
@@ -1411,7 +1409,7 @@ static int ThreadDisplayRenderPicture(vout_thread_sys_t *vout, bool render_now)
         {
         static int i = 0;
         if (((i++)%10) == 0)
-            msg_Info(&vout->obj, "render: avg %d ms var %d ms",
+            msg_Info(&vout->obj.obj, "render: avg %d ms var %d ms",
                      (int)(sys->render.avg/1000), (int)(sys->render.var/1000));
         }
 #endif
@@ -1468,9 +1466,9 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
 
     vlc_mutex_lock(&sys->filter.lock);
     if (sys->filter.changed ||
-        sys->interlacing.has_deint != sys->filter.new_interlaced)
+        sys->obj.interlacing.has_deint != sys->filter.new_interlaced)
     {
-        sys->interlacing.has_deint = sys->filter.new_interlaced;
+        sys->obj.interlacing.has_deint = sys->filter.new_interlaced;
         ThreadChangeFilters(vout);
     }
     vlc_mutex_unlock(&sys->filter.lock);
@@ -1713,7 +1711,7 @@ static void ThreadProcessMouseState(vout_thread_sys_t *p_vout,
 {
     vlc_mouse_t tmp1, tmp2;
     const vlc_mouse_t *m;
-    vout_thread_t *vout = &p_vout->obj;
+    vout_thread_t *vout = &p_vout->obj.obj;
     vout_thread_sys_t *sys = p_vout;
 
     /* pass mouse coordinates in the filter chains. */
@@ -1770,10 +1768,10 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo
         .video = &static_cbs,
         .sys = vout,
     };
-    sys->filter.chain_static = filter_chain_NewVideo(&vout->obj, true, &owner);
+    sys->filter.chain_static = filter_chain_NewVideo(&vout->obj.obj, true, &owner);
 
     owner.video = &interactive_cbs;
-    sys->filter.chain_interactive = filter_chain_NewVideo(&vout->obj, true, &owner);
+    sys->filter.chain_interactive = filter_chain_NewVideo(&vout->obj.obj, true, &owner);
 
     vout_display_cfg_t dcfg;
     int x = 0, y = 0, w = 0, h = 0;
@@ -1823,7 +1821,7 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo
     dcfg.window_props.width = sys->window_width;
     dcfg.window_props.height = sys->window_height;
 
-    sys->display = vout_OpenWrapper(&vout->obj, &sys->private, sys->splitter_name, &dcfg,
+    sys->display = vout_OpenWrapper(&vout->obj.obj, &sys->private, sys->splitter_name, &dcfg,
                                     &sys->original, vctx);
     if (sys->display == NULL) {
         vlc_mutex_unlock(&sys->display_lock);
@@ -1854,7 +1852,7 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo
     sys->spu_blend_chroma        = 0;
     sys->spu_blend               = NULL;
 
-    video_format_Print(VLC_OBJECT(&vout->obj), "original format", &sys->original);
+    video_format_Print(VLC_OBJECT(&vout->obj.obj), "original format", &sys->original);
     return VLC_SUCCESS;
 error:
     if (sys->filter.chain_interactive != NULL)
@@ -1918,7 +1916,7 @@ static void *Thread(void *object)
 
         const bool picture_interlaced = sys->displayed.is_interlaced;
 
-        vout_SetInterlacingState(&vout->obj, &sys->interlacing, picture_interlaced);
+        vout_SetInterlacingState(&vout->obj.obj, picture_interlaced);
     }
 }
 
@@ -1936,7 +1934,7 @@ static void vout_ReleaseDisplay(vout_thread_sys_t *vout)
         vout_FlushUnlocked(vout, true, INT64_MAX);
 
     vlc_mutex_lock(&sys->display_lock);
-    vout_CloseWrapper(&vout->obj, &sys->private, sys->display);
+    vout_CloseWrapper(&vout->obj.obj, &sys->private, sys->display);
     sys->display = NULL;
     vlc_mutex_unlock(&sys->display_lock);
 
@@ -2064,7 +2062,7 @@ static vout_thread_sys_t *vout_CreateCommon(vlc_object_t *object)
     if (!vout)
         return NULL;
 
-    vout_CreateVars(&vout->obj);
+    vout_CreateVars(&vout->obj.obj);
 
     vout_thread_sys_t *sys = vout;
     vlc_atomic_rc_init(&sys->rc);
@@ -2080,7 +2078,7 @@ vout_thread_t *vout_CreateDummy(vlc_object_t *object)
 
     vout_thread_sys_t *sys = vout;
     sys->dummy = true;
-    return &vout->obj;
+    return &vout->obj.obj;
 }
 
 vout_thread_t *vout_Create(vlc_object_t *object)
@@ -2088,7 +2086,7 @@ vout_thread_t *vout_Create(vlc_object_t *object)
     vout_thread_sys_t *p_vout = vout_CreateCommon(object);
     if (!p_vout)
         return NULL;
-    vout_thread_t *vout = &p_vout->obj;
+    vout_thread_t *vout = &p_vout->obj.obj;
     vout_thread_sys_t *sys = p_vout;
     sys->dummy = false;
 
@@ -2126,7 +2124,7 @@ vout_thread_t *vout_Create(vlc_object_t *object)
     sys->title.timeout  = var_InheritInteger(vout, "video-title-timeout");
     sys->title.position = var_InheritInteger(vout, "video-title-position");
 
-    vout_InitInterlacingSupport(vout, &sys->interlacing);
+    vout_InitInterlacingSupport(vout);
 
     sys->is_late_dropped = var_InheritBool(vout, "drop-late-frames");
 
@@ -2195,12 +2193,12 @@ static int EnableWindowLocked(vout_thread_sys_t *vout, const video_format_t *ori
 
     if (!sys->window_enabled) {
         vout_window_cfg_t wcfg = {
-            .is_fullscreen = var_GetBool(&vout->obj, "fullscreen"),
-            .is_decorated = var_InheritBool(&vout->obj, "video-deco"),
+            .is_fullscreen = var_GetBool(&vout->obj.obj, "fullscreen"),
+            .is_decorated = var_InheritBool(&vout->obj.obj, "video-deco"),
         // TODO: take pixel A/R, crop and zoom into account
 #if defined(__APPLE__) || defined(_WIN32)
-            .x = var_InheritInteger(&vout->obj, "video-x"),
-            .y = var_InheritInteger(&vout->obj, "video-y"),
+            .x = var_InheritInteger(&vout->obj.obj, "video-x"),
+            .y = var_InheritInteger(&vout->obj.obj, "video-y"),
 #endif
         };
 
@@ -2208,7 +2206,7 @@ static int EnableWindowLocked(vout_thread_sys_t *vout, const video_format_t *ori
         vout_SizeWindow(vout, original, &wcfg.width, &wcfg.height);
 
         if (vout_window_Enable(sys->display_cfg.window, &wcfg)) {
-            msg_Err(&vout->obj, "failed to enable window");
+            msg_Err(&vout->obj.obj, "failed to enable window");
             return -1;
         }
         sys->window_enabled = true;
@@ -2219,7 +2217,7 @@ static int EnableWindowLocked(vout_thread_sys_t *vout, const video_format_t *ori
 
 static void vout_InitSource(vout_thread_sys_t *vout)
 {
-    char *psz_ar = var_InheritString(&vout->obj, "aspect-ratio");
+    char *psz_ar = var_InheritString(&vout->obj.obj, "aspect-ratio");
     if (psz_ar) {
         unsigned num, den;
         if (!GetAspectRatio(psz_ar, &num, &den))
@@ -2227,7 +2225,7 @@ static void vout_InitSource(vout_thread_sys_t *vout)
         free(psz_ar);
     }
 
-    char *psz_crop = var_InheritString(&vout->obj, "crop");
+    char *psz_crop = var_InheritString(&vout->obj.obj, "crop");
     if (psz_crop) {
         unsigned num, den;
         unsigned y, x;
@@ -2293,7 +2291,7 @@ int vout_Request(const vout_configuration_t *cfg, vlc_video_context *vctx, input
     if (sys->display != NULL)
         vout_StopDisplay(cfg->vout);
 
-    vout_ReinitInterlacingSupport(cfg->vout, &sys->interlacing);
+    vout_ReinitInterlacingSupport(cfg->vout);
 
     sys->original = original;
 
diff --git a/src/video_output/vout_private.h b/src/video_output/vout_private.h
index ff983813e91..c5bae757b9b 100644
--- a/src/video_output/vout_private.h
+++ b/src/video_output/vout_private.h
@@ -43,13 +43,20 @@ struct vout_thread_private_t
     picture_pool_t  *display_pool;
 };
 
+typedef struct
+{
+    vout_thread_t obj;
+
+    vout_thread_interlacing_t interlacing;
+} vout_sys_t;
+
 /* */
 vout_display_t *vout_OpenWrapper(vout_thread_t *, vout_thread_private_t *, const char *,
                      const vout_display_cfg_t *, video_format_t *, vlc_video_context *);
 void vout_CloseWrapper(vout_thread_t *, vout_thread_private_t *, vout_display_t *vd);
 
-void vout_InitInterlacingSupport(vout_thread_t *, vout_thread_interlacing_t *);
-void vout_ReinitInterlacingSupport(vout_thread_t *, vout_thread_interlacing_t *);
-void vout_SetInterlacingState(vout_thread_t *, vout_thread_interlacing_t *, bool is_interlaced);
+void vout_InitInterlacingSupport(vout_thread_t *);
+void vout_ReinitInterlacingSupport(vout_thread_t *);
+void vout_SetInterlacingState(vout_thread_t *, bool is_interlaced);
 
 #endif // LIBVLC_VOUT_PRIVATE_H
-- 
2.26.2



More information about the vlc-devel mailing list