summaryrefslogtreecommitdiffstats
path: root/video/filter/vf_crop.c
diff options
context:
space:
mode:
Diffstat (limited to 'video/filter/vf_crop.c')
-rw-r--r--video/filter/vf_crop.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/video/filter/vf_crop.c b/video/filter/vf_crop.c
index 02787b8f22..79e915fd4a 100644
--- a/video/filter/vf_crop.c
+++ b/video/filter/vf_crop.c
@@ -39,10 +39,11 @@ static const struct vf_priv_s {
//===========================================================================//
-static int config(struct vf_instance *vf,
- int width, int height, int d_width, int d_height,
- unsigned int flags, unsigned int outfmt)
+static int reconfig(struct vf_instance *vf, struct mp_image_params *in,
+ struct mp_image_params *out)
{
+ int width = in->w, height = in->h, d_width = in->d_w, d_height = in->d_h;
+
// calculate the missing parameters:
if(vf->priv->crop_w<=0 || vf->priv->crop_w>width) vf->priv->crop_w=width;
if(vf->priv->crop_h<=0 || vf->priv->crop_h>height) vf->priv->crop_h=height;
@@ -50,7 +51,7 @@ static int config(struct vf_instance *vf,
if(vf->priv->crop_y<0) vf->priv->crop_y=(height-vf->priv->crop_h)/2;
// rounding:
- struct mp_imgfmt_desc fmt = mp_imgfmt_get_desc(outfmt);
+ struct mp_imgfmt_desc fmt = mp_imgfmt_get_desc(in->imgfmt);
vf->priv->crop_x = MP_ALIGN_DOWN(vf->priv->crop_x, fmt.align_x);
vf->priv->crop_y = MP_ALIGN_DOWN(vf->priv->crop_y, fmt.align_y);
@@ -59,11 +60,17 @@ static int config(struct vf_instance *vf,
if(vf->priv->crop_w+vf->priv->crop_x>width ||
vf->priv->crop_h+vf->priv->crop_y>height){
MP_WARN(vf, "Bad position/width/height - cropped area outside of the original!\n");
- return 0;
+ return -1;
}
+
vf_rescale_dsize(&d_width, &d_height, width, height,
vf->priv->crop_w, vf->priv->crop_h);
- return vf_next_config(vf,vf->priv->crop_w,vf->priv->crop_h,d_width,d_height,flags,outfmt);
+ *out = *in;
+ out->w = vf->priv->crop_w;
+ out->h = vf->priv->crop_h;
+ out->d_w = d_width;
+ out->d_h = d_height;
+ return 0;
}
static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
@@ -82,7 +89,7 @@ static int query_format(struct vf_instance *vf, unsigned int fmt)
}
static int vf_open(vf_instance_t *vf){
- vf->config=config;
+ vf->reconfig=reconfig;
vf->filter=filter;
vf->query_format=query_format;
return 1;