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

reduced scope of variables

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