Commit 0ff08fac authored by IOhannes m zmölnig's avatar IOhannes m zmölnig
Browse files

reduced scope of variables

parent b0108ee2
...@@ -1239,31 +1239,28 @@ void filmDS::setProperties(gem::Properties&props) ...@@ -1239,31 +1239,28 @@ void filmDS::setProperties(gem::Properties&props)
void filmDS::getProperties(gem::Properties&props) void filmDS::getProperties(gem::Properties&props)
{ {
std::vector<std::string> keys=props.keys(); std::vector<std::string> keys=props.keys();
gem::any value;
double d;
unsigned int i=0;
if(player && player->isLoaded()) { if(player && player->isLoaded()) {
for(i=0; i<keys.size(); i++) { for(size_t i=0; i<keys.size(); i++) {
std::string key=keys[i]; std::string key=keys[i];
props.erase(key); props.erase(key);
if("fps"==key) { if("fps"==key) {
d=1./player->getAverageTimePerFrame(); double d=1./player->getAverageTimePerFrame();
value=d; gem::any value=d;
props.set(key, value); props.set(key, value);
} }
if("frames"==key) { if("frames"==key) {
d=player->getApproximateNoFrames(); double d=player->getApproximateNoFrames();
value=(int)(d+0.5); gem::any value=(int)(d+0.5);
props.set(key, value); props.set(key, value);
} }
if("width"==key) { if("width"==key) {
d=player->getWidth(); double d=player->getWidth();
value=d; gem::any value=d;
props.set(key, value); props.set(key, value);
} }
if("height"==key) { if("height"==key) {
d=player->getHeight(); double d=player->getHeight();
value=d; gem::any value=d;
props.set(key, value); props.set(key, value);
} }
} }
......
...@@ -649,20 +649,18 @@ void model :: createVBO(void) ...@@ -649,20 +649,18 @@ void model :: createVBO(void)
void model :: copyArray(const std::vector<std::vector<float> >&tab, void model :: copyArray(const std::vector<std::vector<float> >&tab,
gem::VertexBuffer&vb) gem::VertexBuffer&vb)
{ {
unsigned int size(0), i(0), npts(0);
//~std::vector<std::vector<float> > tab = m_loader->getVector(vectorName); //~std::vector<std::vector<float> > tab = m_loader->getVector(vectorName);
if ( tab.empty() ) { if ( tab.empty() ) {
return; return;
} }
size=tab.size(); unsigned int size=tab.size();
if(size!=vb.size) { if(size!=vb.size) {
vb.resize(size); vb.resize(size);
m_size_change_flag=true; m_size_change_flag=true;
} }
for ( i = 0 ; i < size ; i++ ) { for ( unsigned int i = 0 ; i < size ; i++ ) {
for ( int j=0 ; j< std::min(vb.dimen,(unsigned int)tab[i].size()) ; j++) { for ( int j=0 ; j< std::min(vb.dimen,(unsigned int)tab[i].size()) ; j++) {
vb.array[i*vb.dimen + j] = tab[i][j]; vb.array[i*vb.dimen + j] = tab[i][j];
} }
......
...@@ -306,16 +306,13 @@ void rubber :: rubber_dynamics(void) ...@@ -306,16 +306,13 @@ void rubber :: rubber_dynamics(void)
int rubber :: rubber_grab(void) int rubber :: rubber_grab(void)
{ {
float dx[2];
float d;
float min_d=0; float min_d=0;
int min_i=0; int min_i=0;
int i;
for (i = 0; i < m_grid_sizeX*m_grid_sizeY; i++) { for (int i = 0; i < m_grid_sizeX*m_grid_sizeY; i++) {
dx[0] = m_mass[i].x[0] - ctrX; float dx0 = m_mass[i].x[0] - ctrX;
dx[1] = m_mass[i].x[1] - ctrY; float dx1 = m_mass[i].x[1] - ctrY;
d = sqrt(dx[0]*dx[0] + dx[1]*dx[1]); float d = sqrt(dx0*dx0 + dx1*dx1);
if (i == 0 || d < min_d) { if (i == 0 || d < min_d) {
min_i = i; min_i = i;
min_d = d; min_d = d;
......
...@@ -321,10 +321,6 @@ void pix_convolve :: calculate3x3YUV(imageStruct &image, ...@@ -321,10 +321,6 @@ void pix_convolve :: calculate3x3YUV(imageStruct &image,
calculate3x3YUVAltivec(image,tempImg); calculate3x3YUVAltivec(image,tempImg);
return; return;
#else #else
int i;
int j;
int k;
int xsize = tempImg.xsize -1; int xsize = tempImg.xsize -1;
int ysize = tempImg.ysize -1; int ysize = tempImg.ysize -1;
int size = xsize*ysize - xsize-1; int size = xsize*ysize - xsize-1;
...@@ -348,7 +344,7 @@ void pix_convolve :: calculate3x3YUV(imageStruct &image, ...@@ -348,7 +344,7 @@ void pix_convolve :: calculate3x3YUV(imageStruct &image,
range =m_irange; range =m_irange;
if (m_chroma) { if (m_chroma) {
i = xsize; int i = xsize;
#ifdef i386 #ifdef i386
register unsigned char val1 = 0; register unsigned char val1 = 0;
...@@ -376,8 +372,8 @@ void pix_convolve :: calculate3x3YUV(imageStruct &image, ...@@ -376,8 +372,8 @@ void pix_convolve :: calculate3x3YUV(imageStruct &image,
//messed up looking on x86 //messed up looking on x86
i=xsize+2; i=xsize+2;
for (k=1; k<ysize; k++) { for (int k=1; k<ysize; k++) {
for (j=1; j<xsize; j++) { for (int j=1; j<xsize; j++) {
//load furthest value first...the rest should be in cache //load furthest value first...the rest should be in cache
val7 = val8; val7 = val8;
...@@ -416,8 +412,7 @@ void pix_convolve :: calculate3x3YUV(imageStruct &image, ...@@ -416,8 +412,7 @@ void pix_convolve :: calculate3x3YUV(imageStruct &image,
i=k*tempImg.xsize; i=k*tempImg.xsize;
} }
} else { } else {
int i = xsize;
i = xsize;
//make these temp register vars rather than pointers? //make these temp register vars rather than pointers?
short* val1 = 0; short* val1 = 0;
...@@ -441,8 +436,8 @@ void pix_convolve :: calculate3x3YUV(imageStruct &image, ...@@ -441,8 +436,8 @@ void pix_convolve :: calculate3x3YUV(imageStruct &image,
register short* val9 = src+i+xsize+1; //val9 = src[i+xsize+1];*/ register short* val9 = src+i+xsize+1; //val9 = src[i+xsize+1];*/
//int res; //int res;
// for (i=xsize+1;i<size;i++) { // for (i=xsize+1;i<size;i++) {
for (k=1; k<ysize; k++) { for (int k=1; k<ysize; k++) {
for (j=1; j<xsize; j++) { for (int j=1; j<xsize; j++) {
val1 = val2; val1 = val2;
val2 = val3; val2 = val3;
val3 = src+i-xsize+1; val3 = src+i-xsize+1;
......
...@@ -563,9 +563,8 @@ void pix_dot :: sampxy_table_init() ...@@ -563,9 +563,8 @@ void pix_dot :: sampxy_table_init()
void pix_dot :: yuv_init() void pix_dot :: yuv_init()
{ {
static int initialized = 0; static int initialized = 0;
int i;
if(!initialized) { if(!initialized) {
for(i=20; i<256; i++) { for(size_t i=20; i<256; i++) {
#if 0 #if 0
R2Y[i] = static_cast<int>(0.257f*i); R2Y[i] = static_cast<int>(0.257f*i);
G2Y[i] = static_cast<int>(0.504f*i); G2Y[i] = static_cast<int>(0.504f*i);
......
...@@ -69,15 +69,14 @@ void pix_gain :: processRGBAImage(imageStruct &image) ...@@ -69,15 +69,14 @@ void pix_gain :: processRGBAImage(imageStruct &image)
{ {
int datasize = image.xsize * image.ysize; int datasize = image.xsize * image.ysize;
unsigned char *pixels = image.data; unsigned char *pixels = image.data;
short R,G,B,A; short R = static_cast<int>(256 * m_gain[chRed]);
int red,green,blue; short G = static_cast<int>(256 * m_gain[chGreen]);
R = static_cast<int>(256 * m_gain[chRed]); short B = static_cast<int>(256 * m_gain[chBlue]);
G = static_cast<int>(256 * m_gain[chGreen]); short A = static_cast<int>(256 * m_gain[chAlpha]);
B = static_cast<int>(256 * m_gain[chBlue]);
A = static_cast<int>(256 * m_gain[chAlpha]);
if(m_saturate) { if(m_saturate) {
while(datasize--) { while(datasize--) {
int red,green,blue;
red = (pixels[chRed ] * R)>>8; red = (pixels[chRed ] * R)>>8;
pixels[chRed ] = CLAMP(red); pixels[chRed ] = CLAMP(red);
green = (pixels[chGreen] * G)>>8; green = (pixels[chGreen] * G)>>8;
......
...@@ -113,14 +113,8 @@ void pix_motionblur :: processRGBAImage(imageStruct &image) ...@@ -113,14 +113,8 @@ void pix_motionblur :: processRGBAImage(imageStruct &image)
} }
void pix_motionblur :: processGrayImage(imageStruct &image) void pix_motionblur :: processGrayImage(imageStruct &image)
{ {
int h,w,height,width;
long src;
register int G, G1; //too many for x86? i really don't know or care
int rightGain,imageGain;
unsigned char *pixels=image.data;
int Gray; int Gray;
src = 0;
Gray=chGray; Gray=chGray;
unsigned char *saved = m_savedImage.data; unsigned char *saved = m_savedImage.data;
...@@ -134,15 +128,17 @@ void pix_motionblur :: processGrayImage(imageStruct &image) ...@@ -134,15 +128,17 @@ void pix_motionblur :: processGrayImage(imageStruct &image)
} }
saved=m_savedImage.data; saved=m_savedImage.data;
rightGain = m_blur1; int rightGain = m_blur1;
imageGain = m_blur0; int imageGain = m_blur0;
height = image.ysize; int height = image.ysize;
width = image.xsize; int width = image.xsize;
unsigned char *pixels=image.data;
for (h=0; h<height; h++) { long src = 0;
for(w=0; w<width; w++) { for (int h=0; h<height; h++) {
G = pixels[src+chGray]; for(int w=0; w<width; w++) {
G1 = saved[src+chGray]; int G = pixels[src+chGray];
int G1 = saved[src+chGray];
G = G * imageGain; G = G * imageGain;
G1 = G1 * rightGain; G1 = G1 * rightGain;
...@@ -171,7 +167,6 @@ void pix_motionblur :: processYUVImage(imageStruct &image) ...@@ -171,7 +167,6 @@ void pix_motionblur :: processYUVImage(imageStruct &image)
} }
saved=m_savedImage.data; saved=m_savedImage.data;
int h,w,hlength;
register long src,dst; register long src,dst;
register int rightGain,imageGain; register int rightGain,imageGain;
...@@ -194,14 +189,14 @@ void pix_motionblur :: processYUVImage(imageStruct &image) ...@@ -194,14 +189,14 @@ void pix_motionblur :: processYUVImage(imageStruct &image)
rightGain = m_blur1; rightGain = m_blur1;
imageGain = m_blur0; imageGain = m_blur0;
hlength = image.xsize/2; int hlength = image.xsize/2;
//unroll this, add register temps and schedule the ops better to remove the //unroll this, add register temps and schedule the ops better to remove the
//data dependencies //data dependencies
// JMZ: i am not sure whether i really understand what is going on here // JMZ: i am not sure whether i really understand what is going on here
for (h=0; h<image.ysize-1; h++) { for (int h=0; h<image.ysize-1; h++) {
for(w=0; w<hlength; w++) { for(int w=0; w<hlength; w++) {
u = loadU - 128; u = loadU - 128;
u1 = loadU1 >> 8; u1 = loadU1 >> 8;
v = loadV - 128; v = loadV - 128;
...@@ -325,10 +320,7 @@ void pix_motionblur :: processGrayMMX(imageStruct &image) ...@@ -325,10 +320,7 @@ void pix_motionblur :: processGrayMMX(imageStruct &image)
/* start of optimized motionblur */ /* start of optimized motionblur */
void pix_motionblur :: processYUVAltivec(imageStruct &image) void pix_motionblur :: processYUVAltivec(imageStruct &image)
{ {
int h,w,width;
signed short rightGain,imageGain;
unsigned char *saved = m_savedImage.data; unsigned char *saved = m_savedImage.data;
m_savedImage.xsize=image.xsize; m_savedImage.xsize=image.xsize;
m_savedImage.ysize=image.ysize; m_savedImage.ysize=image.ysize;
m_savedImage.setCsizeByFormat(image.format); m_savedImage.setCsizeByFormat(image.format);
...@@ -338,14 +330,14 @@ void pix_motionblur :: processYUVAltivec(imageStruct &image) ...@@ -338,14 +330,14 @@ void pix_motionblur :: processYUVAltivec(imageStruct &image)
} }
saved=m_savedImage.data; saved=m_savedImage.data;
width = image.xsize/8; int width = image.xsize/8;
/* /*
// hmm: why does it read 235 ? // hmm: why does it read 235 ?
rightGain = (signed short)(235. * m_motionblur); rightGain = (signed short)(235. * m_motionblur);
imageGain = (signed short) (255. - (235. * m_motionblur)); imageGain = (signed short) (255. - (235. * m_motionblur));
*/ */
rightGain = m_blur1; signed short rightGain = m_blur1;
imageGain = m_blur0; signed short imageGain = m_blur0;
union { union {
signed short elements[8]; signed short elements[8];
...@@ -369,7 +361,6 @@ void pix_motionblur :: processYUVAltivec(imageStruct &image) ...@@ -369,7 +361,6 @@ void pix_motionblur :: processYUVAltivec(imageStruct &image)
vector unsigned char *inData = (vector unsigned char*) image.data; vector unsigned char *inData = (vector unsigned char*) image.data;
vector unsigned char *rightData = (vector unsigned char*) saved; vector unsigned char *rightData = (vector unsigned char*) saved;
shortBuffer.elements[0] = 128; shortBuffer.elements[0] = 128;
shortBuffer.elements[1] = 0; shortBuffer.elements[1] = 0;
shortBuffer.elements[2] = 128; shortBuffer.elements[2] = 128;
...@@ -413,8 +404,8 @@ void pix_motionblur :: processYUVAltivec(imageStruct &image) ...@@ -413,8 +404,8 @@ void pix_motionblur :: processYUVAltivec(imageStruct &image)
loadImage = inData[0]; loadImage = inData[0];
loadRight = rightData[0]; loadRight = rightData[0];
for ( h=0; h<image.ysize; h++) { for (int h=0; h<image.ysize; h++) {
for (w=0; w<width; w++) { for (int w=0; w<width; w++) {
# ifndef PPC970 # ifndef PPC970
vec_dst( inData, prefetchSize, 0 ); vec_dst( inData, prefetchSize, 0 );
vec_dst( rightData, prefetchSize, 1 ); vec_dst( rightData, prefetchSize, 1 );
......
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