aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpix_2pdp.cpp55
1 files changed, 31 insertions, 24 deletions
diff --git a/pix_2pdp.cpp b/pix_2pdp.cpp
index 34d0a12..f8743f2 100755
--- a/pix_2pdp.cpp
+++ b/pix_2pdp.cpp
@@ -7,6 +7,7 @@
* Many thanks to IOhannes M Zmölnig
*
* Copyright (c) 2005 Georg Holzmann <grh@mur.at>
+ * parts Copyright (c) 2005 James Tittle II <tigital@mac.com>
*
*/
@@ -43,7 +44,7 @@ void pix_2pdp::processImage(imageStruct &image)
void pix_2pdp::bangMess()
{
t_int psize, px, py;
- short int *pY, *pU, *pV;
+ short int *pY, *pY2, *pU, *pV;
unsigned char g1,g2,g3,g4;
t_int helper;
@@ -56,6 +57,7 @@ void pix_2pdp::bangMess()
m_data = (short int *)pdp_packet_data(m_packet0);
pY = m_data;
+ pY2 = m_data + gem_xsize;
pV = m_data+psize;
pU = m_data+psize+(psize>>2);
@@ -64,6 +66,8 @@ void pix_2pdp::bangMess()
// RGB
case GL_RGB:
case GL_RGBA:
+ case GL_BGR:
+ case GL_BGRA:
for ( py=0; py<gem_ysize; py++)
{
for ( px=0; px<gem_xsize; px++)
@@ -88,28 +92,31 @@ void pix_2pdp::bangMess()
// YUV
case GL_YUV422_GEM:
- for ( py=0; py<gem_ysize; py++)
- {
- for ( px=0; px<gem_xsize; px++)
- {
- helper = py*gem_xsize*gem_csize + px*gem_csize;
- g1=gem_image[helper+chU]; // U
- g2=gem_image[helper+chY0]; // Y0
- g3=gem_image[helper+chV]; // V
- g4=gem_image[helper+chY1]; // Y1
-
- if(px%2==0)
- *pY = g2 << 7;
- else
- *pY = g4 << 7;
- pY++;
-
- *pU = (g1-128) << 8;
- *pV = (g3-128) << 8;
- if ( (px%2==0) && (py%2==0) )
- pV++; pU++;
- }
- }
+ int row=gem_ysize>>1;
+ int cols=gem_xsize>>1;
+ short u,v;
+ unsigned char *pixel = gem_image;
+ unsigned char *pixel2 = gem_image + gem_xsize * gem_csize;
+ while (row--){
+ int col=cols;
+ while(col--){
+ u=(pixel[0]-128)<<8; v=(pixel[2]-128)<<8;
+ *pU = u;
+ *pY++ = (pixel[1])<<7;
+ *pV = v;
+ *pY++ = (pixel[3])<<7;
+ *pU = u;
+ *pY2++ = (pixel2[1])<<7;
+ *pV = v;
+ *pY2++ = (pixel2[3])<<7;
+ pixel+=4;
+ pixel2+=4;
+ pU++; pV++;
+ }
+ pixel += gem_xsize * gem_csize;
+ pixel2 += gem_xsize * gem_csize;
+ pY += gem_xsize; pY2 += gem_xsize;
+ }
pdp_packet_pass_if_valid(m_pdpoutlet, &m_packet0);
break;
@@ -139,7 +146,7 @@ void pix_2pdp::bangMess()
void pix_2pdp::obj_setupCallback(t_class *classPtr)
{
- post( "pix_2pdp : a bridge between a Gem pix and PDP/PiDiP, Georg Holzmann 2005 <grh@mur.at>" );
+ post( "pix_2pdp : a bridge between a Gem pix and PDP/PiDiP, Georg Holzmann 2005 <grh@mur.at> & tigital 2005 <tigital@mac.com>" );
class_addmethod(classPtr, (t_method)&pix_2pdp::bangMessCallback,
gensym("bang"), A_NULL);
}