[vlc-devel] [PATCH 2/5] video_output: let the deinterlacing code access vout_thread_private_t

Steve Lhomme robux4 at ycbcr.xyz
Fri Nov 6 15:32:29 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.
---
 src/video_output/video_output.c | 96 ++++++++++++++++-----------------
 src/video_output/vout_private.h |  7 +++
 2 files changed, 54 insertions(+), 49 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index fa68a54a8f7..f3a426dc1e6 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_private_t private;
+    vout_threadsys_t sys;
 
     bool dummy;
 
@@ -186,7 +184,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, sys.obj.obj)
 
 
 /* Maximum delay between 2 displayed pictures.
@@ -339,7 +337,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->sys.obj, "requested window size: %ux%u", width, height);
         vout_window_SetSize(sys->display_cfg.window, width, height);
     } else
         vlc_mutex_unlock(&sys->display_lock);
@@ -471,7 +469,7 @@ picture_t *vout_GetPicture(vout_thread_t *vout)
 {
     vout_thread_sys_t *sys = VOUT_THREAD_TO_SYS(vout);
     assert(!sys->dummy);
-    picture_t *picture = picture_pool_Wait(sys->private.display_pool);
+    picture_t *picture = picture_pool_Wait(sys->sys.private.display_pool);
     if (likely(picture != NULL)) {
         picture_Reset(picture);
         video_format_CopyCropAr(&picture->format, &sys->original);
@@ -838,7 +836,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->sys.obj;
     /* Load configuration */
     cfg->viewpoint = fmt->pose;
 
@@ -902,7 +900,7 @@ static picture_t *VoutVideoFilterInteractiveNewPicture(filter_t *filter)
 {
     vout_thread_sys_t *sys = filter->owner.sys;
 
-    picture_t *picture = picture_pool_Get(sys->private.private_pool);
+    picture_t *picture = picture_pool_Get(sys->sys.private.private_pool);
     if (picture) {
         picture_Reset(picture);
         video_format_CopyCropAr(&picture->format, &filter->fmt_out.video);
@@ -962,7 +960,7 @@ static void ThreadChangeFilters(vout_thread_sys_t *vout)
     vlc_array_init(&array_static);
     vlc_array_init(&array_interactive);
 
-    if (sys->private.interlacing.has_deint)
+    if (sys->sys.private.interlacing.has_deint)
     {
         vout_filter_t *e = malloc(sizeof(*e));
 
@@ -1020,16 +1018,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->sys.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->sys.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->sys.obj, filter, FilterRestartCallback);
 
             free(e->name);
             free(e);
@@ -1043,10 +1041,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->sys.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->sys.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);
@@ -1118,12 +1116,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->sys.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->sys.obj, "picture might be displayed late (missing %"PRId64" ms)", MS_FROM_VLC_TICK(late));
                         vout_statistic_AddLate(&sys->statistic, 1);
                     }
                 }
@@ -1175,7 +1173,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->sys.obj, false, &owner);
     if (!filterc)
         return NULL;
 
@@ -1200,7 +1198,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->sys.obj), &dst.video);
         if (swblend)
         {
             bool success = picture_BlendSubpicture(pic, swblend, subpic) > 0;
@@ -1230,7 +1228,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->sys.obj, "Unsupported timestamp modifications done by chain_interactive");
 
     vout_display_t *vd = sys->display;
 
@@ -1308,9 +1306,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->sys.obj), &fmt_spu);
             if (!sys->spu_blend)
-                msg_Err(&vout->obj, "Failed to create blending filter, OSD/Subtitles will not work");
+                msg_Err(&vout->sys.obj, "Failed to create blending filter, OSD/Subtitles will not work");
         }
     }
 
@@ -1333,7 +1331,7 @@ static int ThreadDisplayRenderPicture(vout_thread_sys_t *vout, bool render_now)
     picture_t *snap_pic = todisplay;
     if (do_early_spu && subpic) {
         if (sys->spu_blend) {
-            picture_t *blent = picture_pool_Get(sys->private.private_pool);
+            picture_t *blent = picture_pool_Get(sys->sys.private.private_pool);
             if (blent) {
                 video_format_CopyCropAr(&blent->format, &filtered->format);
                 picture_Copy(blent, filtered);
@@ -1409,7 +1407,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->sys.obj, "render: avg %d ms var %d ms",
                      (int)(sys->render.avg/1000), (int)(sys->render.var/1000));
         }
 #endif
@@ -1466,9 +1464,9 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
 
     vlc_mutex_lock(&sys->filter.lock);
     if (sys->filter.changed ||
-        sys->private.interlacing.has_deint != sys->filter.new_interlaced)
+        sys->sys.private.interlacing.has_deint != sys->filter.new_interlaced)
     {
-        sys->private.interlacing.has_deint = sys->filter.new_interlaced;
+        sys->sys.private.interlacing.has_deint = sys->filter.new_interlaced;
         ThreadChangeFilters(vout);
     }
     vlc_mutex_unlock(&sys->filter.lock);
@@ -1711,7 +1709,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->sys.obj;
     vout_thread_sys_t *sys = p_vout;
 
     /* pass mouse coordinates in the filter chains. */
@@ -1751,8 +1749,8 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo
     vlc_mouse_Init(&sys->mouse);
 
     sys->decoder_fifo = picture_fifo_New();
-    sys->private.display_pool = NULL;
-    sys->private.private_pool = NULL;
+    sys->sys.private.display_pool = NULL;
+    sys->sys.private.private_pool = NULL;
 
     sys->filter.configuration = NULL;
     video_format_Copy(&sys->filter.src_fmt, &sys->original);
@@ -1768,10 +1766,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->sys.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->sys.obj, true, &owner);
 
     vout_display_cfg_t dcfg;
     int x = 0, y = 0, w = 0, h = 0;
@@ -1821,7 +1819,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->sys.obj, &sys->sys.private, sys->splitter_name, &dcfg,
                                     &sys->original, vctx);
     if (sys->display == NULL) {
         vlc_mutex_unlock(&sys->display_lock);
@@ -1834,7 +1832,7 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo
         vout_SetDisplayAspect(sys->display, num, den);
     vlc_mutex_unlock(&sys->display_lock);
 
-    assert(sys->private.display_pool != NULL && sys->private.private_pool != NULL);
+    assert(sys->sys.private.display_pool != NULL && sys->sys.private.private_pool != NULL);
 
     sys->displayed.current       = NULL;
     sys->displayed.next          = NULL;
@@ -1852,7 +1850,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->sys.obj), "original format", &sys->original);
     return VLC_SUCCESS;
 error:
     if (sys->filter.chain_interactive != NULL)
@@ -1916,7 +1914,7 @@ static void *Thread(void *object)
 
         const bool picture_interlaced = sys->displayed.is_interlaced;
 
-        vout_SetInterlacingState(&vout->obj, &sys->private, picture_interlaced);
+        vout_SetInterlacingState(&vout->sys.obj, &sys->sys.private, picture_interlaced);
     }
 }
 
@@ -1930,11 +1928,11 @@ static void vout_ReleaseDisplay(vout_thread_sys_t *vout)
         filter_DeleteBlend(sys->spu_blend);
 
     /* Destroy the rendering display */
-    if (sys->private.display_pool != NULL)
+    if (sys->sys.private.display_pool != NULL)
         vout_FlushUnlocked(vout, true, INT64_MAX);
 
     vlc_mutex_lock(&sys->display_lock);
-    vout_CloseWrapper(&vout->obj, &sys->private, sys->display);
+    vout_CloseWrapper(&vout->sys.obj, &sys->sys.private, sys->display);
     sys->display = NULL;
     vlc_mutex_unlock(&sys->display_lock);
 
@@ -1955,7 +1953,7 @@ static void vout_ReleaseDisplay(vout_thread_sys_t *vout)
         picture_fifo_Delete(sys->decoder_fifo);
         sys->decoder_fifo = NULL;
     }
-    assert(sys->private.display_pool == NULL);
+    assert(sys->sys.private.display_pool == NULL);
 
     if (sys->mouse_event)
     {
@@ -2062,7 +2060,7 @@ static vout_thread_sys_t *vout_CreateCommon(vlc_object_t *object)
     if (!vout)
         return NULL;
 
-    vout_CreateVars(&vout->obj);
+    vout_CreateVars(&vout->sys.obj);
 
     vout_thread_sys_t *sys = vout;
     vlc_atomic_rc_init(&sys->rc);
@@ -2078,7 +2076,7 @@ vout_thread_t *vout_CreateDummy(vlc_object_t *object)
 
     vout_thread_sys_t *sys = vout;
     sys->dummy = true;
-    return &vout->obj;
+    return &vout->sys.obj;
 }
 
 vout_thread_t *vout_Create(vlc_object_t *object)
@@ -2086,7 +2084,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->sys.obj;
     vout_thread_sys_t *sys = p_vout;
     sys->dummy = false;
 
@@ -2124,7 +2122,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->private);
+    vout_InitInterlacingSupport(vout, &sys->sys.private);
 
     sys->is_late_dropped = var_InheritBool(vout, "drop-late-frames");
 
@@ -2193,12 +2191,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->sys.obj, "fullscreen"),
+            .is_decorated = var_InheritBool(&vout->sys.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->sys.obj, "video-x"),
+            .y = var_InheritInteger(&vout->sys.obj, "video-y"),
 #endif
         };
 
@@ -2206,7 +2204,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->sys.obj, "failed to enable window");
             return -1;
         }
         sys->window_enabled = true;
@@ -2217,7 +2215,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->sys.obj, "aspect-ratio");
     if (psz_ar) {
         unsigned num, den;
         if (!GetAspectRatio(psz_ar, &num, &den))
@@ -2225,7 +2223,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->sys.obj, "crop");
     if (psz_crop) {
         unsigned num, den;
         unsigned y, x;
@@ -2291,7 +2289,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->private);
+    vout_ReinitInterlacingSupport(cfg->vout, &sys->sys.private);
 
     sys->original = original;
 
diff --git a/src/video_output/vout_private.h b/src/video_output/vout_private.h
index 5e8c58dabe7..250b754289b 100644
--- a/src/video_output/vout_private.h
+++ b/src/video_output/vout_private.h
@@ -43,6 +43,13 @@ struct vout_thread_private_t
     picture_pool_t  *display_pool;
 };
 
+typedef struct
+{
+    struct vout_thread_t obj;
+
+    vout_thread_private_t private;
+} vout_threadsys_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 *);
-- 
2.26.2



More information about the vlc-devel mailing list