Skip to content

Commit

Permalink
player: add --sub-ass-feature-* options
Browse files Browse the repository at this point in the history
  • Loading branch information
dyphire authored and github-actions[bot] committed Oct 16, 2023
1 parent 6a0c98a commit abf6961
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 1 deletion.
27 changes: 27 additions & 0 deletions DOCS/man/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2541,6 +2541,33 @@ Subtitles
a subtitle script with another video file. The ``--sub-ass-override``
option doesn't affect how this option is interpreted.

``--sub-ass-feature-bidi-brackets=<yes|no>``
Enable Unicode 6.3+ bracket matching when applying the Unicode Bidirectional
Algorithm for text subtitle and SSA/ASS files.
This is incompatible with VSFilter.

Disabled by default.

``--sub-ass-feature-whole-text-layout=<yes|no>``
Apply bidi, shaping and \\fay to the entire unsplit event text for SSA/ASS
files. This is incompatible with VSFilter.

Disabled by default.

``--sub-ass-feature-wrap-unicode=<yes|no>``
Break lines according to the Unicode Line Breaking Algorithm.If the track
language is set, some additional language-specific tweaks may be applied.
Setting this enables more breaking opportunities compared to classic ASS.
However, it is still possible for long words without breaking opportunities
to cause overfull lines. This is incompatible with VSFilter.

Disabled by default.

.. note::

This works for text subtitle and SSA/ASS files only. libass need compiled
with libunibreak support (if not, it behaves like ``no``).

``--stretch-dvd-subs=<yes|no>``
Stretch DVD subtitles when playing anamorphic videos for better looking
fonts on badly mastered DVDs. This switch has no effect when the
Expand Down
6 changes: 6 additions & 0 deletions options/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ const struct m_sub_options mp_subtitle_sub_opts = {
{"sub-ass-vsfilter-color-compat", OPT_CHOICE(ass_vsfilter_color_compat,
{"no", 0}, {"basic", 1}, {"full", 2}, {"force-601", 3})},
{"sub-ass-vsfilter-blur-compat", OPT_BOOL(ass_vsfilter_blur_compat)},
{"sub-ass-feature-bidi-brackets", OPT_BOOL(ass_feature_bidi_brackets)},
{"sub-ass-feature-whole-text-layout", OPT_BOOL(ass_feature_whole_text_layout)},
{"sub-ass-feature-wrap-unicode", OPT_BOOL(ass_feature_wrap_unicode)},
{"embeddedfonts", OPT_BOOL(use_embedded_fonts), .flags = UPDATE_SUB_HARD},
{"sub-ass-force-style", OPT_STRINGLIST(ass_force_style_list),
.flags = UPDATE_SUB_HARD},
Expand Down Expand Up @@ -340,6 +343,9 @@ const struct m_sub_options mp_subtitle_sub_opts = {
.ass_vsfilter_aspect_compat = true,
.ass_vsfilter_color_compat = 1,
.ass_vsfilter_blur_compat = true,
.ass_feature_bidi_brackets = false,
.ass_feature_whole_text_layout = false,
.ass_feature_wrap_unicode = false,
.ass_style_override = 1,
.sec_sub_override = true,
.ass_shaper = 1,
Expand Down
3 changes: 3 additions & 0 deletions options/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ struct mp_subtitle_opts {
bool ass_vsfilter_aspect_compat;
int ass_vsfilter_color_compat;
bool ass_vsfilter_blur_compat;
bool ass_feature_bidi_brackets;
bool ass_feature_whole_text_layout;
bool ass_feature_wrap_unicode;
bool use_embedded_fonts;
char **ass_force_style_list;
char *ass_styles_file;
Expand Down
7 changes: 7 additions & 0 deletions sub/osd_libass.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ static void create_ass_track(struct osd_state *osd, struct osd_object *obj,
track->WrapStyle = 1; // end-of-line wrapping instead of smart wrapping
track->Kerning = true;
track->ScaledBorderAndShadow = true;

#if LIBASS_VERSION >= 0x01400002
ass_track_set_feature(track, ASS_FEATURE_BIDI_BRACKETS, 1);
#endif
#if LIBASS_VERSION >= 0x01600000
ass_track_set_feature(track, ASS_FEATURE_WHOLE_TEXT_LAYOUT, 1);
#endif
#if LIBASS_VERSION >= 0x01600010
ass_track_set_feature(track, ASS_FEATURE_WRAP_UNICODE, 1);
#endif
Expand Down
11 changes: 10 additions & 1 deletion sub/sd_ass.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,17 @@ static void configure_ass(struct sd *sd, struct mp_osd_res *dim,
ass_set_font_scale(priv, set_font_scale);
ass_set_hinting(priv, set_hinting);
ass_set_line_spacing(priv, set_line_spacing);

#if LIBASS_VERSION >= 0x01400002
if (opts->ass_feature_bidi_brackets)
ass_track_set_feature(track, ASS_FEATURE_BIDI_BRACKETS, 1);
#endif
#if LIBASS_VERSION >= 0x01600000
if (opts->ass_feature_whole_text_layout)
ass_track_set_feature(track, ASS_FEATURE_WHOLE_TEXT_LAYOUT, 1);
#endif
#if LIBASS_VERSION >= 0x01600010
if (converted)
if (converted || opts->ass_feature_wrap_unicode)
ass_track_set_feature(track, ASS_FEATURE_WRAP_UNICODE, 1);
#endif
if (converted) {
Expand Down

0 comments on commit abf6961

Please sign in to comment.