1 /*
2 RawSpeed - RAW file decoder.
3
4 Copyright (C) 2009-2014 Klaus Post
5 Copyright (C) 2014 Pedro Côrte-Real
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include "decoders/MefDecoder.h"
23 #include "decoders/RawDecoderException.h" // for ThrowRDE
24 #include "decompressors/UncompressedDecompressor.h" // for UncompressedDeco...
25 #include "io/Buffer.h" // for Buffer, DataBuffer
26 #include "io/ByteStream.h" // for ByteStream
27 #include "io/Endianness.h" // for Endianness, Endi...
28 #include <string> // for operator==, string
29
30 namespace rawspeed {
31
isAppropriateDecoder(const TiffRootIFD * rootIFD,const Buffer & file)32 bool MefDecoder::isAppropriateDecoder(const TiffRootIFD* rootIFD,
33 const Buffer& file) {
34 const auto id = rootIFD->getID();
35 const std::string& make = id.make;
36
37 // FIXME: magic
38
39 return make == "Mamiya-OP Co.,Ltd.";
40 }
41
checkImageDimensions()42 void MefDecoder::checkImageDimensions() {
43 if (width > 4016 || height > 5344)
44 ThrowRDE("Unexpected image dimensions found: (%u; %u)", width, height);
45 }
46
decodeRawInternal()47 RawImage MefDecoder::decodeRawInternal() {
48 SimpleTiffDecoder::prepareForRawDecoding();
49
50 UncompressedDecompressor u(
51 ByteStream(DataBuffer(mFile.getSubView(off), Endianness::little)), mRaw);
52
53 u.decode12BitRaw<Endianness::big>(width, height);
54
55 return mRaw;
56 }
57
decodeMetaDataInternal(const CameraMetaData * meta)58 void MefDecoder::decodeMetaDataInternal(const CameraMetaData* meta) {
59 setMetaData(meta, "", 0);
60 }
61
62 } // namespace rawspeed
63