[vlc-commits] Add ability to render the subpicture region, but not the text itself

Devin Heitmueller git at videolan.org
Mon Dec 31 14:00:04 CET 2012


vlc | branch: master | Devin Heitmueller <dheitmueller at kernellabs.com> | Thu Dec 27 01:08:23 2012 -0500| [389785860a290082fa0315e162594a9fb8da8b32] | committer: Rafaël Carré

Add ability to render the subpicture region, but not the text itself

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 at videolan.org>

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

 include/vlc_subpicture.h         |    5 +++--
 modules/codec/cc.c               |    4 +++-
 modules/text_renderer/freetype.c |    2 ++
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/include/vlc_subpicture.h b/include/vlc_subpicture.h
index 797f22a..d98e043 100644
--- a/include/vlc_subpicture.h
+++ b/include/vlc_subpicture.h
@@ -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.
  *
diff --git a/modules/codec/cc.c b/modules/codec/cc.c
index 7fd256d..6ea07fd 100644
--- a/modules/codec/cc.c
+++ b/modules/codec/cc.c
@@ -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;
diff --git a/modules/text_renderer/freetype.c b/modules/text_renderer/freetype.c
index dfb08ee..eec6967 100644
--- a/modules/text_renderer/freetype.c
+++ b/modules/text_renderer/freetype.c
@@ -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;
             }



More information about the vlc-commits mailing list