[vlc-commits] codecs: tx3g: map everything to relative sizes
Francois Cartegnie
git at videolan.org
Sat Jul 9 13:10:17 CEST 2016
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Jul 8 16:42:11 2016 +0200| [29310d1b5d14962407e1d1b9e2cd81a505005f1c] | committer: Francois Cartegnie
codecs: tx3g: map everything to relative sizes
devices dpi workaround
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=29310d1b5d14962407e1d1b9e2cd81a505005f1c
---
modules/codec/substx3g.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/modules/codec/substx3g.c b/modules/codec/substx3g.c
index dbd4c51..1563231 100644
--- a/modules/codec/substx3g.c
+++ b/modules/codec/substx3g.c
@@ -63,6 +63,11 @@ static int Open( vlc_object_t *p_this )
p_dec->fmt_out.i_cat = SPU_ES;
p_dec->fmt_out.i_codec = 0;
+ if( p_dec->fmt_out.subs.p_style )
+ {
+ p_dec->fmt_out.subs.p_style->i_font_size = 0;
+ p_dec->fmt_out.subs.p_style->f_font_relsize = 5.0;
+ }
return VLC_SUCCESS;
}
@@ -272,6 +277,26 @@ static void ApplySegmentStyle( tx3g_segment_t **pp_segment, const uint16_t i_abs
}
}
+/* Do relative size conversion using default style size (from stsd),
+ as the line should always be 5%. Apply to each segment specific text size */
+static void FontSizeConvert( const text_style_t *p_default_style, text_style_t *p_style )
+{
+ if( unlikely(!p_style) )
+ {
+ return;
+ }
+ else if( unlikely(!p_default_style) || p_default_style->i_font_size == 0 )
+ {
+ p_style->i_font_size = 0;
+ p_style->f_font_relsize = 5.0;
+ }
+ else
+ {
+ p_style->f_font_relsize = 5.0 * (float) p_style->i_font_size / p_default_style->i_font_size;
+ p_style->i_font_size = 0;
+ }
+}
+
/*****************************************************************************
* Decode:
*****************************************************************************/
@@ -412,11 +437,15 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
p_spu_sys->align = SUBPICTURE_ALIGN_BOTTOM;
+ FontSizeConvert( p_dec->fmt_in.subs.p_style, p_spu_sys->p_default_style );
+
/* Unwrap */
text_segment_t *p_text_segments = p_segment3g->s;
text_segment_t *p_cur = p_text_segments;
while( p_segment3g )
{
+ FontSizeConvert( p_dec->fmt_in.subs.p_style, p_segment3g->s->style );
+
tx3g_segment_t * p_old = p_segment3g;
p_segment3g = p_segment3g->p_next3g;
free( p_old );
More information about the vlc-commits
mailing list