summaryrefslogtreecommitdiffstats
path: root/player/video.c
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2023-08-25 19:21:21 +0200
committerDudemanguy <random342@airmail.cc>2023-08-31 17:37:42 +0000
commitf3f1a79fe3ad9bdae344559ec5802c184af41112 (patch)
tree8ad67cec885e18f6d0618dc9b220288574e1e98f /player/video.c
parentf3211db7911c89883dc392ddeef8ffe53aeb49b0 (diff)
downloadmpv-f3f1a79fe3ad9bdae344559ec5802c184af41112.tar.bz2
mpv-f3f1a79fe3ad9bdae344559ec5802c184af41112.tar.xz
vo: add --video-crop
Just cropping by VO that works with hwdec. Fixes: #12222
Diffstat (limited to 'player/video.c')
-rw-r--r--player/video.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/player/video.c b/player/video.c
index a8556ba700..d9e371d9fd 100644
--- a/player/video.c
+++ b/player/video.c
@@ -1129,6 +1129,34 @@ void write_video(struct MPContext *mpctx)
// Filter output is different from VO input?
struct mp_image_params *p = &mpctx->next_frames[0]->params;
+ // Inject vo crop to notify and reconfig if needed
+ struct mp_rect rc;
+ m_rect_apply(&rc, p->w, p->h, &vo->opts->video_crop);
+ if (rc.x1 > 0 && rc.y1 > 0)
+ {
+ p->crop = rc;
+ if (!mp_image_crop_valid(p)) {
+ char *str = m_option_type_rect.print(NULL, &vo->opts->video_crop);
+ MP_WARN(vo, "Ignoring invalid --video-crop=%s for %dx%d image\n",
+ str, p->w, p->h);
+ talloc_free(str);
+ if (vo->params) {
+ p->crop = vo->params->crop;
+ vo->opts->video_crop = (struct m_geometry){
+ .x = p->crop.x0,
+ .y = p->crop.y0,
+ .w = mp_rect_w(p->crop),
+ .h = mp_rect_h(p->crop),
+ .xy_valid = true,
+ .wh_valid = true,
+ };
+ }
+ if (!mp_image_crop_valid(p)) {
+ p->crop = (struct mp_rect){0};
+ vo->opts->video_crop = (struct m_geometry){0};
+ }
+ }
+ }
if (!vo->params || !mp_image_params_equal(p, vo->params)) {
// Changing config deletes the current frame; wait until it's finished.
if (vo_still_displaying(vo)) {