CVS: main/libmpcodecs vf_crop.c,1.13,1.14
Update of /cvsroot/mplayer/main/libmpcodecs In directory mail:/var/tmp.root/cvs-serv23111/libmpcodecs Modified Files: vf_crop.c Log Message: slices support for vf_crop. now cropping black borders should make a dvd play faster rather than slower... :) Index: vf_crop.c =================================================================== RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_crop.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- vf_crop.c 15 Mar 2003 20:55:33 -0000 1.13 +++ vf_crop.c 27 Apr 2003 21:04:00 -0000 1.14 @@ -91,11 +91,40 @@ return vf_next_put_image(vf,dmpi); } +static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi){ + if(!vf->next->draw_slice){ + mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK; + return; + } + vf_get_image(vf->next, mpi->imgfmt, mpi->type, mpi->flags, + vf->priv->crop_w, vf->priv->crop_h); +} + +static void draw_slice(struct vf_instance_s* vf, + unsigned char** src, int* stride, int w,int h, int x, int y){ + //mp_msg(MSGT_VFILTER, MSGL_V, "crop slice %d %d %d %d ->", w,h,x,y); + if ((x -= vf->priv->crop_x) < 0) { + w += x; + x = 0; + } + if ((y -= vf->priv->crop_y) < 0) { + h += y; + y = 0; + } + if (x+w > vf->priv->crop_w) w = vf->priv->crop_w-x; + if (y+h > vf->priv->crop_h) h = vf->priv->crop_h-y; + //mp_msg(MSGT_VFILTER, MSGL_V, "%d %d %d %d\n", w,h,x,y); + if ((w < 0) || (h < 0)) return; + vf_next_draw_slice(vf,src,stride,w,h,x,y); +} + //===========================================================================// static int open(vf_instance_t *vf, char* args){ vf->config=config; vf->put_image=put_image; + vf->start_slice=start_slice; + vf->draw_slice=draw_slice; vf->default_reqs=VFCAP_ACCEPT_STRIDE; if(!vf->priv) { vf->priv=malloc(sizeof(struct vf_priv_s));
Hi,
+static void draw_slice(struct vf_instance_s* vf, + unsigned char** src, int* stride, int w,int h, int x, int y){ + //mp_msg(MSGT_VFILTER, MSGL_V, "crop slice %d %d %d %d ->", w,h,x,y); + if ((x -= vf->priv->crop_x) < 0) { + w += x; + x = 0; + } + if ((y -= vf->priv->crop_y) < 0) { + h += y; + y = 0; + } + if (x+w > vf->priv->crop_w) w = vf->priv->crop_w-x; + if (y+h > vf->priv->crop_h) h = vf->priv->crop_h-y; + //mp_msg(MSGT_VFILTER, MSGL_V, "%d %d %d %d\n", w,h,x,y); + if ((w < 0) || (h < 0)) return; + vf_next_draw_slice(vf,src,stride,w,h,x,y); +}
imho this is broken. you should adjust src[] too (but copy it instead of in-place modification, it's not allowed!), changing x,y is not enough (it's used only as destination coordinates, src[] points is the upper left pixel of the area to be copied) A'rpi / Astral & ESP-team -- Developer of MPlayer, the Movie Player for Linux - http://www.MPlayerHQ.hu
On Sun, Apr 27, 2003 at 11:12:28PM +0200, Arpi wrote:
Hi,
+static void draw_slice(struct vf_instance_s* vf, + unsigned char** src, int* stride, int w,int h, int x, int y){ + //mp_msg(MSGT_VFILTER, MSGL_V, "crop slice %d %d %d %d ->", w,h,x,y); + if ((x -= vf->priv->crop_x) < 0) { + w += x; + x = 0; + } + if ((y -= vf->priv->crop_y) < 0) { + h += y; + y = 0; + } + if (x+w > vf->priv->crop_w) w = vf->priv->crop_w-x; + if (y+h > vf->priv->crop_h) h = vf->priv->crop_h-y; + //mp_msg(MSGT_VFILTER, MSGL_V, "%d %d %d %d\n", w,h,x,y); + if ((w < 0) || (h < 0)) return; + vf_next_draw_slice(vf,src,stride,w,h,x,y); +}
imho this is broken. you should adjust src[] too (but copy it instead of in-place modification, it's not allowed!), changing x,y is not enough (it's used only as destination coordinates, src[] points is the upper left pixel of the area to be copied)
Doh! You're right....wonder why it works for me...?? I'll fix it... Rich
On Sun, Apr 27, 2003 at 11:12:28PM +0200, Arpi wrote:
Hi,
+static void draw_slice(struct vf_instance_s* vf, + unsigned char** src, int* stride, int w,int h, int x, int y){ + //mp_msg(MSGT_VFILTER, MSGL_V, "crop slice %d %d %d %d ->", w,h,x,y); + if ((x -= vf->priv->crop_x) < 0) { + w += x; + x = 0; + } + if ((y -= vf->priv->crop_y) < 0) { + h += y; + y = 0; + } + if (x+w > vf->priv->crop_w) w = vf->priv->crop_w-x; + if (y+h > vf->priv->crop_h) h = vf->priv->crop_h-y; + //mp_msg(MSGT_VFILTER, MSGL_V, "%d %d %d %d\n", w,h,x,y); + if ((w < 0) || (h < 0)) return; + vf_next_draw_slice(vf,src,stride,w,h,x,y); +}
imho this is broken. you should adjust src[] too (but copy it instead of in-place modification, it's not allowed!), changing x,y is not enough (it's used only as destination coordinates, src[] points is the upper left pixel of the area to be copied)
OK, can you send me one of those huge cola crates? My previous code deserves about 100l -- the slice code was being called, but then the normal put_image happened at the end of the frame too, hiding the broken results of the slice code. All is fixed now, and I'm committing a new version that actually has the reduced cpu usage advertised before... Rich
participants (3)
-
Arpi -
D Richard Felker III -
Richard Felker CVS