Cleanup: removed unused function; also murder instead of call for suicide (delete this)

This commit is contained in:
Ingo Weyrich 2020-08-13 13:10:33 +02:00
parent 130fbb8eb2
commit a5c7713042
13 changed files with 29 additions and 173 deletions

View File

@ -1809,9 +1809,6 @@ public:
* @return The mutex */
virtual MyMutex& getMutex () = 0;
virtual cmsHPROFILE getProfile () const = 0;
/** @brief Returns the bits per pixel of the image.
* @return The bits per pixel of the image */
virtual int getBitsPerPixel () const = 0;
/** @brief Saves the image to file. It autodetects the format (jpg, tif, png are supported).
* @param fname is the name of the file
@return the error code, 0 if none */
@ -1837,7 +1834,7 @@ public:
* @param pl is the pointer to the class implementing the ProgressListener interface */
virtual void setSaveProgressListener (ProgressListener* pl) = 0;
/** @brief Free the image */
virtual void free () = 0;
// virtual void free () = 0;
};
/** @brief This class represents an image having a float pixel planar representation.

View File

@ -258,10 +258,10 @@ void Image16::getStdImage(const ColorTemp &ctemp, int tran, Imagefloat* image, P
lineB[dst_x] = CLIP(bm * btot);
} else {
// computing a special factor for this incomplete sub-region
float area = src_sub_width * src_sub_height;
lineR[dst_x] = CLIP(rm2 * rtot / area);
lineG[dst_x] = CLIP(gm2 * gtot / area);
lineB[dst_x] = CLIP(bm2 * btot / area);
float larea = src_sub_width * src_sub_height;
lineR[dst_x] = CLIP(rm2 * rtot / larea);
lineG[dst_x] = CLIP(gm2 * gtot / larea);
lineB[dst_x] = CLIP(bm2 * btot / larea);
}
}
}
@ -295,21 +295,6 @@ void Image16::getStdImage(const ColorTemp &ctemp, int tran, Imagefloat* image, P
#undef GCLIP
}
Image8* Image16::to8() const
{
Image8* img8 = new Image8(width, height);
for (int h = 0; h < height; ++h) {
for (int w = 0; w < width; ++w) {
img8->r(h, w) = uint16ToUint8Rounded(r(h, w));
img8->g(h, w) = uint16ToUint8Rounded(g(h, w));
img8->b(h, w) = uint16ToUint8Rounded(b(h, w));
}
}
return img8;
}
// Parallelized transformation; create transform with cmsFLAGS_NOCACHE!
void Image16::ExecCMSTransform(cmsHTRANSFORM hTransform)
{

View File

@ -40,8 +40,6 @@ public:
Image16* copy() const;
Image8* to8() const;
void getStdImage(const ColorTemp &ctemp, int tran, Imagefloat* image, PreviewProps pp) const override;
const char* getType() const override
@ -67,11 +65,6 @@ public:
return getEmbeddedProfile();
}
int getBitsPerPixel() const override
{
return 8 * sizeof(unsigned short);
}
int saveToFile(const Glib::ustring &fname) const override
{
return save(fname);
@ -97,10 +90,6 @@ public:
setProgressListener(pl);
}
void free() override
{
delete this;
}
void ExecCMSTransform(cmsHTRANSFORM hTransform);
/* void ExecCMSTransform(cmsHTRANSFORM hTransform, const LabImage &labImage, int cx, int cy); */

View File

@ -64,11 +64,6 @@ public:
return getEmbeddedProfile ();
}
int getBitsPerPixel () const override
{
return 8 * sizeof(unsigned char);
}
int saveToFile (const Glib::ustring &fname) const override
{
return save (fname);
@ -94,11 +89,6 @@ public:
setProgressListener (pl);
}
void free () override
{
delete this;
}
};
}

View File

@ -288,10 +288,10 @@ void Imagefloat::getStdImage (const ColorTemp &ctemp, int tran, Imagefloat* imag
lineB[dst_x] = CLIP0(bm * btot);
} else {
// computing a special factor for this incomplete sub-region
float area = src_sub_width * src_sub_height;
lineR[dst_x] = CLIP0(rm2 * rtot / area);
lineG[dst_x] = CLIP0(gm2 * gtot / area);
lineB[dst_x] = CLIP0(bm2 * btot / area);
float larea = src_sub_width * src_sub_height;
lineR[dst_x] = CLIP0(rm2 * rtot / larea);
lineG[dst_x] = CLIP0(gm2 * gtot / larea);
lineB[dst_x] = CLIP0(bm2 * btot / larea);
}
}
}
@ -327,53 +327,15 @@ void Imagefloat::getStdImage (const ColorTemp &ctemp, int tran, Imagefloat* imag
#endif
}
Image8*
Imagefloat::to8() const
{
Image8* img8 = new Image8(width, height);
#ifdef _OPENMP
#pragma omp parallel for schedule(static)
#endif
for (int h = 0; h < height; ++h) {
for (int w = 0; w < width; ++w) {
img8->r(h, w) = uint16ToUint8Rounded(CLIP(r(h, w)));
img8->g(h, w) = uint16ToUint8Rounded(CLIP(g(h, w)));
img8->b(h, w) = uint16ToUint8Rounded(CLIP(b(h, w)));
}
}
return img8;
}
Image16*
Imagefloat::to16() const
{
Image16* img16 = new Image16(width, height);
#ifdef _OPENMP
#pragma omp parallel for schedule(static)
#endif
for (int h = 0; h < height; ++h) {
for (int w = 0; w < width; ++w) {
img16->r(h, w) = CLIP(r(h, w));
img16->g(h, w) = CLIP(g(h, w));
img16->b(h, w) = CLIP(b(h, w));
}
}
return img16;
}
void Imagefloat::normalizeFloat(float srcMinVal, float srcMaxVal)
{
float scale = MAXVALF / (srcMaxVal - srcMinVal);
int w = width;
int h = height;
const float scale = MAXVALF / (srcMaxVal - srcMinVal);
const int w = width;
const int h = height;
#ifdef _OPENMP
#pragma omp parallel for firstprivate(w, h, srcMinVal, scale) schedule(dynamic, 5)
#pragma omp parallel for schedule(dynamic, 5)
#endif
for (int y = 0; y < h; y++) {
@ -389,11 +351,11 @@ void Imagefloat::normalizeFloat(float srcMinVal, float srcMaxVal)
void Imagefloat::normalizeFloatTo1()
{
int w = width;
int h = height;
const int w = width;
const int h = height;
#ifdef _OPENMP
#pragma omp parallel for firstprivate(w, h) schedule(dynamic, 5)
#pragma omp parallel for schedule(dynamic, 5)
#endif
for (int y = 0; y < h; y++) {
@ -409,11 +371,11 @@ void Imagefloat::normalizeFloatTo1()
void Imagefloat::normalizeFloatTo65535()
{
int w = width;
int h = height;
const int w = width;
const int h = height;
#ifdef _OPENMP
#pragma omp parallel for firstprivate(w, h) schedule(dynamic, 5)
#pragma omp parallel for schedule(dynamic, 5)
#endif
for (int y = 0; y < h; y++) {
@ -425,59 +387,6 @@ void Imagefloat::normalizeFloatTo65535()
}
}
void Imagefloat::calcCroppedHistogram(const ProcParams &params, float scale, LUTu & hist)
{
hist.clear();
// Set up factors to calc the lightness
TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix (params.icm.workingProfile);
float facRed = wprof[1][0];
float facGreen = wprof[1][1];
float facBlue = wprof[1][2];
// calc pixel size
int x1, x2, y1, y2;
params.crop.mapToResized(width, height, scale, x1, x2, y1, y2);
#ifdef _OPENMP
#pragma omp parallel
#endif
{
LUTu histThr(65536);
histThr.clear();
#ifdef _OPENMP
#pragma omp for nowait
#endif
for (int y = y1; y < y2; y++) {
for (int x = x1; x < x2; x++) {
int i = (int)(facRed * r(y, x) + facGreen * g(y, x) + facBlue * b(y, x));
if (i < 0) {
i = 0;
} else if (i > 65535) {
i = 65535;
}
histThr[i]++;
}
}
#ifdef _OPENMP
#pragma omp critical
#endif
{
for(int i = 0; i <= 0xffff; i++) {
hist[i] += histThr[i];
}
}
}
}
// Parallelized transformation; create transform with cmsFLAGS_NOCACHE!
void Imagefloat::ExecCMSTransform(cmsHTRANSFORM hTransform)
{

View File

@ -45,9 +45,6 @@ public:
Imagefloat* copy () const;
Image8* to8() const;
Image16* to16() const;
void getStdImage (const ColorTemp &ctemp, int tran, Imagefloat* image, PreviewProps pp) const override;
const char* getType () const override
@ -72,10 +69,6 @@ public:
{
return getEmbeddedProfile ();
}
int getBitsPerPixel () const override
{
return 8 * sizeof(float);
}
int saveToFile (const Glib::ustring &fname) const override
{
return save (fname);
@ -96,10 +89,6 @@ public:
{
setProgressListener (pl);
}
void free () override
{
delete this;
}
inline uint16_t DNG_FloatToHalf(float f) const
{
@ -220,7 +209,6 @@ public:
void normalizeFloat(float srcMinVal, float srcMaxVal) override;
void normalizeFloatTo1();
void normalizeFloatTo65535();
void calcCroppedHistogram(const ProcParams &params, float scale, LUTu & hist);
void ExecCMSTransform(cmsHTRANSFORM hTransform);
void ExecCMSTransform(cmsHTRANSFORM hTransform, const LabImage &labImage, int cx, int cy);
};

View File

@ -852,8 +852,6 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange)
if ((todo & M_RGBCURVE) || (todo & M_CROP)) {
// if (hListener) oprevi->calcCroppedHistogram(params, scale, histCropped);
//complexCurve also calculated pre-curves histogram depending on crop
CurveFactory::complexCurve(params->toneCurve.expcomp, params->toneCurve.black / 65535.0,
params->toneCurve.hlcompr, params->toneCurve.hlcomprthresh,

View File

@ -699,7 +699,7 @@ rtengine::ProcessingJob* BatchQueue::imageReady(rtengine::IImagefloat* img)
err = img->saveAsJPEG (fname, saveFormat.jpegQuality, saveFormat.jpegSubSamp);
}
img->free ();
delete img;
if (err) {
throw Glib::FileError(Glib::FileError::FAILED, M("MAIN_MSG_CANNOTSAVE") + "\n" + fname);

View File

@ -146,7 +146,7 @@ void BatchQueueEntryUpdater::processThread ()
}
memcpy(current.oimg, img->getData(), prevw * prevh * 3);
img->free();
delete img;
}
}

View File

@ -1795,7 +1795,7 @@ bool EditorPanel::idle_saveImage (ProgressConnector<rtengine::IImagefloat*> *pc,
bool EditorPanel::idle_imageSaved (ProgressConnector<int> *pc, rtengine::IImagefloat* img, Glib::ustring fname, SaveFormat sf, rtengine::procparams::ProcParams &pparams)
{
img->free ();
delete img;
if (! pc->returnValue() ) {
openThm->imageDeveloped ();
@ -1995,7 +1995,7 @@ bool EditorPanel::saveImmediately (const Glib::ustring &filename, const SaveForm
err = 1;
}
img->free();
delete img;
return !err;
}
@ -2057,7 +2057,7 @@ bool EditorPanel::idle_sendToGimp ( ProgressConnector<rtengine::IImagefloat*> *p
}
if (tries == 1000) {
img->free ();
delete img;
return false;
}
@ -2078,7 +2078,7 @@ bool EditorPanel::idle_sendToGimp ( ProgressConnector<rtengine::IImagefloat*> *p
bool EditorPanel::idle_sentToGimp (ProgressConnector<int> *pc, rtengine::IImagefloat* img, Glib::ustring filename)
{
img->free ();
delete img;
int errore = pc->returnValue();
setProgressState(false);
delete pc;

View File

@ -230,7 +230,7 @@ void FileBrowserEntry::updateImage(rtengine::IImage8* img, double scale, const r
--feih->pending;
}
img->free();
delete img;
return false;
}
@ -276,7 +276,7 @@ void FileBrowserEntry::_updateImage(rtengine::IImage8* img, double s, const rten
landscape = newLandscape;
img->free();
delete img;
if (parent) {
if (rotated) {

View File

@ -832,7 +832,7 @@ int processLineParams ( int argc, char **argv )
}
ii->decreaseRef();
resultImage->free();
delete resultImage;
}
if (imgParams) {

View File

@ -110,7 +110,7 @@ void PreviewHandler::delImage(IImage8* i)
oldImg->getMutex().unlock();
}
i->free();
delete i;
pih->phandler->previewImgMutex.lock();
pih->phandler->previewImg.clear();
pih->phandler->previewImgMutex.unlock();