diff options
author | wm4 <wm4@nowhere> | 2014-04-20 21:36:56 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-04-21 02:57:16 +0200 |
commit | ef2885e771d184ff39c688836a8f06595a6cdf86 (patch) | |
tree | 10d7beb187a504e75d46404493fb44750210620e /video/out/aspect.c | |
parent | cc00b3ff36692d42184d2b88cfabbef3151793d8 (diff) | |
download | mpv-ef2885e771d184ff39c688836a8f06595a6cdf86.tar.bz2 mpv-ef2885e771d184ff39c688836a8f06595a6cdf86.tar.xz |
vo: add some general support code for VOs that allow rotation
For rotation, we assume that the source image will be rotated within the
VO, so the aspect/panscan code needs to calculate its param using
rotated coordinates. VOs which support rotation natively can use this.
Diffstat (limited to 'video/out/aspect.c')
-rw-r--r-- | video/out/aspect.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/video/out/aspect.c b/video/out/aspect.c index 1439f5a5db..e92c5e1b5d 100644 --- a/video/out/aspect.c +++ b/video/out/aspect.c @@ -27,18 +27,18 @@ #include "sub/osd.h" static void aspect_calc_panscan(struct mp_log *log, struct mp_vo_opts *opts, - struct mp_image_params *video, + int w, int h, int d_w, int d_h, int window_w, int window_h, double monitor_par, int *out_w, int *out_h) { mp_dbg(log, "aspect(0) fitin: %dx%d monitor_par: %.2f\n", window_w, window_h, monitor_par); int fwidth = window_w; - int fheight = (float)window_w / video->d_w * video->d_h / monitor_par; + int fheight = (float)window_w / d_w * d_h / monitor_par; mp_dbg(log, "aspect(1) wh: %dx%d (org: %dx%d)\n", - fwidth, fheight, video->d_w, video->d_h); - if (fheight > window_h || fheight < video->h) { - int tmpw = (float)window_h / video->d_h * video->d_w * monitor_par; + fwidth, fheight, d_w, d_h); + if (fheight > window_h || fheight < h) { + int tmpw = (float)window_h / d_h * d_w * monitor_par; if (tmpw <= window_w) { fheight = window_h; fwidth = tmpw; @@ -47,7 +47,7 @@ static void aspect_calc_panscan(struct mp_log *log, struct mp_vo_opts *opts, } } mp_dbg(log, "aspect(2) wh: %dx%d (org: %dx%d)\n", - fwidth, fheight, video->d_w, video->d_h); + fwidth, fheight, d_w, d_h); int vo_panscan_area = window_h - fheight; if (!vo_panscan_area) @@ -127,7 +127,7 @@ static void src_dst_split_scaling(int src_size, int dst_size, } void mp_get_src_dst_rects(struct mp_log *log, struct mp_vo_opts *opts, - struct mp_image_params *video, + int vo_caps, struct mp_image_params *video, int window_w, int window_h, double monitor_par, struct mp_rect *out_src, struct mp_rect *out_dst, @@ -135,6 +135,12 @@ void mp_get_src_dst_rects(struct mp_log *log, struct mp_vo_opts *opts, { int src_w = video->w; int src_h = video->h; + int src_dw = video->d_w; + int src_dh = video->d_h; + if (video->rotate % 180 == 90 && (vo_caps & VO_CAP_ROTATE90)) { + MPSWAP(int, src_w, src_h); + MPSWAP(int, src_dw, src_dh); + } window_w = MPMAX(1, window_w); window_h = MPMAX(1, window_h); struct mp_rect dst = {0, 0, window_w, window_h}; @@ -146,7 +152,8 @@ 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(log, opts, video, window_w, window_h, monitor_par, + aspect_calc_panscan(log, opts, src_w, src_h, src_dw, src_dh, + window_w, window_h, monitor_par, &scaled_width, &scaled_height); src_dst_split_scaling(src_w, window_w, scaled_width, opts->unscaled, opts->zoom, opts->align_x, opts->pan_x, |