48 static const std::array<char, 4> magic = {{0x00,
'M',
'R',
'M'}};
50 return 0 == memcmp(data.
begin(), magic.data(), magic.size());
55 ThrowRDE(
"This isn't actually a MRW file, why are you calling me?");
64 const auto headerSize = bs.
getU32();
65 (void)bs.
check(headerSize);
68 const auto dataOffset = bs.
getPosition() + headerSize;
75 bool foundPRD =
false;
81 ThrowRDE(
"Found entry of zero length, MRW is corrupt.");
101 if (12 !=
bpp && 16 !=
bpp)
105 ThrowRDE(
"Bad combination of image size and raw dimensions.");
111 if (0x52 != SM && 0x59 != SM)
116 ThrowRDE(
"Packed/BPP sanity check failed!");
130 std::array<float, 4> wbCoeffs;
132 for (
auto& wb_coeff : wbCoeffs)
133 wb_coeff =
static_cast<float>(bs.
getU16());
148 ThrowRDE(
"Did not find PRD tag. Image corrupt.");
154 assert(imageBits % 8 == 0);
170 u.readUncompressedRaw();
176 u.readUncompressedRaw();
184 ThrowRDE(
"Couldn't find make and model");
195 ThrowRDE(
"Couldn't find make and model");
201 if (
hints.contains(
"swapped_wb")) {
202 std::array<float, 4> wbCoeffs = {};
203 wbCoeffs[0] = (*wb_coeffs)[2];
204 wbCoeffs[1] = (*wb_coeffs)[0];
205 wbCoeffs[2] = (*wb_coeffs)[1];
206 mRaw->metadata.wbCoeffs = wbCoeffs;
208 std::array<float, 4> wbCoeffs = {};
209 wbCoeffs[0] = (*wb_coeffs)[0];
210 wbCoeffs[1] = (*wb_coeffs)[1];
211 wbCoeffs[2] = (*wb_coeffs)[3];
212 mRaw->metadata.wbCoeffs = wbCoeffs;
assert(dim.area() >=area)
Buffer getSubView(size_type offset, size_type size_) const
const uint8_t * begin() const
size_type check(size_type bytes) const
size_type RAWSPEED_READONLY getRemainSize() const
void setPosition(size_type newPos)
Buffer getBuffer(size_type size_)
ByteStream getSubStream(size_type offset, size_type size_) const
void skipBytes(size_type nbytes)
size_type getPosition() const
void decodeMetaDataInternal(const CameraMetaData *meta) override
RawImage decodeRawInternal() override
static int isMRW(Buffer input)
Optional< std::array< float, 4 > > wb_coeffs
void checkSupportInternal(const CameraMetaData *meta) override
virtual void setMetaData(const CameraMetaData *meta, const std::string &make, const std::string &model, const std::string &mode, int iso_speed=0)
bool checkCameraSupported(const CameraMetaData *meta, const std::string &make, const std::string &model, const std::string &mode)
static TiffRootIFDOwner parse(TiffIFD *parent, Buffer data)