libopenraw  0.3.7
ciffcontainer.hpp
1 /* -*- Mode: C++ -*- */
2 /*
3  * libopenraw - ciffcontainer.hpp
4  *
5  * Copyright (C) 2006-2020 Hubert Figuière
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 License
9  * as published by the Free Software Foundation, either version 3 of
10  * 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, see
19  * <http://www.gnu.org/licenses/>.
20  */
21 
22 #pragma once
23 
24 #include <stddef.h>
25 #include <stdint.h>
26 #include <sys/types.h>
27 
28 #include <vector>
29 #include <memory>
30 
31 #include <libopenraw/debug.h>
32 
33 #include "io/stream.hpp"
34 #include "ciff/heap.hpp"
35 #include "rawcontainer.hpp"
36 #include "trace.hpp"
37 
38 namespace OpenRaw {
39 namespace Internals {
40 
41 class CIFFContainer;
42 
47 namespace CIFF {
48 
54 enum {
55  TAG_NULLRECORD = 0x0000,
56  TAG_FREEBYTES = 0x0001,
57  TAG_COLORINFO1 = 0x0032,
58  TAG_FILEDESCRIPTION = 0x0805,
59  TAG_RAWMAKEMODEL = 0x080a,
60  TAG_FIRMWAREVERSION = 0x080b,
61  TAG_COMPONENTVERSION = 0x080c,
62  TAG_ROMOPERATIONMODE = 0x080d,
63  TAG_OWNERNAME = 0x0810,
64  TAG_IMAGETYPE = 0x0815,
65  TAG_ORIGINALFILENAME = 0x0816,
66  TAG_THUMBNAILFILENAME = 0x0817,
67 
68  TAG_TARGETIMAGETYPE = 0x100a,
69  TAG_SHUTTERRELEASEMETHOD = 0x1010,
70  TAG_SHUTTERRELEASETIMING = 0x1011,
71  TAG_RELEASESETTING = 0x1016,
72  TAG_BASEISO = 0x101c,
73  TAG_FOCALLENGTH = 0x1029,
74  TAG_SHOTINFO = 0x102a,
75  TAG_COLORINFO2 = 0x102c,
76  TAG_CAMERASETTINGS = 0x102d,
77  TAG_SENSORINFO = 0x1031,
78  TAG_CUSTOMFUNCTIONS = 0x1033,
79  TAG_PICTUREINFO = 0x1038,
80  TAG_WHITEBALANCETABLE = 0x10a9,
81  TAG_COLORSPACE = 0x10b4,
82 
83  TAG_IMAGESPEC = 0x1803,
84  TAG_RECORDID = 0x1804,
85  TAG_SELFTIMERTIME = 0x1806,
86  TAG_TARGETDISTANCESETTING = 0x1807,
87  TAG_SERIALNUMBER = 0x180b,
88  TAG_CAPTUREDTIME = 0x180e,
89  TAG_IMAGEINFO = 0x1810,
90  TAG_FLASHINFO = 0x1813,
91  TAG_MEASUREDEV = 0x1814,
92  TAG_FILENUMBER = 0x1817,
93  TAG_EXPOSUREINFO = 0x1818,
94  TAG_DECODERTABLE = 0x1835,
95 
96  TAG_RAWIMAGEDATA = 0x2005,
97  TAG_JPEGIMAGE = 0x2007,
98  TAG_JPEGTHUMBNAIL = 0x2008,
99 
100  TAG_IMAGEDESCRIPTION = 0x2804,
101  TAG_CAMERAOBJECT = 0x2807,
102  TAG_SHOOTINGRECORD = 0x3002,
103  TAG_MEASUREDINFO = 0x3003,
104  TAG_CAMERASPECIFICATION = 0x3004,
105  TAG_IMAGEPROPS = 0x300a,
106  TAG_EXIFINFORMATION = 0x300b
107 };
108 
109 class Heap;
110 
112 typedef std::vector<uint16_t> CameraSettings;
113 
117 {
118 public:
119  ImageSpec()
120  : imageWidth(0), imageHeight(0),
123  colorBW(0)
124  {
125  }
126 
132  bool readFrom(off_t offset, CIFFContainer *container);
135  int32_t exifOrientation() const;
136 
137  uint32_t imageWidth;
138  uint32_t imageHeight;
139  uint32_t /*float32*/pixelAspectRatio;
140  int32_t rotationAngle;
141  uint32_t componentBitDepth;
142  uint32_t colorBitDepth;
143  uint32_t colorBW;
144 };
145 
146 
147 
148 } /* namespace CIFF */
149 
154  : public RawContainer
155 {
156 public:
157  CIFFContainer(const IO::Stream::Ptr &file);
158  virtual ~CIFFContainer();
159 
160  CIFFContainer(const CIFFContainer &) = delete;
161  CIFFContainer & operator=(const CIFFContainer &) = delete;
162 
163  CIFF::HeapRef heap();
164 
165  const CIFF::HeapFileHeader & header() const
166  {
167  return m_hdr;
168  }
169  CIFF::HeapRef getImageProps();
170  const CIFF::RecordEntry * getRawDataRecord() const;
171  const CIFF::ImageSpec * getImageSpec();
172  CIFF::HeapRef getCameraProps();
173  CIFF::HeapRef getExifInfo();
174  CIFF::CameraSettings getCameraSettings();
175 private:
176  bool _loadHeap();
177  EndianType _readHeader();
178 
179  friend class CIFF::HeapFileHeader;
180  CIFF::HeapFileHeader m_hdr;
181  CIFF::HeapRef m_heap;
182  CIFF::HeapRef m_imageprops;
183  bool m_hasImageSpec;
184  CIFF::ImageSpec m_imagespec;
185  CIFF::HeapRef m_cameraprops;
186  CIFF::HeapRef m_exifinfo;
187 };
188 
189 
190 }
191 }
std::shared_ptr< Stream > Ptr
Definition: stream.hpp:47
Header of heap CIFF file.
Definition: heap.hpp:85
ImageSpec struct from CIFF.
bool readFrom(off_t offset, CIFFContainer *container)
A record entry from a CIFF Heap.
Definition: recordentry.hpp:69
Generic interface for the RAW file container.
EndianType
Define the endian of the container.
std::shared_ptr< Heap > HeapRef
Shared ptr to Heap.
Definition: heap.hpp:38
std::vector< uint16_t > CameraSettings
Camera settings are stored as array of 16-bits int.
Global namespace for libopenraw.
Definition: arwfile.cpp:29