[vlc-commits] vlc_subpicture: add missing text_align
Francois Cartegnie
git at videolan.org
Mon Oct 23 14:48:21 CEST 2017
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Oct 23 10:17:50 2017 +0200| [bf2f78cac00cb7e51d09e551c7ae9e8f20ede3ac] | committer: Francois Cartegnie
vlc_subpicture: add missing text_align
no longer forces text to have same alignment as picture
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bf2f78cac00cb7e51d09e551c7ae9e8f20ede3ac
---
include/vlc_subpicture.h | 8 ++++----
modules/codec/cc.c | 2 +-
modules/codec/cea708.c | 2 +-
modules/codec/substext.h | 5 ++++-
modules/text_renderer/freetype/freetype.c | 2 +-
5 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/include/vlc_subpicture.h b/include/vlc_subpicture.h
index 0cb358aeb8..cb368c3a61 100644
--- a/include/vlc_subpicture.h
+++ b/include/vlc_subpicture.h
@@ -61,10 +61,12 @@ struct subpicture_region_t
int i_x; /**< position of region, relative to alignment */
int i_y; /**< position of region, relative to alignment */
- int i_align; /**< alignment flags of region and content */
+ int i_align; /**< alignment flags of region */
int i_alpha; /**< transparency */
+ /* Parameters for text regions (p_picture to be rendered) */
text_segment_t *p_text; /**< subtitle text, made of a list of segments */
+ int i_text_align; /**< alignment flags of region content */
bool b_noregionbg; /**< render background under text only */
bool b_gridmode; /** if the decoder sends row/cols based output */
bool b_balanced_text; /** try to balance wrapped text lines */
@@ -80,10 +82,8 @@ 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_LEAVETEXT )
+ SUBPICTURE_ALIGN_TOP |SUBPICTURE_ALIGN_BOTTOM )
/**
* This function will create a new subpicture region.
*
diff --git a/modules/codec/cc.c b/modules/codec/cc.c
index 4bc45957a9..7e98722531 100644
--- a/modules/codec/cc.c
+++ b/modules/codec/cc.c
@@ -507,7 +507,7 @@ static subpicture_t *Subtitle( decoder_t *p_dec, eia608_t *h, mtime_t i_pts )
/* The "leavetext" alignment is a special mode where the subpicture
region itself gets aligned, but the text inside it does not */
p_spu_sys->region.align = SUBPICTURE_ALIGN_TOP|SUBPICTURE_ALIGN_LEFT;
- p_spu_sys->region.inner_align = SUBPICTURE_ALIGN_LEAVETEXT;
+ p_spu_sys->region.inner_align = SUBPICTURE_ALIGN_BOTTOM|SUBPICTURE_ALIGN_LEFT;
p_spu_sys->region.flags = UPDT_REGION_IGNORE_BACKGROUND | UPDT_REGION_USES_GRID_COORDINATES;
/* Set style defaults (will be added to segments if none set) */
diff --git a/modules/codec/cea708.c b/modules/codec/cea708.c
index 19b5811787..1f963275e7 100644
--- a/modules/codec/cea708.c
+++ b/modules/codec/cea708.c
@@ -1036,8 +1036,8 @@ static void CEA708SpuConvert( const cea708_window_t *p_w,
[CEA708_ANCHOR_BOTTOM_RIGHT] = SUBPICTURE_ALIGN_BOTTOM|SUBPICTURE_ALIGN_RIGHT,
};
p_region->align = vlc_subpicture_aligns[p_w->anchor_point];
- p_region->align |= SUBPICTURE_ALIGN_LEAVETEXT;
}
+ p_region->inner_align = SUBPICTURE_ALIGN_BOTTOM|SUBPICTURE_ALIGN_LEFT;
}
static subpicture_t *CEA708_BuildSubtitle( cea708_t *p_cea708 )
diff --git a/modules/codec/substext.h b/modules/codec/substext.h
index ecc408f4a8..f56eb25004 100644
--- a/modules/codec/substext.h
+++ b/modules/codec/substext.h
@@ -75,6 +75,8 @@ static inline void SubpictureUpdaterSysRegionClean(subpicture_updater_sys_region
static inline void SubpictureUpdaterSysRegionInit(subpicture_updater_sys_region_t *p_updtregion)
{
memset(p_updtregion, 0, sizeof(*p_updtregion));
+ p_updtregion->align = SUBPICTURE_ALIGN_BOTTOM /* CENTER */;
+ p_updtregion->inner_align = SUBPICTURE_ALIGN_BOTTOM /* CENTER */;
}
static inline subpicture_updater_sys_region_t *SubpictureUpdaterSysRegionNew( )
@@ -165,7 +167,8 @@ static void SubpictureTextUpdate(subpicture_t *subpic,
pp_last_region = &r->p_next;
r->p_text = text_segment_Copy( p_updtregion->p_segments );
- r->i_align = p_updtregion->inner_align | p_updtregion->align; /* we do not support text align by itself */
+ r->i_align = p_updtregion->align;
+ r->i_text_align = p_updtregion->inner_align;
r->b_noregionbg = p_updtregion->flags & UPDT_REGION_IGNORE_BACKGROUND;
r->b_gridmode = p_updtregion->flags & UPDT_REGION_USES_GRID_COORDINATES;
diff --git a/modules/text_renderer/freetype/freetype.c b/modules/text_renderer/freetype/freetype.c
index 13cc2a79b4..9890e7f175 100644
--- a/modules/text_renderer/freetype/freetype.c
+++ b/modules/text_renderer/freetype/freetype.c
@@ -275,7 +275,7 @@ static FT_Vector GetAlignedOffset( const line_desc_t *p_line,
FT_Vector offsets = { 0, 0 };
const int i_text_width = p_textbbox->xMax - p_textbbox->xMin;
if ( p_line->i_width < i_text_width &&
- (i_align & (SUBPICTURE_ALIGN_LEFT|SUBPICTURE_ALIGN_LEAVETEXT)) == 0 )
+ (i_align & SUBPICTURE_ALIGN_LEFT) == 0 )
{
/* Left offset to take into account alignment */
if( i_align & SUBPICTURE_ALIGN_RIGHT )
More information about the vlc-commits
mailing list