Cppcheck: some fixes
This commit is contained in:
@@ -156,11 +156,9 @@ void RawImageSource::CA_correct_RT(const double cared, const double cablue, cons
|
||||
const int vblsz = ceil((float)(height + border2) / (ts - border2) + 2 + vz1);
|
||||
const int hblsz = ceil((float)(width + border2) / (ts - border2) + 2 + hz1);
|
||||
|
||||
char *buffer1 = (char *) calloc(vblsz * hblsz * (2 * 2 + 1), sizeof(float));
|
||||
|
||||
//block CA shift values and weight assigned to block
|
||||
float *blockwt = (float*)buffer1;
|
||||
float (*blockshifts)[2][2] = (float (*)[2][2])(buffer1 + (vblsz * hblsz * sizeof(float)));
|
||||
float* const blockwt = static_cast<float*>(calloc(vblsz * hblsz * (2 * 2 + 1), sizeof(float)));
|
||||
float (*blockshifts)[2][2] = (float (*)[2][2])(blockwt + vblsz * hblsz);
|
||||
|
||||
double fitparams[2][2][16];
|
||||
|
||||
@@ -1013,7 +1011,7 @@ void RawImageSource::CA_correct_RT(const double cared, const double cablue, cons
|
||||
}
|
||||
|
||||
free(Gtmp);
|
||||
free(buffer1);
|
||||
free(blockwt);
|
||||
free(RawDataTmp);
|
||||
|
||||
if(plistener) {
|
||||
|
||||
@@ -17,20 +17,20 @@ calculates A x where x is some vector. Stops when rms residual < RMSResidual or
|
||||
Stops at n iterates if MaximumIterates = 0 since that many iterates gives exact solution. Applicable to symmetric positive
|
||||
definite problems only, which is what unconstrained smooth optimization pretty much always is.
|
||||
Parameter pass can be passed through, containing whatever info you like it to contain (matrix info?).
|
||||
Takes less memory with OkToModify_b = true, and Preconditioner = NULL. */
|
||||
Takes less memory with OkToModify_b = true, and Preconditioner = nullptr. */
|
||||
float *SparseConjugateGradient(void Ax(float *Product, float *x, void *Pass), float *b, int n, bool OkToModify_b,
|
||||
float *x, float RMSResidual, void *Pass, int MaximumIterates, void Preconditioner(float *Product, float *x, void *Pass))
|
||||
{
|
||||
int iterate, i;
|
||||
|
||||
char* buffer = (char*)malloc(2 * n * sizeof(float) + 128);
|
||||
float *r = (float*)(buffer + 64);
|
||||
float* buffer = (float*)malloc(2 * n * sizeof(float) + 128);
|
||||
float *r = (buffer + 16);
|
||||
|
||||
//Start r and x.
|
||||
if(x == NULL) {
|
||||
if(x == nullptr) {
|
||||
x = new float[n];
|
||||
|
||||
memset(x, 0, sizeof(float)*n); //Zero initial guess if x == NULL.
|
||||
memset(x, 0, sizeof(float)*n); //Zero initial guess if x == nullptr.
|
||||
memcpy(r, b, sizeof(float)*n);
|
||||
} else {
|
||||
Ax(r, x, Pass);
|
||||
@@ -46,7 +46,7 @@ float *SparseConjugateGradient(void Ax(float *Product, float *x, void *Pass), fl
|
||||
//s is preconditionment of r. Without, direct to r.
|
||||
float *s = r, rs = 0.0f;
|
||||
|
||||
if(Preconditioner != NULL) {
|
||||
if(Preconditioner != nullptr) {
|
||||
s = new float[n];
|
||||
|
||||
Preconditioner(s, r, Pass);
|
||||
@@ -61,7 +61,7 @@ float *SparseConjugateGradient(void Ax(float *Product, float *x, void *Pass), fl
|
||||
}
|
||||
|
||||
//Search direction d.
|
||||
float *d = (float*)(buffer + n * sizeof(float) + 128);
|
||||
float *d = (buffer + n + 32);
|
||||
|
||||
memcpy(d, s, sizeof(float)*n);
|
||||
|
||||
@@ -114,7 +114,7 @@ float *SparseConjugateGradient(void Ax(float *Product, float *x, void *Pass), fl
|
||||
break;
|
||||
}
|
||||
|
||||
if(Preconditioner != NULL) {
|
||||
if(Preconditioner != nullptr) {
|
||||
Preconditioner(s, r, Pass);
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ MultiDiagonalSymmetricMatrix::MultiDiagonalSymmetricMatrix(int Dimension, int Nu
|
||||
{
|
||||
n = Dimension;
|
||||
m = NumberOfDiagonalsInLowerTriangle;
|
||||
IncompleteCholeskyFactorization = NULL;
|
||||
IncompleteCholeskyFactorization = nullptr;
|
||||
|
||||
Diagonals = new float *[m];
|
||||
StartRows = new int [m + 1];
|
||||
@@ -196,7 +196,7 @@ MultiDiagonalSymmetricMatrix::MultiDiagonalSymmetricMatrix(int Dimension, int Nu
|
||||
|
||||
MultiDiagonalSymmetricMatrix::~MultiDiagonalSymmetricMatrix()
|
||||
{
|
||||
if(DiagBuffer != NULL) {
|
||||
if(DiagBuffer != nullptr) {
|
||||
free(buffer);
|
||||
} else
|
||||
for(int i = 0; i < m; i++) {
|
||||
@@ -216,12 +216,12 @@ bool MultiDiagonalSymmetricMatrix::CreateDiagonal(int index, int StartRow)
|
||||
if(index == 0) {
|
||||
buffer = (char*)calloc( (n + padding) * m * sizeof(float) + (m + 16) * 64 + 63, 1);
|
||||
|
||||
if(buffer == NULL)
|
||||
if(buffer == nullptr)
|
||||
// no big memory block available => try to allocate smaller blocks
|
||||
{
|
||||
DiagBuffer = NULL;
|
||||
DiagBuffer = nullptr;
|
||||
} else {
|
||||
DiagBuffer = (char*)( ( uintptr_t(buffer) + uintptr_t(63)) / 64 * 64);
|
||||
DiagBuffer = (float*)( ( uintptr_t(buffer) + uintptr_t(63)) / 64 * 64);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,12 +236,12 @@ bool MultiDiagonalSymmetricMatrix::CreateDiagonal(int index, int StartRow)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(DiagBuffer != NULL) {
|
||||
Diagonals[index] = (float*)(DiagBuffer + (index * (n + padding) * sizeof(float)) + ((index + 16) * 64));
|
||||
if(DiagBuffer != nullptr) {
|
||||
Diagonals[index] = (DiagBuffer + (index * (n + padding)) + ((index + 16) * 16));
|
||||
} else {
|
||||
Diagonals[index] = new float[DiagonalLength(StartRow)];
|
||||
|
||||
if(Diagonals[index] == NULL) {
|
||||
if(Diagonals[index] == nullptr) {
|
||||
printf("Error in MultiDiagonalSymmetricMatrix::CreateDiagonal: memory allocation failed. Out of memory?\n");
|
||||
return false;
|
||||
}
|
||||
@@ -673,7 +673,7 @@ EdgePreservingDecomposition::EdgePreservingDecomposition(int width, int height)
|
||||
A->CreateDiagonal(3, w) &&
|
||||
A->CreateDiagonal(4, w + 1))) {
|
||||
delete A;
|
||||
A = NULL;
|
||||
A = nullptr;
|
||||
printf("Error in EdgePreservingDecomposition construction: out of memory.\n");
|
||||
} else {
|
||||
a0 = A->Diagonals[0];
|
||||
@@ -692,7 +692,7 @@ EdgePreservingDecomposition::~EdgePreservingDecomposition()
|
||||
SSEFUNCTION float *EdgePreservingDecomposition::CreateBlur(float *Source, float Scale, float EdgeStopping, int Iterates, float *Blur, bool UseBlurForEdgeStop)
|
||||
{
|
||||
|
||||
if(Blur == NULL)
|
||||
if(Blur == nullptr)
|
||||
UseBlurForEdgeStop = false, //Use source if there's no supplied Blur.
|
||||
Blur = new float[n];
|
||||
|
||||
@@ -864,7 +864,7 @@ float *EdgePreservingDecomposition::CreateIteratedBlur(float *Source, float Scal
|
||||
}
|
||||
|
||||
//Create a blur here, initialize.
|
||||
if(Blur == NULL) {
|
||||
if(Blur == nullptr) {
|
||||
Blur = new float[n];
|
||||
}
|
||||
|
||||
@@ -923,7 +923,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 == NULL) {
|
||||
if(Compressed == nullptr) {
|
||||
Compressed = u;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ ben_s or nonbasketless. Enjoy!
|
||||
#include "noncopyable.h"
|
||||
|
||||
//This is for solving big symmetric positive definite linear problems.
|
||||
float *SparseConjugateGradient(void Ax(float *Product, float *x, void *Pass), float *b, int n, bool OkToModify_b = true, float *x = NULL, float RMSResidual = 0.0f, void *Pass = NULL, int MaximumIterates = 0, void Preconditioner(float *Product, float *x, void *Pass) = NULL);
|
||||
float *SparseConjugateGradient(void Ax(float *Product, float *x, void *Pass), float *b, int n, bool OkToModify_b = true, float *x = nullptr, float RMSResidual = 0.0f, void *Pass = nullptr, int MaximumIterates = 0, void Preconditioner(float *Product, float *x, void *Pass) = nullptr);
|
||||
|
||||
//Storage and use class for symmetric matrices, the nonzero contents of which are confined to diagonals.
|
||||
class MultiDiagonalSymmetricMatrix :
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
*/
|
||||
float **Diagonals;
|
||||
char *buffer;
|
||||
char *DiagBuffer;
|
||||
float *DiagBuffer;
|
||||
int *StartRows;
|
||||
bool CreateDiagonal(int index, int StartRow);
|
||||
int n, m; //The matrix is n x n, with m diagonals on the lower triangle. Don't change these. They should be private but aren't for convenience.
|
||||
@@ -143,16 +143,16 @@ public:
|
||||
|
||||
//Create an edge preserving blur of Source. Will create and return, or fill into Blur if not NULL. In place not ok.
|
||||
//If UseBlurForEdgeStop is true, supplied not NULL Blur is used to calculate the edge stopping function instead of Source.
|
||||
float *CreateBlur(float *Source, float Scale, float EdgeStopping, int Iterates, float *Blur = NULL, bool UseBlurForEdgeStop = false);
|
||||
float *CreateBlur(float *Source, float Scale, float EdgeStopping, int Iterates, float *Blur = nullptr, bool UseBlurForEdgeStop = false);
|
||||
|
||||
//Iterates CreateBlur such that the smoothness term approaches a specific norm via iteratively reweighted least squares. In place not ok.
|
||||
float *CreateIteratedBlur(float *Source, float Scale, float EdgeStopping, int Iterates, int Reweightings, float *Blur = NULL);
|
||||
float *CreateIteratedBlur(float *Source, float Scale, float EdgeStopping, int Iterates, int Reweightings, float *Blur = nullptr);
|
||||
|
||||
/*Lowers global contrast while preserving or boosting local contrast. Can fill into Compressed. The smaller Compression
|
||||
the more compression is applied, with Compression = 1 giving no effect and above 1 the opposite effect. You can totally
|
||||
use Compression = 1 and play with DetailBoost for some really sweet unsharp masking. If working on luma/grey, consider giving it a logarithm.
|
||||
In place calculation to save memory (Source == Compressed) is totally ok. Reweightings > 0 invokes CreateIteratedBlur instead of CreateBlur. */
|
||||
float *CompressDynamicRange(float *Source, float Scale = 1.0f, float EdgeStopping = 1.4f, float CompressionExponent = 0.8f, float DetailBoost = 0.1f, int Iterates = 20, int Reweightings = 0, float *Compressed = NULL);
|
||||
float *CompressDynamicRange(float *Source, float Scale = 1.0f, float EdgeStopping = 1.4f, float CompressionExponent = 0.8f, float DetailBoost = 0.1f, int Iterates = 20, int Reweightings = 0, float *Compressed = nullptr);
|
||||
|
||||
private:
|
||||
MultiDiagonalSymmetricMatrix *A; //The equations are simple enough to not mandate a matrix class, but fast solution NEEDS a complicated preconditioner.
|
||||
|
||||
@@ -68,11 +68,10 @@ void RawImageSource::CLASS cfa_linedn(float noise)
|
||||
{
|
||||
|
||||
// allocate memory and assure the arrays don't have same 64 byte boundary to avoid L1 conflict misses
|
||||
char *buffer = (char*)malloc(4 * TS * TS * sizeof(float) + 3 * 64);
|
||||
float *cfain = (float*)(buffer);
|
||||
float *cfablur = (float*)(buffer + (TS * TS * sizeof(float)) + 1 * 64);
|
||||
float *cfadiff = (float*)(buffer + (2 * TS * TS * sizeof(float)) + 2 * 64);
|
||||
float *cfadn = (float*)(buffer + (3 * TS * TS * sizeof(float)) + 3 * 64);
|
||||
float *cfain = (float*)malloc(4 * TS * TS * sizeof(float) + 3 * 16 * sizeof(float));
|
||||
float *cfablur = (cfain + (TS * TS) + 1 * 16);
|
||||
float *cfadiff = (cfain + (2 * TS * TS) + 2 * 16);
|
||||
float *cfadn = (cfain + (3 * TS * TS) + 3 * 16);
|
||||
|
||||
|
||||
float linehvar[4], linevvar[4], noisefactor[4][8][2], coeffsq;
|
||||
@@ -250,7 +249,7 @@ void RawImageSource::CLASS cfa_linedn(float noise)
|
||||
}
|
||||
|
||||
// clean up
|
||||
free(buffer);
|
||||
free(cfain);
|
||||
|
||||
// copy temporary buffer back to image matrix
|
||||
#pragma omp for
|
||||
|
||||
@@ -88,8 +88,8 @@ ImProcCoordinator::ImProcCoordinator ()
|
||||
fullw(1), fullh(1),
|
||||
pW(-1), pH(-1),
|
||||
plistener(NULL), imageListener(NULL), aeListener(NULL), acListener(NULL), abwListener(NULL), actListener(NULL), adnListener(NULL), awavListener(NULL), dehaListener(NULL), hListener(NULL),
|
||||
resultValid(false), lastOutputProfile("BADFOOD"), lastOutputIntent(RI__COUNT), lastOutputBPC(false), changeSinceLast(0), updaterRunning(false), destroying(false), utili(false), autili(false), wavcontlutili(false),
|
||||
butili(false), ccutili(false), cclutili(false), clcutili(false), opautili(false), conversionBuffer(1, 1)
|
||||
resultValid(false), lastOutputProfile("BADFOOD"), lastOutputIntent(RI__COUNT), lastOutputBPC(false), thread(nullptr), changeSinceLast(0), updaterRunning(false), destroying(false), utili(false), autili(false), wavcontlutili(false),
|
||||
butili(false), ccutili(false), cclutili(false), clcutili(false), opautili(false), conversionBuffer(1, 1), colourToningSatLimit(0.f), colourToningSatLimitOpacity(0.f)
|
||||
{}
|
||||
|
||||
void ImProcCoordinator::assign (ImageSource* imgsrc)
|
||||
|
||||
@@ -361,7 +361,7 @@ int fscanf (IMFILE* f, const char* s ...)
|
||||
// of file data and vsscanf() won't tell us how many characters that
|
||||
// were parsed. However, only dcraw.cc code use it and only for "%f" and
|
||||
// "%d", so we make a dummy fscanf here just to support dcraw case.
|
||||
char buf[50], *endptr;
|
||||
char buf[50], *endptr = nullptr;
|
||||
int copy_sz = f->size - f->pos;
|
||||
|
||||
if (copy_sz > sizeof(buf)) {
|
||||
@@ -377,6 +377,7 @@ int fscanf (IMFILE* f, const char* s ...)
|
||||
int i = strtol(buf, &endptr, 10);
|
||||
|
||||
if (endptr == buf) {
|
||||
va_end (ap);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -386,6 +387,7 @@ int fscanf (IMFILE* f, const char* s ...)
|
||||
float f = strtof(buf, &endptr);
|
||||
|
||||
if (endptr == buf) {
|
||||
va_end (ap);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -735,6 +735,7 @@ void Thumbnail::init ()
|
||||
}
|
||||
|
||||
Thumbnail::Thumbnail () :
|
||||
iColorMatrix{}, cam2xyz{}, scale(1.0), colorMatrix{}, isRaw(true),
|
||||
camProfile(nullptr), thumbImg(nullptr),
|
||||
camwbRed(1.0), camwbGreen(1.0), camwbBlue(1.0),
|
||||
redAWBMul(-1.0), greenAWBMul(-1.0), blueAWBMul(-1.0),
|
||||
|
||||
@@ -394,8 +394,8 @@ void Options::setDefaults ()
|
||||
gimpDir = "";
|
||||
psDir = "";
|
||||
customEditorProg = "";
|
||||
CPBKeys = CPBKT_TID;
|
||||
editorToSendTo = 1;
|
||||
liveThumbnails = true;
|
||||
favoriteDirs.clear();
|
||||
tpOpen.clear ();
|
||||
//crvOpen.clear ();
|
||||
@@ -1093,10 +1093,6 @@ int Options::readFromFile (Glib::ustring fname)
|
||||
thumbInterp = keyFile.get_integer ("File Browser", "ThumbnailInterpolation");
|
||||
}
|
||||
|
||||
if (keyFile.has_key ("File Browser", "LiveThumbnails")) {
|
||||
liveThumbnails = keyFile.get_boolean ("File Browser", "LiveThumbnails");
|
||||
}
|
||||
|
||||
if (keyFile.has_key ("File Browser", "FavoriteDirs")) {
|
||||
favoriteDirs = keyFile.get_string_list ("File Browser", "FavoriteDirs");
|
||||
}
|
||||
@@ -1894,7 +1890,6 @@ int Options::saveToFile (Glib::ustring fname)
|
||||
keyFile.set_integer_list ("File Browser", "ParseExtensionsEnabled", pextena);
|
||||
keyFile.set_integer ("File Browser", "ThumbnailArrangement", fbArrangement);
|
||||
keyFile.set_integer ("File Browser", "ThumbnailInterpolation", thumbInterp);
|
||||
keyFile.set_boolean ("File Browser", "LiveThumbnails", liveThumbnails);
|
||||
Glib::ArrayHandle<Glib::ustring> pfav = favoriteDirs;
|
||||
keyFile.set_string_list ("File Browser", "FavoriteDirs", pfav);
|
||||
Glib::ArrayHandle<Glib::ustring> pren = renameTemplates;
|
||||
|
||||
@@ -180,9 +180,7 @@ public:
|
||||
int editorToSendTo;
|
||||
int maxThumbnailHeight;
|
||||
std::size_t maxCacheEntries;
|
||||
ThFileType thumbnailFormat;
|
||||
int thumbInterp; // 0: nearest, 1: bilinear
|
||||
bool liveThumbnails;
|
||||
std::vector<Glib::ustring> parseExtensions; // List containing all extensions type
|
||||
std::vector<int> parseExtensionsEnabled; // List of bool to retain extension or not
|
||||
std::vector<Glib::ustring> parsedExtensions; // List containing all retained extensions (lowercase)
|
||||
@@ -203,7 +201,6 @@ public:
|
||||
bool showFileNames;
|
||||
bool filmStripShowFileNames;
|
||||
bool tabbedUI;
|
||||
int previewSizeTab, previewSizeBrowser;
|
||||
bool rememberZoomAndPan;
|
||||
int multiDisplayMode; // 0=none, 1=Edit panels on other display
|
||||
std::vector<double> cutOverlayBrush; // Red;Green;Blue;Alpha , all ranging 0..1
|
||||
@@ -219,7 +216,6 @@ public:
|
||||
//int histogramWorking; // 0=disabled, 1=left pane, 2=right pane
|
||||
bool histogramBar;
|
||||
bool histogramFullMode;
|
||||
bool showProfileSelector;
|
||||
bool FileBrowserToolbarSingleRow;
|
||||
bool hideTPVScrollbar;
|
||||
bool UseIconNoText;
|
||||
|
||||
Reference in New Issue
Block a user