diff --git a/DOCS/interface-changes/sub-ass-override-default.txt b/DOCS/interface-changes/sub-ass-override-default.txt new file mode 100644 index 0000000000..9195601156 --- /dev/null +++ b/DOCS/interface-changes/sub-ass-override-default.txt @@ -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. diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 9a34a69c50..872958c07d 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -2501,7 +2501,7 @@ Subtitles Using this option may lead to incorrect subtitle rendering. -``--sub-ass-override=`` +``--sub-ass-override=`` 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 a subtitle is considered a "sign". @@ -2511,16 +2511,16 @@ Subtitles :yes: Apply all the ``--sub-ass-*`` style override options. Changing the default for any of these options can lead to incorrect subtitle rendering (default). + :scale: Like ``yes``, but also apply ``--sub-scale``. :force: Like ``yes``, but also force all ``--sub-*`` options. Can break rendering easily. - :scale: Like ``yes``, but also apply ``--sub-scale``. :strip: Radically strip all ASS tags and styles from the subtitle. This is equivalent to the old ``--no-ass`` / ``--no-sub-ass`` options. This also controls some bitmap subtitle overrides, as well as HTML tags in formats like SRT, despite the name of the option. -``--secondary-sub-ass-override=`` +``--secondary-sub-ass-override=`` Control whether user secondary substyle overrides should be applied. This works exactly like ``--sub-ass-override``. diff --git a/options/options.c b/options/options.c index 039f8fc481..f164c1c75f 100644 --- a/options/options.c +++ b/options/options.c @@ -46,6 +46,7 @@ #include "video/hwdec.h" #include "video/image_writer.h" #include "sub/osd.h" +#include "sub/sd.h" #include "player/core.h" #include "player/command.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])}, {"secondary-sub-visibility", OPT_BOOL(sub_visibility[1])}, {"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}, {"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}, {0} }, @@ -374,8 +383,8 @@ const struct m_sub_options mp_subtitle_shared_sub_opts = { .sub_visibility[0] = true, .sub_visibility[1] = true, .sub_pos[0] = 100, - .ass_style_override[0] = 1, - .ass_style_override[1] = 5, + .ass_style_override[0] = ASS_STYLE_OVERRIDE_YES, + .ass_style_override[1] = ASS_STYLE_OVERRIDE_STRIP, }, .change_flags = UPDATE_OSD, }; diff --git a/sub/sd.h b/sub/sd.h index 0f5b8c7c72..cb80c2eb22 100644 --- a/sub/sd.h +++ b/sub/sd.h @@ -13,6 +13,14 @@ #define SUB_SEEK_OFFSET 0.01 #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 mpv_global *global; struct mp_log *log; diff --git a/sub/sd_ass.c b/sub/sd_ass.c index 27d003e0ee..82e39b6f54 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -476,7 +476,7 @@ static void configure_ass(struct sd *sd, struct mp_osd_res *dim, bool set_scale_by_window = true; bool total_override = false; // 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_use_margins = opts->sub_use_margins; 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_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; } 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; if (total_override) 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; if (converted) 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); - 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; // 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 mp_subtitle_opts *opts = sd->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; ASS_Track *track = no_ass ? ctx->shadow_track : ctx->ass_track; ASS_Renderer *renderer = ctx->ass_renderer;