]> git.sesse.net Git - vlc/commitdiff
Add ability to render the subpicture region, but not the text itself
authorDevin Heitmueller <dheitmueller@kernellabs.com>
Thu, 27 Dec 2012 06:08:23 +0000 (01:08 -0500)
committerRafaël Carré <funman@videolan.org>
Mon, 31 Dec 2012 12:59:20 +0000 (13:59 +0100)
We want to center the subpicture region, but the text itself needs
to be rendered left justified in order to get consistent placement
of captions (e.g. indentation).

Introduce a new alignment type which centers the subpicture, but
not the text it contains within (and enable it for the EIA-608 decoder).

Signed-off-by: Rafaël Carré <funman@videolan.org>
include/vlc_subpicture.h
modules/codec/cc.c
modules/text_renderer/freetype.c

index 797f22ab3e39787a4af758af7546336e22a639cc..d98e043f6eb90623944ec0cba840cc74a061d23d 100644 (file)
@@ -77,9 +77,10 @@ struct subpicture_region_t
 #define SUBPICTURE_ALIGN_RIGHT 0x2
 #define SUBPICTURE_ALIGN_TOP 0x4
 #define SUBPICTURE_ALIGN_BOTTOM 0x8
+#define SUBPICTURE_ALIGN_LEAVETEXT 0x10 /**< Align the subpicture, but not the text inside */
 #define SUBPICTURE_ALIGN_MASK ( SUBPICTURE_ALIGN_LEFT|SUBPICTURE_ALIGN_RIGHT| \
-                                SUBPICTURE_ALIGN_TOP |SUBPICTURE_ALIGN_BOTTOM )
-
+                                SUBPICTURE_ALIGN_TOP |SUBPICTURE_ALIGN_BOTTOM| \
+                                SUBPICTURE_ALIGN_LEAVETEXT )
 /**
  * This function will create a new subpicture region.
  *
index 7fd256d2a646a6986f52c4fe62c9df5c968a2e2e..6ea07fd557f43e54787e20b0c243db85b605086b 100644 (file)
@@ -327,7 +327,9 @@ static subpicture_t *Subtitle( decoder_t *p_dec, char *psz_subtitle, char *psz_h
 
     subpicture_updater_sys_t *p_spu_sys = p_spu->updater.p_sys;
 
-    p_spu_sys->align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_LEFT;
+    /* The "leavetext" alignment is a special mode where the subpicture
+       region itself gets aligned, but the text inside it does not */
+    p_spu_sys->align = SUBPICTURE_ALIGN_LEAVETEXT;
     p_spu_sys->text  = psz_subtitle;
     p_spu_sys->html  = psz_html;
     p_spu_sys->i_font_height_percent = 5;
index dfb08eecc9a27c15c564fd2b7bf1c8a269f9a767..eec696778334bda227bed2d5b1ed8d1037403505 100644 (file)
@@ -1090,6 +1090,8 @@ static inline int RenderAXYZ( filter_t *p_filter,
                 /* Left offset to take into account alignment */
                 if( (p_region->i_align & 0x3) == SUBPICTURE_ALIGN_RIGHT )
                     i_align_left += ( i_text_width - p_line->i_width );
+               else if( (p_region->i_align & 0x10) == SUBPICTURE_ALIGN_LEAVETEXT)
+                    i_align_left = i_margin; /* Keep it the way it is */
                 else if( (p_region->i_align & 0x3) != SUBPICTURE_ALIGN_LEFT )
                     i_align_left += ( i_text_width - p_line->i_width ) / 2;
             }