1 /*
2     RawSpeed - RAW file decoder.
3 
4     Copyright (C) 2009-2014 Klaus Post
5     Copyright (C) 2017 Axel Waggershauser
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 #pragma once
23 
24 #include <cstdint> // for uint32_t
25 #include <map>     // for map
26 #include <memory>  // for unique_ptr
27 #include <utility> // for pair
28 #include <vector>  // for vector
29 
30 namespace rawspeed {
31 
32 class RawImage;
33 
34 class TiffEntry;
35 
36 class ByteStream;
37 
38 class DngOpcodes
39 {
40 public:
41   DngOpcodes(const RawImage& ri, TiffEntry* entry);
42   ~DngOpcodes();
43   void applyOpCodes(const RawImage& ri);
44 
45 private:
46   class DngOpcode;
47   std::vector<std::unique_ptr<DngOpcode>> opcodes;
48 
49 protected:
50   class FixBadPixelsConstant;
51   class FixBadPixelsList;
52   class ROIOpcode;
53   class DummyROIOpcode;
54   class TrimBounds;
55   class PixelOpcode;
56   class LookupOpcode;
57   class TableMap;
58   class PolynomialMap;
59   class DeltaRowOrColBase;
60   template <typename S> class DeltaRowOrCol;
61   template <typename S> class OffsetPerRowOrCol;
62   template <typename S> class ScalePerRowOrCol;
63 
64   template <class Opcode>
65   static std::unique_ptr<DngOpcode> constructor(const RawImage& ri,
66                                                 ByteStream* bs);
67 
68   using constructor_t = std::unique_ptr<DngOpcode> (*)(const RawImage& ri,
69                                                        ByteStream* bs);
70   static const std::map<uint32_t, std::pair<const char*, constructor_t>> Map;
71 };
72 
73 } // namespace rawspeed
74