[vlc-devel] [PATCH 7/7] display: clean the math for the crop values to apply to osys->source

Steve Lhomme robux4 at ycbcr.xyz
Fri Nov 13 16:56:34 CET 2020


---
 src/video_output/display.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/video_output/display.c b/src/video_output/display.c
index 0255537fd79..98e79f0d754 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -476,26 +476,20 @@ static int vout_UpdateSourceCrop(vout_display_t *vd)
         }
     }
 
-    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;
-    int left = VLC_CLIP((int)osys->source.i_x_offset + crop_left,
-                          0, right_max - 1);
-    int top  = VLC_CLIP((int)osys->source.i_y_offset + crop_top,
-                        0, bottom_max - 1);
+    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;
+    int left = VLC_CLIP((int)osys->source.i_x_offset + crop_left, 0, right_max - 1);
+    int top  = VLC_CLIP((int)osys->source.i_y_offset + crop_top, 0, bottom_max - 1);
     int right, bottom;
 
+    right = osys->source.i_x_offset + crop_right;
     if (crop_right <= 0)
-        right = (int)(osys->source.i_x_offset + osys->source.i_visible_width) + crop_right;
-    else
-        right = (int)osys->source.i_x_offset + crop_right;
+        right += osys->source.i_visible_width;
     right = VLC_CLIP(right, left + 1, right_max);
 
+    bottom = osys->source.i_y_offset + crop_bottom;
     if (crop_bottom <= 0)
-        bottom = (int)(osys->source.i_y_offset + osys->source.i_visible_height) + crop_bottom;
-    else
-        bottom = (int)osys->source.i_y_offset + crop_bottom;
+        bottom += osys->source.i_visible_height;
     bottom = VLC_CLIP(bottom, top + 1, bottom_max);
 
     osys->source.i_x_offset       = left;
-- 
2.26.2



More information about the vlc-devel mailing list