summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Haas <git@nand.wakku.to>2016-04-10 17:26:32 +0200
committerwm4 <wm4@nowhere>2016-04-10 18:29:20 +0200
commitb968d779afb9114694976792e903b0591a71a816 (patch)
tree25f128c719d098d2fd2f0611e06c8182a1cce037
parentb18bfd0352cc1723ad9194a2cd31e263124e62b5 (diff)
downloadmpv-b968d779afb9114694976792e903b0591a71a816.tar.bz2
mpv-b968d779afb9114694976792e903b0591a71a816.tar.xz
aspect: rework --video-unscaled
In the past, --video-unscaled also disabled zooming and aspect ratio corrections. But this didn't make much sense in terms of being a useful option. The new behavior just sets the initial video size to be unscaled, but it's still affected by zoom commands and aspect ratio corrections. To get the old behavior back, --video-aspect=0 --video-zoom=0 need to be added as well (in the general case). Most of the time it should not make a difference though. Also, there seems to have been some additional dst_rect clamping code inside src_dst_split_scaling that didn't seem to either be necessary nor ever get triggered. (The code immediately above it already makes sure to crop the video if it's larger than the dst_rect) No idea why it was there, but I just removed it.
-rw-r--r--DOCS/interface-changes.rst2
-rw-r--r--DOCS/man/options.rst11
-rw-r--r--video/out/aspect.c34
3 files changed, 18 insertions, 29 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index f884296707..ee6e135808 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -28,6 +28,8 @@ Interface changes
- rename --input-unix-socket to --input-ipc-server, and make it work on
Windows too
- change the exact behavior of the "video-zoom" property
+ - --video-unscaled no longer disables --video-zoom and --video-aspect
+ To force the old behavior, set --video-zoom=0 and --video-aspect=0
--- mpv 0.16.0 ---
- change --audio-channels default to stereo (use --audio-channels=auto to
get the old default)
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 72a67c85b4..18ac7fd2f0 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -684,15 +684,12 @@ Video
``--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. (But not all; for
- example ``--video-zoom`` does nothing if this option is enabled.)
-
- The video and monitor aspects aspect will be ignored. Aspect correction
- would require scaling the video in the X or Y direction, but this option
- disables scaling, disabling all aspect correction.
+ can be influenced by the other ``--video-...`` options.
Note that the scaler algorithm may still be used, even if the video isn't
- scaled. For example, this can influence chroma conversion.
+ scaled. For example, this can influence chroma conversion. The video will
+ also still be scaled in one dimension if the source uses non-square pixels
+ (e.g. anamorphic widescreen DVDs).
This option is disabled if the ``--no-keepaspect`` option is used.
diff --git a/video/out/aspect.c b/video/out/aspect.c
index 178fd28724..205ee3b89f 100644
--- a/video/out/aspect.c
+++ b/video/out/aspect.c
@@ -27,7 +27,7 @@
#include "sub/osd.h"
static void aspect_calc_panscan(struct mp_vo_opts *opts,
- int w, int h, int d_w, int d_h,
+ int w, int h, int d_w, int d_h, bool unscaled,
int window_w, int window_h, double monitor_par,
int *out_w, int *out_h)
{
@@ -44,12 +44,18 @@ static void aspect_calc_panscan(struct mp_vo_opts *opts,
int vo_panscan_area = window_h - fheight;
double f_w = fwidth / (double)fheight;
double f_h = 1;
- if (!vo_panscan_area) {
+ if (vo_panscan_area == 0) {
vo_panscan_area = window_w - fwidth;
f_w = 1;
f_h = fheight / (double)fwidth;
}
+ if (unscaled) {
+ fwidth = w * monitor_par;
+ fheight = h;
+ vo_panscan_area = 0;
+ }
+
*out_w = fwidth + vo_panscan_area * opts->panscan * f_w;
*out_h = fheight + vo_panscan_area * opts->panscan * f_h;
}
@@ -66,17 +72,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, bool unscaled,
+ int scaled_src_size,
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;
- zoom = 0.0;
- }
-
scaled_src_size *= powf(2, zoom);
align = (align + 1) / 2;
@@ -103,17 +104,6 @@ static void src_dst_split_scaling(int src_size, int dst_size,
*dst_end = dst_size;
}
- if (unscaled) {
- // 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);
@@ -145,14 +135,14 @@ void mp_get_src_dst_rects(struct mp_log *log, struct mp_vo_opts *opts,
};
if (opts->keepaspect) {
int scaled_width, scaled_height;
- aspect_calc_panscan(opts, src_w, src_h, src_dw, src_dh,
+ aspect_calc_panscan(opts, src_w, src_h, src_dw, src_dh, opts->unscaled,
window_w, window_h, monitor_par,
&scaled_width, &scaled_height);
- src_dst_split_scaling(src_w, window_w, scaled_width, opts->unscaled,
+ src_dst_split_scaling(src_w, window_w, scaled_width,
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, window_h, scaled_height, opts->unscaled,
+ src_dst_split_scaling(src_h, window_h, scaled_height,
opts->zoom, opts->align_y, opts->pan_y,
&src.y0, &src.y1, &dst.y0, &dst.y1,
&osd.mt, &osd.mb);