Commit 22469573 authored by François Cartegnie's avatar François Cartegnie 🤞

subpicture: allow decoders to remove margin

Can't behave well if renderers add their own arbitrary margins
and we have a rows/cols based sub
parent 1eefe9ff
......@@ -66,6 +66,7 @@ struct subpicture_region_t
text_segment_t *p_text; /**< subtitle text, made of a list of segments */
bool b_renderbg; /**< render black background under text */
bool b_gridmode; /** if the decoder sends row/cols based output */
subpicture_region_t *p_next; /**< next region in the list */
subpicture_region_private_t *p_private; /**< Private data for spu_t *only* */
......
......@@ -425,6 +425,7 @@ static subpicture_t *Subtitle( decoder_t *p_dec, text_segment_t *p_segments, mti
p_spu_sys->align = SUBPICTURE_ALIGN_LEAVETEXT;
p_spu_sys->p_segments = p_segments;
p_spu_sys->renderbg = p_dec->p_sys->b_opaque;
p_spu_sys->gridmode = true;
/* Set style defaults (will be added to segments if none set) */
p_spu_sys->p_default_style->i_style_flags |= STYLE_MONOSPACED;
p_spu_sys->p_default_style->i_font_color = rgi_eia608_colors[EIA608_COLOR_DEFAULT];
......
......@@ -12,6 +12,7 @@ struct subpicture_updater_sys_t {
int fixed_width;
int fixed_height;
bool renderbg;
bool gridmode;
/* styling */
text_style_t *p_default_style; /* decoder (full or partial) defaults */
......@@ -66,6 +67,7 @@ static void SubpictureTextUpdate(subpicture_t *subpic,
r->p_text = sys->p_segments;
r->i_align = sys->align;
r->b_renderbg = sys->renderbg;
r->b_gridmode = sys->gridmode;
if (!sys->is_fixed) {
const float margin_ratio = 0.04;
const int margin_h = margin_ratio * fmt_dst->i_visible_width;
......
......@@ -1047,7 +1047,7 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region_out,
uint8_t i_background_opacity = var_InheritInteger( p_filter, "freetype-background-opacity" );
i_background_opacity = VLC_CLIP( i_background_opacity, 0, 255 );
const int i_margin = i_background_opacity > 0 ? i_max_face_height / 4 : 0;
const int i_margin = (i_background_opacity > 0 && !p_region_in->b_gridmode) ? i_max_face_height / 4 : 0;
for( const vlc_fourcc_t *p_chroma = p_chroma_list; *p_chroma != 0; p_chroma++ )
{
rv = VLC_EGENERIC;
......
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