[vlc-devel] [PATCH 5/6] cea708: Fix positioning of captions with bottom anchor points.

Devin Heitmueller dheitmueller at ltnglobal.com
Wed Jan 23 23:09:14 CET 2019


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>
---
 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
     {
-- 
2.13.2



More information about the vlc-devel mailing list