diff options
author | llyyr <llyyr.public@gmail.com> | 2023-12-16 01:32:45 +0530 |
---|---|---|
committer | Kacper Michajłow <kasper93@gmail.com> | 2024-04-18 00:14:44 +0200 |
commit | 805577c79274d1f3acda02904a13273d84770fa1 (patch) | |
tree | a3c4b3ed0060ad6f94a3efcdc2e5280c0a2b5752 | |
parent | f862d3b6cd66abee98f2af21c36255ef7361cb80 (diff) | |
download | mpv-805577c79274d1f3acda02904a13273d84770fa1.tar.bz2 mpv-805577c79274d1f3acda02904a13273d84770fa1.tar.xz |
sd_ass: add `sub-vsfilter-bidi-compat` to enable vsfilter bidi compat
Enable ASS_FEATURE_{WHOLE_TEXT_LAYOUT, BIDI_BRACKETS} and auto base
detection by default, and add an option to disable this if needed.
This is strictly an improvement for webvtt files as they always use
auto base detection. This _fixes_ right-to-left text rendering for
webvtt files which correctly mark rtl/ltr. Webvtt files obtained from
sources which sideload the RTL information through css also see an
improvement due to the auto detection.
Generally SRT files also want this, but some are also written to
workaround VSFilter quirks.
See also: https://github.com/mpv-player/mpv/pull/12985#issuecomment-1839565138
-rw-r--r-- | DOCS/man/options.rst | 9 | ||||
-rw-r--r-- | options/options.c | 1 | ||||
-rw-r--r-- | options/options.h | 1 | ||||
-rw-r--r-- | sub/sd_ass.c | 10 |
4 files changed, 20 insertions, 1 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index c7b6a8e7d3..1412726ef6 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -2560,6 +2560,15 @@ Subtitles offset scale factor, not what the video filter chain or the video output use. +``--sub-vsfilter-bidi-compat=<yes|no>`` + Set implicit bidi detection to ``ltr`` instead of ``auto`` to match ASS' + default. This also disables libass' incompatible extensions. This currently + includes bracket pair matching according to the revised Unicode + Bidirectional Algorithm introduced in Unicode 6.3, and also affects how BiDi + runs are split and processed, as well as soft linewrapping of unicode text. + + This affects plaintext (non-ASS) subtitles only. Default: no. + ``--sub-ass-vsfilter-color-compat=<basic|full|force-601|no>`` Mangle colors like (xy-)vsfilter do (default: basic). Historically, VSFilter was not color space aware. This was no problem as long as the color space diff --git a/options/options.c b/options/options.c index 59c7c4d236..c059f4157d 100644 --- a/options/options.c +++ b/options/options.c @@ -309,6 +309,7 @@ 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-vsfilter-bidi-compat", OPT_BOOL(sub_vsfilter_bidi_compat)}, {"embeddedfonts", OPT_BOOL(use_embedded_fonts), .flags = UPDATE_SUB_HARD}, {"sub-ass-style-overrides", OPT_STRINGLIST(ass_style_override_list), .flags = UPDATE_SUB_HARD}, diff --git a/options/options.h b/options/options.h index ae75ec9d11..6f7b011975 100644 --- a/options/options.h +++ b/options/options.h @@ -105,6 +105,7 @@ struct mp_subtitle_opts { bool ass_vsfilter_aspect_compat; int ass_vsfilter_color_compat; bool ass_vsfilter_blur_compat; + bool sub_vsfilter_bidi_compat; bool use_embedded_fonts; char **ass_style_override_list; char *ass_styles_file; diff --git a/sub/sd_ass.c b/sub/sd_ass.c index 9983f74682..8ff6443f5b 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -527,8 +527,16 @@ static void configure_ass(struct sd *sd, struct mp_osd_res *dim, ass_set_hinting(priv, set_hinting); ass_set_line_spacing(priv, set_line_spacing); #if LIBASS_VERSION >= 0x01600010 - if (converted) + if (converted) { ass_track_set_feature(track, ASS_FEATURE_WRAP_UNICODE, 1); + if (!opts->sub_vsfilter_bidi_compat) { + for (int n = 0; n < track->n_styles; n++) { + track->styles[n].Encoding = -1; + } + ass_track_set_feature(track, ASS_FEATURE_BIDI_BRACKETS, 1); + ass_track_set_feature(track, ASS_FEATURE_WHOLE_TEXT_LAYOUT, 1); + } + } #endif if (converted) { bool override_playres = true; |