summaryrefslogtreecommitdiffstats
path: root/libmpcodecs/vf_crop.c
diff options
context:
space:
mode:
authorarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-05-12 19:06:15 +0000
committerarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-05-12 19:06:15 +0000
commit6ab0d987add91595f0d01116d9506d06620719d1 (patch)
tree66368cff64099254943ff838f26ba91fac2ada46 /libmpcodecs/vf_crop.c
parent762d6ac6aad55f59959037ffbfbfbaa5ec34439d (diff)
downloadmpv-6ab0d987add91595f0d01116d9506d06620719d1.tar.bz2
mpv-6ab0d987add91595f0d01116d9506d06620719d1.tar.xz
keep aspect ratio - based on Fredrik Kuivinen's idea
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6061 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpcodecs/vf_crop.c')
-rw-r--r--libmpcodecs/vf_crop.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/libmpcodecs/vf_crop.c b/libmpcodecs/vf_crop.c
index 9288b4f477..8b90621ebf 100644
--- a/libmpcodecs/vf_crop.c
+++ b/libmpcodecs/vf_crop.c
@@ -13,24 +13,30 @@ struct vf_priv_s {
int crop_x,crop_y;
};
+extern int opt_screen_size_x;
+extern int opt_screen_size_y;
+
//===========================================================================//
static int config(struct vf_instance_s* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
- int ret;
- printf("crop->config() called\n");
// 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;
if(vf->priv->crop_x<0) vf->priv->crop_x=(width-vf->priv->crop_w)/2;
if(vf->priv->crop_y<0) vf->priv->crop_y=(height-vf->priv->crop_h)/2;
// check:
- if(vf->priv->crop_w+vf->priv->crop_x>width) return 0; // bad width
- if(vf->priv->crop_h+vf->priv->crop_y>height) return 0; // bad height
- ret=vf_next_config(vf,vf->priv->crop_w,vf->priv->crop_h,d_width,d_height,flags,outfmt);
- printf("crop->config() return %d\n",ret);
- return ret;
+ if(vf->priv->crop_w+vf->priv->crop_x>width ||
+ vf->priv->crop_h+vf->priv->crop_y>height){
+ printf("crop: bad position/width/height - cropped area is out of the original!\n");
+ return 0;
+ }
+ if(!opt_screen_size_x && !opt_screen_size_y){
+ d_width=d_width*vf->priv->crop_w/width;
+ d_height=d_height*vf->priv->crop_h/height;
+ }
+ return vf_next_config(vf,vf->priv->crop_w,vf->priv->crop_h,d_width,d_height,flags,outfmt);
}
static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){