mirror of
https://github.com/mpv-player/mpv
synced 2025-03-21 02:41:13 +00:00
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.
This commit is contained in:
parent
2fd5b9b4dd
commit
582c7556c6
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user