[vlc-commits] codec: libass: add support for sub-text-scale
Francois Cartegnie
git at videolan.org
Fri Jan 22 22:16:28 UTC 2021
vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Jan 20 23:16:18 2021 +0100| [72fd3b20f855198959e0dfb6b331acc5cb4502c6] | committer: Francois Cartegnie
codec: libass: add support for sub-text-scale
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=72fd3b20f855198959e0dfb6b331acc5cb4502c6
---
modules/codec/libass.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/modules/codec/libass.c b/modules/codec/libass.c
index f743fbb616..3e3eb548b4 100644
--- a/modules/codec/libass.c
+++ b/modules/codec/libass.c
@@ -75,12 +75,14 @@ static void Flush( decoder_t * );
struct decoder_sys_t
{
mtime_t i_max_stop;
+ int i_scale;
/* The following fields of decoder_sys_t are shared between decoder and spu units */
vlc_mutex_t lock;
int i_refcount;
/* */
+ vlc_object_t *p_callbackobj;
ASS_Library *p_library;
ASS_Renderer *p_renderer;
video_format_t fmt;
@@ -123,6 +125,19 @@ typedef struct
static int BuildRegions( rectangle_t *p_region, int i_max_region, ASS_Image *p_img_list, int i_width, int i_height );
static void RegionDraw( subpicture_region_t *p_region, ASS_Image *p_img );
+static int ScalingCallback (vlc_object_t *obj, const char *var,
+ vlc_value_t old, vlc_value_t cur, void *data)
+{
+ decoder_sys_t *p_sys = data;
+ VLC_UNUSED(obj);
+ VLC_UNUSED(var);
+ VLC_UNUSED(old);
+ vlc_mutex_lock(&p_sys->lock);
+ p_sys->i_scale = cur.i_int;
+ vlc_mutex_unlock(&p_sys->lock);
+ return VLC_SUCCESS;
+}
+
//#define DEBUG_REGION
/*****************************************************************************
@@ -148,6 +163,7 @@ static int Create( vlc_object_t *p_this )
p_sys->i_refcount = 1;
memset( &p_sys->fmt, 0, sizeof(p_sys->fmt) );
p_sys->i_max_stop = VLC_TS_INVALID;
+ p_sys->i_scale = var_InheritInteger( p_dec, "sub-text-scale" );
p_sys->p_library = NULL;
p_sys->p_renderer = NULL;
p_sys->p_track = NULL;
@@ -272,6 +288,18 @@ static int Create( vlc_object_t *p_this )
}
ass_process_codec_private( p_track, p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra );
+ vlc_value_t val;
+ for ( vlc_object_t *obj = p_dec; obj; obj = obj->obj.parent )
+ {
+ if( var_GetChecked( obj, "sub-text-scale" ,
+ VLC_VAR_INTEGER, &val ) == VLC_SUCCESS )
+ {
+ var_AddCallback( obj, "sub-text-scale", ScalingCallback, p_sys );
+ p_sys->p_callbackobj = obj;
+ break;
+ }
+ }
+
p_dec->fmt_out.i_codec = VLC_CODEC_RGBA;
return VLC_SUCCESS;
@@ -304,6 +332,11 @@ static void DecSysRelease( decoder_sys_t *p_sys )
return;
}
vlc_mutex_unlock( &p_sys->lock );
+
+ if( p_sys->p_callbackobj )
+ var_DelCallback( p_sys->p_callbackobj, "sub-text-scale",
+ ScalingCallback, p_sys );
+
vlc_mutex_destroy( &p_sys->lock );
if( p_sys->p_track )
@@ -436,6 +469,8 @@ static int SubpictureValidate( subpicture_t *p_subpic,
p_sys->fmt = fmt;
}
+ ass_set_font_scale( p_sys->p_renderer, p_sys->i_scale / 100.0 );
+
/* */
const mtime_t i_stream_date = p_subpic->updater.p_sys->i_pts + (i_ts - p_subpic->i_start);
int i_changed;
More information about the vlc-commits
mailing list