mirror of
https://github.com/mpv-player/mpv
synced 2024-12-25 00:02:13 +00:00
video: add unscaled mode with --video-unscaled
This commit is contained in:
parent
f5144077ac
commit
4d62b90f88
@ -2498,6 +2498,18 @@
|
||||
|
||||
This option is disabled if the ``--no-keepaspect`` option is used.
|
||||
|
||||
``--video-unscaled=<value>``
|
||||
Disable scaling of the video. If the window is larger than the video,
|
||||
black bars are added. Otherwise, the video is cropped. The video still
|
||||
can be influenced by the other ``--video-...`` options. (If the
|
||||
``--video-zoom`` option is set to a value other than ``1``, scaling is
|
||||
enabled, but the video isn't automatically scaled to the window size.)
|
||||
|
||||
Note that the scaler algorithm may still be used, even if the video isn't
|
||||
scaled. For example, this can influence chroma conversion.
|
||||
|
||||
This option is disabled if the ``--no-keepaspect`` option is used.
|
||||
|
||||
``--video-zoom=<value>``
|
||||
Adjust the video display scale factor by the given value. The unit is in
|
||||
fractions of original video size.
|
||||
|
@ -1782,6 +1782,7 @@ static const m_option_t mp_properties[] = {
|
||||
M_OPTION_PROPERTY_CUSTOM("video-align-y", panscan_property_helper),
|
||||
M_OPTION_PROPERTY_CUSTOM("video-pan-x", panscan_property_helper),
|
||||
M_OPTION_PROPERTY_CUSTOM("video-pan-y", panscan_property_helper),
|
||||
M_OPTION_PROPERTY_CUSTOM("video-unscaled", panscan_property_helper),
|
||||
{ "video-format", mp_property_video_format, CONF_TYPE_STRING,
|
||||
0, 0, 0, NULL },
|
||||
{ "video-codec", mp_property_video_codec, CONF_TYPE_STRING,
|
||||
|
@ -587,6 +587,7 @@ const m_option_t mp_opts[] = {
|
||||
OPT_FLOATRANGE("video-pan-y", vo.pan_y, 0, -3.0, 3.0),
|
||||
OPT_FLOATRANGE("video-align-x", vo.align_x, 0, -1.0, 1.0),
|
||||
OPT_FLOATRANGE("video-align-y", vo.align_y, 0, -1.0, 1.0),
|
||||
OPT_FLAG("video-unscaled", vo.unscaled, 0),
|
||||
OPT_FLAG("force-rgba-osd-rendering", force_rgba_osd, 0),
|
||||
OPT_CHOICE("colormatrix", requested_colorspace, 0,
|
||||
({"auto", MP_CSP_AUTO},
|
||||
|
@ -22,6 +22,7 @@ typedef struct mp_vo_opts {
|
||||
float zoom;
|
||||
float pan_x, pan_y;
|
||||
float align_x, align_y;
|
||||
int unscaled;
|
||||
|
||||
struct m_geometry geometry;
|
||||
struct m_geometry autofit;
|
||||
|
@ -490,12 +490,15 @@ static void clamp_size(int size, int *start, int *end)
|
||||
#define VID_SRC_ROUND_UP(x) (((x) + 1) & ~1)
|
||||
|
||||
static void src_dst_split_scaling(int src_size, int dst_size,
|
||||
int scaled_src_size,
|
||||
int scaled_src_size, bool unscaled,
|
||||
float zoom, float align, float pan,
|
||||
int *src_start, int *src_end,
|
||||
int *dst_start, int *dst_end,
|
||||
int *osd_margin_a, int *osd_margin_b)
|
||||
{
|
||||
if (unscaled)
|
||||
scaled_src_size = src_size;
|
||||
|
||||
scaled_src_size += zoom * src_size;
|
||||
align = (align + 1) / 2;
|
||||
|
||||
@ -522,6 +525,17 @@ static void src_dst_split_scaling(int src_size, int dst_size,
|
||||
*dst_end = dst_size;
|
||||
}
|
||||
|
||||
if (unscaled && zoom == 1.0) {
|
||||
// Force unscaled by reducing the range for src or dst
|
||||
int src_s = *src_end - *src_start;
|
||||
int dst_s = *dst_end - *dst_start;
|
||||
if (src_s > dst_s) {
|
||||
*src_end = *src_start + dst_s;
|
||||
} else if (src_s < dst_s) {
|
||||
*dst_end = *dst_start + src_s;
|
||||
}
|
||||
}
|
||||
|
||||
// For sanity: avoid bothering VOs with corner cases
|
||||
clamp_size(src_size, src_start, src_end);
|
||||
clamp_size(dst_size, dst_start, dst_end);
|
||||
@ -549,11 +563,11 @@ void vo_get_src_dst_rects(struct vo *vo, struct mp_rect *out_src,
|
||||
if (opts->keepaspect) {
|
||||
int scaled_width, scaled_height;
|
||||
aspect_calc_panscan(vo, &scaled_width, &scaled_height);
|
||||
src_dst_split_scaling(src_w, vo->dwidth, scaled_width,
|
||||
src_dst_split_scaling(src_w, vo->dwidth, scaled_width, opts->unscaled,
|
||||
opts->zoom, opts->align_x, opts->pan_x,
|
||||
&src.x0, &src.x1, &dst.x0, &dst.x1,
|
||||
&osd.ml, &osd.mr);
|
||||
src_dst_split_scaling(src_h, vo->dheight, scaled_height,
|
||||
src_dst_split_scaling(src_h, vo->dheight, scaled_height, opts->unscaled,
|
||||
opts->zoom, opts->align_y, opts->pan_y,
|
||||
&src.y0, &src.y1, &dst.y0, &dst.y1,
|
||||
&osd.mt, &osd.mb);
|
||||
|
Loading…
Reference in New Issue
Block a user