* Fixed a few large memory holes (Dano even crashes on low memory...).
* Removed printing progress updates to stdout. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20649 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -118,6 +118,7 @@ DCRaw::DCRaw(BPositionIO& stream)
|
|||||||
fThumbIndex(-1),
|
fThumbIndex(-1),
|
||||||
fDNGVersion(0),
|
fDNGVersion(0),
|
||||||
fIsTIFF(false),
|
fIsTIFF(false),
|
||||||
|
fImageData(NULL),
|
||||||
fThreshold(0),
|
fThreshold(0),
|
||||||
fHalfSize(false),
|
fHalfSize(false),
|
||||||
fUseCameraWhiteBalance(true),
|
fUseCameraWhiteBalance(true),
|
||||||
@@ -170,7 +171,9 @@ DCRaw::~DCRaw()
|
|||||||
delete[] fCurve;
|
delete[] fCurve;
|
||||||
|
|
||||||
delete[] cbrt;
|
delete[] cbrt;
|
||||||
|
|
||||||
free(fHistogram);
|
free(fHistogram);
|
||||||
|
free(fImageData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3328,8 +3331,11 @@ DCRaw::ReadImageAt(uint32 index, uint8*& outputBuffer, size_t& bufferSize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
outputBuffer = (uint8*)malloc(bufferSize);
|
outputBuffer = (uint8*)malloc(bufferSize);
|
||||||
if (outputBuffer == NULL)
|
if (outputBuffer == NULL) {
|
||||||
|
free(fImageData);
|
||||||
|
fImageData = NULL;
|
||||||
throw (status_t)B_NO_MEMORY;
|
throw (status_t)B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
fRead.Seek(image.data_offset, SEEK_SET);
|
fRead.Seek(image.data_offset, SEEK_SET);
|
||||||
|
|
||||||
@@ -3372,6 +3378,9 @@ DCRaw::ReadImageAt(uint32 index, uint8*& outputBuffer, size_t& bufferSize)
|
|||||||
_WriteJPEG(image, outputBuffer);
|
_WriteJPEG(image, outputBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(fImageData);
|
||||||
|
fImageData = NULL;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,23 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
class FreeAllocation {
|
||||||
|
public:
|
||||||
|
FreeAllocation(void* buffer)
|
||||||
|
:
|
||||||
|
fBuffer(buffer)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~FreeAllocation()
|
||||||
|
{
|
||||||
|
free(fBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void* fBuffer;
|
||||||
|
};
|
||||||
|
|
||||||
// Extensions that ShowImage supports
|
// Extensions that ShowImage supports
|
||||||
const char* kDocumentCount = "/documentCount";
|
const char* kDocumentCount = "/documentCount";
|
||||||
const char* kDocumentIndex = "/documentIndex";
|
const char* kDocumentIndex = "/documentIndex";
|
||||||
@@ -65,7 +82,6 @@ const uint32 kNumOutputFormats = sizeof(sOutputFormats) / sizeof(translation_for
|
|||||||
const uint32 kNumDefaultSettings = sizeof(sDefaultSettings) / sizeof(TranSetting);
|
const uint32 kNumDefaultSettings = sizeof(sDefaultSettings) / sizeof(TranSetting);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
@@ -140,9 +156,6 @@ RAWTranslator::DerivedIdentify(BPositionIO *stream,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bigtime_t gStart;
|
|
||||||
|
|
||||||
|
|
||||||
/*static*/ void
|
/*static*/ void
|
||||||
RAWTranslator::_ProgressMonitor(const char* message, float percentage,
|
RAWTranslator::_ProgressMonitor(const char* message, float percentage,
|
||||||
void* data)
|
void* data)
|
||||||
@@ -154,19 +167,6 @@ RAWTranslator::_ProgressMonitor(const char* message, float percentage,
|
|||||||
update.AddFloat("percent", percentage);
|
update.AddFloat("percent", percentage);
|
||||||
update.AddInt64("time", system_time());
|
update.AddInt64("time", system_time());
|
||||||
|
|
||||||
#if 1
|
|
||||||
static bigtime_t last;
|
|
||||||
static int32 lastHash;
|
|
||||||
int32 hash = *(int32*)message;
|
|
||||||
|
|
||||||
if (system_time() - last > 500000 || hash != lastHash) {
|
|
||||||
printf("%6.3fs: %3.1f%% %s\n",
|
|
||||||
(system_time() - gStart) / 1000000.0, percentage, message);
|
|
||||||
last = system_time();
|
|
||||||
lastHash = hash;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
messenger.SendMessage(&update);
|
messenger.SendMessage(&update);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,8 +200,6 @@ RAWTranslator::DerivedTranslate(BPositionIO* source,
|
|||||||
size_t bufferSize;
|
size_t bufferSize;
|
||||||
status_t status;
|
status_t status;
|
||||||
|
|
||||||
gStart = system_time();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
status = raw.Identify();
|
status = raw.Identify();
|
||||||
|
|
||||||
@@ -211,7 +209,7 @@ RAWTranslator::DerivedTranslate(BPositionIO* source,
|
|||||||
imageIndex--;
|
imageIndex--;
|
||||||
else
|
else
|
||||||
imageIndex = 0;
|
imageIndex = 0;
|
||||||
|
|
||||||
if (imageIndex < 0 || imageIndex >= (int32)raw.CountImages())
|
if (imageIndex < 0 || imageIndex >= (int32)raw.CountImages())
|
||||||
status = B_BAD_VALUE;
|
status = B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
@@ -224,7 +222,8 @@ RAWTranslator::DerivedTranslate(BPositionIO* source,
|
|||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return B_NO_TRANSLATOR;
|
return B_NO_TRANSLATOR;
|
||||||
|
|
||||||
printf("TOTAL: %6.3fs\n", (system_time() - gStart) / 1000000.0);
|
FreeAllocation _(buffer);
|
||||||
|
// frees the buffer on destruction
|
||||||
|
|
||||||
image_meta_info meta;
|
image_meta_info meta;
|
||||||
raw.GetMetaInfo(meta);
|
raw.GetMetaInfo(meta);
|
||||||
|
|||||||
Reference in New Issue
Block a user