Some Coverity fixes (#3558)

This commit is contained in:
heckflosse
2017-06-05 14:12:34 +02:00
parent 051670160b
commit 9e5ce9a99b
12 changed files with 33 additions and 22 deletions

View File

@@ -6,7 +6,7 @@
#endif
#include "sleef.c"
#include "opthelper.h"
#include <iostream>
#define pow_F(a,b) (xexpf(b*xlogf(a)))
#define DIAGONALS 5
@@ -883,7 +883,7 @@ float *EdgePreservingDecomposition::CreateIteratedBlur(float *Source, float Scal
return Blur;
}
SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Source, float Scale, float EdgeStopping, float CompressionExponent, float DetailBoost, int Iterates, int Reweightings, float *Compressed)
SSEFUNCTION void EdgePreservingDecomposition::CompressDynamicRange(float *Source, float Scale, float EdgeStopping, float CompressionExponent, float DetailBoost, int Iterates, int Reweightings)
{
if(w < 300 && h < 300) { // set number of Reweightings to zero for small images (thumbnails). We could try to find a better solution here.
Reweightings = 0;
@@ -926,12 +926,7 @@ SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Sour
//Blur. Also setup memory for Compressed (we can just use u since each element of u is used in one calculation).
float *u = CreateIteratedBlur(Source, Scale, EdgeStopping, Iterates, Reweightings);
if(Compressed == nullptr) {
Compressed = u;
}
//Apply compression, detail boost, unlogging. Compression is done on the logged data and detail boost on unlogged.
// float temp = CompressionExponent - 1.0f;
float temp;
if(DetailBoost > 0.f) {
@@ -958,8 +953,7 @@ SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Sour
cev = xexpf(LVFU(Source[i]) + LVFU(u[i]) * (tempv)) - epsv;
uev = xexpf(LVFU(u[i])) - epsv;
sourcev = xexpf(LVFU(Source[i])) - epsv;
_mm_storeu_ps( &Source[i], sourcev);
_mm_storeu_ps( &Compressed[i], cev + DetailBoostv * (sourcev - uev) );
_mm_storeu_ps( &Source[i], cev + DetailBoostv * (sourcev - uev) );
}
}
@@ -967,7 +961,7 @@ SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Sour
float ce = xexpf(Source[i] + u[i] * (temp)) - eps;
float ue = xexpf(u[i]) - eps;
Source[i] = xexpf(Source[i]) - eps;
Compressed[i] = ce + DetailBoost * (Source[i] - ue);
Source[i] = ce + DetailBoost * (Source[i] - ue);
}
#else
@@ -979,16 +973,11 @@ SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Sour
float ce = xexpf(Source[i] + u[i] * (temp)) - eps;
float ue = xexpf(u[i]) - eps;
Source[i] = xexpf(Source[i]) - eps;
Compressed[i] = ce + DetailBoost * (Source[i] - ue);
Source[i] = ce + DetailBoost * (Source[i] - ue);
}
#endif
if(Compressed != u) {
delete[] u;
}
return Compressed;
delete[] u;
}