Commit 5f52d4bd authored by François Cartegnie's avatar François Cartegnie 🤞

codec: ttml: handle missing default text alignment

refs #19147 #19146
parent 38227a2d
......@@ -64,6 +64,7 @@ typedef struct
ttml_length_t font_size;
ttml_length_t extent_h, extent_v;
int i_text_align;
bool b_text_align_set;
int i_direction;
bool b_direction_set;
bool b_preserve_space;
......@@ -188,7 +189,8 @@ static ttml_region_t *ttml_region_New( )
SubpictureUpdaterSysRegionInit( &p_ttml_region->updt );
p_ttml_region->pp_last_segment = &p_ttml_region->updt.p_segments;
/* Align to top by default. !Warn: center align is obtained with NO flags */
p_ttml_region->updt.align = SUBPICTURE_ALIGN_TOP;
p_ttml_region->updt.align = SUBPICTURE_ALIGN_TOP|SUBPICTURE_ALIGN_LEFT;
p_ttml_region->updt.inner_align = SUBPICTURE_ALIGN_TOP|SUBPICTURE_ALIGN_LEFT;
return p_ttml_region;
}
......@@ -465,6 +467,7 @@ static void FillTTMLStyle( const char *psz_attr, const char *psz_val,
else if( strcasecmp ( "center", psz_val ) )
/* == "start" FIXME: should be BIDI based */
p_ttml_style->i_text_align |= SUBPICTURE_ALIGN_LEFT;
p_ttml_style->b_text_align_set = true;
printf("**%s %x\n", psz_val, p_ttml_style->i_text_align);
}
else if( !strcasecmp( "tts:fontSize", psz_attr ) )
......@@ -800,8 +803,11 @@ static void AppendTextToRegion( ttml_context_t *p_ctx, const tt_textnode_t *p_tt
/* we don't have paragraph, so no per text line alignment.
* Text style brings horizontal textAlign to region.
* Region itself is styled with vertical displayAlign */
p_region->updt.inner_align &= ~(SUBPICTURE_ALIGN_LEFT|SUBPICTURE_ALIGN_RIGHT);
p_region->updt.inner_align |= s->i_text_align;
if( s->b_text_align_set )
{
p_region->updt.inner_align &= ~(SUBPICTURE_ALIGN_LEFT|SUBPICTURE_ALIGN_RIGHT);
p_region->updt.inner_align |= s->i_text_align;
}
ttml_style_Delete( s );
}
......@@ -1030,7 +1036,7 @@ static int ParseBlock( decoder_t *p_dec, const block_t *p_block )
p_spu->i_start = VLC_TS_0 + tt_time_Convert( &p_timings_array[i] );
p_spu->i_stop = VLC_TS_0 + tt_time_Convert( &p_timings_array[i+1] ) - 1;
p_spu->b_ephemer = true;
p_spu->b_absolute = false;
p_spu->b_absolute = true;
subpicture_updater_sys_t *p_spu_sys = p_spu->updater.p_sys;
subpicture_updater_sys_region_t *p_updtregion = NULL;
......
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