[vlc-commits] Revert "vout: change spu_area to unsigned"

Jean-Baptiste Kempf git at videolan.org
Wed Jan 17 23:58:36 CET 2018


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Wed Jan 17 23:56:19 2018 +0100| [704e380dc97c4136f4023681c251a3e72ba06d06] | committer: Jean-Baptiste Kempf

Revert "vout: change spu_area to unsigned"

This reverts commit 956af56870bf3218fa0dae4933a45631bebd27b3.

Close #18665

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

 src/video_output/vout_subpictures.c | 38 +++++++++++++++++--------------------
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/src/video_output/vout_subpictures.c b/src/video_output/vout_subpictures.c
index 5524347887..0a1b9e6808 100644
--- a/src/video_output/vout_subpictures.c
+++ b/src/video_output/vout_subpictures.c
@@ -332,15 +332,15 @@ static int spu_invscale_h(unsigned v, const spu_scale_t s)
  * A few area functions helpers
  */
 typedef struct {
-    unsigned x;
-    unsigned y;
-    unsigned width;
-    unsigned height;
+    int x;
+    int y;
+    int width;
+    int height;
 
     spu_scale_t scale;
 } spu_area_t;
 
-static spu_area_t spu_area_create(unsigned x, unsigned y, unsigned w, unsigned h, spu_scale_t s)
+static spu_area_t spu_area_create(int x, int y, int w, int h, spu_scale_t s)
 {
     spu_area_t a = { .x = x, .y = y, .width = w, .height = h, .scale = s };
     return a;
@@ -378,7 +378,7 @@ static bool spu_area_overlap(spu_area_t a, spu_area_t b)
     a = spu_area_scaled(a);
     b = spu_area_scaled(b);
 
-    return __MAX(a.x, b.x) < __MIN(a.x + a.width, b.x + b.width ) &&
+    return __MAX(a.x, b.x) < __MIN(a.x + a.width , b.x + b.width ) &&
            __MAX(a.y, b.y) < __MIN(a.y + a.height, b.y + b.height);
 }
 
@@ -432,21 +432,17 @@ static void SpuAreaFitInside(spu_area_t *area, const spu_area_t *boundary)
 {
     spu_area_t a = spu_area_scaled(*area);
 
-    if((a.x + a.width) > boundary->width)
-    {
-        if(boundary->width > a.width)
-            a.x = boundary->width - a.width;
-        else
-            a.x = 0;
-    }
-
-    if((a.y + a.height) > boundary->height)
-    {
-        if(boundary->height > a.height)
-            a.y = boundary->height - a.height;
-        else
-            a.y = 0;
-    }
+    const int i_error_x = (a.x + a.width) - boundary->width;
+    if (i_error_x > 0)
+        a.x -= i_error_x;
+    if (a.x < 0)
+        a.x = 0;
+
+    const int i_error_y = (a.y + a.height) - boundary->height;
+    if (i_error_y > 0)
+        a.y -= i_error_y;
+    if (a.y < 0)
+        a.y = 0;
 
     *area = spu_area_unscaled(a, area->scale);
 }



More information about the vlc-commits mailing list