LUT.h : fix cppcheck warnings

This commit is contained in:
Ingo Weyrich 2021-02-14 17:48:10 +01:00
parent 53e86a7433
commit c3df0b1d86

View File

@ -110,7 +110,7 @@ public:
/// The user have to handle it itself, even if some method can (re)initialize it /// The user have to handle it itself, even if some method can (re)initialize it
bool dirty; bool dirty;
LUT(int s, int flags = LUT_CLIP_BELOW | LUT_CLIP_ABOVE, bool initZero = false) explicit LUT(int s, int flags = LUT_CLIP_BELOW | LUT_CLIP_ABOVE, bool initZero = false)
{ {
#ifndef NDEBUG #ifndef NDEBUG
@ -141,7 +141,7 @@ public:
} }
} }
LUT(const std::vector<T>& input, int flags = LUT_CLIP_BELOW | LUT_CLIP_ABOVE) : explicit LUT(const std::vector<T>& input, int flags = LUT_CLIP_BELOW | LUT_CLIP_ABOVE) :
maxs(input.size() - 2), maxs(input.size() - 2),
maxsf(maxs), maxsf(maxs),
data(new T[input.size() + 3]), // Add a few extra elements so [](vfloat) won't access out-of-bounds memory. data(new T[input.size() + 3]), // Add a few extra elements so [](vfloat) won't access out-of-bounds memory.
@ -362,11 +362,11 @@ public:
// of [values[0][0] ... values[3][0]] and the second [values[0][1] ... values[3][1]]. // of [values[0][0] ... values[3][0]] and the second [values[0][1] ... values[3][1]].
__m128i temp0 = _mm_unpacklo_epi32(values[0], values[1]); __m128i temp0 = _mm_unpacklo_epi32(values[0], values[1]);
__m128i temp1 = _mm_unpacklo_epi32(values[2], values[3]); __m128i temp1 = _mm_unpacklo_epi32(values[2], values[3]);
vfloat lower = _mm_castsi128_ps(_mm_unpacklo_epi64(temp0, temp1)); vfloat lowerVal = _mm_castsi128_ps(_mm_unpacklo_epi64(temp0, temp1));
vfloat upper = _mm_castsi128_ps(_mm_unpackhi_epi64(temp0, temp1)); vfloat upperVal = _mm_castsi128_ps(_mm_unpackhi_epi64(temp0, temp1));
vfloat diff = vmaxf(ZEROV, indexv) - _mm_cvtepi32_ps(indexes); vfloat diff = vmaxf(ZEROV, indexv) - _mm_cvtepi32_ps(indexes);
return vintpf(diff, upper, lower); return vintpf(diff, upperVal, lowerVal);
} }
// NOTE: This version requires LUTs which clip at upper and lower bounds // NOTE: This version requires LUTs which clip at upper and lower bounds
@ -394,11 +394,11 @@ public:
// of [values[0][0] ... values[3][0]] and the second [values[0][1] ... values[3][1]]. // of [values[0][0] ... values[3][0]] and the second [values[0][1] ... values[3][1]].
__m128i temp0 = _mm_unpacklo_epi32(values[0], values[1]); __m128i temp0 = _mm_unpacklo_epi32(values[0], values[1]);
__m128i temp1 = _mm_unpacklo_epi32(values[2], values[3]); __m128i temp1 = _mm_unpacklo_epi32(values[2], values[3]);
vfloat lower = _mm_castsi128_ps(_mm_unpacklo_epi64(temp0, temp1)); vfloat lowerVal = _mm_castsi128_ps(_mm_unpacklo_epi64(temp0, temp1));
vfloat upper = _mm_castsi128_ps(_mm_unpackhi_epi64(temp0, temp1)); vfloat upperVal = _mm_castsi128_ps(_mm_unpackhi_epi64(temp0, temp1));
vfloat diff = vclampf(indexv, ZEROV, sizev) - _mm_cvtepi32_ps(indexes); // this automagically uses ZEROV in case indexv is NaN vfloat diff = vclampf(indexv, ZEROV, sizev) - _mm_cvtepi32_ps(indexes); // this automagically uses ZEROV in case indexv is NaN
return vintpf(diff, upper, lower); return vintpf(diff, upperVal, lowerVal);
} }
// NOTE: This version requires LUTs which do not clip at upper and lower bounds // NOTE: This version requires LUTs which do not clip at upper and lower bounds
@ -425,11 +425,11 @@ public:
// of [values[0][0] ... values[3][0]] and the second [values[0][1] ... values[3][1]]. // of [values[0][0] ... values[3][0]] and the second [values[0][1] ... values[3][1]].
__m128i temp0 = _mm_unpacklo_epi32(values[0], values[1]); __m128i temp0 = _mm_unpacklo_epi32(values[0], values[1]);
__m128i temp1 = _mm_unpacklo_epi32(values[2], values[3]); __m128i temp1 = _mm_unpacklo_epi32(values[2], values[3]);
vfloat lower = _mm_castsi128_ps(_mm_unpacklo_epi64(temp0, temp1)); vfloat lowerVal = _mm_castsi128_ps(_mm_unpacklo_epi64(temp0, temp1));
vfloat upper = _mm_castsi128_ps(_mm_unpackhi_epi64(temp0, temp1)); vfloat upperVal = _mm_castsi128_ps(_mm_unpackhi_epi64(temp0, temp1));
vfloat diff = indexv - _mm_cvtepi32_ps(indexes); vfloat diff = indexv - _mm_cvtepi32_ps(indexes);
return vintpf(diff, upper, lower); return vintpf(diff, upperVal, lowerVal);
} }
// vectorized LUT access with integer indices. Clips at lower and upper bounds // vectorized LUT access with integer indices. Clips at lower and upper bounds