Removed StopWatches and cleaned code
This commit is contained in:
@@ -19,14 +19,13 @@
|
|||||||
#include "image16.h"
|
#include "image16.h"
|
||||||
#include "imagefloat.h"
|
#include "imagefloat.h"
|
||||||
#include "image8.h"
|
#include "image8.h"
|
||||||
#include <cstring>
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include "rtengine.h"
|
#include "rtengine.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
void getScanline8 (uint16_t *red, uint16_t *green, uint16_t *blue, int width, unsigned char* buffer)
|
void getScanline8 (const uint16_t *red, const uint16_t *green, const uint16_t *blue, int width, unsigned char* buffer)
|
||||||
{
|
{
|
||||||
for (int i = 0, ix = 0; i < width; i++) {
|
for (int i = 0, ix = 0; i < width; i++) {
|
||||||
buffer[ix++] = red[i] >> 8;
|
buffer[ix++] = red[i] >> 8;
|
||||||
@@ -35,7 +34,7 @@ void getScanline8 (uint16_t *red, uint16_t *green, uint16_t *blue, int width, un
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void getScanline16 (uint16_t *red, uint16_t *green, uint16_t *blue, int width, unsigned short* buffer)
|
void getScanline16 (const uint16_t *red, const uint16_t *green, const uint16_t *blue, int width, unsigned short* buffer)
|
||||||
{
|
{
|
||||||
for (int i = 0, ix = 0; i < width; i++) {
|
for (int i = 0, ix = 0; i < width; i++) {
|
||||||
buffer[ix++] = red[i];
|
buffer[ix++] = red[i];
|
||||||
@@ -64,14 +63,14 @@ Image16::~Image16 ()
|
|||||||
void Image16::getScanline (int row, unsigned char* buffer, int bps)
|
void Image16::getScanline (int row, unsigned char* buffer, int bps)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (data == NULL) {
|
if (data == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bps == 16) {
|
if (bps == 16) {
|
||||||
getScanline16 (&r(row, 0), &g(row, 0), &b(row, 0), width, (unsigned short*)buffer);
|
getScanline16 (r(row), g(row), b(row), width, (unsigned short*)buffer);
|
||||||
} else if (bps == 8) {
|
} else if (bps == 8) {
|
||||||
getScanline8 (&r(row, 0), &g(row, 0), &b(row, 0), width, buffer);
|
getScanline8 (r(row), g(row), b(row), width, buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,11 +81,11 @@ void Image16::getScanline (int row, unsigned char* buffer, int bps)
|
|||||||
void Image16::setScanline (int row, unsigned char* buffer, int bps, float *minValue, float *maxValue)
|
void Image16::setScanline (int row, unsigned char* buffer, int bps, float *minValue, float *maxValue)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (data == NULL) {
|
if (data == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For optimization purpose, we're assuming that this class never have to provide min/max bound
|
// For optimization purpose, we're assuming that this class never has to provide min/max bounds
|
||||||
assert(!minValue);
|
assert(!minValue);
|
||||||
|
|
||||||
switch (sampleFormat) {
|
switch (sampleFormat) {
|
||||||
@@ -116,7 +115,7 @@ void Image16::setScanline (int row, unsigned char* buffer, int bps, float *minVa
|
|||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Other type are ignored, but could be implemented if necessary
|
// Other types are ignored, but could be implemented if necessary
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,8 +41,7 @@
|
|||||||
#include "color.h"
|
#include "color.h"
|
||||||
|
|
||||||
#include "jpeg.h"
|
#include "jpeg.h"
|
||||||
#define BENCHMARK
|
|
||||||
#include "StopWatch.h"
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace rtengine;
|
using namespace rtengine;
|
||||||
using namespace rtengine::procparams;
|
using namespace rtengine::procparams;
|
||||||
@@ -62,6 +61,7 @@ FILE* g_fopen_withBinaryAndLock(const Glib::ustring& fname)
|
|||||||
std::unique_ptr<wchar_t, GFreeFunc> wfname (reinterpret_cast<wchar_t*>(g_utf8_to_utf16 (fname.c_str (), -1, NULL, NULL, NULL)), g_free);
|
std::unique_ptr<wchar_t, GFreeFunc> wfname (reinterpret_cast<wchar_t*>(g_utf8_to_utf16 (fname.c_str (), -1, NULL, NULL, NULL)), g_free);
|
||||||
|
|
||||||
HANDLE hFile = CreateFileW ( wfname.get (), GENERIC_READ | GENERIC_WRITE, 0 /* no sharing allowed */, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
HANDLE hFile = CreateFileW ( wfname.get (), GENERIC_READ | GENERIC_WRITE, 0 /* no sharing allowed */, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
|
|
||||||
if (hFile != INVALID_HANDLE_VALUE) {
|
if (hFile != INVALID_HANDLE_VALUE) {
|
||||||
f = _fdopen (_open_osfhandle ((intptr_t)hFile, 0), "wb");
|
f = _fdopen (_open_osfhandle ((intptr_t)hFile, 0), "wb");
|
||||||
}
|
}
|
||||||
@@ -918,7 +918,7 @@ int ImageIO::loadPPMFromMemory(const char* buffer, int width, int height, bool s
|
|||||||
|
|
||||||
int ImageIO::savePNG (Glib::ustring fname, int compression, volatile int bps)
|
int ImageIO::savePNG (Glib::ustring fname, int compression, volatile int bps)
|
||||||
{
|
{
|
||||||
BENCHFUN
|
|
||||||
FILE *file = g_fopen_withBinaryAndLock (fname);
|
FILE *file = g_fopen_withBinaryAndLock (fname);
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
@@ -1012,7 +1012,7 @@ BENCHFUN
|
|||||||
// Quality 0..100, subsampling: 1=low quality, 2=medium, 3=high
|
// Quality 0..100, subsampling: 1=low quality, 2=medium, 3=high
|
||||||
int ImageIO::saveJPEG (Glib::ustring fname, int quality, int subSamp)
|
int ImageIO::saveJPEG (Glib::ustring fname, int quality, int subSamp)
|
||||||
{
|
{
|
||||||
BENCHFUN
|
|
||||||
FILE *file = g_fopen_withBinaryAndLock (fname);
|
FILE *file = g_fopen_withBinaryAndLock (fname);
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
@@ -1199,7 +1199,7 @@ BENCHFUN
|
|||||||
|
|
||||||
int ImageIO::saveTIFF (Glib::ustring fname, int bps, bool uncompressed)
|
int ImageIO::saveTIFF (Glib::ustring fname, int bps, bool uncompressed)
|
||||||
{
|
{
|
||||||
BENCHFUN
|
|
||||||
//TODO: Handling 32 bits floating point output images!
|
//TODO: Handling 32 bits floating point output images!
|
||||||
bool writeOk = true;
|
bool writeOk = true;
|
||||||
int width = getW ();
|
int width = getW ();
|
||||||
@@ -1228,8 +1228,10 @@ BENCHFUN
|
|||||||
|
|
||||||
// buffer for the exif and iptc
|
// buffer for the exif and iptc
|
||||||
int bufferSize = 165535; //TODO: Is it really 165535... or 65535 ?
|
int bufferSize = 165535; //TODO: Is it really 165535... or 65535 ?
|
||||||
if(profileData)
|
|
||||||
|
if(profileData) {
|
||||||
bufferSize += profileLength;
|
bufferSize += profileLength;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned char* buffer = new unsigned char[bufferSize];
|
unsigned char* buffer = new unsigned char[bufferSize];
|
||||||
unsigned char* iptcdata = NULL;
|
unsigned char* iptcdata = NULL;
|
||||||
|
Reference in New Issue
Block a user