Skip to content

Commit 8ab3f8b

Browse files
idontwannagooDudemanguy
authored andcommitted
options: add secondary-sub-scale
This allows scaling secondary subtitles independently from primary subtitles. The option defaults to 1 like --sub-scale and follows the other secondary-sub-* options by not inheriting from the primary subtitle setting. Fixes #14989.
1 parent 25451bc commit 8ab3f8b

7 files changed

Lines changed: 17 additions & 6 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
add `--secondary-sub-scale` option
2+
`--sub-scale` now only affects primary subtitles

DOCS/man/options.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2518,6 +2518,10 @@ Subtitles
25182518
This affects ASS subtitles as well, and may lead to incorrect subtitle
25192519
rendering. Use with care, or use ``--sub-font-size`` instead.
25202520

2521+
``--secondary-sub-scale=<0-100>``
2522+
Factor for the secondary subtitle font size. This is similar to
2523+
``--sub-scale`` but for secondary subtitles (default: 1).
2524+
25212525
``--sub-scale-signs=<yes|no>``
25222526
When set to yes, also apply ``--sub-scale`` to typesetting (or "signs").
25232527
When this is set to no, ``--sub-scale`` is only applied to dialogue. The

options/options.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ const struct m_sub_options mp_subtitle_sub_opts = {
316316
{"sub-gauss", OPT_FLOAT(sub_gauss), M_RANGE(0.0, 3.0)},
317317
{"sub-gray", OPT_BOOL(sub_gray)},
318318
{"sub-ass", OPT_BOOL(ass_enabled), .flags = UPDATE_SUB_HARD},
319-
{"sub-scale", OPT_FLOAT(sub_scale), M_RANGE(0, 100)},
320319
{"sub-scale-signs", OPT_BOOL(sub_scale_signs)},
321320
{"sub-line-spacing", OPT_FLOAT(sub_line_spacing), M_RANGE(-1000, 1000)},
322321
{"sub-ass-line-spacing", OPT_REPLACED("sub-line-spacing")},
@@ -366,7 +365,6 @@ const struct m_sub_options mp_subtitle_sub_opts = {
366365
.sub_scale_with_window = true,
367366
.ass_prune_delay = -1.0,
368367
.teletext_page = 0,
369-
.sub_scale = 1,
370368
.ass_vsfilter_color_compat = 1,
371369
.ass_use_video_data = 2,
372370
.ass_video_aspect = 0,
@@ -385,6 +383,8 @@ const struct m_sub_options mp_subtitle_shared_sub_opts = {
385383
{"secondary-sub-delay", OPT_DOUBLE(sub_delay[1])},
386384
{"sub-pos", OPT_FLOAT(sub_pos[0]), M_RANGE(0.0, 150.0)},
387385
{"secondary-sub-pos", OPT_FLOAT(sub_pos[1]), M_RANGE(0.0, 150.0)},
386+
{"sub-scale", OPT_FLOAT(sub_scale[0]), M_RANGE(0, 100)},
387+
{"secondary-sub-scale", OPT_FLOAT(sub_scale[1]), M_RANGE(0, 100)},
388388
{"sub-visibility", OPT_BOOL(sub_visibility[0])},
389389
{"secondary-sub-visibility", OPT_BOOL(sub_visibility[1])},
390390
{"sub-ass-override", OPT_CHOICE(ass_style_override[0],
@@ -408,6 +408,8 @@ const struct m_sub_options mp_subtitle_shared_sub_opts = {
408408
.sub_visibility[0] = true,
409409
.sub_visibility[1] = true,
410410
.sub_pos[0] = 100,
411+
.sub_scale[0] = 1,
412+
.sub_scale[1] = 1,
411413
.ass_style_override[0] = ASS_STYLE_OVERRIDE_SCALE,
412414
.ass_style_override[1] = ASS_STYLE_OVERRIDE_STRIP,
413415
},
@@ -1190,6 +1192,7 @@ static const struct MPOpts mp_default_opts = {
11901192
"secondary-sid",
11911193
"secondary-sub-delay",
11921194
"secondary-sub-pos",
1195+
"secondary-sub-scale",
11931196
"secondary-sub-ass-override",
11941197
"secondary-sub-visibility",
11951198
"ab-loop-a",

options/options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ struct mp_subtitle_opts {
110110
bool sub_scale_with_window;
111111
bool ass_scale_with_window;
112112
struct osd_style_opts *sub_style;
113-
float sub_scale;
114113
bool sub_scale_signs;
115114
float sub_gauss;
116115
bool sub_gray;
@@ -141,6 +140,7 @@ struct mp_subtitle_opts {
141140
struct mp_subtitle_shared_opts {
142141
double sub_delay[2];
143142
float sub_pos[2];
143+
float sub_scale[2];
144144
bool sub_visibility[2];
145145
int ass_style_override[2];
146146
};

player/command.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5098,6 +5098,7 @@ static const struct property_osd_display {
50985098
"${?secondary-sub-visibility==yes:visible${?secondary-sid==no: (but no secondary subtitles selected)}}"},
50995099
{"sub-forced-events-only", "Forced sub only"},
51005100
{"sub-scale", "Sub Scale"},
5101+
{"secondary-sub-scale", "Secondary sub scale"},
51015102
{"sub-ass-use-video-data", "Subtitle using video properties"},
51025103
{"sub-ass-video-aspect-override", "Subtitle aspect override"},
51035104
{"sub-ass-override", "ASS subtitle style override"},

sub/sd_ass.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ static void configure_ass(struct sd *sd, struct mp_osd_res *dim,
539539
bool set_scale_with_window = false;
540540
bool set_scale_by_window = true;
541541
bool total_override = false;
542+
542543
// With forced overrides, apply the --sub-* specific options
543544
if (converted || shared_opts->ass_style_override[sd->order] == ASS_STYLE_OVERRIDE_FORCE) {
544545
set_scale_with_window = opts->sub_scale_with_window;
@@ -555,7 +556,7 @@ static void configure_ass(struct sd *sd, struct mp_osd_res *dim,
555556
set_hinting = opts->sub_hinting;
556557
}
557558
if (total_override || shared_opts->ass_style_override[sd->order] == ASS_STYLE_OVERRIDE_SCALE) {
558-
set_font_scale = opts->sub_scale;
559+
set_font_scale = shared_opts->sub_scale[sd->order];
559560
}
560561
if (set_scale_with_window) {
561562
set_font_scale *= dim->h / MPMAX(get_libass_scale_height(dim, set_use_margins), 1);

sub/sd_lavc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,11 +526,11 @@ static struct sub_bitmaps *get_bitmaps(struct sd *sd, struct mp_osd_res d,
526526

527527
osd_rescale_bitmaps(res, w, h, d, video_par);
528528

529-
if (opts->sub_scale != 1.0 && shared_opts->ass_style_override[sd->order]) {
529+
if (shared_opts->sub_scale[sd->order] != 1.0 && shared_opts->ass_style_override[sd->order]) {
530530
for (int n = 0; n < res->num_parts; n++) {
531531
struct sub_bitmap *sub = &res->parts[n];
532532

533-
float shit = (opts->sub_scale - 1.0f) / 2;
533+
float shit = (shared_opts->sub_scale[sd->order] - 1.0f) / 2;
534534

535535
// Fortunately VO isn't supposed to give a FUCKING FUCK about
536536
// whether the sub might e.g. go outside of the screen.

0 commit comments

Comments
 (0)