Commit 3f28de33 authored by cclepper's avatar cclepper
Browse files

added #ifdef for PPC970/G5


git-svn-id: https://pd-gem.svn.sourceforge.net/svnroot/pd-gem/trunk/Gem@527 49b2a0ca-c541-4d49-a7ef-d785e4371512
parent 3b329658
......@@ -181,7 +181,7 @@ void pix_add :: processYUV_Altivec(imageStruct &image, imageStruct &right)
//vector signed char v;
vector unsigned char v;
}charBuffer;
//vector unsigned char c;
register vector signed short d, hiImage, loImage, YRight, UVRight, YImage, UVImage, UVTemp, YTemp;
// vector unsigned char zero = vec_splat_u8(0);
......@@ -219,18 +219,18 @@ void pix_add :: processYUV_Altivec(imageStruct &image, imageStruct &right)
//Load it into the vector unit
d = shortBuffer.v;
d = (vector signed short)vec_splat((vector signed short)d,0);
#ifndef PPC970
UInt32 prefetchSize = GetPrefetchConstant( 16, 1, 256 );
vec_dst( inData, prefetchSize, 0 );
vec_dst( rightData, prefetchSize, 1 );
#endif
for ( h=0; h<image.ysize; h++){
for (w=0; w<width; w++)
{
#ifndef PPC970
vec_dst( inData, prefetchSize, 0 );
vec_dst( rightData, prefetchSize, 1 );
#endif
//interleaved U Y V Y chars
//vec_mule UV * 2 to short vector U V U V shorts
......@@ -260,8 +260,10 @@ void pix_add :: processYUV_Altivec(imageStruct &image, imageStruct &right)
inData++;
rightData++;
}
#ifndef PPC970
vec_dss( 0 );
vec_dss( 1 );
#endif
} /*end of working altivec function */
#endif
}
......
......@@ -25,23 +25,23 @@ pix_background :: pix_background()
inletBlur = inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float, gensym("blur"));
m_Yrange = 0;
m_Urange = 0;
m_Vrange = 0;
m_blur = 0;
m_reset = 0;
m_blurH = 240;
m_blurW = 240;
m_blurBpp = 2;
size = 320 * 240 * 4;
saved = new unsigned char [size];
src=0;
for (i=0;i<size/2;i++)
{
saved[src] = 128;
saved[src+1] = 0;
src += 2;
}
m_Yrange = 0;
m_Urange = 0;
m_Vrange = 0;
m_blur = 0;
m_reset = 0;
m_blurH = 240;
m_blurW = 240;
m_blurBpp = 2;
size = 320 * 240 * 4;
saved = new unsigned char [size];
src=0;
for (i=0;i<size/2;i++)
{
saved[src] = 128;
saved[src+1] = 0;
src += 2;
}
}
/////////////////////////////////////////////////////////
......@@ -258,11 +258,11 @@ int pixsize = image.xsize * image.ysize * image.csize;
for ( i=0; i<h; i++){
for (j=0; j<w; j++)
{
#ifndef PPC970
//this function is probably memory bound on most G4's -- what else is new?
vec_dst( inData, prefetchSize, 0 );
vec_dst( rightData, prefetchSize, 1 );
#endif
//separate the U and V from Y
UVres1 = (vector unsigned short)vec_mule(one,inData[0]);
UVres2 = (vector unsigned short)vec_mule(one,rightData[0]);
......@@ -331,8 +331,10 @@ int pixsize = image.xsize * image.ysize * image.csize;
rightData++;
}
#ifndef PPC970
vec_dss(1);
vec_dss(0);
#endif
}
#endif //ALTIVEC
......
......@@ -273,18 +273,18 @@ unsigned short rightGain,imageGain;
//Load it into the vector unit
gainAdd = shortBuffer.v;
gainAdd = (vector unsigned short)vec_splat((vector unsigned short)gainAdd,0);
#ifndef PPC970
UInt32 prefetchSize = GetPrefetchConstant( 16, 1, 256 );
vec_dst( inData, prefetchSize, 0 );
vec_dst( rightData, prefetchSize, 1 );
#endif
for ( h=0; h<image.ysize; h++){
for (w=0; w<width; w++)
{
#ifndef PPC970
vec_dst( inData, prefetchSize, 0 );
vec_dst( rightData, prefetchSize, 1 );
#endif
//interleaved U Y V Y chars
//expand the UInt8's to short's
......@@ -334,9 +334,11 @@ unsigned short rightGain,imageGain;
rightData++;
}
}
#ifndef PPC970
//stop the cache streams
vec_dss( 0 );
vec_dss( 1 );
#endif
/* end of working altivec function */
#endif
......
......@@ -393,22 +393,22 @@ register int h,w,i,j,width;
Vlo = longBuffer.v;
#ifndef PPC970
//setup the cache prefetch -- A MUST!!!
UInt32 prefetchSize = GetPrefetchConstant( 16, 1, 256 );
vec_dst( inData, prefetchSize, 0 );
vec_dst( rightData, prefetchSize, 1 );
#endif
if (m_direction) {
for ( i=0; i<h; i++){
for (j=0; j<w; j++)
{
#ifndef PPC970
//this function is probably memory bound on most G4's -- what else is new?
vec_dst( inData, prefetchSize, 0 );
vec_dst( rightData, prefetchSize, 1 );
#endif
//separate the U and V from Y
......@@ -474,8 +474,10 @@ register int h,w,i,j,width;
rightData++;
}
#ifndef PPC970
vec_dss(1);
vec_dss(0);
#endif
}
}else{
/*
......
......@@ -161,22 +161,23 @@ register int h,w,i,j,width;
vector unsigned char *inData = (vector unsigned char*) image.data;
vector unsigned char *rightData = (vector unsigned char*) right.data;
#ifndef PPC970
//setup the cache prefetch -- A MUST!!!
UInt32 prefetchSize = GetPrefetchConstant( 16, 1, 256 );
vec_dst( inData, prefetchSize, 0 );
vec_dst( rightData, prefetchSize, 1 );
#endif
if (m_direction) {
for ( i=0; i<h; i++){
for (j=0; j<w; j++)
{
#ifndef PPC970
//this function is probably memory bound on most G4's -- what else is new?
vec_dst( inData, prefetchSize, 0 );
vec_dst( rightData, prefetchSize, 1 );
#endif
//separate the U and V from Y
UVres1 = (vector unsigned short)vec_mule(one,inData[0]);
UVres2 = (vector unsigned short)vec_mule(one,rightData[0]);
......@@ -204,18 +205,21 @@ register int h,w,i,j,width;
rightData++;
}
#ifndef PPC970
vec_dss(1);
vec_dss(0);
#endif
}
}else{
for ( i=0; i<h; i++){
for (j=0; j<w; j++)
{
#ifndef PPC970
vec_dst( inData, prefetchSize, 0 );
vec_dst( rightData, prefetchSize, 1 );
#endif
UVres1 = (vector unsigned short)vec_mule(one,inData[0]);
UVres2 = (vector unsigned short)vec_mule(one,rightData[0]);
......@@ -239,8 +243,10 @@ register int h,w,i,j,width;
rightData++;
}
#ifndef PPC970
vec_dss(1);
vec_dss(0);
#endif
}
......
......@@ -114,7 +114,7 @@ void pix_convolve :: calculateRGBA3x3(imageStruct &image,imageStruct &tempImg)
val8 = val9;
val9 = src+i+xsize+1;
if (i%xsize == 0 || i%xsize == xsize-1) continue;
#ifndef MACOSX
#ifndef __APPLE__
for (j=0;j<3;j++)
#else
for (j=1;j<4;j++)
......@@ -405,7 +405,7 @@ i=xsize+1;
val9 = src+i+xsize+1;
/* if (i%xsize == 0 || i%xsize == xsize-1) continue;
#ifndef MACOSX
#ifndef __APPLE__
for (j=0;j<3;j++)
#else
for (j=1;j<3;j+=2)
......@@ -473,7 +473,7 @@ void pix_convolve :: calculate3x3YUVAltivec(imageStruct &image,imageStruct &temp
register vector signed short y1,y2,y3,y4,y5,y6,y7,y8,y9,yres,uvres,hiImage,loImage;
vector signed short range,uvnone,uv128;
unsigned char *dst = (unsigned char*) image.data;
unsigned char *src = tempImg.data;
unsigned char *src = (unsigned char*) tempImg.data;
one = vec_splat_u8( 1 );
......@@ -531,11 +531,11 @@ void pix_convolve :: calculate3x3YUVAltivec(imageStruct &image,imageStruct &temp
shortBuffer.elements[0] = 128;
uv128 = shortBuffer.v;
uv128 = (vector signed short)vec_splat((vector signed short)uv128,0);
#ifndef PPC970
UInt32 prefetchSize = GetPrefetchConstant( 16, 1, 256 );
vec_dst( src, prefetchSize, 0 );
vec_dst( dst, prefetchSize, 0 );
#endif
i = xsize*2;
......@@ -543,13 +543,14 @@ void pix_convolve :: calculate3x3YUVAltivec(imageStruct &image,imageStruct &temp
//or just skip the first 2 rows ;)
for ( h=2; h<image.ysize-1; h++){
i+=2; //this gets rid of the echoes but kills the vertical edge-detects???
for (w=0; w<width; w++)
// i+=2; //this gets rid of the echoes but kills the vertical edge-detects???
i+=8;
for (w=0; w<width-1; w++)
{
#ifndef PPC970
vec_dst( src, prefetchSize, 0 );
vec_dst( dst, prefetchSize, 1 );
#endif
val1 = vec_ld(0,src+(i-xsize-2));//this might crash?
val2 = vec_ld(0,src+(i-xsize));
......@@ -622,6 +623,8 @@ void pix_convolve :: calculate3x3YUVAltivec(imageStruct &image,imageStruct &temp
//pack back to one short vector??
yhi = vec_mergeh(res1a,res1);
ylo = vec_mergel(res1a,res1);
yres = vec_packs(yhi,ylo);
......@@ -636,9 +639,10 @@ void pix_convolve :: calculate3x3YUVAltivec(imageStruct &image,imageStruct &temp
}
i = h * xsize;
#ifndef PPC970
vec_dss( 0 );
vec_dss( 1 );
#endif
} /*end of working altivec function */
......
......@@ -201,16 +201,16 @@ void pix_gain :: processYUV_Altivec(imageStruct &image)
//Load it into the vector unit
d = shortBuffer.v;
d = (vector signed short)vec_splat((vector signed short)d,0);
#ifndef PPC970
UInt32 prefetchSize = GetPrefetchConstant( 16, 1, 256 );
vec_dst( inData, prefetchSize, 0 );
#endif
for ( h=0; h<image.ysize; h++){
for (w=0; w<width; w++)
{
#ifndef PPC970
vec_dst( inData, prefetchSize, 0 );
#endif
//interleaved U Y V Y chars
//expand the UInt8's to short's
......@@ -255,7 +255,9 @@ void pix_gain :: processYUV_Altivec(imageStruct &image)
inData++;
}
#ifndef PPC970
vec_dss( 0 );
#endif
} /* end of working altivec function */
#endif
}
......
......@@ -123,21 +123,23 @@ int h,w,width;
charBuffer.c[0] = 255;
offset = charBuffer.v;
offset = (vector unsigned char) vec_splat(offset,0);
#ifndef PPC970
UInt32 prefetchSize = GetPrefetchConstant( 16, 1, 256 );
vec_dst( inData, prefetchSize, 0 );
#endif
for ( h=0; h<image.ysize; h++){
for (w=0; w<width; w++)
{
#ifndef PPC970
vec_dst( inData, prefetchSize, 0 );
#endif
inData[0]=vec_subs(offset,inData[0]);
inData++;
}
#ifndef PPC970
vec_dss( 0 );
#endif
} /*end of working altivec function */
#endif // ALTIVEC
......
......@@ -161,7 +161,7 @@ long h,w, width;
}charBuffer;
//vector unsigned char c;
register vector signed short gainAdd, hiImage, loImage,hiRight,loRight, YImage, UVImage,YRight, UVRight, UVTemp, YTemp;
register vector signed short gainAdd, hiImage, loImage,hiRight,loRight, YImage, UVImage, UVRight, UVTemp, YTemp;
register vector unsigned char zero = vec_splat_u8(0);
//vector signed short szero = vec_splat_s16(0);
register vector unsigned char c,one;
......@@ -171,7 +171,7 @@ long h,w, width;
register vector unsigned int bitshift;
vector unsigned char *inData = (vector unsigned char*) image.data;
vector unsigned char *rightData = (vector unsigned char*) right.data;
register vector unsigned char tempImage,tempRight;
register vector unsigned char tempImage;//,tempRight;
//Write the pixel (pair) to the transfer buffer
charBuffer.elements[0] = 2;
......@@ -233,18 +233,18 @@ long h,w, width;
//Load it into the vector unit
gainAdd = shortBuffer.v;
gainAdd = (vector signed short)vec_splat((vector signed short)gainAdd,0);
#ifndef PPC970
UInt32 prefetchSize = GetPrefetchConstant( 16, 1, 256 );
vec_dst( inData, prefetchSize, 0 );
vec_dst( rightData, prefetchSize, 1 );
#endif
for ( h=0; h<image.ysize; h++){
for (w=0; w<width; w++)
{
#ifndef PPC970
vec_dst( inData, prefetchSize, 0 );
vec_dst( rightData, prefetchSize, 1 );
#endif
//interleaved U Y V Y chars
//expand the UInt8's to short's
......@@ -347,16 +347,28 @@ long h,w, width;
inData++;
rightData++;
}
//stop the cache streams
vec_dss( 0 );
vec_dss( 1 );
} /* end of working altivec function */
#ifndef PPC970
//stop the cache streams
vec_dss( 0 );
vec_dss( 1 );
#endif
#endif
}
/////////////////////////////////////////////////////////
//gain converted from float to int
//
/////////////////////////////////////////////////////////
void pix_mix :: gainMess (float X, float Y)
{
imageGain = (int)(255.f * X);
rightGain = (int)(255.f * Y);
}
/////////////////////////////////////////////////////////
// static member function
//
......@@ -369,7 +381,10 @@ void pix_mix :: obj_setupCallback(t_class *classPtr)
void pix_mix :: gainCallback(void *data, t_floatarg X, t_floatarg Y)
{
GetMyClass(data)->imageGain=((int)X);
GetMyClass(data)->rightGain=((int)Y);
GetMyClass(data)->gainMess((float) X, (float) Y);
//GetMyClass(data)->imageGain=((int)X);
//GetMyClass(data)->rightGain=((int)Y);
}
......@@ -315,18 +315,18 @@ signed short rightGain,imageGain;
//Load it into the vector unit
gainAdd = shortBuffer.v;
gainAdd = (vector signed short)vec_splat((vector signed short)gainAdd,0);
#ifndef PPC970
UInt32 prefetchSize = GetPrefetchConstant( 16, 1, 256 );
vec_dst( inData, prefetchSize, 0 );
vec_dst( rightData, prefetchSize, 1 );
#endif
for ( h=0; h<image.ysize; h++){
for (w=0; w<width; w++)
{
#ifndef PPC970
vec_dst( inData, prefetchSize, 0 );
vec_dst( rightData, prefetchSize, 1 );
#endif
//interleaved U Y V Y chars
//expand the UInt8's to short's
......@@ -399,9 +399,11 @@ signed short rightGain,imageGain;
rightData++;
}
}
#ifndef PPC970
//stop the cache streams
vec_dss( 0 );
vec_dss( 1 );
#endif
/* end of working altivec function */
#endif
......
......@@ -159,16 +159,16 @@ width = image.xsize/8; //for altivec
// inData++;
// }
// }
#ifndef PPC970
UInt32 prefetchSize = GetPrefetchConstant( 16, 1, 256 );
vec_dst( inData, prefetchSize, 0 );
#endif
for ( h=0; h<image.ysize; h++){
for (w=0; w<width; w++)
{
#ifndef PPC970
vec_dst( inData, prefetchSize, 0 );
#endif
//expand the UInt8's to short's
hi = (vector signed short) vec_mergeh( zero, inData[0] );
lo = (vector signed short) vec_mergel( zero, inData[0] );
......@@ -184,8 +184,10 @@ width = image.xsize/8; //for altivec
}
}
#ifndef PPC970
vec_dss( 0 ); /*end of working altivec function */
#endif
#endif
}
/////////////////////////////////////////////////////////
......
......@@ -222,16 +222,16 @@ void pix_subtract :: processYUVAltivec(imageStruct &image, imageStruct &right)
//Load it into the vector unit
d = shortBuffer.v;
d = (vector signed short)vec_splat((vector signed short)d,0);
#ifndef PPC970
UInt32 prefetchSize = GetPrefetchConstant( 16, 1, 256 );
vec_dst( inData, prefetchSize, 0 );
#endif
for ( h=0; h<image.ysize; h++){
for (w=0; w<width; w++)
{
#ifndef PPC970
vec_dst( inData, prefetchSize, 0 );
#endif
//interleaved U Y V Y chars
//vec_mule UV * 2 to short vector U V U V shorts
......@@ -260,7 +260,9 @@ void pix_subtract :: processYUVAltivec(imageStruct &image, imageStruct &right)
inData++;
rightData++;
}
#ifndef PPC970
vec_dss( 0 );
#endif
} /*end of working altivec function */
#endif
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment