[vlc-commits] vout: rationalize function arguments

Rémi Denis-Courmont git at videolan.org
Sat Jan 26 19:51:22 CET 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jan 26 15:43:48 2019 +0200| [1964a189e2bfab203c7614265df3ae5ad8f81502] | committer: Rémi Denis-Courmont

vout: rationalize function arguments

Avoid video_format_Copy().

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1964a189e2bfab203c7614265df3ae5ad8f81502
---

 src/video_output/video_output.c | 57 +++++++++++++++++++----------------------
 1 file changed, 26 insertions(+), 31 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 745b516128..b84aa2bf8d 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -110,10 +110,12 @@ static bool VideoFormatIsCropArEqual(video_format_t *dst,
            dst->i_visible_height == src->i_visible_height;
 }
 
-static void vout_display_SizeWindow(vlc_object_t *obj,
-    const video_format_t *restrict source,
-    const vout_display_cfg_t *restrict cfg,
-    unsigned *restrict width, unsigned *restrict height)
+static void vout_display_SizeWindow(unsigned *restrict width,
+                                    unsigned *restrict height,
+                                    unsigned w, unsigned h,
+                                    unsigned sar_num, unsigned sar_den,
+                                    video_orientation_t orientation,
+                                    const vout_display_cfg_t *restrict cfg)
 {
     *width = cfg->display.width;
     *height = cfg->display.height;
@@ -123,14 +125,11 @@ static void vout_display_SizeWindow(vlc_object_t *obj,
         return;
 
     /* Compute intended video resolution from source. */
-    unsigned w = source->i_visible_width;
-    unsigned h = source->i_visible_height;
-
-    assert(source->i_sar_num > 0 && source->i_sar_den > 0);
-    w = (w * source->i_sar_num) / source->i_sar_den;
+    assert(sar_num > 0 && sar_den > 0);
+    w = (w * sar_num) / sar_den;
 
     /* Adjust video size for orientation and pixel A/R. */
-    if (ORIENT_IS_SWAP(source->orientation)) {
+    if (ORIENT_IS_SWAP(orientation)) {
         unsigned x = w;
 
         w = h;
@@ -161,21 +160,18 @@ static void vout_SizeWindow(vout_thread_t *vout, unsigned *restrict width,
                             unsigned *restrict height)
 {
     vout_thread_sys_t *sys = vout->p;
-    video_format_t source;
-
-    video_format_Copy(&source, &sys->original);
+    unsigned w = sys->original.i_visible_width;
+    unsigned h = sys->original.i_visible_height;
+    unsigned sar_num = sys->original.i_sar_num;
+    unsigned sar_den = sys->original.i_sar_num;
 
-    /* Note: x & y offsets are not correctly computed
-     * since they are not used in vout_display_SizeWindow() anyhow.
-     * TODO: Pass only width, height and SAR instead of video_format_t.
-     */
     switch (sys->source.crop.mode) {
         case VOUT_CROP_NONE:
             if (sys->source.dar.num > 0 && sys->source.dar.den > 0) {
-                unsigned num = sys->source.dar.num * source.i_visible_height;
-                unsigned den = sys->source.dar.den * source.i_visible_width;
+                unsigned num = sys->source.dar.num * h;
+                unsigned den = sys->source.dar.den * w;
 
-                vlc_ureduce(&source.i_sar_num, &source.i_sar_den, num, den, 0);
+                vlc_ureduce(&sar_num, &sar_den, num, den, 0);
             }
             break;
 
@@ -183,29 +179,28 @@ static void vout_SizeWindow(vout_thread_t *vout, unsigned *restrict width,
             unsigned num = sys->source.crop.ratio.num;
             unsigned den = sys->source.crop.ratio.den;
 
-            if (source.i_visible_width * den > source.i_visible_height * num)
-                source.i_visible_width = source.i_visible_height * num / den;
+            if (w * den > h * num)
+                w = h * num / den;
             else
-                source.i_visible_height = source.i_visible_width * den / num;
+                h = w * den / num;
             break;
         }
 
         case VOUT_CROP_WINDOW:
-            source.i_visible_width = sys->source.crop.window.width;
-            source.i_visible_height = sys->source.crop.window.height;
+            w = sys->source.crop.window.width;
+            h = sys->source.crop.window.height;
             break;
 
         case VOUT_CROP_BORDER:
-            source.i_visible_width =
-                sys->source.crop.border.right - sys->source.crop.border.left;
-            source.i_visible_height =
-                sys->source.crop.border.bottom - sys->source.crop.border.top;
+            w = sys->source.crop.border.right - sys->source.crop.border.left;
+            h = sys->source.crop.border.bottom - sys->source.crop.border.top;
             break;
     }
 
     /* If the vout thread is running, the window lock must be held here. */
-    vout_display_SizeWindow(VLC_OBJECT(vout), &source, &sys->display_cfg,
-                            width, height);
+    vout_display_SizeWindow(width, height, w, h, sar_num, sar_den,
+                            sys->original.orientation,
+                            &sys->display_cfg);
 }
 
 static vout_thread_t *VoutCreate(vlc_object_t *object,



More information about the vlc-commits mailing list