[vlc-devel] [PATCH 7/7] vout: display: pass the vout_display_priv_t directly in internal calls

Steve Lhomme robux4 at ycbcr.xyz
Wed Oct 9 17:36:49 CEST 2019


---
 src/video_output/display.c | 62 ++++++++++++++++++--------------------
 1 file changed, 30 insertions(+), 32 deletions(-)

diff --git a/src/video_output/display.c b/src/video_output/display.c
index 4fe7654e710..a8a7f19cdce 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -295,9 +295,9 @@ static const struct filter_video_callbacks vout_display_filter_cbs = {
     VideoBufferNew,
 };
 
-static int VoutDisplayCreateRender(vout_display_t *vd)
+static int VoutDisplayCreateRender(vout_display_priv_t *osys)
 {
-    vout_display_priv_t *osys = container_of(vd, vout_display_priv_t, display);
+    vout_display_t *vd = &osys->display;
     filter_owner_t owner = {
         .video = &vout_display_filter_cbs,
         .sys = vd,
@@ -462,9 +462,9 @@ void VoutDisplayFlush(vout_display_t *vd)
         filter_chain_VideoFlush(osys->converters);
 }
 
-static void VoutDisplayReset(vout_display_t *vd)
+static void VoutDisplayReset(vout_display_priv_t *osys)
 {
-    vout_display_priv_t *osys = container_of(vd, vout_display_priv_t, display);
+    vout_display_t *vd = &osys->display;
 
     if (osys->converters != NULL) {
         filter_chain_Delete(osys->converters);
@@ -478,28 +478,26 @@ static void VoutDisplayReset(vout_display_t *vd)
 
     if (vout_display_Control(vd, VOUT_DISPLAY_RESET_PICTURES, &osys->cfg,
                              &vd->fmt)
-     || VoutDisplayCreateRender(vd))
+     || VoutDisplayCreateRender(osys))
         msg_Err(vd, "Failed to adjust render format");
 }
 
-static void VoutDisplayCheckReset(vout_display_t *vd)
+static void VoutDisplayCheckReset(vout_display_priv_t *osys)
 {
 #ifdef _WIN32
-    vout_display_priv_t *osys = container_of(vd, vout_display_priv_t, display);
-
     if (unlikely(atomic_exchange_explicit(&osys->reset_pictures, false,
                                           memory_order_relaxed))) {
         atomic_thread_fence(memory_order_acquire);
-        VoutDisplayReset(vd);
+        VoutDisplayReset(osys);
     }
 #else
-    (void) vd;
+    (void) osys;
 #endif
 }
 
-static int VoutDisplayUpdateSourceCrop(vout_display_t *vd)
+static int VoutDisplayUpdateSourceCrop(vout_display_priv_t *osys)
 {
-    vout_display_priv_t *osys = container_of(vd, vout_display_priv_t, display);
+    vout_display_t *vd = &osys->display;
     unsigned crop_num = osys->crop.num;
     unsigned crop_den = osys->crop.den;
 
@@ -555,10 +553,10 @@ static int VoutDisplayUpdateSourceCrop(vout_display_t *vd)
     return ret;
 }
 
-static int VoutDisplaySetSourceAspect(vout_display_t *vd,
+static int VoutDisplaySetSourceAspect(vout_display_priv_t *osys,
                                 unsigned sar_num, unsigned sar_den)
 {
-    vout_display_priv_t *osys = container_of(vd, vout_display_priv_t, display);
+    vout_display_t *vd = &osys->display;
     int ret = 0;
 
     if (sar_num > 0 && sar_den > 0) {
@@ -575,7 +573,7 @@ static int VoutDisplaySetSourceAspect(vout_display_t *vd,
 
     /* If a crop ratio is requested, recompute the parameters */
     if (osys->crop.num != 0 && osys->crop.den != 0
-     && VoutDisplayUpdateSourceCrop(vd))
+     && VoutDisplayUpdateSourceCrop(osys))
         ret = -1;
 
     return ret;
@@ -605,7 +603,7 @@ void vout_UpdateDisplaySourceProperties(vout_display_t *vd, const video_format_t
         osys->source.i_sar_den = fixed_src.i_sar_den;
 
         /* FIXME it will override any AR that the user would have forced */
-        err1 = VoutDisplaySetSourceAspect(vd, osys->source.i_sar_num,
+        err1 = VoutDisplaySetSourceAspect(osys, osys->source.i_sar_num,
                                     osys->source.i_sar_den);
     }
     if (source->i_x_offset       != osys->source.i_x_offset ||
@@ -617,13 +615,13 @@ void vout_UpdateDisplaySourceProperties(vout_display_t *vd, const video_format_t
 
         /* Force the vout to reapply the current user crop settings
          * over the new decoder crop settings. */
-        err2 = VoutDisplayUpdateSourceCrop(vd);
+        err2 = VoutDisplayUpdateSourceCrop(osys);
     }
 
     if (err1 || err2)
-        VoutDisplayReset(vd);
+        VoutDisplayReset(osys);
 
-    VoutDisplayCheckReset(vd);
+    VoutDisplayCheckReset(osys);
 }
 
 void vout_display_SetSize(vout_display_t *vd, unsigned width, unsigned height)
@@ -633,8 +631,8 @@ void vout_display_SetSize(vout_display_t *vd, unsigned width, unsigned height)
     osys->cfg.display.width  = width;
     osys->cfg.display.height = height;
     if (vout_display_Control(vd, VOUT_DISPLAY_CHANGE_DISPLAY_SIZE, &osys->cfg))
-        VoutDisplayReset(vd);
-    VoutDisplayCheckReset(vd);
+        VoutDisplayReset(osys);
+    VoutDisplayCheckReset(osys);
 }
 
 void VoutDisplaySetFilled(vout_display_t *vd, bool is_filled)
@@ -647,8 +645,8 @@ void VoutDisplaySetFilled(vout_display_t *vd, bool is_filled)
     osys->cfg.is_display_filled = is_filled;
     if (vout_display_Control(vd, VOUT_DISPLAY_CHANGE_DISPLAY_FILLED,
                              &osys->cfg))
-        VoutDisplayReset(vd);
-    VoutDisplayCheckReset(vd);
+        VoutDisplayReset(osys);
+    VoutDisplayCheckReset(osys);
 }
 
 void VoutDisplaySetZoom(vout_display_t *vd, unsigned num, unsigned den)
@@ -662,8 +660,8 @@ void VoutDisplaySetZoom(vout_display_t *vd, unsigned num, unsigned den)
     osys->cfg.zoom.num = num;
     osys->cfg.zoom.den = den;
     if (vout_display_Control(vd, VOUT_DISPLAY_CHANGE_ZOOM, &osys->cfg))
-        VoutDisplayReset(vd);
-    VoutDisplayCheckReset(vd);
+        VoutDisplayReset(osys);
+    VoutDisplayCheckReset(osys);
 }
 
 void VoutDisplaySetAspectRatio(vout_display_t *vd, unsigned dar_num, unsigned dar_den)
@@ -680,9 +678,9 @@ void VoutDisplaySetAspectRatio(vout_display_t *vd, unsigned dar_num, unsigned da
         sar_den = 0;
     }
 
-    if (VoutDisplaySetSourceAspect(vd, sar_num, sar_den))
-        VoutDisplayReset(vd);
-    VoutDisplayCheckReset(vd);
+    if (VoutDisplaySetSourceAspect(osys, sar_num, sar_den))
+        VoutDisplayReset(osys);
+    VoutDisplayCheckReset(osys);
 }
 
 void VoutDisplaySetCrop(vout_display_t *vd,
@@ -703,9 +701,9 @@ void VoutDisplaySetCrop(vout_display_t *vd,
         osys->crop.num    = crop_num;
         osys->crop.den    = crop_den;
 
-        if (VoutDisplayUpdateSourceCrop(vd))
-            VoutDisplayReset(vd);
-        VoutDisplayCheckReset(vd);
+        if (VoutDisplayUpdateSourceCrop(osys))
+            VoutDisplayReset(osys);
+        VoutDisplayCheckReset(osys);
     }
 }
 
@@ -793,7 +791,7 @@ vout_display_t *vout_display_New(vlc_object_t *parent,
                              (unsigned)VOUT_WINDOW_STATE_ABOVE);
 #endif
 
-    if (VoutDisplayCreateRender(vd)) {
+    if (VoutDisplayCreateRender(osys)) {
         if (vd->close != NULL)
             vd->close(vd);
         vlc_objres_clear(VLC_OBJECT(vd));
-- 
2.17.1



More information about the vlc-devel mailing list