From f3f1a79fe3ad9bdae344559ec5802c184af41112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Fri, 25 Aug 2023 19:21:21 +0200 Subject: vo: add --video-crop Just cropping by VO that works with hwdec. Fixes: #12222 --- common/common.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'common/common.c') diff --git a/common/common.c b/common/common.c index 79f135a516..e59db7e906 100644 --- a/common/common.c +++ b/common/common.c @@ -126,6 +126,37 @@ bool mp_rect_equals(const struct mp_rect *rc1, const struct mp_rect *rc2) rc1->x1 == rc2->x1 && rc1->y1 == rc2->y1; } +// Rotate mp_rect by 90 degrees increments +void mp_rect_rotate(struct mp_rect *rc, int w, int h, int rotation) +{ + rotation %= 360; + + if (rotation >= 180) { + rotation -= 180; + MPSWAP(int, rc->x0, rc->x1); + MPSWAP(int, rc->y0, rc->y1); + } + + if (rotation == 90) { + *rc = (struct mp_rect) { + .x0 = rc->y1, + .y0 = rc->x0, + .x1 = rc->y0, + .y1 = rc->x1, + }; + } + + if (rc->x1 < rc->x0) { + rc->x0 = w - rc->x0; + rc->x1 = w - rc->x1; + } + + if (rc->y1 < rc->y0) { + rc->y0 = h - rc->y0; + rc->y1 = h - rc->y1; + } +} + // Compute rc1-rc2, put result in res_array, return number of rectangles in // res_array. In the worst case, there are 4 rectangles, so res_array must // provide that much storage space. -- cgit v1.2.3