[vlc-commits] [Git][videolan/vlc][master] vlc_subpicture: pass the SPU updater update configuration as a struct
Steve Lhomme (@robUx4)
gitlab at videolan.org
Thu Jan 23 13:14:00 UTC 2025
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
336220d8 by Steve Lhomme at 2025-01-23T12:59:11+00:00
vlc_subpicture: pass the SPU updater update configuration as a struct
So we don't have to discard multiple parameters in all implementations.
- - - - -
13 changed files:
- include/vlc_subpicture.h
- modules/access/bluray.c
- modules/codec/arib/libaribcaption.c
- modules/codec/arib/substext.h
- modules/codec/kate.c
- modules/codec/libass.c
- modules/codec/substext.h
- modules/codec/ttml/imageupdater.h
- modules/spu/subsdelay.c
- src/misc/subpicture.c
- src/video_output/video_epg.c
- src/video_output/video_text.c
- src/video_output/video_widgets.c
Changes:
=====================================
include/vlc_subpicture.h
=====================================
@@ -170,6 +170,21 @@ VLC_API void subpicture_region_Delete( subpicture_region_t *p_region );
*/
VLC_API void vlc_spu_regions_Clear( vlc_spu_regions * );
+struct vlc_spu_updater_configuration
+{
+ // source video format of the video under the SPU
+ const video_format_t *video_src;
+ // scaled video format of the video under the SPU
+ const video_format_t *video_dst;
+ // source video format of the previous vlc_spu_updater_ops.update call
+ const video_format_t *prev_src;
+ // scaled video format of the previous vlc_spu_updater_ops.update call
+ const video_format_t *prev_dst;
+ // timestamp when the SPU will be displayed, between i_start and i_stop
+ // for subtitles
+ vlc_tick_t pts;
+};
+
/**
* Subpicture updater operation virtual table.
*
@@ -181,9 +196,7 @@ struct vlc_spu_updater_ops
* the main job of creating the subpicture regions for the
* current video_format */
void (*update)(subpicture_t *,
- const video_format_t *prev_src, const video_format_t *p_fmt_src,
- const video_format_t *prev_dst, const video_format_t *p_fmt_dst,
- vlc_tick_t);
+ const struct vlc_spu_updater_configuration *);
/** Optional callback for subpicture private data cleanup */
void (*destroy)(subpicture_t *);
=====================================
modules/access/bluray.c
=====================================
@@ -1585,13 +1585,9 @@ static void updater_unlock_overlay(bluray_spu_updater_sys_t *p_upd_sys)
}
static void subpictureUpdaterUpdate(subpicture_t *p_subpic,
- const video_format_t *prev_src, const video_format_t *p_fmt_src,
- const video_format_t *prev_dst, const video_format_t *p_fmt_dst,
- vlc_tick_t i_ts)
+ const struct vlc_spu_updater_configuration *cfg)
{
- VLC_UNUSED(prev_src); VLC_UNUSED(p_fmt_src);
- VLC_UNUSED(prev_dst); VLC_UNUSED(p_fmt_dst);
- VLC_UNUSED(i_ts);
+ VLC_UNUSED(cfg);
bluray_spu_updater_sys_t *p_upd_sys = p_subpic->updater.sys;
bluray_overlay_t *p_overlay = updater_lock_overlay(p_upd_sys);
=====================================
modules/codec/arib/libaribcaption.c
=====================================
@@ -107,16 +107,16 @@ static void CopyImageToRegion(picture_t *dst_pic, const aribcc_image_t *image)
}
static void SubpictureUpdate(subpicture_t *p_subpic,
- const video_format_t *prev_src, const video_format_t *p_src_format,
- const video_format_t *prev_dst, const video_format_t *p_dst_format,
- vlc_tick_t i_ts)
+ const struct vlc_spu_updater_configuration *cfg)
{
libaribcaption_spu_updater_sys_t *p_spusys = p_subpic->updater.sys;
decoder_sys_t *p_sys = p_spusys->p_dec_sys;
+ const video_format_t *p_src_format = cfg->video_src;
+ const video_format_t *p_dst_format = cfg->video_dst;
- bool b_src_changed = p_src_format->i_visible_width != prev_src->i_visible_width ||
- p_src_format->i_visible_height != prev_src->i_visible_height;
- bool b_dst_changed = !video_format_IsSimilar(prev_dst, p_dst_format);
+ bool b_src_changed = p_src_format->i_visible_width != cfg->prev_src->i_visible_width ||
+ p_src_format->i_visible_height != cfg->prev_src->i_visible_height;
+ bool b_dst_changed = !video_format_IsSimilar(cfg->prev_dst, p_dst_format);
unsigned i_render_area_width = p_dst_format->i_visible_width;
unsigned i_render_area_height = p_src_format->i_visible_height * p_dst_format->i_visible_width /
@@ -127,7 +127,7 @@ static void SubpictureUpdate(subpicture_t *p_subpic,
i_render_area_height);
}
- const vlc_tick_t i_stream_date = p_spusys->i_pts + (i_ts - p_subpic->i_start);
+ const vlc_tick_t i_stream_date = p_spusys->i_pts + (cfg->pts - p_subpic->i_start);
/* Retrieve the expected render status for detecting whether the subtitle image changed */
aribcc_render_status_t status = aribcc_renderer_try_render(p_sys->p_renderer,
=====================================
modules/codec/arib/substext.h
=====================================
@@ -47,13 +47,10 @@ typedef struct
} arib_spu_updater_sys_t;
static void SubpictureTextUpdate(subpicture_t *subpic,
- const video_format_t *prev_src, const video_format_t *fmt_src,
- const video_format_t *prev_dst, const video_format_t *fmt_dst,
- vlc_tick_t ts)
+ const struct vlc_spu_updater_configuration *cfg)
{
arib_spu_updater_sys_t *sys = subpic->updater.sys;
- VLC_UNUSED(fmt_src); VLC_UNUSED(ts);
- VLC_UNUSED(prev_src); VLC_UNUSED(prev_dst);
+ const video_format_t *fmt_dst = cfg->video_dst;
if ( !sys->first )
return;
=====================================
modules/codec/kate.c
=====================================
@@ -800,19 +800,19 @@ static void PostprocessTigerImage( plane_t *p_plane, unsigned int i_width )
Looks good with white though since it's all luma. Hopefully that will be the
common case. */
static void TigerUpdateSubpicture( subpicture_t *p_subpic,
- const video_format_t *prev_src, const video_format_t *p_fmt_src,
- const video_format_t *prev_dst, const video_format_t *p_fmt_dst,
- vlc_tick_t ts )
+ const struct vlc_spu_updater_configuration *cfg )
{
kate_spu_updater_sys_t *p_spusys = p_subpic->updater.sys;
decoder_sys_t *p_sys = p_spusys->p_dec_sys;
+ const video_format_t *p_fmt_src = cfg->video_src;
+ const video_format_t *p_fmt_dst = cfg->video_dst;
plane_t *p_plane;
/* time in seconds from the start of the stream */
- kate_float t = (p_spusys->i_start + ts - p_subpic->i_start ) / 1000000.0f;
+ kate_float t = (p_spusys->i_start + cfg->pts - p_subpic->i_start ) / 1000000.0f;
bool new_regions = false;
- if( !video_format_IsSimilar(prev_src, p_fmt_src) ||
- !video_format_IsSimilar(prev_dst, p_fmt_dst) )
+ if( !video_format_IsSimilar(cfg->prev_src, p_fmt_src) ||
+ !video_format_IsSimilar(cfg->prev_dst, p_fmt_dst) )
new_regions = true;
if (!new_regions)
=====================================
modules/codec/libass.c
=====================================
@@ -94,10 +94,7 @@ static void DecSysRelease( decoder_sys_t *p_sys );
static void DecSysHold( decoder_sys_t *p_sys );
/* */
-static void SubpictureUpdate( subpicture_t *,
- const video_format_t *, const video_format_t *,
- const video_format_t *, const video_format_t *,
- vlc_tick_t );
+static void SubpictureUpdate( subpicture_t *, const struct vlc_spu_updater_configuration * );
static void SubpictureDestroy( subpicture_t * );
typedef struct
@@ -416,16 +413,16 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
*
****************************************************************************/
static void SubpictureUpdate( subpicture_t *p_subpic,
- const video_format_t *prev_src, const video_format_t *p_fmt_src,
- const video_format_t *prev_dst, const video_format_t *p_fmt_dst,
- vlc_tick_t i_ts )
+ const struct vlc_spu_updater_configuration *cfg )
{
libass_spu_updater_sys_t *p_spusys = p_subpic->updater.sys;
decoder_sys_t *p_sys = p_spusys->p_dec_sys;
+ const video_format_t *p_fmt_src = cfg->video_src;
+ const video_format_t *p_fmt_dst = cfg->video_dst;
- bool b_fmt_src = p_fmt_src->i_visible_width != prev_src->i_visible_width ||
- p_fmt_src->i_visible_height != prev_src->i_visible_height;
- bool b_fmt_dst = !video_format_IsSimilar(prev_dst, p_fmt_dst);
+ bool b_fmt_src = p_fmt_src->i_visible_width != cfg->prev_src->i_visible_width ||
+ p_fmt_src->i_visible_height != cfg->prev_src->i_visible_height;
+ bool b_fmt_dst = !video_format_IsSimilar(cfg->prev_dst, p_fmt_dst);
vlc_mutex_lock( &p_sys->lock );
@@ -445,7 +442,7 @@ static void SubpictureUpdate( subpicture_t *p_subpic,
}
/* */
- const vlc_tick_t i_stream_date = p_spusys->i_pts + (i_ts - p_subpic->i_start);
+ const vlc_tick_t i_stream_date = p_spusys->i_pts + (cfg->pts - p_subpic->i_start);
int i_changed;
ASS_Image *p_img = ass_render_frame( p_sys->p_renderer, p_sys->p_track,
MS_FROM_VLC_TICK( i_stream_date ), &i_changed );
=====================================
modules/codec/substext.h
=====================================
@@ -97,15 +97,15 @@ static inline void SubpictureUpdaterSysRegionAdd(substext_updater_region_t *p_pr
}
static void SubpictureTextUpdate(subpicture_t *subpic,
- const video_format_t *prev_src, const video_format_t *fmt_src,
- const video_format_t *prev_dst, const video_format_t *fmt_dst,
- vlc_tick_t ts)
+ const struct vlc_spu_updater_configuration *cfg)
{
subtext_updater_sys_t *sys = subpic->updater.sys;
+ const video_format_t *fmt_src = cfg->video_src;
+ const video_format_t *fmt_dst = cfg->video_dst;
- if (fmt_src->i_visible_height == prev_src->i_visible_height &&
- video_format_IsSimilar(prev_dst, fmt_dst) &&
- (sys->i_next_update == VLC_TICK_INVALID || sys->i_next_update > ts))
+ if (fmt_src->i_visible_height == cfg->prev_src->i_visible_height &&
+ video_format_IsSimilar(cfg->prev_dst, fmt_dst) &&
+ (sys->i_next_update == VLC_TICK_INVALID || sys->i_next_update > cfg->pts))
return;
substext_updater_region_t *p_updtregion = &sys->region;
@@ -266,9 +266,9 @@ static void SubpictureTextUpdate(subpicture_t *subpic,
}
if( b_schedule_blink_update &&
- (sys->i_next_update == VLC_TICK_INVALID || sys->i_next_update < ts) )
+ (sys->i_next_update == VLC_TICK_INVALID || sys->i_next_update < cfg->pts) )
{
- sys->i_next_update = ts + VLC_TICK_FROM_SEC(1);
+ sys->i_next_update = cfg->pts + VLC_TICK_FROM_SEC(1);
sys->b_blink_even = !sys->b_blink_even;
}
}
=====================================
modules/codec/ttml/imageupdater.h
=====================================
@@ -74,17 +74,13 @@ static void TTML_ImageSpuAppendRegion(ttml_image_updater_sys_t *p_sys,
}
static void TTML_ImageSpuUpdate(subpicture_t *p_spu,
- const video_format_t *prev_src, const video_format_t *p_fmt_src,
- const video_format_t *prev_dst, const video_format_t *p_fmt_dst,
- vlc_tick_t i_ts)
+ const struct vlc_spu_updater_configuration *cfg)
{
- VLC_UNUSED(p_fmt_src);
- VLC_UNUSED(i_ts);
- VLC_UNUSED(prev_src);
ttml_image_updater_sys_t *p_sys = p_spu->updater.sys;
+ const video_format_t *p_fmt_dst = cfg->video_dst;
- if (p_fmt_dst->i_visible_width == prev_dst->i_visible_width &&
- p_fmt_dst->i_visible_height == prev_dst->i_visible_height)
+ if (p_fmt_dst->i_visible_width == cfg->prev_dst->i_visible_width &&
+ p_fmt_dst->i_visible_height == cfg->prev_dst->i_visible_height)
return;
vlc_spu_regions_Clear( &p_spu->regions );
=====================================
modules/spu/subsdelay.c
=====================================
@@ -214,10 +214,7 @@ static bool SubsdelayIsTextEmpty( const subpicture_region_t * );
* Subpicture functions
*****************************************************************************/
-static void SubpicUpdateWrapper( subpicture_t *p_subpic,
- const video_format_t *prev_src, const video_format_t *p_fmt_src,
- const video_format_t *prev_dst, const video_format_t *p_fmt_dst,
- vlc_tick_t i_ts );
+static void SubpicUpdateWrapper( subpicture_t *, const struct vlc_spu_updater_configuration * );
static void SubpicDestroyWrapper( subpicture_t *p_subpic );
@@ -917,12 +914,9 @@ static void SubsdelayRecalculateDelays( filter_t *p_filter )
* SubpicUpdateWrapper: Subpicture update callback wrapper
*****************************************************************************/
static void SubpicUpdateWrapper( subpicture_t *p_subpic,
- const video_format_t *prev_src, const video_format_t *p_fmt_src,
- const video_format_t *prev_dst, const video_format_t *p_fmt_dst,
- vlc_tick_t i_ts )
+ const struct vlc_spu_updater_configuration *cfg )
{
subsdelay_heap_entry_t *p_entry;
- vlc_tick_t i_new_ts;
p_entry = p_subpic->updater.sys;
if( !p_entry )
@@ -947,20 +941,19 @@ static void SubpicUpdateWrapper( subpicture_t *p_subpic,
vlc_spu_regions_Clear( &p_subpic->regions );
/* call source update */
- i_new_ts = p_entry->p_source->i_start +
- ( (double)( p_entry->p_source->i_stop - p_entry->p_source->i_start ) * ( i_ts - p_entry->p_source->i_start ) ) /
+ struct vlc_spu_updater_configuration new_cfg = *cfg;
+ new_cfg.pts = p_entry->p_source->i_start +
+ ( (double)( p_entry->p_source->i_stop - p_entry->p_source->i_start ) * ( cfg->pts - p_entry->p_source->i_start ) ) /
( p_entry->i_new_stop - p_entry->p_source->i_start );
p_entry->p_source->regions = p_entry->p_subpic->regions;
subpicture_updater_t *updater = &p_entry->p_source->updater;
- updater->ops->update( p_entry->p_source,
- prev_src, p_fmt_src,
- prev_dst, p_fmt_dst, i_new_ts );
+ updater->ops->update( p_entry->p_source, &new_cfg );
p_entry->p_subpic->regions = p_entry->p_source->regions;
- SubpicLocalUpdate( p_subpic, i_ts );
+ SubpicLocalUpdate( p_subpic, cfg->pts );
}
/*****************************************************************************
=====================================
src/misc/subpicture.c
=====================================
@@ -183,10 +183,14 @@ void subpicture_Update( subpicture_t *p_subpicture,
if (p_upd->ops == NULL)
return;
- p_upd->ops->update(p_subpicture,
- &p_private->src, p_fmt_src,
- &p_private->dst, p_fmt_dst,
- i_ts);
+ struct vlc_spu_updater_configuration cfg = {
+ .prev_src = &p_private->src,
+ .prev_dst = &p_private->dst,
+ .video_src = p_fmt_src,
+ .video_dst = p_fmt_dst,
+ .pts = i_ts,
+ };
+ p_upd->ops->update( p_subpicture, &cfg );
video_format_Clean( &p_private->src );
video_format_Clean( &p_private->dst );
=====================================
src/video_output/video_epg.c
=====================================
@@ -498,15 +498,12 @@ static void vout_BuildOSDEpg(epg_spu_updater_sys_t *p_sys,
}
static void OSDEpgUpdate(subpicture_t *subpic,
- const video_format_t *prev_src, const video_format_t *fmt_src,
- const video_format_t *prev_dst, const video_format_t *fmt_dst,
- vlc_tick_t ts)
+ const struct vlc_spu_updater_configuration *cfg)
{
epg_spu_updater_sys_t *sys = subpic->updater.sys;
- VLC_UNUSED(fmt_src); VLC_UNUSED(ts);
- VLC_UNUSED(prev_src);
+ const video_format_t *fmt_dst = cfg->video_dst;
- if (video_format_IsSimilar(prev_dst, fmt_dst))
+ if (video_format_IsSimilar(cfg->prev_dst, fmt_dst))
return;
vlc_spu_regions_Clear( &subpic->regions );
=====================================
src/video_output/video_text.c
=====================================
@@ -38,15 +38,12 @@ typedef struct {
} osd_spu_updater_sys_t;
static void OSDTextUpdate(subpicture_t *subpic,
- const video_format_t *prev_src, const video_format_t *fmt_src,
- const video_format_t *prev_dst, const video_format_t *fmt_dst,
- vlc_tick_t ts)
+ const struct vlc_spu_updater_configuration *cfg)
{
osd_spu_updater_sys_t *sys = subpic->updater.sys;
- VLC_UNUSED(fmt_src); VLC_UNUSED(ts);
- VLC_UNUSED(prev_src);
+ const video_format_t *fmt_dst = cfg->video_dst;
- if (video_format_IsSimilar(prev_dst, fmt_dst))
+ if (video_format_IsSimilar(cfg->prev_dst, fmt_dst))
return;
vlc_spu_regions_Clear( &subpic->regions );
=====================================
src/video_output/video_widgets.c
=====================================
@@ -255,16 +255,13 @@ typedef struct {
} osdwidget_spu_updater_sys_t;
static void OSDWidgetUpdate(subpicture_t *subpic,
- const video_format_t *prev_src, const video_format_t *fmt_src,
- const video_format_t *prev_dst, const video_format_t *fmt_dst,
- vlc_tick_t ts)
+ const struct vlc_spu_updater_configuration *cfg)
{
osdwidget_spu_updater_sys_t *sys = subpic->updater.sys;
subpicture_region_t *p_region;
- VLC_UNUSED(fmt_src); VLC_UNUSED(ts);
- VLC_UNUSED(prev_src);
+ const video_format_t *fmt_dst = cfg->video_dst;
- if (video_format_IsSimilar(prev_dst, fmt_dst))
+ if (video_format_IsSimilar(cfg->prev_dst, fmt_dst))
return;
vlc_spu_regions_Clear( &subpic->regions );
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/336220d827c5f8447800c7db4aab392998b255a3
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/336220d827c5f8447800c7db4aab392998b255a3
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list