Skip to content

Commit

Permalink
sd_ass: introduce sub-ass-prune-delay
Browse files Browse the repository at this point in the history
  • Loading branch information
llyyr committed Oct 30, 2024
1 parent aa66f0d commit bd83197
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions DOCS/man/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2533,6 +2533,16 @@ Subtitles
``complex`` is the default. If libass hasn't been compiled against HarfBuzz,
libass silently reverts to ``simple``.

``--sub-ass-prune-delay=<-1|seconds>``
Set the automatic pruning delay for events from memory in libass. When
enabled, subtitle events are removed from memory once their end timestamp is
older than the specified delay.

:-1: disables automatic pruning (default).
:seconds: specify how many seconds after an event is no longer displayed
should the pruning occur. ``0`` prunes events as soon as they're
off screen.

``--sub-ass-styles=<filename>``
Load all SSA/ASS styles found in the specified file and use them for
rendering text subtitles. The syntax of the file is exactly like the ``[V4
Expand Down
2 changes: 2 additions & 0 deletions options/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ const struct m_sub_options mp_subtitle_sub_opts = {
{"none", 0}, {"light", 1}, {"normal", 2}, {"native", 3})},
{"sub-ass-shaper", OPT_CHOICE(ass_shaper,
{"simple", 0}, {"complex", 1})},
{"sub-ass-prune-delay", OPT_DOUBLE(ass_prune_delay), M_RANGE(-1.0, DBL_MAX)},
{"sub-ass-justify", OPT_BOOL(ass_justify)},
{"sub-scale-by-window", OPT_BOOL(sub_scale_by_window)},
{"sub-scale-with-window", OPT_BOOL(sub_scale_with_window)},
Expand All @@ -355,6 +356,7 @@ const struct m_sub_options mp_subtitle_sub_opts = {
.sub_scale_by_window = true,
.sub_use_margins = true,
.sub_scale_with_window = true,
.ass_prune_delay = -1.0,
.teletext_page = 0,
.sub_scale = 1,
.ass_vsfilter_color_compat = 1,
Expand Down
1 change: 1 addition & 0 deletions options/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ struct mp_subtitle_opts {
char *ass_styles_file;
int ass_hinting;
int ass_shaper;
double ass_prune_delay;
bool ass_justify;
bool sub_clear_on_seek;
int teletext_page;
Expand Down
3 changes: 3 additions & 0 deletions sub/sd_ass.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,9 @@ static void configure_ass(struct sd *sd, struct mp_osd_res *dim,
ass_set_use_margins(priv, set_use_margins);
ass_set_line_position(priv, set_sub_pos);
ass_set_shaper(priv, opts->ass_shaper);
#if LIBASS_VERSION >= 0x01703010
ass_configure_prune(priv, MP_TIME_S_TO_NS(opts->ass_prune_delay));
#endif
int set_force_flags = 0;
if (total_override) {
set_force_flags |= ASS_OVERRIDE_BIT_FONT_NAME
Expand Down

0 comments on commit bd83197

Please sign in to comment.