[PD-cvs] externals/gem2pdp pix_2pdp.cpp,1.5,1.6 pix_2pdp.h,1.2,1.3

Jamie Tittle tigital at users.sourceforge.net
Fri Mar 17 04:08:18 CET 2006


Update of /cvsroot/pure-data/externals/gem2pdp
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4831

Modified Files:
	pix_2pdp.cpp pix_2pdp.h 
Log Message:
added YUV422_to_YV12_altivec()

Index: pix_2pdp.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/gem2pdp/pix_2pdp.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** pix_2pdp.cpp	22 Dec 2005 16:39:28 -0000	1.5
--- pix_2pdp.cpp	17 Mar 2006 03:08:15 -0000	1.6
***************
*** 8,12 ****
   *
   *  Copyright (c) 2005 Georg Holzmann <grh at mur.at>
!  *  parts Copyright (c) 2005 James Tittle II <tigital at mac.com>
   *
   */
--- 8,12 ----
   *
   *  Copyright (c) 2005 Georg Holzmann <grh at mur.at>
!  *  parts Copyright (c) 2005-2006 James Tittle II <tigital at mac.com>
   *
   */
***************
*** 96,99 ****
--- 96,102 ----
        // YUV
        case GL_YUV422_GEM: {
+ #ifdef __VEC__
+  		YUV422_to_YV12_altivec(pY, pY2, pV, pU, psize);
+ #else
  	    int row=gem_ysize>>1;
  		int cols=gem_xsize>>1;
***************
*** 101,105 ****
  		unsigned char *pixel = gem_image;
  		unsigned char *pixel2 = gem_image + gem_xsize * gem_csize;
!                 const int row_length = gem_xsize* gem_csize;
                  if(0==gem_upsidedown){
                    pixel=gem_image+row_length * (gem_ysize-1);
--- 104,108 ----
  		unsigned char *pixel = gem_image;
  		unsigned char *pixel2 = gem_image + gem_xsize * gem_csize;
!         const int row_length = gem_xsize* gem_csize;
                  if(0==gem_upsidedown){
                    pixel=gem_image+row_length * (gem_ysize-1);
***************
*** 114,120 ****
  				*pV = v;
  				*pY++ = (pixel[3])<<7;
- 				*pU = u;
  				*pY2++ = (pixel2[1])<<7;
- 				*pV = v;
  				*pY2++ = (pixel2[3])<<7;
  				pixel+=4;
--- 117,121 ----
***************
*** 131,134 ****
--- 132,136 ----
                    pY += gem_xsize; pY2 += gem_xsize;
  		}
+ #endif // __VEC__
          pdp_packet_pass_if_valid(m_pdpoutlet, &m_packet0);
          } break;
***************
*** 159,162 ****
--- 161,236 ----
  }
  
+ #ifdef __VEC__
+ void pix_2pdp :: YUV422_to_YV12_altivec(short*pY, short*pY2, short*pU, short*pV, size_t psize)
+ {
+   // UYVY UYVY UYVY UYVY
+   vector unsigned char *pixels1=(vector unsigned char *)gem_image;
+   vector unsigned char *pixels2=(vector unsigned char *)(gem_image+(gem_xsize*2));
+   // PDP packet to be filled:
+   // first Y plane
+   vector signed short *py1 = (vector signed short *)pY;
+   // 2nd Y pixel
+   vector signed short *py2 = (vector signed short *)pY2;
+   // U plane
+   vector signed short *pCr = (vector signed short *)pU;
+   // V plane
+   vector signed short *pCb = (vector signed short *)pV;
+   vector signed short uvSub = (vector signed short)( 128, 128, 128, 128,
+ 													 128, 128, 128, 128 );
+   vector signed short yShift = (vector signed short)( 7, 7, 7, 7, 7, 7, 7, 7 );
+   vector signed short uvShift = (vector signed short)( 8, 8, 8, 8, 8, 8, 8, 8 );
+   
+   vector signed short tempY1, tempY2, tempY3, tempY4,
+ 		tempUV1, tempUV2, tempUV3, tempUV4, tempUV5, tempUV6;
+ 
+   vector unsigned char uvPerm = (vector unsigned char)( 16, 0, 17, 4, 18,  8, 19, 12,   // u0..u3
+   														20, 2, 21, 6, 22, 10, 23, 14 ); // v0..v3
+ 
+   vector unsigned char uPerm = (vector unsigned char)( 0, 1, 2, 3, 4, 5, 6, 7, 
+ 													   16,17,18,19,20,21,22,23);
+   vector unsigned char vPerm = (vector unsigned char)( 8, 9, 10,11,12,13,14,15,
+ 													   24,25,26,27,28,29,30,31);
+   
+   vector unsigned char yPerm = (vector unsigned char)( 16, 1, 17,  3, 18,  5, 19,  7, // y0..y3
+ 													   20, 9, 21, 11, 23, 13, 25, 15);// y4..y7
+   vector unsigned char zeroVec = (vector unsigned char)(0);
+   
+   int row=gem_ysize>>1;
+   int cols=gem_xsize>>4;
+   
+   while(row--){
+     int col=cols;
+     while(col--){
+       tempUV1 = (vector signed short) vec_perm( *pixels1, zeroVec, uvPerm);
+       tempY1  = (vector signed short) vec_perm( *pixels1, zeroVec, yPerm);
+       tempY2  = (vector signed short) vec_perm( *pixels2, zeroVec, yPerm);
+ 	  pixels1++;pixels2++;
+       
+       tempUV2 = (vector signed short) vec_perm( *pixels1, zeroVec, uvPerm);
+       tempY3  = (vector signed short) vec_perm( *pixels1, zeroVec, yPerm);
+       tempY4  = (vector signed short) vec_perm( *pixels2, zeroVec, yPerm);
+ 	  pixels1++;pixels2++;
+   
+ 	  tempUV3 = vec_sub( tempUV1, uvSub );
+ 	  tempUV4 = vec_sub( tempUV2, uvSub );
+ 	  tempUV5 = vec_sl( tempUV3, uvShift );
+ 	  tempUV6 = vec_sl( tempUV4, uvShift );
+ 	  
+ 	  *pCb = vec_perm( tempUV5, tempUV6, uPerm );
+ 	  *pCr = vec_perm( tempUV5, tempUV6, vPerm );
+ 	  pCr++; pCb++;
+ 
+ 	  *py1++ = vec_sl( tempY1, yShift);
+       *py2++ = vec_sl( tempY2, yShift);
+       *py1++ = vec_sl( tempY3, yShift);
+       *py2++ = vec_sl( tempY4, yShift);      
+ 	}
+ 
+ 	py1+=(gem_xsize>>3); py2+=(gem_xsize>>3);
+ 	pixels1+=(gem_xsize*2)>>4; pixels2+=(gem_xsize*2)>>4;
+   }
+ }
+ #endif
+ 
  void pix_2pdp::obj_setupCallback(t_class *classPtr)
  {

Index: pix_2pdp.h
===================================================================
RCS file: /cvsroot/pure-data/externals/gem2pdp/pix_2pdp.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** pix_2pdp.h	11 Oct 2005 15:34:35 -0000	1.2
--- pix_2pdp.h	17 Mar 2006 03:08:15 -0000	1.3
***************
*** 37,40 ****
--- 37,45 ----
      virtual void bangMess(void);
      
+     // altivec processing
+ #ifdef __VEC__
+     virtual void YUV422_to_YV12_altivec(short*pY, short*pY2, short*pU, short*pV, size_t psize);
+ #endif
+ 
      // the pixBlock with the current image
      unsigned char *gem_image;





More information about the Pd-cvs mailing list