mirror of
https://github.com/mpv-player/mpv
synced 2025-01-18 04:51:52 +00:00
options: make video-crop validation more strict
This commit is contained in:
parent
582c7556c6
commit
20e584f60b
@ -1574,7 +1574,7 @@ Video
|
||||
This works with hwdec, unlike the equivalent 'lavfi-crop'. When offset is
|
||||
omitted, the central area will be cropped. Setting the crop to empty one
|
||||
``--video-crop=0x0+0+0`` overrides container crop and disables cropping.
|
||||
Setting the crop to ``--video-crop=0`` disables manual cropping and restores
|
||||
Setting the crop to ``--video-crop=""`` disables manual cropping and restores
|
||||
the container crop if it's specified.
|
||||
|
||||
``--video-zoom=<value>``
|
||||
|
@ -124,8 +124,8 @@ end
|
||||
|
||||
function remove_filter(label)
|
||||
if options.use_vo_crop and label == labels.crop then
|
||||
if mp.get_property('video-crop') ~= '0x0' then
|
||||
mp.command(string.format("%s set video-crop 0", command_prefix))
|
||||
if mp.get_property('video-crop') ~= "" then
|
||||
mp.command(string.format("%s set video-crop ''", command_prefix))
|
||||
return true
|
||||
end
|
||||
return false
|
||||
|
@ -2393,8 +2393,10 @@ void m_rect_apply(struct mp_rect *rc, int w, int h, struct m_geometry *gm)
|
||||
rc->x1 = w - rc->x0;
|
||||
if (!gm->wh_valid || rc->y1 == 0 || rc->y1 == INT_MIN)
|
||||
rc->y1 = h - rc->y0;
|
||||
rc->x1 += rc->x0;
|
||||
rc->y1 += rc->y0;
|
||||
if (gm->wh_valid && (gm->w || gm->h))
|
||||
rc->x1 += rc->x0;
|
||||
if (gm->wh_valid && (gm->w || gm->h))
|
||||
rc->y1 += rc->y0;
|
||||
}
|
||||
|
||||
static int parse_rect(struct mp_log *log, const m_option_t *opt,
|
||||
@ -2408,12 +2410,12 @@ static int parse_rect(struct mp_log *log, const m_option_t *opt,
|
||||
if (!parse_geometry_str(&gm, param))
|
||||
goto exit;
|
||||
|
||||
if (gm.x_sign || gm.y_sign || gm.ws ||
|
||||
(gm.wh_valid && (gm.w < 0 || gm.h < 0)) ||
|
||||
(gm.xy_valid && (gm.x < 0 || gm.y < 0)))
|
||||
{
|
||||
bool invalid = gm.x_sign || gm.y_sign || gm.ws;
|
||||
invalid |= gm.wh_valid && (gm.w < 0 || gm.h < 0);
|
||||
invalid |= gm.wh_valid && !gm.xy_valid && gm.w <= 0 && gm.h <= 0;
|
||||
|
||||
if (invalid)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (dst)
|
||||
*((struct m_geometry *)dst) = gm;
|
||||
|
@ -2338,8 +2338,7 @@ static struct mp_image_params get_video_out_params(struct MPContext *mpctx)
|
||||
struct mp_image_params o_params = mpctx->vo_chain->filter->output_params;
|
||||
if (mpctx->video_out) {
|
||||
struct m_geometry *gm = &mpctx->video_out->opts->video_crop;
|
||||
if (gm->xy_valid || (gm->wh_valid && (gm->w > 0 || gm->w_per > 0 ||
|
||||
gm->h > 0 || gm->h_per > 0)))
|
||||
if (gm->xy_valid || (gm->wh_valid && (gm->w > 0 || gm->h > 0)))
|
||||
{
|
||||
m_rect_apply(&o_params.crop, o_params.w, o_params.h, gm);
|
||||
}
|
||||
|
@ -1015,8 +1015,7 @@ static void apply_video_crop(struct MPContext *mpctx, struct vo *vo)
|
||||
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)))
|
||||
if (gm->xy_valid || (gm->wh_valid && (gm->w > 0 || gm->h > 0)))
|
||||
{
|
||||
m_rect_apply(&p.crop, p.w, p.h, gm);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user