[vlc-commits] [Git][videolan/vlc][master] 2 commits: vout: avoid structure copy

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Tue Sep 28 13:21:12 UTC 2021



Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC


Commits:
6ea34b63 by Rémi Denis-Courmont at 2021-09-28T12:44:10+00:00
vout: avoid structure copy

- - - - -
13282687 by Rémi Denis-Courmont at 2021-09-28T12:44:10+00:00
vout: simplify update of display source crop

Refs #22001.

- - - - -


1 changed file:

- src/video_output/display.c


Changes:

=====================================
src/video_output/display.c
=====================================
@@ -451,9 +451,10 @@ static void vout_display_Reset(vout_display_t *vd)
 static int vout_UpdateSourceCrop(vout_display_t *vd)
 {
     vout_display_priv_t *osys = container_of(vd, vout_display_priv_t, display);
-    video_format_t fmt = osys->source;
     int left, top, right, bottom;
 
+    video_format_Print(VLC_OBJECT(vd), "SOURCE ", &osys->source);
+
     switch (osys->crop.mode) {
         case VOUT_CROP_NONE:
             left = top = right = bottom = 0;
@@ -465,45 +466,37 @@ static int vout_UpdateSourceCrop(vout_display_t *vd)
         case VOUT_CROP_WINDOW:
             left = osys->crop.window.x;
             top = osys->crop.window.y;
-            right = osys->crop.window.width;
-            bottom = osys->crop.window.height;
+            right = left + osys->crop.window.width;
+            bottom = top + osys->crop.window.height;
             break;
         case VOUT_CROP_BORDER:
             left = osys->crop.border.left;
             top = osys->crop.border.top;
-            right = -(int)osys->crop.border.right;
-            bottom = -(int)osys->crop.border.bottom;
+            right = osys->source.i_visible_width - osys->crop.border.right;
+            bottom = osys->source.i_visible_height - osys->crop.border.bottom;
             break;
         default:
             /* left/top/right/bottom must be initialized */
             vlc_assert_unreachable();
     }
 
-    const int right_max  = osys->source.i_x_offset
-                           + osys->source.i_visible_width;
-    const int bottom_max = osys->source.i_y_offset
-                           + osys->source.i_visible_height;
-
-    left = VLC_CLIP((int)osys->source.i_x_offset + left, 0, right_max - 1);
-    top  = VLC_CLIP((int)osys->source.i_y_offset + top, 0, bottom_max - 1);
-
-    if (right <= 0)
-        right = (int)(osys->source.i_x_offset + osys->source.i_visible_width) + right;
-    else
-        right = (int)osys->source.i_x_offset + right;
-    right = VLC_CLIP(right, left + 1, right_max);
-
-    if (bottom <= 0)
-        bottom = (int)(osys->source.i_y_offset + osys->source.i_visible_height) + bottom;
-    else
-        bottom = (int)osys->source.i_y_offset + bottom;
-    bottom = VLC_CLIP(bottom, top + 1, bottom_max);
-
-    osys->source.i_x_offset       = left;
-    osys->source.i_y_offset       = top;
-    osys->source.i_visible_width  = right - left;
+    if (left >= right)
+        left = right - 1;
+    if (top >= bottom)
+        top = bottom - 1;
+    if (left < 0)
+        left = 0;
+    if (top < 0)
+        top = 0;
+    if ((unsigned)right > osys->source.i_visible_width)
+        right = osys->source.i_visible_width;
+    if ((unsigned)bottom > osys->source.i_visible_height)
+        right = osys->source.i_visible_height;
+
+    osys->source.i_x_offset += left;
+    osys->source.i_y_offset += top;
+    osys->source.i_visible_width = right - left;
     osys->source.i_visible_height = bottom - top;
-    video_format_Print(VLC_OBJECT(vd), "SOURCE ", &fmt);
     video_format_Print(VLC_OBJECT(vd), "CROPPED ", &osys->source);
 
     return vout_display_Control(vd, VOUT_DISPLAY_CHANGE_SOURCE_CROP);



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/bd12c7ad37642a2ea6e3b3fa9e5e4210d4a7c4a0...13282687881f743ac31b5f8db8e1f94111058196

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/bd12c7ad37642a2ea6e3b3fa9e5e4210d4a7c4a0...13282687881f743ac31b5f8db8e1f94111058196
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list