[Mplayer-cvslog] CVS: main/libmpcodecs mp_image.h,1.12,1.13 vf.c,1.36,1.37 vf_expand.c,1.12,1.13 vf_flip.c,1.5,1.6 vf_mirror.c,1.2,1.3 vf_rotate.c,1.1,1.2 vf_test.c,1.2,1.3

Alex Beregszaszi alex at mplayerhq.hu
Sun Jun 23 23:08:34 CEST 2002


Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/var/tmp.root/cvs-serv16561

Modified Files:
	mp_image.h vf.c vf_expand.c vf_flip.c vf_mirror.c vf_rotate.c 
	vf_test.c 
Log Message:
better planar support, chroma subsampling support and Y8/Y800 support

Index: mp_image.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/mp_image.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- mp_image.h	23 Jun 2002 20:42:19 -0000	1.12
+++ mp_image.h	23 Jun 2002 21:08:31 -0000	1.13
@@ -58,8 +58,8 @@
     /* these are only used by planar formats Y,U(Cb),V(Cr) */
     int chroma_width;
     int chroma_height;
-    int chroma_h_shift;
-    int chroma_v_shift;
+    int chroma_x_shift; // horizontal
+    int chroma_y_shift; // vertical
 } mp_image_t;
 
 #ifdef IMGFMT_YUY2
@@ -91,8 +91,8 @@
 	mpi->bpp=12;
 	mpi->chroma_width=(mpi->width>>1);
 	mpi->chroma_height=(mpi->height>>1);
-	mpi->chroma_h_shift=1;
-	mpi->chroma_v_shift=1;
+	mpi->chroma_x_shift=1;
+	mpi->chroma_y_shift=1;
 	return;
     case IMGFMT_IF09:
 	mpi->num_planes=4;
@@ -101,8 +101,8 @@
 	mpi->bpp=9;
 	mpi->chroma_width=(mpi->width>>2);
 	mpi->chroma_height=(mpi->height>>2);
-	mpi->chroma_h_shift=2;
-	mpi->chroma_v_shift=2;
+	mpi->chroma_x_shift=2;
+	mpi->chroma_y_shift=2;
 	return;
     case IMGFMT_Y800:
     case IMGFMT_Y8:

Index: vf.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- vf.c	23 Jun 2002 15:01:45 -0000	1.36
+++ vf.c	23 Jun 2002 21:08:31 -0000	1.37
@@ -72,19 +72,18 @@
 void vf_mpi_clear(mp_image_t* mpi,int x0,int y0,int w,int h){
     int y;
     if(mpi->flags&MP_IMGFLAG_PLANAR){
-	int div = (mpi->imgfmt == IMGFMT_YVU9 || mpi->imgfmt == IMGFMT_IF09) ? 2 : 1;
 	y0&=~1;h+=h&1;
 	if(x0==0 && w==mpi->width){
 	    // full width clear:
 	    memset(mpi->planes[0]+mpi->stride[0]*y0,0,mpi->stride[0]*h);
-	    memset(mpi->planes[1]+mpi->stride[1]*(y0>>div),128,mpi->stride[1]*(h>>div));
-	    memset(mpi->planes[2]+mpi->stride[2]*(y0>>div),128,mpi->stride[2]*(h>>div));
+	    memset(mpi->planes[1]+mpi->stride[1]*(y0>>mpi->chroma_y_shift),128,mpi->stride[1]*(h>>mpi->chroma_y_shift));
+	    memset(mpi->planes[2]+mpi->stride[2]*(y0>>mpi->chroma_y_shift),128,mpi->stride[2]*(h>>mpi->chroma_y_shift));
 	} else
 	for(y=y0;y<y0+h;y+=2){
 	    memset(mpi->planes[0]+x0+mpi->stride[0]*y,0,w);
 	    memset(mpi->planes[0]+x0+mpi->stride[0]*(y+1),0,w);
-	    memset(mpi->planes[1]+(x0>>div)+mpi->stride[1]*(y>>div),128,(w>>div));
-	    memset(mpi->planes[2]+(x0>>div)+mpi->stride[2]*(y>>div),128,(w>>div));
+	    memset(mpi->planes[1]+(x0>>mpi->chroma_x_shift)+mpi->stride[1]*(y>>mpi->chroma_y_shift),128,(w>>mpi->chroma_x_shift));
+	    memset(mpi->planes[2]+(x0>>mpi->chroma_x_shift)+mpi->stride[2]*(y>>mpi->chroma_y_shift),128,(w>>mpi->chroma_x_shift));
 	}
 	return;
     }
@@ -166,32 +165,27 @@
         if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
           // non-direct and not yet allocated image. allocate it!
 	  // IF09 - allocate space for 4. plane delta info - unused
-	  if (mpi->imgfmt == IMGFMT_IF09) 
+	  if (mpi->imgfmt == IMGFMT_IF09)
+	  {
 	     mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8+
-	    				(mpi->width>>2)*(mpi->height>>2));
+	    				mpi->chroma_width*mpi->chroma_height);
+	     /* delta table, just for fun ;) */
+	     mpi->planes[3]=mpi->planes[0]+2*(mpi->chroma_width*mpi->chroma_height);
+	  }
 	  else
 	     mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8);
 	  if(mpi->flags&MP_IMGFLAG_PLANAR){
 	      // YV12/I420/YVU9/IF09. feel free to add other planar formats here...
 	      if(!mpi->stride[0]) mpi->stride[0]=mpi->width;
-	      if (!mpi->stride[1])
-	      {
-	        if (mpi->imgfmt == IMGFMT_YVU9 || mpi->imgfmt == IMGFMT_IF09)
-		    mpi->stride[1]=mpi->stride[2]=mpi->width/4;
-	        else
-		    mpi->stride[1]=mpi->stride[2]=mpi->width/2;
-	      }
+	      if(!mpi->stride[1]) mpi->stride[1]=mpi->stride[2]=mpi->chroma_width;
 	      if(mpi->flags&MP_IMGFLAG_SWAPPED){
 	          // I420/IYUV  (Y,U,V)
 	          mpi->planes[1]=mpi->planes[0]+mpi->width*mpi->height;
-	          mpi->planes[2]=mpi->planes[1]+(mpi->width>>1)*(mpi->height>>1);
+	          mpi->planes[2]=mpi->planes[1]+mpi->chroma_width*mpi->chroma_height;
 	      } else {
-	          // YV12,YVU9  (Y,V,U)
+	          // YV12,YVU9,IF09  (Y,V,U)
 	          mpi->planes[2]=mpi->planes[0]+mpi->width*mpi->height;
-		  if (mpi->imgfmt == IMGFMT_YVU9 || mpi->imgfmt == IMGFMT_IF09)
-		    mpi->planes[1]=mpi->planes[2]+(mpi->width>>2)*(mpi->height>>2);
-		  else
-	            mpi->planes[1]=mpi->planes[2]+(mpi->width>>1)*(mpi->height>>1);
+	          mpi->planes[1]=mpi->planes[2]+mpi->chroma_width*mpi->chroma_height;
 	      }
 	  } else {
 	      if(!mpi->stride[0]) mpi->stride[0]=mpi->width*mpi->bpp/8;
@@ -209,9 +203,10 @@
 		  (mpi->flags&MP_IMGFLAG_YUV)?"YUV":"RGB",
 		  (mpi->flags&MP_IMGFLAG_PLANAR)?"planar":"packed",
 	          mpi->bpp*mpi->width*mpi->height/8);
-	    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"(imgfmt: %x, planes: %x,%x,%x strides: %d,%d,%d)\n",
+	    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"(imgfmt: %x, planes: %x,%x,%x strides: %d,%d,%d, chroma: %dx%d, shift: h:%d,v:%d)\n",
 		mpi->imgfmt, mpi->planes[0], mpi->planes[1], mpi->planes[2],
-		mpi->stride[0], mpi->stride[1], mpi->stride[2]);
+		mpi->stride[0], mpi->stride[1], mpi->stride[2],
+		mpi->chroma_width, mpi->chroma_height, mpi->chroma_x_shift, mpi->chroma_y_shift);
 	    mpi->flags|=MP_IMGFLAG_TYPE_DISPLAYED;
     }
 

Index: vf_expand.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_expand.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- vf_expand.c	23 Jun 2002 19:33:55 -0000	1.12
+++ vf_expand.c	23 Jun 2002 21:08:31 -0000	1.13
@@ -199,20 +199,10 @@
 	if(mpi->flags&MP_IMGFLAG_PLANAR){
 	    mpi->planes[0]=vf->priv->dmpi->planes[0]+
 		vf->priv->exp_y*vf->priv->dmpi->stride[0]+vf->priv->exp_x;
-	    if (mpi->imgfmt == IMGFMT_YVU9)
-	    {
 	    mpi->planes[1]=vf->priv->dmpi->planes[1]+
-		(vf->priv->exp_y>>2)*vf->priv->dmpi->stride[1]+(vf->priv->exp_x>>2);
+		(vf->priv->exp_y>>mpi->chroma_y_shift)*vf->priv->dmpi->stride[1]+(vf->priv->exp_x>>mpi->chroma_x_shift);
 	    mpi->planes[2]=vf->priv->dmpi->planes[2]+
-		(vf->priv->exp_y>>2)*vf->priv->dmpi->stride[2]+(vf->priv->exp_x>>2);
-	    }
-	    else
-	    {
-	    mpi->planes[1]=vf->priv->dmpi->planes[1]+
-		(vf->priv->exp_y>>1)*vf->priv->dmpi->stride[1]+(vf->priv->exp_x>>1);
-	    mpi->planes[2]=vf->priv->dmpi->planes[2]+
-		(vf->priv->exp_y>>1)*vf->priv->dmpi->stride[2]+(vf->priv->exp_x>>1);
-	    }
+		(vf->priv->exp_y>>mpi->chroma_y_shift)*vf->priv->dmpi->stride[2]+(vf->priv->exp_x>>mpi->chroma_x_shift);
 	    mpi->stride[1]=vf->priv->dmpi->stride[1];
 	    mpi->stride[2]=vf->priv->dmpi->stride[2];
 	} else {
@@ -246,28 +236,14 @@
 	        vf->priv->exp_y*vf->priv->dmpi->stride[0]+vf->priv->exp_x,
 		mpi->planes[0], mpi->w, mpi->h,
 		vf->priv->dmpi->stride[0],mpi->stride[0]);
-	if (mpi->imgfmt == IMGFMT_YVU9)
-	{
-	memcpy_pic(vf->priv->dmpi->planes[1]+
-		(vf->priv->exp_y>>2)*vf->priv->dmpi->stride[1]+(vf->priv->exp_x>>2),
-		mpi->planes[1], mpi->w>>2, mpi->h>>2,
-		vf->priv->dmpi->stride[1],mpi->stride[1]);
-	memcpy_pic(vf->priv->dmpi->planes[2]+
-		(vf->priv->exp_y>>2)*vf->priv->dmpi->stride[2]+(vf->priv->exp_x>>2),
-		mpi->planes[2], mpi->w>>2, mpi->h>>2,
-		vf->priv->dmpi->stride[2],mpi->stride[2]);
-	}
-	else
-	{
 	memcpy_pic(vf->priv->dmpi->planes[1]+
-		(vf->priv->exp_y>>1)*vf->priv->dmpi->stride[1]+(vf->priv->exp_x>>1),
-		mpi->planes[1], mpi->w>>1, mpi->h>>1,
+		(vf->priv->exp_y>>mpi->chroma_y_shift)*vf->priv->dmpi->stride[1]+(vf->priv->exp_x>>mpi->chroma_x_shift),
+		mpi->planes[1], mpi->chroma_width, mpi->chroma_height,
 		vf->priv->dmpi->stride[1],mpi->stride[1]);
 	memcpy_pic(vf->priv->dmpi->planes[2]+
-		(vf->priv->exp_y>>1)*vf->priv->dmpi->stride[2]+(vf->priv->exp_x>>1),
-		mpi->planes[2], mpi->w>>1, mpi->h>>1,
+		(vf->priv->exp_y>>mpi->chroma_y_shift)*vf->priv->dmpi->stride[2]+(vf->priv->exp_x>>mpi->chroma_x_shift),
+		mpi->planes[2], mpi->chroma_width, mpi->chroma_height,
 		vf->priv->dmpi->stride[2],mpi->stride[2]);
-	}
     } else {
 	memcpy_pic(vf->priv->dmpi->planes[0]+
 	        vf->priv->exp_y*vf->priv->dmpi->stride[0]+vf->priv->exp_x*(vf->priv->dmpi->bpp/8),

Index: vf_flip.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_flip.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- vf_flip.c	20 May 2002 02:27:10 -0000	1.5
+++ vf_flip.c	23 Jun 2002 21:08:31 -0000	1.6
@@ -34,10 +34,10 @@
 	mpi->stride[0]=-vf->priv->dmpi->stride[0];
 	if(mpi->flags&MP_IMGFLAG_PLANAR){
 	    mpi->planes[1]=vf->priv->dmpi->planes[1]+
-		    vf->priv->dmpi->stride[1]*((vf->priv->dmpi->height>>1)-1);
+		    vf->priv->dmpi->stride[1]*((vf->priv->dmpi->height>>mpi->chroma_y_shift)-1);
 	    mpi->stride[1]=-vf->priv->dmpi->stride[1];
 	    mpi->planes[2]=vf->priv->dmpi->planes[2]+
-		    vf->priv->dmpi->stride[2]*((vf->priv->dmpi->height>>1)-1);
+		    vf->priv->dmpi->stride[2]*((vf->priv->dmpi->height>>mpi->chroma_y_shift)-1);
 	    mpi->stride[2]=-vf->priv->dmpi->stride[2];
 	}
 	mpi->flags|=MP_IMGFLAG_DIRECT;
@@ -60,10 +60,10 @@
     vf->priv->dmpi->stride[0]=-mpi->stride[0];
     if(vf->priv->dmpi->flags&MP_IMGFLAG_PLANAR){
         vf->priv->dmpi->planes[1]=mpi->planes[1]+
-	    mpi->stride[1]*((mpi->height>>1)-1);
+	    mpi->stride[1]*((mpi->height>>mpi->chroma_y_shift)-1);
 	vf->priv->dmpi->stride[1]=-mpi->stride[1];
 	vf->priv->dmpi->planes[2]=mpi->planes[2]+
-	    mpi->stride[2]*((mpi->height>>1)-1);
+	    mpi->stride[2]*((mpi->height>>mpi->chroma_y_shift)-1);
 	vf->priv->dmpi->stride[2]=-mpi->stride[2];
     }
     

Index: vf_mirror.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_mirror.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- vf_mirror.c	21 Apr 2002 16:42:08 -0000	1.2
+++ vf_mirror.c	23 Jun 2002 21:08:31 -0000	1.3
@@ -56,10 +56,10 @@
 	       dmpi->w,dmpi->h,1);
 	       mirror(dmpi->planes[1],mpi->planes[1],
 	       dmpi->stride[1],mpi->stride[1],
-	       dmpi->w>>1,dmpi->h>>1,1);
+	       dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1);
 	       mirror(dmpi->planes[2],mpi->planes[2],
 	       dmpi->stride[2],mpi->stride[2],
-	       dmpi->w>>1,dmpi->h>>1,1);
+	       dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1);
     } else {
 	mirror(dmpi->planes[0],mpi->planes[0],
 	       dmpi->stride[0],mpi->stride[0],

Index: vf_rotate.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_rotate.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- vf_rotate.c	19 Apr 2002 02:18:46 -0000	1.1
+++ vf_rotate.c	23 Jun 2002 21:08:31 -0000	1.2
@@ -74,10 +74,10 @@
 	       dmpi->w,dmpi->h,1,vf->priv->direction);
 	rotate(dmpi->planes[1],mpi->planes[1],
 	       dmpi->stride[1],mpi->stride[1],
-	       dmpi->w>>1,dmpi->h>>1,1,vf->priv->direction);
+	       dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1,vf->priv->direction);
 	rotate(dmpi->planes[2],mpi->planes[2],
 	       dmpi->stride[2],mpi->stride[2],
-	       dmpi->w>>1,dmpi->h>>1,1,vf->priv->direction);
+	       dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1,vf->priv->direction);
     } else {
 	rotate(dmpi->planes[0],mpi->planes[0],
 	       dmpi->stride[0],mpi->stride[0],

Index: vf_test.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_test.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- vf_test.c	13 Jun 2002 13:18:50 -0000	1.2
+++ vf_test.c	23 Jun 2002 21:08:31 -0000	1.3
@@ -279,8 +279,8 @@
 
     // clean
     memset(dmpi->planes[0], 0, dmpi->stride[0]*dmpi->h);
-    memset(dmpi->planes[1], 128, dmpi->stride[1]*dmpi->h>>1);
-    memset(dmpi->planes[2], 128, dmpi->stride[2]*dmpi->h>>1);
+    memset(dmpi->planes[1], 128, dmpi->stride[1]*dmpi->h>>dmpi->chroma_y_shift);
+    memset(dmpi->planes[2], 128, dmpi->stride[2]*dmpi->h>>dmpi->chroma_y_shift);
 
     if(frame%30)
     {




More information about the MPlayer-cvslog mailing list