Commit ecb368ef authored by François Cartegnie's avatar François Cartegnie 🤞
Browse files

substext: pass margin and font to regions

parent 00473993
......@@ -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 );
......
......@@ -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))
{
......
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