Skip to content

Commit 2be2bda

Browse files
committed
possible multiframe RawImage
1 parent c4939da commit 2be2bda

27 files changed

+497
-475
lines changed

src/librawspeed/common/RawImage.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141

4242
namespace rawspeed {
4343

44-
class RawImage;
45-
4644
class RawImageData;
4745

4846
enum class RawImageType { UINT16, F32 };
@@ -226,6 +224,27 @@ class RawImageDataFloat final : public RawImageData {
226224
friend class RawImage;
227225
};
228226

227+
class RawImageAbstract
228+
{
229+
230+
};
231+
232+
class RawImage {
233+
using storage_t = std::vector<std::shared_ptr<RawImageData>>;
234+
235+
public:
236+
[[nodiscard]] std::shared_ptr<RawImageData>
237+
get(storage_t::size_type pos) const {
238+
return data.at(pos);
239+
}
240+
[[nodiscard]] storage_t::size_type numFrames() const { return data.size(); }
241+
void clear() { data.clear(); }
242+
void appendFrame(RawImageData* frame) { data.emplace_back(frame); }
243+
244+
private:
245+
std::vector<std::shared_ptr<RawImageData>> data;
246+
};
247+
229248
// setWithLookUp will set a single pixel by using the lookup table if supplied,
230249
// You must supply the destination where the value should be written, and a
231250
// pointer to a value that will be used to store a random counter that can be

src/librawspeed/common/RawImageDataFloat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ RawImageDataFloat::RawImageDataFloat() {
141141
calculateBlackAreas();
142142

143143
startWorker(RawImageWorker::RawImageWorkerTask::SCALE_VALUES, true);
144-
}
144+
}
145145

146146
#if 0 // def WITH_SSE2
147147

src/librawspeed/decoders/ArwDecoder.cpp

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ void ArwDecoder::decodeSRF(const TiffIFD* raw) {
9595
Buffer di(std::move(image_decoded), len);
9696

9797
// And now decode as a normal 16bit raw
98-
mRaw->dim = iPoint2D(width, height);
99-
mRaw->createData();
98+
mRaw.get(0)->dim = iPoint2D(width, height);
99+
mRaw.get(0)->createData();
100100

101101
UncompressedDecompressor u(
102102
ByteStream(DataBuffer(di.getSubView(0, len), Endianness::little)),
103-
mRaw.get());
103+
mRaw.get(0).get());
104104
u.decodeRawUnpacked<16, Endianness::big>(width, height);
105105
}
106106

@@ -119,11 +119,11 @@ void ArwDecoder::decodeRawInternal() {
119119
uint32_t width = 3881;
120120
uint32_t height = 2608;
121121

122-
mRaw->dim = iPoint2D(width, height);
122+
mRaw.get(0)->dim = iPoint2D(width, height);
123123

124124
ByteStream input(DataBuffer(mFile.getSubView(off), Endianness::little));
125-
SonyArw1Decompressor a(mRaw.get());
126-
mRaw->createData();
125+
SonyArw1Decompressor a(mRaw.get(0).get());
126+
mRaw.get(0)->createData();
127127
a.decompress(input);
128128

129129
return;
@@ -193,7 +193,7 @@ void ArwDecoder::decodeRawInternal() {
193193
if (arw1)
194194
height += 8;
195195

196-
mRaw->dim = iPoint2D(width, height);
196+
mRaw.get(0)->dim = iPoint2D(width, height);
197197

198198
std::vector<uint16_t> curve(0x4001);
199199
const TiffEntry* c = raw->getEntry(TiffTag::SONY_CURVE);
@@ -209,7 +209,7 @@ void ArwDecoder::decodeRawInternal() {
209209
for (uint32_t j = sony_curve[i] + 1; j <= sony_curve[i + 1]; j++)
210210
curve[j] = curve[j - 1] + (1 << i);
211211

212-
RawImageCurveGuard curveHandler(mRaw.get(), curve, uncorrectedRawValues);
212+
RawImageCurveGuard curveHandler(mRaw.get(0).get(), curve, uncorrectedRawValues);
213213

214214
uint32_t c2 = counts->getU32();
215215
uint32_t off = offsets->getU32();
@@ -223,8 +223,8 @@ void ArwDecoder::decodeRawInternal() {
223223
ByteStream input(DataBuffer(mFile.getSubView(off, c2), Endianness::little));
224224

225225
if (arw1) {
226-
SonyArw1Decompressor a(mRaw.get());
227-
mRaw->createData();
226+
SonyArw1Decompressor a(mRaw.get(0).get());
227+
mRaw.get(0)->createData();
228228
a.decompress(input);
229229
} else
230230
DecodeARW2(input, width, height, bitPerPixel);
@@ -236,7 +236,7 @@ void ArwDecoder::DecodeUncompressed(const TiffIFD* raw) const {
236236
uint32_t off = raw->getEntry(TiffTag::STRIPOFFSETS)->getU32();
237237
uint32_t c2 = raw->getEntry(TiffTag::STRIPBYTECOUNTS)->getU32();
238238

239-
mRaw->dim = iPoint2D(width, height);
239+
mRaw.get(0)->dim = iPoint2D(width, height);
240240

241241
if (width == 0 || height == 0 || width > 9600 || height > 6376)
242242
ThrowRDE("Unexpected image dimensions found: (%u; %u)", width, height);
@@ -246,10 +246,10 @@ void ArwDecoder::DecodeUncompressed(const TiffIFD* raw) const {
246246

247247
const Buffer buf(mFile.getSubView(off, c2));
248248

249-
mRaw->createData();
249+
mRaw.get(0)->createData();
250250

251251
UncompressedDecompressor u(ByteStream(DataBuffer(buf, Endianness::little)),
252-
mRaw.get());
252+
mRaw.get(0).get());
253253

254254
if (hints.has("sr2_format"))
255255
u.decodeRawUnpacked<14, Endianness::big>(width, height);
@@ -261,16 +261,16 @@ void ArwDecoder::DecodeARW2(const ByteStream& input, uint32_t w, uint32_t h,
261261
uint32_t bpp) {
262262

263263
if (bpp == 8) {
264-
SonyArw2Decompressor a2(mRaw.get(), input);
265-
mRaw->createData();
264+
SonyArw2Decompressor a2(mRaw.get(0).get(), input);
265+
mRaw.get(0)->createData();
266266
a2.decompress();
267267
return;
268268
} // End bpp = 8
269269

270270
if (bpp == 12) {
271-
mRaw->createData();
271+
mRaw.get(0)->createData();
272272
UncompressedDecompressor u(
273-
ByteStream(DataBuffer(input, Endianness::little)), mRaw.get());
273+
ByteStream(DataBuffer(input, Endianness::little)), mRaw.get(0).get());
274274
u.decode12BitRaw<Endianness::little>(w, h);
275275

276276
// Shift scales, since black and white are the same as compressed precision
@@ -326,9 +326,9 @@ void ArwDecoder::ParseA100WB() const {
326326
for (auto& coeff : tmp)
327327
coeff = bs.getU16();
328328

329-
mRaw->metadata.wbCoeffs[0] = static_cast<float>(tmp[0]);
330-
mRaw->metadata.wbCoeffs[1] = static_cast<float>(tmp[1]);
331-
mRaw->metadata.wbCoeffs[2] = static_cast<float>(tmp[3]);
329+
mRaw.get(0)->metadata.wbCoeffs[0] = static_cast<float>(tmp[0]);
330+
mRaw.get(0)->metadata.wbCoeffs[1] = static_cast<float>(tmp[1]);
331+
mRaw.get(0)->metadata.wbCoeffs[2] = static_cast<float>(tmp[3]);
332332

333333
// only need this one block, no need to process any further
334334
break;
@@ -339,7 +339,7 @@ void ArwDecoder::decodeMetaDataInternal(const CameraMetaData* meta) {
339339
//Default
340340
int iso = 0;
341341

342-
mRaw->cfa.setCFA(iPoint2D(2, 2), CFAColor::RED, CFAColor::GREEN,
342+
mRaw.get(0)->cfa.setCFA(iPoint2D(2, 2), CFAColor::RED, CFAColor::GREEN,
343343
CFAColor::GREEN, CFAColor::BLUE);
344344

345345
if (mRootIFD->hasEntryRecursive(TiffTag::ISOSPEEDRATINGS))
@@ -348,8 +348,8 @@ void ArwDecoder::decodeMetaDataInternal(const CameraMetaData* meta) {
348348
auto id = mRootIFD->getID();
349349

350350
setMetaData(meta, id, "", iso);
351-
mRaw->whitePoint >>= mShiftDownScale;
352-
mRaw->blackLevel >>= mShiftDownScale;
351+
mRaw.get(0)->whitePoint >>= mShiftDownScale;
352+
mRaw.get(0)->blackLevel >>= mShiftDownScale;
353353

354354
// Set the whitebalance
355355
try {
@@ -359,7 +359,7 @@ void ArwDecoder::decodeMetaDataInternal(const CameraMetaData* meta) {
359359
GetWB();
360360
}
361361
} catch (const RawspeedException& e) {
362-
mRaw->setError(e.what());
362+
mRaw.get(0)->setError(e.what());
363363
// We caught an exception reading WB, just ignore it
364364
}
365365
}
@@ -454,16 +454,16 @@ void ArwDecoder::GetWB() const {
454454
const TiffEntry* wb = encryptedIFD.getEntry(TiffTag::SONYGRBGLEVELS);
455455
if (wb->count != 4)
456456
ThrowRDE("WB has %d entries instead of 4", wb->count);
457-
mRaw->metadata.wbCoeffs[0] = wb->getFloat(1);
458-
mRaw->metadata.wbCoeffs[1] = wb->getFloat(0);
459-
mRaw->metadata.wbCoeffs[2] = wb->getFloat(2);
457+
mRaw.get(0)->metadata.wbCoeffs[0] = wb->getFloat(1);
458+
mRaw.get(0)->metadata.wbCoeffs[1] = wb->getFloat(0);
459+
mRaw.get(0)->metadata.wbCoeffs[2] = wb->getFloat(2);
460460
} else if (encryptedIFD.hasEntry(TiffTag::SONYRGGBLEVELS)) {
461461
const TiffEntry* wb = encryptedIFD.getEntry(TiffTag::SONYRGGBLEVELS);
462462
if (wb->count != 4)
463463
ThrowRDE("WB has %d entries instead of 4", wb->count);
464-
mRaw->metadata.wbCoeffs[0] = wb->getFloat(0);
465-
mRaw->metadata.wbCoeffs[1] = wb->getFloat(1);
466-
mRaw->metadata.wbCoeffs[2] = wb->getFloat(3);
464+
mRaw.get(0)->metadata.wbCoeffs[0] = wb->getFloat(0);
465+
mRaw.get(0)->metadata.wbCoeffs[1] = wb->getFloat(1);
466+
mRaw.get(0)->metadata.wbCoeffs[2] = wb->getFloat(3);
467467
}
468468
}
469469
}

0 commit comments

Comments
 (0)