From 9dc0857b3d989148fb9d871e6cd3f1bc3c9110db Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Mon, 9 Aug 2021 08:59:55 -0500 Subject: command: check for rotation in window-scale The vo currently handles rotations in 90 degree steps and some VOs set this via VO_CAP_ROTATE90. When the rotation exactly hits either 90 or 270 degrees, this causes the values of dwidth and dheight to perfectly swap like one would expect. However, the mp_image_params_get_dsize function call in both of the window scale functions do not take this special case into account. So the width/height values returned will be incorrectly flipped in the 90 and 270 degree cases if the vo driver does implement VO_CAP_ROTATE90 (like vo=gpu). Fortunately, the mp_image_params struct keeps track of the rotation for us. So all we need to do is check if the image is rotated at 90 or 270 degrees and check that the current vo driver supports VO_CAP_ROTATE90. If so, then swap vid_w and vid_h to their true, correct values. --- player/command.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/player/command.c b/player/command.c index d703c39afe..6e8679d1ad 100644 --- a/player/command.c +++ b/player/command.c @@ -2330,6 +2330,9 @@ static int mp_property_current_window_scale(void *ctx, struct m_property *prop, if (vid_w < 1 || vid_h < 1) return M_PROPERTY_UNAVAILABLE; + if (params.rotate % 180 == 90 && (vo->driver->caps & VO_CAP_ROTATE90)) + MPSWAP(int, vid_w, vid_h); + if (action == M_PROPERTY_SET) { // Also called by update_window_scale as a NULL property. double scale = *(double *)arg; -- cgit v1.2.3