[vlc-commits] substext: pass margin and font to regions
Francois Cartegnie
git at videolan.org
Tue Sep 26 22:43:58 CEST 2017
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Sep 19 14:15:22 2017 +0200| [ecb368ef38469b7d53abaf45e33991a7c257b70a] | committer: Francois Cartegnie
substext: pass margin and font to regions
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ecb368ef38469b7d53abaf45e33991a7c257b70a
---
modules/codec/cc.c | 4 +++-
modules/codec/substext.h | 15 +++++----------
2 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/modules/codec/cc.c b/modules/codec/cc.c
index e9d0b5e810..2ed58cc27a 100644
--- a/modules/codec/cc.c
+++ b/modules/codec/cc.c
@@ -452,9 +452,11 @@ static subpicture_t *Subtitle( decoder_t *p_dec, eia608_t *h, mtime_t i_pts )
p_spu_sys->p_default_style->i_features |= STYLE_HAS_BACKGROUND_ALPHA;
p_spu_sys->p_default_style->i_style_flags |= STYLE_BACKGROUND;
}
+ p_spu_sys->margin_ratio = 0.10;
p_spu_sys->p_default_style->i_font_color = rgi_eia608_colors[EIA608_COLOR_DEFAULT];
/* FCC defined "safe area" for EIA-608 captions is 80% of the height of the display */
- p_spu_sys->p_default_style->f_font_relsize = 100 * 8 / 10 / EIA608_SCREEN_ROWS;
+ p_spu_sys->p_default_style->f_font_relsize = EIA608_VISIBLE * 100 / EIA608_SCREEN_ROWS /
+ FONT_TO_LINE_HEIGHT_RATIO;
p_spu_sys->p_default_style->i_features |= (STYLE_HAS_FONT_COLOR | STYLE_HAS_FLAGS);
Eia608FillUpdaterRegions( p_spu_sys, h );
diff --git a/modules/codec/substext.h b/modules/codec/substext.h
index 23cb0d4e13..6fd519e0b8 100644
--- a/modules/codec/substext.h
+++ b/modules/codec/substext.h
@@ -66,6 +66,7 @@ struct subpicture_updater_sys_t {
/* styling */
text_style_t *p_default_style; /* decoder (full or partial) defaults */
+ float margin_ratio;
};
static inline void SubpictureUpdaterSysRegionClean(subpicture_updater_sys_region_t *p_updtregion)
@@ -178,7 +179,7 @@ static void SubpictureTextUpdate(subpicture_t *subpic,
if (!(p_updtregion->flags & UPDT_REGION_FIX_DONE))
{
- const float margin_ratio = ( r->b_gridmode ) ? 0.10 : 0.04;
+ const float margin_ratio = sys->margin_ratio;
const int margin_h = margin_ratio * (( r->b_gridmode ) ? (unsigned) subpic->i_original_picture_width
: fmt_dst->i_visible_width );
const int margin_v = margin_ratio * fmt_dst->i_visible_height;
@@ -216,17 +217,10 @@ static void SubpictureTextUpdate(subpicture_t *subpic,
p_segment->style = text_style_Duplicate( sys->p_default_style );
/* Update all segments font sizes in pixels, *** metric used by renderers *** */
/* We only do this when a fixed font size isn't set */
- if( r->b_gridmode )
- {
- /* Ensure font size is correct for grid layout */
- p_segment->style->f_font_relsize = 0; /* Force to unset */
- p_segment->style->i_font_size = EIA608_VISIBLE * subpic->i_original_picture_height /
- EIA608_ROWS / FONT_TO_LINE_HEIGHT_RATIO;
- }
- else if( p_segment->style && p_segment->style->f_font_relsize && !p_segment->style->i_font_size )
+ if( p_segment->style && p_segment->style->f_font_relsize && !p_segment->style->i_font_size )
{
p_segment->style->i_font_size = p_segment->style->f_font_relsize *
- subpic->i_original_picture_height / 100;
+ subpic->i_original_picture_height / 100;
}
}
@@ -258,6 +252,7 @@ static inline subpicture_t *decoder_NewSubpictureText(decoder_t *decoder)
.p_sys = sys,
};
SubpictureUpdaterSysRegionInit( &sys->region );
+ sys->margin_ratio = 0.04;
sys->p_default_style = text_style_Create( STYLE_NO_DEFAULTS );
if(unlikely(!sys->p_default_style))
{
More information about the vlc-commits
mailing list