[vlc-commits] subpicture: allow decoders to remove margin

Francois Cartegnie git at videolan.org
Mon Aug 17 17:59:40 CEST 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Aug 17 15:19:02 2015 +0200| [22469573e9ed4805e5e5e0ff761f627625a8153f] | committer: Francois 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

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=22469573e9ed4805e5e5e0ff761f627625a8153f
---

 include/vlc_subpicture.h         |    1 +
 modules/codec/cc.c               |    1 +
 modules/codec/substext.h         |    2 ++
 modules/text_renderer/freetype.c |    2 +-
 4 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/vlc_subpicture.h b/include/vlc_subpicture.h
index a5f827a..3103f09 100644
--- a/include/vlc_subpicture.h
+++ b/include/vlc_subpicture.h
@@ -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* */
diff --git a/modules/codec/cc.c b/modules/codec/cc.c
index 99da3a6..cef162c 100644
--- a/modules/codec/cc.c
+++ b/modules/codec/cc.c
@@ -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];
diff --git a/modules/codec/substext.h b/modules/codec/substext.h
index 1b27b4f..51c6af5 100644
--- a/modules/codec/substext.h
+++ b/modules/codec/substext.h
@@ -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;
diff --git a/modules/text_renderer/freetype.c b/modules/text_renderer/freetype.c
index 8fbdebd..ca06368 100644
--- a/modules/text_renderer/freetype.c
+++ b/modules/text_renderer/freetype.c
@@ -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;



More information about the vlc-commits mailing list