Skip to content
This repository has been archived by the owner on Jul 22, 2018. It is now read-only.

Commit

Permalink
Cr2Decoder::decodeRawInternal(): don't stack-allocate LJpegPlain
Browse files Browse the repository at this point in the history
Was taking ~27Kb
  • Loading branch information
LebedevRI committed Nov 4, 2016
1 parent e39d1bb commit f73cc07
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions RawSpeed/Cr2Decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ RawImage Cr2Decoder::decodeRawInternal() {
}

mRaw->createData();
LJpegPlain l(mFile, mRaw);
LJpegPlain *l = new LJpegPlain(mFile, mRaw);
try {
l.startDecoder(off, mFile->getSize()-off, 0, 0);
l->startDecoder(off, mFile->getSize()-off, 0, 0);
} catch (IOException& e) {
mRaw->setError(e.what());
}

delete l;

if(hints.find("double_line_ljpeg") != hints.end()) {
// We now have a double width half height image we need to convert to the
// normal format
Expand Down Expand Up @@ -144,8 +146,9 @@ RawImage Cr2Decoder::decodeRawInternal() {
slice.offset = offsets[0].getInt();
slice.count = counts[0].getInt();
SOFInfo sof;
LJpegPlain l(mFile, mRaw);
l.getSOF(&sof, slice.offset, slice.count);
LJpegPlain *l = new LJpegPlain(mFile, mRaw);
l->getSOF(&sof, slice.offset, slice.count);
delete l;
slice.w = sof.w * sof.cps;
slice.h = sof.h;
if (sof.cps == 4 && slice.w > slice.h * 4) {
Expand Down Expand Up @@ -212,12 +215,13 @@ RawImage Cr2Decoder::decodeRawInternal() {
for (uint32 i = 0; i < slices.size(); i++) {
Cr2Slice slice = slices[i];
try {
LJpegPlain l(mFile, mRaw);
l.addSlices(s_width);
l.mUseBigtable = true;
l.mCanonFlipDim = flipDims;
l.mCanonDoubleHeight = doubleHeight;
l.startDecoder(slice.offset, slice.count, 0, offY);
LJpegPlain *l = new LJpegPlain(mFile, mRaw);
l->addSlices(s_width);
l->mUseBigtable = true;
l->mCanonFlipDim = flipDims;
l->mCanonDoubleHeight = doubleHeight;
l->startDecoder(slice.offset, slice.count, 0, offY);
delete l;
} catch (RawDecoderException &e) {
if (i == 0)
throw;
Expand Down

0 comments on commit f73cc07

Please sign in to comment.