libopenraw
arwfile.cpp
1 /*
2  * libopenraw - arwfile.cpp
3  *
4  * Copyright (C) 2006-2017 Hubert Figuiere
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 License
8  * as published by the Free Software Foundation, either version 3 of
9  * 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, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 #include <libopenraw/cameraids.h>
23 
24 #include "ifdfilecontainer.hpp"
25 #include "arwfile.hpp"
26 #include "rawfile_private.hpp"
27 
28 using namespace Debug;
29 
30 namespace OpenRaw {
31 
32 class RawData;
33 
34 namespace Internals {
35 
36 #define OR_MAKE_SONY_TYPEID(camid) \
37  OR_MAKE_FILE_TYPEID(OR_TYPEID_VENDOR_SONY,camid)
38 
39 /* taken from dcraw, by default */
40 static const BuiltinColourMatrix s_matrices[] = {
41  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A100), 0, 0xfeb,
42  { 9437,-2811,-774,-8405,16215,2290,-710,596,7181 } },
43  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A200), 0, 0,
44  { 9847,-3091,-928,-8485,16345,2225,-715,595,7103 } },
45  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A380), 0, 0,
46  { 6038,-1484,-579,-9145,16746,2512,-875,746,7218 } },
47  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A390), 0, 0,
48  { 6038,-1484,-579,-9145,16746,2512,-875,746,7218 } },
49  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A550), 128, 0xfeb,
50  { 4950,-580,-103,-5228,12542,3029,-709,1435,7371 } },
51  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A560), 128, 0xfeb,
52  { 4950,-580,-103,-5228,12542,3029,-709,1435,7371 } },
53  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A700), 126, 0,
54  { 5775,-805,-359,-8574,16295,2391,-1943,2341,7249 } },
55  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A850), 128, 0,
56  { 5413,-1162,-365,-5665,13098,2866,-608,1179,8440 } },
57  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A900), 128, 0,
58  { 5209,-1072,-397,-8845,16120,2919,-1618,1803,8654 } },
59  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA33), 128, 0,
60  { 6069,-1221,-366,-5221,12779,2734,-1024,2066,6834 } },
61  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA35), 128, 0,
62  { 5986,-1618,-415,-4557,11820,3120,-681,1404,6971 } },
63  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA55), 128, 0,
64  { 5932,-1492,-411,-4813,12285,2856,-741,1524,6739 } },
65  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA57), 128, 0,
66  { 5991,-1456,-455,-4764,12135,2980,-707,1425,6701 } },
67  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA58), 128, 0,
68  { 5991,-1456,-455,-4764,12135,2980,-707,1425,6701 } },
69  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA65), 128, 0,
70  { 5491,-1192,-363,-4951,12342,2948,-911,1722,7192 } },
71  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA77), 128, 0,
72  { 5491,-1192,-363,-4951,12342,2948,-911,1722,7192 } },
73  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA99),
74  0,
75  0,
76  { 6344, -1612, -462, -4863, 12477, 2681, -865, 1786, 6899 } },
77  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX3), 128, 0, /* Adobe */
78  { 6549,-1550,-436,-4880,12435,2753,-854,1868,6976 } },
79  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX5), 128, 0, /* Adobe */
80  { 6549,-1550,-436,-4880,12435,2753,-854,1868,6976 } },
81  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX5N), 128, 0,
82  { 5991,-1456,-455,-4764,12135,2980,-707,1425,6701 } },
83  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX5R), 128, 0,
84  { 6129,-1545,-418,-4930,12490,2743,-977,1693,6615 } },
85  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX5T), 128, 0,
86  { 6129,-1545,-418,-4930,12490,2743,-977,1693,6615 } },
87  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEXC3), 128, 0,
88  { 5991,-1456,-455,-4764,12135,2980,-707,1425,6701 } },
89  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEXF3), 128, 0,
90  { 5991,-1456,-455,-4764,12135,2980,-707,1425,6701 } },
91  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX6), 128, 0,
92  { 6129,-1545,-418,-4930,12490,2743,-977,1693,6615 } },
93  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX7), 128, 0,
94  { 5491,-1192,-363,-4951,12342,2948,-911,1722,7192 } },
95  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX100),
96  0,
97  0,
98  { 8651, -2754, -1057, -3464, 12207, 1373, -568, 1398, 4434 } },
99  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX100M2),
100  0,
101  0,
102  { 6596, -2079, -562, -4782, 13016, 1933, -970, 1581, 5181 } },
103  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX100M3),
104  0,
105  0,
106  { 6596, -2079, -562, -4782, 13016, 1933, -970, 1581, 5181 } },
107  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX100M4),
108  0,
109  0,
110  { 6596, -2079, -562, -4782, 13016, 1933, -970, 1581, 5181 } },
111  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX1),
112  0,
113  0,
114  { 6344, -1612, -462, -4863, 12477, 2681, -865, 1786, 6899 } },
115  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX1R),
116  0,
117  0,
118  { 6344, -1612, -462, -4863, 12477, 2681, -865, 1786, 6899 } },
119  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX1RM2),
120  0,
121  0,
122  { 6629, -1900, -483, -4618, 12349, 2550, -622, 1381, 6514 } },
123 
124  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A3000), 128, 0,
125  { 5991,-1456,-455,-4764,12135,2980,-707,1425,6701 } },
126  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A6000), 128, 0,
127  { 5991,-1456,-455,-4764,12135,2980,-707,1425,6701 } },
128  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A6300),
129  0,
130  0,
131  { 5973, -1695, -419, -3826, 11797, 2293, -639, 1398, 5789 } },
132  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A7), 128, 0,
133  { 5271,-712,-347,-6153,13653,2763,-1601,2366,7242 } },
134  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A7R), 128, 0,
135  { 4913,-541,-202,-6130,13513,2906,-1564,2151,7183 } },
136  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A7RM2),
137  0,
138  0,
139  { 6629, -1900, -483, -4618, 12349, 2550, -622, 1381, 6514 } },
140 
141  { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
142 };
143 
144 const IfdFile::camera_ids_t ArwFile::s_def[] = {
145  { "DSLR-A100", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A100) },
146  { "DSLR-A200", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A200) },
147  { "DSLR-A380", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A380) },
148  { "DSLR-A390", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A390) },
149  { "DSLR-A550", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A550) },
150  { "DSLR-A560", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A560) },
151  { "DSLR-A580", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A580) },
152  { "DSLR-A700", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A700) },
153  { "DSLR-A850", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A850) },
154  { "DSLR-A900", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A900) },
155  { "SLT-A33", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA33) },
156  // Likely a pre-release.
157  { "SLT-A00", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA35) },
158  { "SLT-A55V", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA55) },
159  { "SLT-A57", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA57) },
160  { "SLT-A58", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA58) },
161  { "SLT-A65V", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA65) },
162  { "SLT-A77V", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA77) },
163  { "SLT-A99V", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA99) },
164  { "NEX-3", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX3) },
165  { "NEX-5", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX5) },
166  { "NEX-5N", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX5N) },
167  // There are pre-production files with the type NEX-C00....
168  { "NEX-C3", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEXC3) },
169  { "NEX-F3", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEXF3) },
170  { "NEX-7", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX7) },
171  { "DSC-RX10", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX10) },
172  { "DSC-RX10M2", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX10M2) },
173  { "DSC-RX10M3", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX10M3) },
174  { "DSC-RX100", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX100) },
175  { "DSC-RX100M2", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX100M2) },
176  { "DSC-RX100M3", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX100M3) },
177  { "DSC-RX100M4", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX100M4) },
178  { "DSC-RX100M5", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX100M5) },
179  { "DSC-RX1", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX1) },
180  { "DSC-RX1R", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX1R) },
181  { "DSC-RX1RM2", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX1RM2) },
182  { "NEX-6", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX6) },
183  { "NEX-5R", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX5R) },
184  { "NEX-5T", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX5T) },
185  { "ILCA-99M2", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A99M2) },
186  { "ILCE-3000", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A3000) },
187  { "ILCE-6000", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A6000) },
188  { "ILCE-6300", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A6300) },
189  { "ILCE-6500", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A6500) },
190  { "ILCE-7", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A7) },
191  { "ILCE-7R", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A7R) },
192  { "ILCE-7RM2", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A7RM2) },
193  { 0, 0 }
194 };
195 
196 
197 RawFile *ArwFile::factory(const IO::Stream::Ptr & s)
198 {
199  return new ArwFile(s);
200 }
201 
202 ArwFile::ArwFile(const IO::Stream::Ptr &s)
203  : TiffEpFile(s, OR_RAWFILE_TYPE_ARW)
204 {
205  _setIdMap(s_def);
206  _setMatrices(s_matrices);
207 }
208 
209 ArwFile::~ArwFile()
210 {
211 }
212 
213 IfdDir::Ref ArwFile::_locateCfaIfd()
214 {
215  if(!isA100())
216  {
217  return TiffEpFile::_locateCfaIfd();
218  }
219  return mainIfd();
220 }
221 
222 
223 IfdDir::Ref ArwFile::_locateMainIfd()
224 {
225  return m_container->setDirectory(0);
226 }
227 
228 ::or_error ArwFile::_getRawData(RawData & data, uint32_t options)
229 {
230  if(isA100())
231  {
232  // TODO implement for A100
233  return OR_ERROR_NOT_FOUND;
234  }
235  return TiffEpFile::_getRawData(data, options);
236 }
237 
238 }
239 }
240 /*
241  Local Variables:
242  mode:c++
243  c-file-style:"stroustrup"
244  c-file-offsets:((innamespace . 0))
245  indent-tabs-mode:nil
246  fill-column:80
247  End:
248 */
CIFF is the container for CRW files. It is an attempt from Canon to make this a standard. I guess it failed.
Definition: arwfile.cpp:30
Definition: trace.cpp:30