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.
This commit is contained in:
Dudemanguy 2021-08-09 08:59:55 -05:00
parent 77f2fd97f8
commit 9dc0857b3d
1 changed files with 3 additions and 0 deletions

View File

@ -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;