From 5357d18fe6e8e849f3b947b710efa633a6ac3176 Mon Sep 17 00:00:00 2001 From: Oneric Date: Tue, 27 Aug 2024 23:15:52 +0200 Subject: [PATCH] sub: add ass-video-aspect-override option It is unclear whether there actually is any usecase for this option which isn't better served by sub-ass-use-video-data and/or LayoutRes overrides, but prior to the introduction of sub-ass-use-video-data it was possible to pass along storage resolution while faking an aspect ratio of 1:1. sub-ass-video-aspect-override=1 combined with sub-ass-use-video-data=all now makes this possible again. The uper limit of a 10:1 aspect matches the general video-aspect-override option. --- DOCS/interface-changes/sub-ass-use-video-data.txt | 1 + DOCS/man/options.rst | 6 ++++++ options/options.c | 2 ++ options/options.h | 1 + player/command.c | 1 + sub/sd_ass.c | 6 ++++-- 6 files changed, 15 insertions(+), 2 deletions(-) diff --git a/DOCS/interface-changes/sub-ass-use-video-data.txt b/DOCS/interface-changes/sub-ass-use-video-data.txt index 8779658b25..f446a70086 100644 --- a/DOCS/interface-changes/sub-ass-use-video-data.txt +++ b/DOCS/interface-changes/sub-ass-use-video-data.txt @@ -1,5 +1,6 @@ Remove sub-ass-vsfilter-aspect-compat. Remove sub-ass-vsfilter-blur-compat. Add sub-ass-use-video-data. +Add sub-ass-video-aspect-override. Change default V keybind to cycle sub-ass-use-video-data instead of toggling the now removed sub-ass-vsfilter-aspect-compat. diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index f0595fd894..3e0a8f4408 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -2585,6 +2585,12 @@ Subtitles Default: ``all`` +``--sub-ass-video-aspect-override=`` + Allows passing any arbitrary aspect ratio to libass instead of the video’s + actual aspect ratio. Zero or negative aspect ratios are identical to ``no``. + + This has no effect if ``sub-ass-use-video-data`` is set to none. + ``--sub-vsfilter-bidi-compat=`` Set implicit bidi detection to ``ltr`` instead of ``auto`` to match ASS' default. This also disables libass' incompatible extensions. This currently diff --git a/options/options.c b/options/options.c index c863ea0686..af99ba0be8 100644 --- a/options/options.c +++ b/options/options.c @@ -326,6 +326,7 @@ const struct m_sub_options mp_subtitle_sub_opts = { {"sub-ass-vsfilter-blur-compat", OPT_REMOVED("replaced by sub-ass-use-video-data=all")}, {"sub-ass-use-video-data", OPT_CHOICE(ass_use_video_data, {"none", 0}, {"aspect-ratio", 1}, {"all", 2})}, + {"sub-ass-video-aspect-override", OPT_ASPECT(ass_video_aspect), M_RANGE(0, 10)}, {"embeddedfonts", OPT_BOOL(use_embedded_fonts), .flags = UPDATE_SUB_HARD}, {"sub-ass-style-overrides", OPT_STRINGLIST(ass_style_override_list), .flags = UPDATE_SUB_HARD}, @@ -358,6 +359,7 @@ const struct m_sub_options mp_subtitle_sub_opts = { .sub_scale = 1, .ass_vsfilter_color_compat = 1, .ass_use_video_data = 2, + .ass_video_aspect = 0, .ass_shaper = 1, .use_embedded_fonts = true, }, diff --git a/options/options.h b/options/options.h index e2f7746055..9bed9ca291 100644 --- a/options/options.h +++ b/options/options.h @@ -112,6 +112,7 @@ struct mp_subtitle_opts { int ass_vsfilter_color_compat; bool sub_vsfilter_bidi_compat; int ass_use_video_data; + double ass_video_aspect; bool use_embedded_fonts; char **ass_style_override_list; char *ass_styles_file; diff --git a/player/command.c b/player/command.c index 50accfdc25..6891f4e70f 100644 --- a/player/command.c +++ b/player/command.c @@ -4465,6 +4465,7 @@ static const struct property_osd_display { {"sub-forced-events-only", "Forced sub only"}, {"sub-scale", "Sub Scale"}, {"sub-ass-use-video-data", "Subtitle using video properties"}, + {"sub-ass-video-aspect-override", "Subtitle aspect override"}, {"sub-ass-override", "ASS subtitle style override"}, {"secondary-sub-ass-override", "Secondary sub ASS subtitle style override"}, {"vf", "Video filters", .msg = "Video filters:\n${vf}"}, diff --git a/sub/sd_ass.c b/sub/sd_ass.c index d3b2e9272e..4f82bc470c 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -706,8 +706,10 @@ static struct sub_bitmaps *get_bitmaps(struct sd *sd, struct mp_osd_res dim, if (!converted && (!shared_opts->ass_style_override[sd->order] || opts->ass_use_video_data >= 1)) { - // Let's use the original video PAR for vsfilter compatibility: - double par = ctx->video_params.p_w / (double)ctx->video_params.p_h; + // Let's factor in video PAR for vsfilter compatibility: + double par = opts->ass_video_aspect > 0 ? + opts->ass_video_aspect : + ctx->video_params.p_w / (double)ctx->video_params.p_h; if (isnormal(par)) scale *= par; }