diff options
-rw-r--r-- | video/out/aspect.c | 23 | ||||
-rw-r--r-- | video/out/aspect.h | 2 | ||||
-rw-r--r-- | video/out/vo.c | 11 | ||||
-rw-r--r-- | video/out/vo.h | 6 |
4 files changed, 30 insertions, 12 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, diff --git a/video/out/aspect.h b/video/out/aspect.h index db8aa37040..04d314971e 100644 --- a/video/out/aspect.h +++ b/video/out/aspect.h @@ -25,7 +25,7 @@ struct mp_image_params; struct mp_rect; struct mp_osd_res; 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, diff --git a/video/out/vo.c b/video/out/vo.c index 340817633d..9af1d59c6d 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -424,7 +424,11 @@ int vo_reconfig(struct vo *vo, struct mp_image_params *params, int flags) int d_height = params->d_h; if (vo_control(vo, VOCTRL_UPDATE_SCREENINFO, NULL) == VO_TRUE) { - determine_window_geometry(vo, params->d_w, params->d_h); + int w = params->d_w, h = params->d_h; + if ((vo->driver->caps & VO_CAP_ROTATE90) && + params->rotate % 180 == 90) + MPSWAP(int, w, h); + determine_window_geometry(vo, w, h); d_width = vo->dwidth; d_height = vo->dheight; } @@ -472,8 +476,9 @@ int lookup_keymap_table(const struct mp_keymap *map, int key) { void vo_get_src_dst_rects(struct vo *vo, struct mp_rect *out_src, struct mp_rect *out_dst, struct mp_osd_res *out_osd) { - mp_get_src_dst_rects(vo->log, vo->opts, vo->params, vo->dwidth, vo->dheight, - vo->monitor_par, out_src, out_dst, out_osd); + mp_get_src_dst_rects(vo->log, vo->opts, vo->driver->caps, vo->params, + vo->dwidth, vo->dheight, vo->monitor_par, + out_src, out_dst, out_osd); } // Return the window title the VO should set. Always returns a null terminated diff --git a/video/out/vo.h b/video/out/vo.h index 28cb3a00ed..b9887d2119 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -130,6 +130,9 @@ struct voctrl_screenshot_args { #define VOFLAG_GL_DEBUG 0x40 // Hint to request debug OpenGL context #define VOFLAG_ALPHA 0x80 // Hint to request alpha framebuffer +// VO does handle mp_image_params.rotate in 90 degree steps +#define VO_CAP_ROTATE90 1 + struct vo; struct osd_state; struct mp_image; @@ -143,6 +146,9 @@ struct vo_driver { // Encoding functionality, which can be invoked via --o only. bool encode; + // VO_CAP_* bits + int caps; + const char *name; const char *description; |