options: add --video-scale-x/y

Requested.

Fixes: #6303
This commit is contained in:
wm4 2020-06-03 17:26:08 +02:00
parent baa7b5c8dd
commit 5f49009849
4 changed files with 18 additions and 4 deletions

View File

@ -1467,6 +1467,15 @@ Video
This option is disabled if the ``--no-keepaspect`` option is used.
``--video-scale-x=<value>``, ``--video-scale-y=<value>``
Multiply the video display size with the given value (default: 1.0). If a
non-default value is used, this will be different from the window size, so
video will be either cut off, or black bars are added.
This value is multiplied with the value derived from ``--video-zoom`` and
the normal video aspect aspect ratio. This option is disabled if the
``--no-keepaspect`` option is used.
``--video-align-x=<-1-1>``, ``--video-align-y=<-1-1>``
Moves the video rectangle within the black borders, which are usually added
to pad the video to screen if video and screen aspect ratios are different.

View File

@ -136,6 +136,8 @@ static const m_option_t mp_vo_opt_list[] = {
{"video-pan-y", OPT_FLOAT(pan_y), M_RANGE(-3.0, 3.0)},
{"video-align-x", OPT_FLOAT(align_x), M_RANGE(-1.0, 1.0)},
{"video-align-y", OPT_FLOAT(align_y), M_RANGE(-1.0, 1.0)},
{"video-scale-x", OPT_FLOAT(scale_x), M_RANGE(0, 10000.0)},
{"video-scale-y", OPT_FLOAT(scale_y), M_RANGE(0, 10000.0)},
{"video-margin-ratio-left", OPT_FLOAT(margin_x[0]), M_RANGE(0.0, 1.0)},
{"video-margin-ratio-right", OPT_FLOAT(margin_x[1]), M_RANGE(0.0, 1.0)},
{"video-margin-ratio-top", OPT_FLOAT(margin_y[0]), M_RANGE(0.0, 1.0)},
@ -177,6 +179,8 @@ const struct m_sub_options vo_sub_opts = {
.screen_id = -1,
.fsscreen_id = -1,
.panscan = 0.0f,
.scale_x = 1.0f,
.scale_y = 1.0f,
.keepaspect = 1,
.keepaspect_window = 1,
.hidpi_window_scale = 1,

View File

@ -31,6 +31,7 @@ typedef struct mp_vo_opts {
float zoom;
float pan_x, pan_y;
float align_x, align_y;
float scale_x, scale_y;
float margin_x[2];
float margin_y[2];
int unscaled;

View File

@ -77,12 +77,12 @@ static void clamp_size(int size, int *start, int *end)
static void src_dst_split_scaling(int src_size, int dst_size,
int scaled_src_size,
float zoom, float align, float pan,
float zoom, float align, float pan, float scale,
int *src_start, int *src_end,
int *dst_start, int *dst_end,
int *osd_margin_a, int *osd_margin_b)
{
scaled_src_size *= powf(2, zoom);
scaled_src_size *= powf(2, zoom) * scale;
align = (align + 1) / 2;
*src_start = 0;
@ -168,11 +168,11 @@ void mp_get_src_dst_rects(struct mp_log *log, struct mp_vo_opts *opts,
vid_window_w, vid_window_h, monitor_par,
&scaled_width, &scaled_height);
src_dst_split_scaling(src_w, vid_window_w, scaled_width,
opts->zoom, opts->align_x, opts->pan_x,
opts->zoom, opts->align_x, opts->pan_x, opts->scale_x,
&src.x0, &src.x1, &dst.x0, &dst.x1,
&osd.ml, &osd.mr);
src_dst_split_scaling(src_h, vid_window_h, scaled_height,
opts->zoom, opts->align_y, opts->pan_y,
opts->zoom, opts->align_y, opts->pan_y, opts->scale_y,
&src.y0, &src.y1, &dst.y0, &dst.y1,
&osd.mt, &osd.mb);
}