Merge branch 'pfcorrect-cleanup' of https://github.com/Beep6581/RawTherapee into pfcorrect-cleanup
This commit is contained in:
commit
b439719cc5
@ -92,7 +92,7 @@ void RawImageSource::eahd_demosaic ()
|
||||
|
||||
// end of cielab preparation
|
||||
|
||||
const JaggedArray<float>
|
||||
JaggedArray<float>
|
||||
rh (W, 3), gh (W, 4), bh (W, 3),
|
||||
rv (W, 3), gv (W, 4), bv (W, 3),
|
||||
lLh (W, 3), lah (W, 3), lbh (W, 3),
|
||||
@ -497,7 +497,7 @@ void RawImageSource::hphd_demosaic ()
|
||||
plistener->setProgress (0.0);
|
||||
}
|
||||
|
||||
const JaggedArray<float> hpmap (W, H, true);
|
||||
JaggedArray<float> hpmap (W, H, true);
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel
|
||||
|
@ -19,6 +19,8 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "noncopyable.h"
|
||||
|
||||
namespace rtengine
|
||||
@ -26,60 +28,46 @@ namespace rtengine
|
||||
|
||||
// These emulate a jagged array, but use only 2 allocations instead of 1 + H.
|
||||
|
||||
template<class T>
|
||||
inline T** const allocJaggedArray (const int W, const int H, const bool initZero = false)
|
||||
{
|
||||
T** const a = new T*[H];
|
||||
a[0] = new T[H * W];
|
||||
|
||||
for (int i = 1; i < H; ++i) {
|
||||
a[i] = a[i - 1] + W;
|
||||
}
|
||||
|
||||
if (initZero) {
|
||||
std::memset(a[0], 0, sizeof(T) * W * H);
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void freeJaggedArray (T** const a)
|
||||
{
|
||||
delete [] a[0];
|
||||
delete [] a;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
template<typename T>
|
||||
class JaggedArray :
|
||||
public NonCopyable
|
||||
{
|
||||
public:
|
||||
JaggedArray (const int W, const int H, const bool initZero = false)
|
||||
JaggedArray(std::size_t width, std::size_t height, bool init_zero = false) :
|
||||
array(
|
||||
[width, height, init_zero]() -> T**
|
||||
{
|
||||
a = allocJaggedArray<T> (W, H, initZero);
|
||||
}
|
||||
~JaggedArray ()
|
||||
{
|
||||
if (a) {
|
||||
freeJaggedArray<T> (a);
|
||||
a = nullptr;
|
||||
}
|
||||
T** const res = new T*[height];
|
||||
res[0] = new T[height * width];
|
||||
|
||||
for (std::size_t i = 1; i < height; ++i) {
|
||||
res[i] = res[i - 1] + width;
|
||||
}
|
||||
|
||||
operator T** const () const
|
||||
if (init_zero) {
|
||||
std::memset(res[0], 0, sizeof(T) * width * height);
|
||||
}
|
||||
|
||||
return res;
|
||||
}()
|
||||
)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
~JaggedArray ()
|
||||
{
|
||||
delete[] array[0];
|
||||
delete[] array;
|
||||
}
|
||||
|
||||
operator T** ()
|
||||
{
|
||||
return array;
|
||||
}
|
||||
|
||||
private:
|
||||
T** a;
|
||||
T** const array;
|
||||
|
||||
};
|
||||
|
||||
// Declared but not defined to prevent
|
||||
// explicitly freeing a JaggedArray<T> implicitly cast to T**.
|
||||
template<class T>
|
||||
void freeJaggedArray (JaggedArray<T>&);
|
||||
|
||||
} // rtengine
|
||||
|
@ -124,7 +124,7 @@ void SHMap::update (Imagefloat* img, double radius, double lumi[3], bool hq, int
|
||||
rangefn[lutSize - 1] = 1e-15f;
|
||||
|
||||
// We need one temporary buffer
|
||||
const JaggedArray<float> buffer (W, H);
|
||||
JaggedArray<float> buffer (W, H);
|
||||
|
||||
// the final result has to be in map
|
||||
// for an even number of levels that means: map => buffer, buffer => map
|
||||
@ -255,7 +255,7 @@ void SHMap::updateL (float** L, double radius, bool hq, int skip)
|
||||
//printf("lut=%d rf5=%f rfm=%f\n thre=%f",lutSize, rangefn[5],rangefn[lutSize-10],thresh );
|
||||
|
||||
// We need one temporary buffer
|
||||
const JaggedArray<float> buffer (W, H);
|
||||
JaggedArray<float> buffer (W, H);
|
||||
|
||||
// the final result has to be in map
|
||||
// for an even number of levels that means: map => buffer, buffer => map
|
||||
|
Loading…
x
Reference in New Issue
Block a user