libopenraw
arwfile.cpp
1 /*
2  * libopenraw - arwfile.cpp
3  *
4  * Copyright (C) 2006-2016 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), 128, 0,
74  { 6344,-1612,-462,-4863,12477,2681,-865,1786,6899 } },
75  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX3), 128, 0, /* Adobe */
76  { 6549,-1550,-436,-4880,12435,2753,-854,1868,6976 } },
77  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX5), 128, 0, /* Adobe */
78  { 6549,-1550,-436,-4880,12435,2753,-854,1868,6976 } },
79  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX5N), 128, 0,
80  { 5991,-1456,-455,-4764,12135,2980,-707,1425,6701 } },
81  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX5R), 128, 0,
82  { 6129,-1545,-418,-4930,12490,2743,-977,1693,6615 } },
83  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX5T), 128, 0,
84  { 6129,-1545,-418,-4930,12490,2743,-977,1693,6615 } },
85  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEXC3), 128, 0,
86  { 5991,-1456,-455,-4764,12135,2980,-707,1425,6701 } },
87  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEXF3), 128, 0,
88  { 5991,-1456,-455,-4764,12135,2980,-707,1425,6701 } },
89  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX6), 128, 0,
90  { 6129,-1545,-418,-4930,12490,2743,-977,1693,6615 } },
91  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX7), 128, 0,
92  { 5491,-1192,-363,-4951,12342,2948,-911,1722,7192 } },
93  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX100), 200, 0,
94  { 8651,-2754,-1057,-3464,12207,1373,-568,1398,4434 } },
95  /* Adobe DNG converter 8.1 - strangely dcraw has one different */
96  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX100M2), 200, 0,
97  { 8651,-2754,-1057,-3464,12207,1373,-568,1398,4434 } },
98  /* Adone DNG converter 8.7-rc */
99  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX100M3), 200, 0,
100  { 6596, -2079, -562, -4782, 13016, 1933, -970, 1581, 5181 } },
101  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX1), 128, 0,
102  { 6344,-1612,-462,-4863,12477,2681,-865,1786,6899 } },
103  /* Adobe DNG converter 8.1 */
104  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX1R), 128, 0,
105  { 6344,-1612,-462,-4863,12477,2681,-865,1786,6899 } },
106 
107  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A3000), 128, 0,
108  { 5991,-1456,-455,-4764,12135,2980,-707,1425,6701 } },
109  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A6000), 128, 0,
110  { 5991,-1456,-455,-4764,12135,2980,-707,1425,6701 } },
111  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A7), 128, 0,
112  { 5271,-712,-347,-6153,13653,2763,-1601,2366,7242 } },
113  { OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A7R), 128, 0,
114  { 4913,-541,-202,-6130,13513,2906,-1564,2151,7183 } },
115 
116  { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
117 };
118 
119 const IfdFile::camera_ids_t ArwFile::s_def[] = {
120  { "DSLR-A100", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A100) },
121  { "DSLR-A200", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A200) },
122  { "DSLR-A380", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A380) },
123  { "DSLR-A390", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A390) },
124  { "DSLR-A550", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A550) },
125  { "DSLR-A560", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A560) },
126  { "DSLR-A580", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A580) },
127  { "DSLR-A700", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A700) },
128  { "DSLR-A850", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A850) },
129  { "DSLR-A900", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A900) },
130  { "SLT-A33", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA33) },
131  // Likely a pre-release.
132  { "SLT-A00", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA35) },
133  { "SLT-A55V", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA55) },
134  { "SLT-A57", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA57) },
135  { "SLT-A58", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA58) },
136  { "SLT-A65V", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA65) },
137  { "SLT-A77V", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA77) },
138  { "SLT-A99V", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_SLTA99) },
139  { "NEX-3", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX3) },
140  { "NEX-5", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX5) },
141  { "NEX-5N", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX5N) },
142  // There are pre-production files with the type NEX-C00....
143  { "NEX-C3", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEXC3) },
144  { "NEX-F3", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEXF3) },
145  { "NEX-7", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX7) },
146  { "DSC-RX100", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX100) },
147  { "DSC-RX100M2", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX100M2) },
148  { "DSC-RX100M3", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX100M3) },
149  { "DSC-RX1", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX1) },
150  { "DSC-RX1R", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_RX1R) },
151  { "NEX-6", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX6) },
152  { "NEX-5R", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX5R) },
153  { "NEX-5T", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_NEX5T) },
154  { "ILCE-3000", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A3000) },
155  { "ILCE-6000", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A6000) },
156  { "ILCE-7", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A7) },
157  { "ILCE-7R", OR_MAKE_SONY_TYPEID(OR_TYPEID_SONY_A7R) },
158  { 0, 0 }
159 };
160 
161 
162 RawFile *ArwFile::factory(const IO::Stream::Ptr & s)
163 {
164  return new ArwFile(s);
165 }
166 
167 ArwFile::ArwFile(const IO::Stream::Ptr &s)
168  : TiffEpFile(s, OR_RAWFILE_TYPE_ARW)
169 {
170  _setIdMap(s_def);
171  _setMatrices(s_matrices);
172 }
173 
174 ArwFile::~ArwFile()
175 {
176 }
177 
178 IfdDir::Ref ArwFile::_locateCfaIfd()
179 {
180  if(!isA100())
181  {
182  return TiffEpFile::_locateCfaIfd();
183  }
184  return mainIfd();
185 }
186 
187 
188 IfdDir::Ref ArwFile::_locateMainIfd()
189 {
190  return m_container->setDirectory(0);
191 }
192 
193 ::or_error ArwFile::_getRawData(RawData & data, uint32_t options)
194 {
195  if(isA100())
196  {
197  // TODO implement for A100
198  return OR_ERROR_NOT_FOUND;
199  }
200  return TiffEpFile::_getRawData(data, options);
201 }
202 
203 }
204 }
205 /*
206  Local Variables:
207  mode:c++
208  c-file-style:"stroustrup"
209  c-file-offsets:((innamespace . 0))
210  indent-tabs-mode:nil
211  fill-column:80
212  End:
213 */
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