player: make sub-pos a float value

mpv makes this option an integer, but the underlying ass API actually
accepts doubles. From some testing, there is no meaningful precision
difference between float or double (it seems to go in roughly 0.05
steps), so just make it a float. sd_lavc also can handle non-integer
values here. Closes #11583.
This commit is contained in:
Dudemanguy 2023-08-10 15:51:44 -05:00
parent 331832f55d
commit 6ea08be59a
6 changed files with 8 additions and 7 deletions

View File

@ -35,6 +35,7 @@ Interface changes
- include `--hdr-peak-percentile` in the `gpu-hq` profile
- change `--audiotrack-pcm-float` default from `no` to `yes`
- add video-params/aspect-name
- change type of `--sub-pos` to float
--- mpv 0.36.0 ---
- add `--target-contrast`
- Target luminance value is now also applied when ICC profile is used.

View File

@ -267,7 +267,7 @@ const struct m_sub_options mp_subtitle_sub_opts = {
{"stretch-image-subs-to-screen", OPT_BOOL(stretch_image_subs)},
{"image-subs-video-resolution", OPT_BOOL(image_subs_video_res)},
{"sub-fix-timing", OPT_BOOL(sub_fix_timing)},
{"sub-pos", OPT_INT(sub_pos), M_RANGE(0, 150)},
{"sub-pos", OPT_FLOAT(sub_pos), M_RANGE(0.0, 150.0)},
{"sub-gauss", OPT_FLOAT(sub_gauss), M_RANGE(0.0, 3.0)},
{"sub-gray", OPT_BOOL(sub_gray)},
{"sub-ass", OPT_BOOL(ass_enabled), .flags = UPDATE_SUB_HARD},

View File

@ -78,7 +78,7 @@ typedef struct mp_vo_opts {
struct mp_subtitle_opts {
bool sub_visibility;
bool sec_sub_visibility;
int sub_pos;
float sub_pos;
float sub_delay;
float sub_fps;
float sub_speed;

View File

@ -2909,7 +2909,7 @@ static int mp_property_sub_pos(void *ctx, struct m_property *prop,
MPContext *mpctx = ctx;
struct MPOpts *opts = mpctx->opts;
if (action == M_PROPERTY_PRINT) {
*(char **)arg = talloc_asprintf(NULL, "%d/100", opts->subs_rend->sub_pos);
*(char **)arg = talloc_asprintf(NULL, "%4.2f%%/100", opts->subs_rend->sub_pos);
return M_PROPERTY_OK;
}
return mp_property_generic_option(mpctx, prop, action, arg);

View File

@ -388,7 +388,7 @@ static void configure_ass(struct sd *sd, struct mp_osd_res *dim,
ass_set_margins(priv, dim->mt, dim->mb, dim->ml, dim->mr);
bool set_use_margins = false;
int set_sub_pos = 0;
float set_sub_pos = 0.0f;
float set_line_spacing = 0;
float set_font_scale = 1;
int set_hinting = 0;
@ -406,7 +406,7 @@ static void configure_ass(struct sd *sd, struct mp_osd_res *dim,
set_use_margins = opts->ass_use_margins;
}
if (converted || opts->ass_style_override) {
set_sub_pos = 100 - opts->sub_pos;
set_sub_pos = 100.0f - opts->sub_pos;
set_line_spacing = opts->ass_line_spacing;
set_hinting = opts->ass_hinting;
set_font_scale = opts->sub_scale;

View File

@ -462,8 +462,8 @@ static struct sub_bitmaps *get_bitmaps(struct sd *sd, struct mp_osd_res d,
h = MPMAX(priv->video_params.h, current->src_h);
}
if (opts->sub_pos != 100 && opts->ass_style_override) {
int offset = (100 - opts->sub_pos) / 100.0 * h;
if (opts->sub_pos != 100.0f && opts->ass_style_override) {
float offset = (100.0f - opts->sub_pos) / 100.0f * h;
for (int n = 0; n < res->num_parts; n++) {
struct sub_bitmap *sub = &res->parts[n];