From 4d62b90f88aaed64775fdf6f0866e5ee5b3f9328 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 1 Sep 2013 03:27:03 +0200 Subject: video: add unscaled mode with --video-unscaled --- DOCS/man/en/options.rst | 12 ++++++++++++ mpvcore/command.c | 1 + mpvcore/options.c | 1 + mpvcore/options.h | 1 + video/out/vo.c | 20 +++++++++++++++++--- 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst index 61fa750b76..5c33e325f1 100644 --- a/DOCS/man/en/options.rst +++ b/DOCS/man/en/options.rst @@ -2498,6 +2498,18 @@ This option is disabled if the ``--no-keepaspect`` option is used. +``--video-unscaled=`` + 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=`` Adjust the video display scale factor by the given value. The unit is in fractions of original video size. diff --git a/mpvcore/command.c b/mpvcore/command.c index db4b2a7a9c..cfb3c3c60a 100644 --- a/mpvcore/command.c +++ b/mpvcore/command.c @@ -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, diff --git a/mpvcore/options.c b/mpvcore/options.c index e508262378..62bbfc0101 100644 --- a/mpvcore/options.c +++ b/mpvcore/options.c @@ -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}, diff --git a/mpvcore/options.h b/mpvcore/options.h index 033d3c89c6..cac2630040 100644 --- a/mpvcore/options.h +++ b/mpvcore/options.h @@ -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; diff --git a/video/out/vo.c b/video/out/vo.c index d134163141..aa027fc349 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -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); -- cgit v1.2.3