[MPlayer-dev-eng] [PATCH] mp_image flags in filters

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Wed Jul 27 18:33:42 CEST 2005


Hi,
I think a lot of filters use the wrong flags in their vf_get_image
calls, most of them use MP_IMAGETYPE_TEMP, to which mp_image.h says:
> //codec just needs some WO memory, where it writes/copies the whole frame

But a lot of codecs also read from it, IMHO they should/must set
MP_IMGFLAG_READABLE then (as it currently is this just gives horrible
performance when doign dr directly into video ram).
For others like softpulldown, telecine and tinterlace I really can't see why they
set MP_IMGFLAG_PRESERVE, since they seem to never use that mp_image
again.
For tile I think MP_IMGTYPE_STATIC is not neccessary, as I understand it
you'd only need that if you call vf_next_put_image more than once with
the same mp_image, which is not the case here.
Please tell me if I misunderstood something or if you have any
comments/questions.
Proposed patch attached.

Greetings,
Reimar Döffinger
P.S. some filters _really_ miss direct rendering support, like e.g.
rectangle and bmovl, they change hardly anything of the image but
nevertheless memcpy all of it...
-------------- next part --------------
Index: libmpcodecs/vf_boxblur.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_boxblur.c,v
retrieving revision 1.3
diff -u -r1.3 vf_boxblur.c
--- libmpcodecs/vf_boxblur.c	15 Mar 2003 18:01:02 -0000	1.3
+++ libmpcodecs/vf_boxblur.c	27 Jul 2005 16:22:39 -0000
@@ -137,7 +137,7 @@
 	int ch= mpi->h >> mpi->chroma_y_shift;
 
 	mp_image_t *dmpi=vf_get_image(vf->next,mpi->imgfmt,
-		MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
+		MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_READABLE,
 		mpi->w,mpi->h);
 
 	assert(mpi->flags&MP_IMGFLAG_PLANAR);
Index: libmpcodecs/vf_denoise3d.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_denoise3d.c,v
retrieving revision 1.6
diff -u -r1.6 vf_denoise3d.c
--- libmpcodecs/vf_denoise3d.c	15 Mar 2003 18:01:02 -0000	1.6
+++ libmpcodecs/vf_denoise3d.c	27 Jul 2005 16:22:40 -0000
@@ -120,7 +120,8 @@
         int W = mpi->w, H = mpi->h;
 
 	mp_image_t *dmpi=vf_get_image(vf->next,mpi->imgfmt,
-		MP_IMGTYPE_IP, MP_IMGFLAG_ACCEPT_STRIDE,
+		MP_IMGTYPE_IP, MP_IMGFLAG_ACCEPT_STRIDE |
+		MP_IMGFLAG_PRESERVE | MP_IMGFLAG_READABLE,
                 mpi->w,mpi->h);
 
 	if(!dmpi) return 0;
Index: libmpcodecs/vf_dint.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_dint.c,v
retrieving revision 1.3
diff -u -r1.3 vf_dint.c
--- libmpcodecs/vf_dint.c	15 Mar 2003 18:01:02 -0000	1.3
+++ libmpcodecs/vf_dint.c	27 Jul 2005 16:22:41 -0000
@@ -76,6 +76,7 @@
     unsigned char *cur0, *prv0;
     register unsigned char *cur, *prv;
 
+    if (rowsize > MAXROWSIZE) rowsize = MAXROWSIZE;
     // check if nothing to do
     if (mpi->imgfmt == vf->priv->imgfmt)
     {
Index: libmpcodecs/vf_divtc.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_divtc.c,v
retrieving revision 1.2
diff -u -r1.2 vf_divtc.c
--- libmpcodecs/vf_divtc.c	21 Oct 2004 11:55:19 -0000	1.2
+++ libmpcodecs/vf_divtc.c	27 Jul 2005 16:22:43 -0000
@@ -342,7 +342,8 @@
 	 if(p->deghost>0)
 	    {
 	    tmpi=vf_get_image(vf->next, mpi->imgfmt,
-			      MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
+			      MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE |
+			      MP_IMGFLAG_READABLE,
 			      mpi->width, mpi->height);
 	    vf_clone_mpi_attributes(tmpi, mpi);
 
Index: libmpcodecs/vf_down3dright.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_down3dright.c,v
retrieving revision 1.4
diff -u -r1.4 vf_down3dright.c
--- libmpcodecs/vf_down3dright.c	24 Feb 2005 17:04:04 -0000	1.4
+++ libmpcodecs/vf_down3dright.c	27 Jul 2005 16:22:44 -0000
@@ -85,7 +85,8 @@
 
 	// hope we'll get DR buffer:
 	dmpi=vf_get_image(vf->next, IMGFMT_YV12,
-			  MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
+			  MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE |
+			  (vf->priv->scaleh == 1) ? MP_IMGFLAG_READABLE : 0,
 			  mpi->w * vf->priv->scalew,
 			  mpi->h / vf->priv->scaleh - vf->priv->skipline);
 
Index: libmpcodecs/vf_kerndeint.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_kerndeint.c,v
retrieving revision 1.3
diff -u -r1.3 vf_kerndeint.c
--- libmpcodecs/vf_kerndeint.c	23 Feb 2004 21:12:06 -0000	1.3
+++ libmpcodecs/vf_kerndeint.c	27 Jul 2005 16:22:44 -0000
@@ -103,7 +103,8 @@
 		MP_IMGTYPE_IP, MP_IMGFLAG_ACCEPT_STRIDE,
 		mpi->w,mpi->h);
 	mp_image_t *pmpi=vf_get_image(vf->next,mpi->imgfmt,
-		MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
+		MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE |
+		MP_IMGFLAG_READABLE,
 		mpi->w,mpi->h);
 	if(!dmpi) return 0;
 
Index: libmpcodecs/vf_pp.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_pp.c,v
retrieving revision 1.32
diff -u -r1.32 vf_pp.c
--- libmpcodecs/vf_pp.c	20 Jul 2005 01:22:24 -0000	1.32
+++ libmpcodecs/vf_pp.c	27 Jul 2005 16:22:45 -0000
@@ -114,7 +114,8 @@
     if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
 	// no DR, so get a new image! hope we'll get DR buffer:
 	vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
-	    MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE,
+	    MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE
+	    | MP_IMGFLAG_READABLE,
 //	    MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
 //	    mpi->w,mpi->h);
 	    (mpi->width+7)&(~7),(mpi->height+7)&(~7));
Index: libmpcodecs/vf_rectangle.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_rectangle.c,v
retrieving revision 1.9
diff -u -r1.9 vf_rectangle.c
--- libmpcodecs/vf_rectangle.c	25 Oct 2003 18:37:34 -0000	1.9
+++ libmpcodecs/vf_rectangle.c	27 Jul 2005 16:22:46 -0000
@@ -69,7 +69,8 @@
     unsigned int bpp = mpi->bpp / 8;
     unsigned int x, y, w, h;
     dmpi = vf_get_image(vf->next, mpi->imgfmt, MP_IMGTYPE_TEMP,
-			MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_PREFER_ALIGNED_STRIDE,
+			MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_PREFER_ALIGNED_STRIDE|
+			MP_IMGFLAG_READABLE,
 			mpi->w, mpi->h);
 
     memcpy_pic(dmpi->planes[0],mpi->planes[0],mpi->w*bpp, mpi->h,
Index: libmpcodecs/vf_smartblur.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_smartblur.c,v
retrieving revision 1.8
diff -u -r1.8 vf_smartblur.c
--- libmpcodecs/vf_smartblur.c	20 Jan 2005 13:22:52 -0000	1.8
+++ libmpcodecs/vf_smartblur.c	27 Jul 2005 16:22:46 -0000
@@ -187,9 +187,11 @@
 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
 	int cw= mpi->w >> mpi->chroma_x_shift;
 	int ch= mpi->h >> mpi->chroma_y_shift;
+	FilterParam *f= &vf->priv;
 
 	mp_image_t *dmpi=vf_get_image(vf->next,mpi->imgfmt,
-		MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
+		MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE|
+		(f->threshold) ? MP_IMGFLAG_READABLE : 0,
 		mpi->w,mpi->h);
 
 	assert(mpi->flags&MP_IMGFLAG_PLANAR);
Index: libmpcodecs/vf_softpulldown.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_softpulldown.c,v
retrieving revision 1.3
diff -u -r1.3 vf_softpulldown.c
--- libmpcodecs/vf_softpulldown.c	19 Jun 2005 09:17:44 -0000	1.3
+++ libmpcodecs/vf_softpulldown.c	27 Jul 2005 16:22:47 -0000
@@ -41,8 +41,8 @@
 	int state = vf->priv->state;
 
 	dmpi = vf_get_image(vf->next, mpi->imgfmt,
-	                    MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE |
-	                    MP_IMGFLAG_PRESERVE, mpi->width, mpi->height);
+	                    MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE,
+	                    mpi->width, mpi->height);
 
 	vf->priv->in++;
 
Index: libmpcodecs/vf_telecine.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_telecine.c,v
retrieving revision 1.2
diff -u -r1.2 vf_telecine.c
--- libmpcodecs/vf_telecine.c	15 Mar 2003 18:01:02 -0000	1.2
+++ libmpcodecs/vf_telecine.c	27 Jul 2005 16:22:47 -0000
@@ -38,8 +38,8 @@
 	vf->priv->frame = (vf->priv->frame+1)%4;
 	
 	dmpi = vf_get_image(vf->next, mpi->imgfmt,
-		MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE |
-		MP_IMGFLAG_PRESERVE, mpi->width, mpi->height);
+		MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE,
+		mpi->width, mpi->height);
 
 	ret = 0;
 	//    0/0  1/1  2/2  2/3  3/0
Index: libmpcodecs/vf_tile.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_tile.c,v
retrieving revision 1.1
diff -u -r1.1 vf_tile.c
--- libmpcodecs/vf_tile.c	31 Aug 2003 21:41:24 -0000	1.1
+++ libmpcodecs/vf_tile.c	27 Jul 2005 16:22:48 -0000
@@ -116,7 +116,7 @@
 
     /* Get the big image! */
     dmpi=vf_get_image(vf->next, mpi->imgfmt,
-                      MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE,
+                      MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
                       xw, yh);
 
     /* bytes x pixel & bytes x line */
Index: libmpcodecs/vf_tinterlace.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_tinterlace.c,v
retrieving revision 1.1
diff -u -r1.1 vf_tinterlace.c
--- libmpcodecs/vf_tinterlace.c	11 Aug 2003 20:04:30 -0000	1.1
+++ libmpcodecs/vf_tinterlace.c	27 Jul 2005 16:22:48 -0000
@@ -45,8 +45,7 @@
 		dmpi = vf->priv->dmpi;
 		if (dmpi == NULL) {
 			dmpi = vf_get_image(vf->next, mpi->imgfmt,
-					    MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE |
-					    MP_IMGFLAG_PRESERVE | MP_IMGFLAG_READABLE,
+					    MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE,
 					    mpi->width, mpi->height*2);
 
 			vf->priv->dmpi = dmpi;


More information about the MPlayer-dev-eng mailing list