libopenraw  0.3.7
neffile.hpp
1 /* -*- Mode: C++ -*- */
2 /*
3  * libopenraw - neffile.hpp
4  *
5  * Copyright (C) 2006-2020 Hubert Figuière
6  * Copyright (C) 2008 Novell, Inc.
7  *
8  * This library is free software: you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3 of
11  * the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library. If not, see
20  * <http://www.gnu.org/licenses/>.
21  */
22 
23 #pragma once
24 
25 #include <stdint.h>
26 
27 #include <array>
28 
29 #include <libopenraw/consts.h>
30 
31 #include "rawfile.hpp"
32 #include "tiffepfile.hpp"
33 #include "ifdfile.hpp"
34 #include "io/stream.hpp"
35 
36 
37 namespace OpenRaw {
38 
39 class RawData;
40 
41 namespace Internals {
42 
43 class RawContainer;
44 struct HuffmanNode;
45 
46 class NefFile
47  : public TiffEpFile
48 {
49  template<typename T>
50  friend void audit_coefficients();
51 
52 public:
53  static RawFile *factory(const IO::Stream::Ptr & _f);
54  NefFile(const IO::Stream::Ptr & _f);
55  virtual ~NefFile();
56 
57  NefFile(const NefFile&) = delete;
58  NefFile & operator=(const NefFile &) = delete;
59 
63  static bool isCompressed(RawContainer & container, uint32_t offset);
64  bool isNrw();
65 
67  public:
69  : curve(0x8000, 0) {
70  }
71  uint16_t vpred[2][2];
72  std::vector<uint16_t> curve;
73  const HuffmanNode* huffman;
74  };
75 
76 protected:
77 
78  virtual ::or_error _enumThumbnailSizes(std::vector<uint32_t> &list) override;
79  virtual uint32_t _translateCompressionType(IFD::TiffCompress tiffCompression) override;
80  virtual ::or_error _unpackData(uint16_t bpc, uint32_t compression,
81  RawData &data, uint32_t x, uint32_t y,
82  uint32_t offset, uint32_t byte_length) override;
83 
84 private:
85  static const IfdFile::camera_ids_t s_def[];
86 
87  bool _getCompressionCurve(RawData&, NEFCompressionInfo&);
88  ::or_error _decompressNikonQuantized(RawData&);
89  virtual ::or_error _decompressIfNeeded(RawData&, uint32_t) override;
90 };
91 
92 }
93 }
std::shared_ptr< Stream > Ptr
Definition: stream.hpp:47
static bool isCompressed(RawContainer &container, uint32_t offset)
Definition: neffile.cpp:555
virtual ::or_error _enumThumbnailSizes(std::vector< uint32_t > &list) override
List the thumbnails in the IFD.
Definition: neffile.cpp:599
virtual uint32_t _translateCompressionType(IFD::TiffCompress tiffCompression) override
Translate the compression type from the tiff type (16MSB) to the RAW specific type if needed (16MSB)
Definition: neffile.cpp:622
Generic interface for the RAW file container.
TIFF.EP conformant files.
Definition: tiffepfile.hpp:44
Represent camera raw data.
Definition: rawdata.hpp:38
RAW file.
Definition: rawfile.hpp:66
or_error
Error codes returned by libopenraw.
Definition: consts.h:42
TiffCompress
TIFF compression.
Definition: ifd.hpp:55
Global namespace for libopenraw.
Definition: arwfile.cpp:29