[vlc-devel] [RFC 7/7] subpictures: add option to enable/disable non-constrained subpictures

Salah-Eddin Shaban salah at videolan.org
Mon Feb 19 11:43:10 CET 2018


---
 src/libvlc-module.c                 |  1 +
 src/video_output/vout_subpictures.c | 15 ++++++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 77ab8283ab..30a76ce7bd 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -1677,6 +1677,7 @@ vlc_module_begin ()
     add_bool( "spu", 1, SPU_TEXT, SPU_LONGTEXT, false )
         change_safe ()
     add_bool( "osd", 1, OSD_TEXT, OSD_LONGTEXT, false )
+    add_bool( "spu-constrain", 1, "Constrained subpictures", "Subpictures constrained to video area", false )
     add_module( "text-renderer", "text renderer", NULL, TEXTRENDERER_TEXT,
                 TEXTRENDERER_LONGTEXT, true )
 
diff --git a/src/video_output/vout_subpictures.c b/src/video_output/vout_subpictures.c
index d81c1e76e7..f753f5b4bd 100644
--- a/src/video_output/vout_subpictures.c
+++ b/src/video_output/vout_subpictures.c
@@ -1061,12 +1061,13 @@ static subpicture_t *SpuRenderSubpictures(spu_t *spu,
         }
 
         if (sys->text) {
-            /* FIXME aspect ratio ? */
+            bool b_spu_constrain = var_InheritBool( spu, "spu-constrain" );
+            const video_format_t *p_fmt = b_spu_constrain ? fmt_dst : fmt_display;
             sys->text->fmt_out.video.i_width          =
-            sys->text->fmt_out.video.i_visible_width  = subpic->i_original_picture_width;
+            sys->text->fmt_out.video.i_visible_width = p_fmt->i_visible_width;
 
             sys->text->fmt_out.video.i_height         =
-            sys->text->fmt_out.video.i_visible_height = subpic->i_original_picture_height;
+            sys->text->fmt_out.video.i_visible_height = p_fmt->i_visible_height;
         }
 
         /* Render all regions */
@@ -1597,8 +1598,12 @@ subpicture_t *spu_Render(spu_t *spu,
     for (unsigned i = 0; i < subpicture_count; i++) {
         subpicture_t *subpic = subpicture_array[i];
 
-        /* allow rendering outside the video area only if both the vout and the subpicture allow it */
-        bool b_constrained = video_format_IsSimilar( fmt_display, fmt_dst ) || subpic->b_constrained;
+        /*
+         * allow rendering outside the video area only if it's allowed globally,
+         * and supported by the vout and the subpicture
+         */
+        bool b_spu_constrain = var_InheritBool(spu, "spu-constrain");
+        bool b_constrained = b_spu_constrain || video_format_IsSimilar( fmt_display, fmt_dst ) || subpic->b_constrained;
 
         subpicture_Update(subpic,
                           fmt_src, b_constrained ? fmt_dst : fmt_display,
-- 
2.13.6



More information about the vlc-devel mailing list