[vlc-devel] [RFC 5/7] libass: allow rendering SSA subtitles in display dimensions

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


---
 modules/codec/libass.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/modules/codec/libass.c b/modules/codec/libass.c
index f743fbb616..01e8aa346b 100644
--- a/modules/codec/libass.c
+++ b/modules/codec/libass.c
@@ -63,6 +63,7 @@ vlc_module_begin ()
     set_category( CAT_INPUT )
     set_subcategory( SUBCAT_INPUT_SCODEC )
     set_callbacks( Create, Destroy )
+    add_bool( "ssa-constrain", true, "Constrain SSA to video area", "Constrain SSA to video area", false );
 vlc_module_end ()
 
 /*****************************************************************************
@@ -391,6 +392,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
     p_spu->i_stop = __MAX( p_sys->i_max_stop, p_block->i_pts + p_block->i_length );
     p_spu->b_ephemer = true;
     p_spu->b_absolute = true;
+    p_spu->b_constrained = var_InheritBool( p_dec, "ssa-constrain" );
 
     p_sys->i_max_stop = p_spu->i_stop;
 
@@ -418,6 +420,8 @@ static int SubpictureValidate( subpicture_t *p_subpic,
                                bool b_fmt_dst, const video_format_t *p_fmt_dst,
                                mtime_t i_ts )
 {
+    VLC_UNUSED( p_fmt_src );
+
     decoder_sys_t *p_sys = p_subpic->updater.p_sys->p_dec_sys;
 
     vlc_mutex_lock( &p_sys->lock );
@@ -430,9 +434,7 @@ static int SubpictureValidate( subpicture_t *p_subpic,
     if( b_fmt_src || b_fmt_dst )
     {
         ass_set_frame_size( p_sys->p_renderer, fmt.i_visible_width, fmt.i_visible_height );
-        const double src_ratio = (double)p_fmt_src->i_visible_width / p_fmt_src->i_visible_height;
-        const double dst_ratio = (double)p_fmt_dst->i_visible_width / p_fmt_dst->i_visible_height;
-        ass_set_aspect_ratio( p_sys->p_renderer, dst_ratio / src_ratio, 1 );
+        ass_set_pixel_aspect( p_sys->p_renderer, 1 );
         p_sys->fmt = fmt;
     }
 
-- 
2.13.6



More information about the vlc-devel mailing list