[vlc-commits] cea708: Fix positioning of captions with bottom anchor points.

Devin Heitmueller git at videolan.org
Sat Jan 26 00:36:24 CET 2019


vlc | branch: master | Devin Heitmueller <dheitmueller at ltnglobal.com> | Wed Jan 23 17:09:14 2019 -0500| [0ecc0aca9e2cb1583175e76a25d2b5791da8b375] | committer: Jean-Baptiste Kempf

cea708: Fix positioning of captions with bottom anchor points.

In the 708 specification, the origin for references to window location
is always the top left corner regardless of the anchor type (see
CTA-708E Sec 8.2).  However VLC's internal representation for
 subpictures with SUBPICTURE_ALIGN_BOTTOM expect the origin to be
relative to bottom left corner of the screen.  Hence we need to do
a bit of math to handle this conversion or else windows which are
supposed to be at the bottom according to the spec are rendered
at the top.

In other words, a Y-value of 99% for a window of type
CEA708_ANCHOR_BOTTOM_LEFT should be rendered at the bottom of
the screen, not at the top of the screen.

Signed-off-by: Devin Heitmueller <dheitmueller at ltnglobal.com>
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/codec/cea708.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/modules/codec/cea708.c b/modules/codec/cea708.c
index 4fa9923104..8c5d11fb17 100644
--- a/modules/codec/cea708.c
+++ b/modules/codec/cea708.c
@@ -1018,8 +1018,25 @@ static void CEA708SpuConvert( const cea708_window_t *p_w,
 
     if( p_w->b_relative )
     {
+        /* FIXME: take into account left/right anchors */
         p_region->origin.x = p_w->i_anchor_offset_h / 100.0;
-        p_region->origin.y = p_w->i_anchor_offset_v / 100.0;
+
+        switch (p_w->anchor_point) {
+        case CEA708_ANCHOR_TOP_LEFT:
+        case CEA708_ANCHOR_TOP_CENTER:
+        case CEA708_ANCHOR_TOP_RIGHT:
+            p_region->origin.y = p_w->i_anchor_offset_v / 100.0;
+            break;
+        case CEA708_ANCHOR_BOTTOM_LEFT:
+        case CEA708_ANCHOR_BOTTOM_CENTER:
+        case CEA708_ANCHOR_BOTTOM_RIGHT:
+            p_region->origin.y = 1.0 - (p_w->i_anchor_offset_v / 100.0);
+            break;
+        default:
+            /* FIXME: for CENTER vertical justified, just position as top */
+            p_region->origin.y = p_w->i_anchor_offset_v / 100.0;
+            break;
+        }
     }
     else
     {



More information about the vlc-commits mailing list