Commit 38978586 authored by Devin Heitmueller's avatar Devin Heitmueller Committed by 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é's avatarRafaël Carré <funman@videolan.org>
parent 75402b8f
......@@ -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.
*
......
......@@ -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;
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment