0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-19 19:42:24 +02:00

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.
This commit is contained in:
Oneric 2024-08-27 23:15:52 +02:00 committed by sfan5
parent 207b1a2c91
commit 5357d18fe6
6 changed files with 15 additions and 2 deletions

View File

@ -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.

View File

@ -2585,6 +2585,12 @@ Subtitles
Default: ``all``
``--sub-ass-video-aspect-override=<no|ratio>``
Allows passing any arbitrary aspect ratio to libass instead of the videos
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=<yes|no>``
Set implicit bidi detection to ``ltr`` instead of ``auto`` to match ASS'
default. This also disables libass' incompatible extensions. This currently

View File

@ -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,
},

View File

@ -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;

View File

@ -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}"},

View File

@ -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;
}