libopenraw  0.3.7
ifdfile.hpp
1 /* -*- Mode: C++ -*- */
2 /*
3  * libopenraw - ifdfile.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 <stdint.h>
25 #include <sys/types.h>
26 
27 #include <vector>
28 
29 #include <libopenraw/consts.h>
30 
31 #include "rawfile.hpp"
32 #include "io/stream.hpp"
33 #include "ifd.hpp"
34 #include "rawcontainer.hpp"
35 #include "ifddir.hpp"
36 #include "makernotedir.hpp"
37 
38 namespace OpenRaw {
39 
40 class MetaValue;
41 class RawData;
42 
43 namespace Internals {
48 class IfdFileContainer;
49 
51 class IfdFile : public OpenRaw::RawFile {
52 #if defined(IN_TESTSUITE)
53 public:
54  friend class ::Test; // for testing
55 #endif
56 
57 protected:
58  IfdFile(const IO::Stream::Ptr &s, Type _type,
59  bool instantiateContainer = true);
60  virtual ~IfdFile();
61 
68  std::vector<uint32_t> &list) override;
69 
74  ::or_error _addThumbnailFromStream(uint32_t offset, uint32_t len,
75  std::vector<uint32_t>& list);
80  ::or_error _addThumbnailFromEntry(const IfdEntry::Ref& e, off_t offset,
81  std::vector<uint32_t>& list);
82 
89  std::vector<uint32_t> &list);
96 
103  virtual uint32_t _getJpegThumbnailOffset(const IfdDir::Ref &dir,
104  uint32_t &len);
105 
110  virtual RawContainer *getContainer() const override;
111 
113  virtual IfdDir::Ref _locateCfaIfd() override;
115  virtual IfdDir::Ref _locateMainIfd() override;
116 
118  virtual void _identifyId() override;
119 
121  virtual MetaValue *_getMetaValue(int32_t meta_index) override;
122 
129  virtual uint32_t _translateCompressionType(
130  IFD::TiffCompress tiffCompression);
131 
142  virtual ::or_error _unpackData(uint16_t bpc, uint32_t compression,
143  RawData &data, uint32_t x, uint32_t y,
144  uint32_t offset, uint32_t byte_length);
145 
147  virtual ::or_error _getRawData(RawData &data, uint32_t options) override;
150 
151 private:
152 
153  IfdFile(const IfdFile &) = delete;
154  IfdFile &operator=(const IfdFile &) = delete;
155 };
157 }
158 }
159 
160 /*
161  Local Variables:
162  mode:c++
163  c-file-style:"stroustrup"
164  c-file-offsets:((innamespace . 0))
165  tab-width:2
166  c-basic-offset:2
167  indent-tabs-mode:nil
168  fill-column:80
169  End:
170 */
std::shared_ptr< Stream > Ptr
Definition: stream.hpp:47
std::shared_ptr< IfdDir > Ref
Shared ptr of an IfdDir.
Definition: ifddir.hpp:56
std::shared_ptr< IfdEntry > Ref
IfdEntry reference (ie shared pointer)
Definition: ifdentry.hpp:202
A generic IFD (TIFF) based raw file.
Definition: ifdfile.hpp:51
virtual ::or_error _unpackData(uint16_t bpc, uint32_t compression, RawData &data, uint32_t x, uint32_t y, uint32_t offset, uint32_t byte_length)
Unpack the data.
Definition: ifdfile.cpp:685
::or_error _addThumbnailFromStream(uint32_t offset, uint32_t len, std::vector< uint32_t > &list)
Add a thumbnail from a stream.
Definition: ifdfile.cpp:133
IO::Stream::Ptr m_io
Definition: ifdfile.hpp:106
virtual ::or_error _decompressIfNeeded(RawData &, uint32_t)
Call to decompress if needed from _getRawData()
Definition: ifdfile.cpp:527
virtual ::or_error _enumThumbnailSizes(std::vector< uint32_t > &list) override
List the thumbnails in the IFD.
Definition: ifdfile.cpp:173
IfdFileContainer * m_container
Definition: ifdfile.hpp:107
virtual ::or_error _getRawData(RawData &data, uint32_t options) override
Get the RAW data.
Definition: ifdfile.cpp:508
virtual ::or_error _locateThumbnail(const IfdDir::Ref &dir, std::vector< uint32_t > &list)
Locate the thumnail in the IFD.
Definition: ifdfile.cpp:209
virtual IfdDir::Ref _locateCfaIfd() override
Locate the IFD for the raw data.
Definition: ifdfile.cpp:73
::or_error _getRawDataFromDir(RawData &data, const IfdDir::Ref &dir)
Load the compressed raw data from a standard location in an IFD.
Definition: ifdfile.cpp:533
virtual RawContainer * getContainer() const override
Get the container.
Definition: ifdfile.cpp:336
virtual void _identifyId() override
Identify the file and set the ID internally.
Definition: ifdfile.cpp:93
::or_error _addThumbnailFromEntry(const IfdEntry::Ref &e, off_t offset, std::vector< uint32_t > &list)
Add the thumbnail found in the IfdEntry.
Definition: ifdfile.cpp:158
virtual MetaValue * _getMetaValue(int32_t meta_index) override
Implementation for getMetaValue()
Definition: ifdfile.cpp:356
virtual uint32_t _getJpegThumbnailOffset(const IfdDir::Ref &dir, uint32_t &len)
Get the JPEG thumbnail offset from dir.
Definition: ifdfile.cpp:341
virtual IfdDir::Ref _locateMainIfd() override
Locate the main IFD.
Definition: ifdfile.cpp:79
virtual uint32_t _translateCompressionType(IFD::TiffCompress tiffCompression)
Translate the compression type from the tiff type (16MSB) to the RAW specific type if needed (16MSB)
Definition: ifdfile.cpp:382
Generic interface for the RAW file container.
Metadata value.
Definition: metavalue.hpp:35
Represent camera raw data.
Definition: rawdata.hpp:38
RAW file.
Definition: rawfile.hpp:66
or_rawfile_type
Types of RAW files.
Definition: consts.h:59
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