RawSpeed
fast raw decoding library
Loading...
Searching...
No Matches
NefDecoder.h
Go to the documentation of this file.
1/*
2 RawSpeed - RAW file decoder.
3
4 Copyright (C) 2009-2014 Klaus Post
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19*/
20
21#pragma once
22
23#include "common/RawImage.h"
25#include "decoders/RawDecoder.h"
26#include "io/Buffer.h"
27#include "tiff/TiffIFD.h"
28#include <array>
29#include <cstdint>
30#include <string>
31#include <utility>
32#include <vector>
33
34namespace rawspeed {
35
36class Buffer;
37class ByteStream;
38class CameraMetaData;
39class iPoint2D;
40
41class NefDecoder final : public AbstractTiffDecoder {
42public:
43 static bool isAppropriateDecoder(const TiffRootIFD* rootIFD, Buffer file);
45 : AbstractTiffDecoder(std::move(root), file) {}
46
47 RawImage decodeRawInternal() override;
48 void decodeMetaDataInternal(const CameraMetaData* meta) override;
49 void checkSupportInternal(const CameraMetaData* meta) override;
50
51private:
52 struct NefSlice final : RawSlice {};
53
54 [[nodiscard]] int getDecoderVersion() const override { return 5; }
55 [[nodiscard]] bool D100IsCompressed(uint32_t offset) const;
56 static bool NEFIsUncompressed(const TiffIFD* raw);
57 static bool NEFIsUncompressedRGB(const TiffIFD* raw);
58 void DecodeUncompressed() const;
59 void DecodeD100Uncompressed() const;
60 void DecodeSNefUncompressed() const;
61 void readCoolpixSplitRaw(ByteStream input, const iPoint2D& size,
62 const iPoint2D& offset, int inputPitch) const;
63 void DecodeNikonSNef(ByteStream input) const;
64 void parseWhiteBalance() const;
65 [[nodiscard]] int getBitPerSample() const;
66 [[nodiscard]] std::string getMode() const;
67 [[nodiscard]] std::string getExtendedMode(const std::string& mode) const;
68 static std::vector<uint16_t> gammaCurve(double pwr, double ts, int imax);
69
70 // We use this for the D50 and D2X whacky WB "encryption"
71 static const std::array<uint8_t, 256> serialmap;
72 static const std::array<uint8_t, 256> keymap;
73};
74
75} // namespace rawspeed
AbstractTiffDecoder(TiffRootIFDOwner &&root, Buffer file)
std::string getExtendedMode(const std::string &mode) const
int getDecoderVersion() const override
Definition NefDecoder.h:54
static bool NEFIsUncompressed(const TiffIFD *raw)
static std::vector< uint16_t > gammaCurve(double pwr, double ts, int imax)
static bool NEFIsUncompressedRGB(const TiffIFD *raw)
void DecodeNikonSNef(ByteStream input) const
std::string getMode() const
RawImage decodeRawInternal() override
void DecodeSNefUncompressed() const
NefDecoder(TiffRootIFDOwner &&root, Buffer file)
Definition NefDecoder.h:44
void DecodeD100Uncompressed() const
void checkSupportInternal(const CameraMetaData *meta) override
void DecodeUncompressed() const
void decodeMetaDataInternal(const CameraMetaData *meta) override
static const std::array< uint8_t, 256 > serialmap
Definition NefDecoder.h:71
static bool isAppropriateDecoder(const TiffRootIFD *rootIFD, Buffer file)
bool D100IsCompressed(uint32_t offset) const
void readCoolpixSplitRaw(ByteStream input, const iPoint2D &size, const iPoint2D &offset, int inputPitch) const
static const std::array< uint8_t, 256 > keymap
Definition NefDecoder.h:72
int getBitPerSample() const
void parseWhiteBalance() const
std::unique_ptr< TiffRootIFD > TiffRootIFDOwner
Definition TiffIFD.h:46