summaryrefslogtreecommitdiffstats
path: root/player/video.c
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2023-09-10 00:50:38 +0200
committerDudemanguy <random342@airmail.cc>2023-09-20 19:08:19 +0000
commit582c7556c697a1efd24c9e71c91ef8c5a77acd0d (patch)
tree98c10684246cb0cf41b72f9a7d60af80bb82b353 /player/video.c
parent2fd5b9b4dda14c858f24548801da587dea747cac (diff)
downloadmpv-582c7556c697a1efd24c9e71c91ef8c5a77acd0d.tar.bz2
mpv-582c7556c697a1efd24c9e71c91ef8c5a77acd0d.tar.xz
player/video: don't try to restore old crop when invalid were provided
Instead just reset the crop to give user feedback that it was wrong. Also don't override decoder crop on invalid crops.
Diffstat (limited to 'player/video.c')
-rw-r--r--player/video.c49
1 files changed, 20 insertions, 29 deletions
diff --git a/player/video.c b/player/video.c
index 22e0dcf51b..6f5a69bcc7 100644
--- a/player/video.c
+++ b/player/video.c
@@ -1010,38 +1010,30 @@ static void calculate_frame_duration(struct MPContext *mpctx)
MP_STATS(mpctx, "value %f frame-duration-approx", MPMAX(0, approx_duration));
}
-static void apply_video_crop(struct vo *vo, struct mp_image_params *p)
+static void apply_video_crop(struct MPContext *mpctx, struct vo *vo)
{
- 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)) {
+ for (int n = 0; n < mpctx->num_next_frames; n++) {
+ struct m_geometry *gm = &vo->opts->video_crop;
+ struct mp_image_params p = mpctx->next_frames[n]->params;
+ if (gm->xy_valid || (gm->wh_valid && (gm->w > 0 || gm->w_per > 0 ||
+ gm->h > 0 || gm->h_per > 0)))
+ {
+ m_rect_apply(&p.crop, p.w, p.h, gm);
+ }
+
+ if (p.crop.x1 == 0 && p.crop.y1 == 0)
+ return;
+
+ if (!mp_image_crop_valid(&p)) {
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);
+ str, p.w, p.h);
talloc_free(str);
- if (vo->params) {
- p->crop = vo->params->crop;
- *gm = (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};
- *gm = (struct m_geometry){0};
- }
+ *gm = (struct m_geometry){0};
+ mp_property_do("video-crop", M_PROPERTY_SET, gm, mpctx);
+ return;
}
+ mpctx->next_frames[n]->params.crop = p.crop;
}
}
@@ -1163,8 +1155,7 @@ void write_video(struct MPContext *mpctx)
}
// Inject vo crop to notify and reconfig if needed
- for (int n = 0; n < mpctx->num_next_frames; n++)
- apply_video_crop(vo, &mpctx->next_frames[n]->params);
+ apply_video_crop(mpctx, vo);
// Filter output is different from VO input?
struct mp_image_params *p = &mpctx->next_frames[0]->params;