]> granicus.if.org Git - handbrake/commitdiff
deccc608sub: fix cropping of CCs
authorjstebbins <jstebbins.hb@gmail.com>
Tue, 6 May 2014 13:55:49 +0000 (13:55 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Tue, 6 May 2014 13:55:49 +0000 (13:55 +0000)
If the CC was in the crop area at the top of the image, it's position
was not moved properly.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6172 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/deccc608sub.c

index 5f4066b671d394f3a28b43b6d7cc075127f8f565..38e912cf55a59e2baa4afe6c67b6ca2aed7f4ecb 100644 (file)
@@ -851,7 +851,7 @@ static int write_cc_buffer_as_ssa(struct eia608_screen *data,
             // Get position for this CC
             if (row == -1)
             {
-                int last, x, y, safe_zone, cell_width, cell_height;
+                int last, x, y, top, safe_zone, cell_width, cell_height;
                 int cropped_width, cropped_height, font_size;
                 char *pos;
 
@@ -874,14 +874,15 @@ static int write_cc_buffer_as_ssa(struct eia608_screen *data,
                 // the baseline of the text which is lower left corner
                 // of bottom row of characters
                 y = cell_height * (row + 1 + rows) + safe_zone - wb->crop[0];
+                top = y - rows * font_size;
                 x = cell_width * col + safe_zone - wb->crop[2];
-                if (y < 0)
+                if (top < safe_zone)
                     y = (rows * font_size) + safe_zone;
-                if (x < 0)
+                if (x < safe_zone)
                     x = safe_zone;
-                if (y > cropped_height)
+                if (y > cropped_height - safe_zone)
                     y = cropped_height - safe_zone;
-                if (x + columns * cell_width > cropped_width)
+                if (x + columns * cell_width > cropped_width - safe_zone)
                     x = cropped_width - columns * cell_width - safe_zone;
                 pos = hb_strdup_printf("{\\a1\\pos(%d,%d)}", x, y);
                 wb->enc_buffer_used += encode_line(