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

options: move sub-ass-override 'scale' above 'force'

Also make it an enum for clarity

This is the right order in terms of both destructiveness and also the
total number of --sub-* options applied.
This commit is contained in:
llyyr 2024-05-26 12:05:40 +05:30 committed by Dudemanguy
parent af7ab6f603
commit f37691a156
5 changed files with 32 additions and 12 deletions

View File

@ -0,0 +1 @@
move 'scale' above 'force' for `sub-ass-override` in documentation as well as code. This more accurately reflects destructiveness of these options.

View File

@ -2501,7 +2501,7 @@ Subtitles
Using this option may lead to incorrect subtitle rendering. Using this option may lead to incorrect subtitle rendering.
``--sub-ass-override=<yes|no|force|scale|strip>`` ``--sub-ass-override=<no|yes|scale|force|strip>``
Control whether user style overrides should be applied. Note that all of Control whether user style overrides should be applied. Note that all of
these overrides try to be somewhat smart about figuring out whether or not these overrides try to be somewhat smart about figuring out whether or not
a subtitle is considered a "sign". a subtitle is considered a "sign".
@ -2511,16 +2511,16 @@ Subtitles
:yes: Apply all the ``--sub-ass-*`` style override options. Changing the :yes: Apply all the ``--sub-ass-*`` style override options. Changing the
default for any of these options can lead to incorrect subtitle default for any of these options can lead to incorrect subtitle
rendering (default). rendering (default).
:scale: Like ``yes``, but also apply ``--sub-scale``.
:force: Like ``yes``, but also force all ``--sub-*`` options. Can break :force: Like ``yes``, but also force all ``--sub-*`` options. Can break
rendering easily. rendering easily.
:scale: Like ``yes``, but also apply ``--sub-scale``.
:strip: Radically strip all ASS tags and styles from the subtitle. This :strip: Radically strip all ASS tags and styles from the subtitle. This
is equivalent to the old ``--no-ass`` / ``--no-sub-ass`` options. is equivalent to the old ``--no-ass`` / ``--no-sub-ass`` options.
This also controls some bitmap subtitle overrides, as well as HTML tags in This also controls some bitmap subtitle overrides, as well as HTML tags in
formats like SRT, despite the name of the option. formats like SRT, despite the name of the option.
``--secondary-sub-ass-override=<yes|no|force|scale|strip>`` ``--secondary-sub-ass-override=<no|yes|scale|force|strip>``
Control whether user secondary substyle overrides should be applied. This Control whether user secondary substyle overrides should be applied. This
works exactly like ``--sub-ass-override``. works exactly like ``--sub-ass-override``.

View File

@ -46,6 +46,7 @@
#include "video/hwdec.h" #include "video/hwdec.h"
#include "video/image_writer.h" #include "video/image_writer.h"
#include "sub/osd.h" #include "sub/osd.h"
#include "sub/sd.h"
#include "player/core.h" #include "player/core.h"
#include "player/command.h" #include "player/command.h"
#include "stream/stream.h" #include "stream/stream.h"
@ -362,10 +363,18 @@ const struct m_sub_options mp_subtitle_shared_sub_opts = {
{"sub-visibility", OPT_BOOL(sub_visibility[0])}, {"sub-visibility", OPT_BOOL(sub_visibility[0])},
{"secondary-sub-visibility", OPT_BOOL(sub_visibility[1])}, {"secondary-sub-visibility", OPT_BOOL(sub_visibility[1])},
{"sub-ass-override", OPT_CHOICE(ass_style_override[0], {"sub-ass-override", OPT_CHOICE(ass_style_override[0],
{"no", 0}, {"yes", 1}, {"force", 3}, {"scale", 4}, {"strip", 5}), {"no", ASS_STYLE_OVERRIDE_NONE},
{"yes", ASS_STYLE_OVERRIDE_YES},
{"scale", ASS_STYLE_OVERRIDE_SCALE},
{"force", ASS_STYLE_OVERRIDE_FORCE},
{"strip", ASS_STYLE_OVERRIDE_STRIP}),
.flags = UPDATE_SUB_HARD}, .flags = UPDATE_SUB_HARD},
{"secondary-sub-ass-override", OPT_CHOICE(ass_style_override[1], {"secondary-sub-ass-override", OPT_CHOICE(ass_style_override[1],
{"no", 0}, {"yes", 1}, {"force", 3}, {"scale", 4}, {"strip", 5}), {"no", ASS_STYLE_OVERRIDE_NONE},
{"yes", ASS_STYLE_OVERRIDE_YES},
{"scale", ASS_STYLE_OVERRIDE_SCALE},
{"force", ASS_STYLE_OVERRIDE_FORCE},
{"strip", ASS_STYLE_OVERRIDE_STRIP}),
.flags = UPDATE_SUB_HARD}, .flags = UPDATE_SUB_HARD},
{0} {0}
}, },
@ -374,8 +383,8 @@ const struct m_sub_options mp_subtitle_shared_sub_opts = {
.sub_visibility[0] = true, .sub_visibility[0] = true,
.sub_visibility[1] = true, .sub_visibility[1] = true,
.sub_pos[0] = 100, .sub_pos[0] = 100,
.ass_style_override[0] = 1, .ass_style_override[0] = ASS_STYLE_OVERRIDE_YES,
.ass_style_override[1] = 5, .ass_style_override[1] = ASS_STYLE_OVERRIDE_STRIP,
}, },
.change_flags = UPDATE_OSD, .change_flags = UPDATE_OSD,
}; };

View File

@ -13,6 +13,14 @@
#define SUB_SEEK_OFFSET 0.01 #define SUB_SEEK_OFFSET 0.01
#define SUB_SEEK_WITHOUT_VIDEO_OFFSET 0.1 #define SUB_SEEK_WITHOUT_VIDEO_OFFSET 0.1
enum ass_style_override {
ASS_STYLE_OVERRIDE_NONE,
ASS_STYLE_OVERRIDE_YES,
ASS_STYLE_OVERRIDE_SCALE,
ASS_STYLE_OVERRIDE_FORCE,
ASS_STYLE_OVERRIDE_STRIP,
};
struct sd { struct sd {
struct mpv_global *global; struct mpv_global *global;
struct mp_log *log; struct mp_log *log;

View File

@ -476,7 +476,7 @@ static void configure_ass(struct sd *sd, struct mp_osd_res *dim,
bool set_scale_by_window = true; bool set_scale_by_window = true;
bool total_override = false; bool total_override = false;
// With forced overrides, apply the --sub-* specific options // With forced overrides, apply the --sub-* specific options
if (converted || shared_opts->ass_style_override[sd->order] == 3) { // 'force' if (converted || shared_opts->ass_style_override[sd->order] == ASS_STYLE_OVERRIDE_FORCE) {
set_scale_with_window = opts->sub_scale_with_window; set_scale_with_window = opts->sub_scale_with_window;
set_use_margins = opts->sub_use_margins; set_use_margins = opts->sub_use_margins;
set_scale_by_window = opts->sub_scale_by_window; set_scale_by_window = opts->sub_scale_by_window;
@ -490,7 +490,7 @@ static void configure_ass(struct sd *sd, struct mp_osd_res *dim,
set_line_spacing = opts->ass_line_spacing; set_line_spacing = opts->ass_line_spacing;
set_hinting = opts->ass_hinting; set_hinting = opts->ass_hinting;
} }
if (total_override || shared_opts->ass_style_override[sd->order] == 4) { if (total_override || shared_opts->ass_style_override[sd->order] == ASS_STYLE_OVERRIDE_SCALE) {
set_font_scale = opts->sub_scale; set_font_scale = opts->sub_scale;
} }
if (set_scale_with_window) { if (set_scale_with_window) {
@ -508,7 +508,7 @@ static void configure_ass(struct sd *sd, struct mp_osd_res *dim,
int set_force_flags = 0; int set_force_flags = 0;
if (total_override) if (total_override)
set_force_flags |= ASS_OVERRIDE_BIT_STYLE | ASS_OVERRIDE_BIT_SELECTIVE_FONT_SCALE; set_force_flags |= ASS_OVERRIDE_BIT_STYLE | ASS_OVERRIDE_BIT_SELECTIVE_FONT_SCALE;
if (shared_opts->ass_style_override[sd->order] == 4) // 'scale' if (shared_opts->ass_style_override[sd->order] == ASS_STYLE_OVERRIDE_SCALE)
set_force_flags |= ASS_OVERRIDE_BIT_SELECTIVE_FONT_SCALE; set_force_flags |= ASS_OVERRIDE_BIT_SELECTIVE_FONT_SCALE;
if (converted) if (converted)
set_force_flags |= ASS_OVERRIDE_BIT_ALIGNMENT; set_force_flags |= ASS_OVERRIDE_BIT_ALIGNMENT;
@ -589,7 +589,8 @@ static long long find_timestamp(struct sd *sd, double pts)
long long ts = llrint(pts * 1000); long long ts = llrint(pts * 1000);
if (!sd->opts->sub_fix_timing || sd->shared_opts->ass_style_override[sd->order] == 0) if (!sd->opts->sub_fix_timing ||
sd->shared_opts->ass_style_override[sd->order] == ASS_STYLE_OVERRIDE_NONE)
return ts; return ts;
// Try to fix small gaps and overlaps. // Try to fix small gaps and overlaps.
@ -652,7 +653,8 @@ static struct sub_bitmaps *get_bitmaps(struct sd *sd, struct mp_osd_res dim,
struct sd_ass_priv *ctx = sd->priv; struct sd_ass_priv *ctx = sd->priv;
struct mp_subtitle_opts *opts = sd->opts; struct mp_subtitle_opts *opts = sd->opts;
struct mp_subtitle_shared_opts *shared_opts = sd->shared_opts; struct mp_subtitle_shared_opts *shared_opts = sd->shared_opts;
bool no_ass = !opts->ass_enabled || shared_opts->ass_style_override[sd->order] == 5; bool no_ass = !opts->ass_enabled ||
shared_opts->ass_style_override[sd->order] == ASS_STYLE_OVERRIDE_STRIP;
bool converted = (ctx->is_converted && !lavc_conv_is_styled(ctx->converter)) || no_ass; bool converted = (ctx->is_converted && !lavc_conv_is_styled(ctx->converter)) || no_ass;
ASS_Track *track = no_ass ? ctx->shadow_track : ctx->ass_track; ASS_Track *track = no_ass ? ctx->shadow_track : ctx->ass_track;
ASS_Renderer *renderer = ctx->ass_renderer; ASS_Renderer *renderer = ctx->ass_renderer;