diff options
author | Kacper Michajłow <kasper93@gmail.com> | 2023-09-01 12:24:13 +0200 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-09-08 02:27:08 +0000 |
commit | 37d0deadd40d57b43bd8020f0143be46f3bf998a (patch) | |
tree | acb8f26714b9f6c28a452c4ef8ed8e549c8f5789 /player/video.c | |
parent | ff7da2f5c0ec0bded0c843c04cdbe1adba976a45 (diff) | |
download | mpv-37d0deadd40d57b43bd8020f0143be46f3bf998a.tar.bz2 mpv-37d0deadd40d57b43bd8020f0143be46f3bf998a.tar.xz |
video: allow overriding container crop if it is present
Setting `--video-crop=0x0+0+0` applies full frame crop, ignoring the
container one. Setting --video-crop=0 disables manual crop and restores
container one if it is available.
Diffstat (limited to 'player/video.c')
-rw-r--r-- | player/video.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/player/video.c b/player/video.c index d9e371d9fd..e67fa66785 100644 --- a/player/video.c +++ b/player/video.c @@ -1130,19 +1130,23 @@ 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) + struct m_geometry *gm = &vo->opts->video_crop; + struct mp_rect rc = {0}; + if (gm->xy_valid || (gm->wh_valid && (gm->w > 0 || gm->w_per > 0 || + gm->h > 0 || gm->h_per > 0))) { + m_rect_apply(&rc, p->w, p->h, gm); + } + 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); + char *str = m_option_type_rect.print(NULL, gm); 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){ + *gm = (struct m_geometry){ .x = p->crop.x0, .y = p->crop.y0, .w = mp_rect_w(p->crop), @@ -1153,7 +1157,7 @@ void write_video(struct MPContext *mpctx) } if (!mp_image_crop_valid(p)) { p->crop = (struct mp_rect){0}; - vo->opts->video_crop = (struct m_geometry){0}; + *gm = (struct m_geometry){0}; } } } |