[vlc-commits] [Git][videolan/vlc][master] codec: webvtt: fix line/position alignment

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Nov 20 09:50:43 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
ea392ee9 by François Cartegnie at 2025-11-20T09:34:24+00:00
codec: webvtt: fix line/position alignment

- - - - -


1 changed file:

- modules/codec/webvtt/subsvtt.c


Changes:

=====================================
modules/codec/webvtt/subsvtt.c
=====================================
@@ -260,27 +260,39 @@ static void webvtt_get_cueboxrect( const webvtt_cue_settings_t *p_settings,
     {
         p_rect->y = line_offset >= 0 ? line_offset : 1.0 + line_offset;
         p_rect->w = (extent) ? extent : 1.0;
-        if( indent_anchor_position > 0 &&
-            (alignment_on_indent_anchor == WEBVTT_ALIGN_LEFT ||
-             alignment_on_indent_anchor == WEBVTT_ALIGN_START) )
+
+        if( indent_anchor_position > 0 )
         {
-            p_rect->x  = indent_anchor_position;
-            p_rect->w -= p_rect->x;
+            if( alignment_on_indent_anchor == WEBVTT_ALIGN_LEFT ||
+                alignment_on_indent_anchor == WEBVTT_ALIGN_START )
+            {
+                p_rect->x  = indent_anchor_position;
+                p_rect->w -= p_rect->x;
+            }
+            else if( alignment_on_indent_anchor == WEBVTT_ALIGN_CENTER )
+            {
+                p_rect->x  = indent_anchor_position - 0.5;
+                p_rect->w  = p_rect->x >= 0 ? 1.0 - p_rect->x: 1.0 + p_rect->x;
+            }
         }
     }
-    else /* Vertical text */
+    else /* Vertical text, but no support in the text renderer */
     {
-        if( p_settings->vertical == WEBVTT_ALIGN_LEFT )
+        if( p_settings->vertical == WEBVTT_ALIGN_RIGHT )
             p_rect->x = line_offset >= 0 ? 1.0 - line_offset : -line_offset;
         else
             p_rect->x = line_offset >= 0 ? line_offset : 1.0 + line_offset;
-        p_rect->y = (extent) ? extent : 1.0;
+        p_rect->w = (extent >= 0) ? extent : 1.0;
 
-        if( indent_anchor_position > 0 &&
-            alignment_on_indent_anchor == WEBVTT_ALIGN_START )
+        if( p_settings->vertical == WEBVTT_ALIGN_LEFT )
         {
             p_rect->y  = indent_anchor_position;
-            p_rect->h -= p_rect->y;
+            p_rect->h  = 1.0 - p_rect->y;
+        }
+        else
+        {
+            p_rect->y  = 1.0 - indent_anchor_position;
+            p_rect->h  = 1.0 - p_rect->y;
         }
     }
 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/ea392ee93bc652a1bcb399d989e2b169a68fbe1a

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/ea392ee93bc652a1bcb399d989e2b169a68fbe1a
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list