[vlc-devel] [PATCH 11/11] Add ability to render the subpicture region, but not the text itself
Devin Heitmueller
dheitmueller at kernellabs.com
Thu Dec 27 07:08:23 CET 2012
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).
---
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 4329c1c..11b7e93 100644
--- a/modules/codec/cc.c
+++ b/modules/codec/cc.c
@@ -333,7 +333,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 bb9ded4..aa96333 100644
--- a/modules/text_renderer/freetype.c
+++ b/modules/text_renderer/freetype.c
@@ -1096,6 +1096,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;
}
--
1.7.9.5
More information about the vlc-devel
mailing list