/src/LibRaw/src/metadata/pentax.cpp
Line | Count | Source |
1 | | /* -*- C++ -*- |
2 | | * Copyright 2019-2025 LibRaw LLC (info@libraw.org) |
3 | | * |
4 | | |
5 | | LibRaw is free software; you can redistribute it and/or modify |
6 | | it under the terms of the one of two licenses as you choose: |
7 | | |
8 | | 1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1 |
9 | | (See file LICENSE.LGPL provided in LibRaw distribution archive for details). |
10 | | |
11 | | 2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 |
12 | | (See file LICENSE.CDDL provided in LibRaw distribution archive for details). |
13 | | |
14 | | */ |
15 | | |
16 | | #include "../../internal/dcraw_defs.h" |
17 | | #include "../../internal/libraw_cameraids.h" |
18 | | |
19 | | void LibRaw::setPentaxBodyFeatures(unsigned long long id) |
20 | 18.5k | { |
21 | | |
22 | 18.5k | ilm.CamID = id; |
23 | | |
24 | 18.5k | switch (id) { |
25 | 38 | case PentaxID_staristD: |
26 | 160 | case PentaxID_staristDS: |
27 | 176 | case PentaxID_staristDL: |
28 | 252 | case PentaxID_staristDS2: |
29 | 290 | case PentaxID_GX_1S: |
30 | 364 | case PentaxID_staristDL2: |
31 | 394 | case PentaxID_GX_1L: |
32 | 1.44k | case PentaxID_K100D: |
33 | 1.91k | case PentaxID_K110D: |
34 | 2.00k | case PentaxID_K100D_Super: |
35 | 2.01k | case PentaxID_K10D: |
36 | 2.02k | case PentaxID_GX10: |
37 | 2.10k | case PentaxID_K20D: |
38 | 2.20k | case PentaxID_GX20: |
39 | 2.36k | case PentaxID_K200D: |
40 | 2.36k | case PentaxID_K2000: |
41 | 2.36k | case PentaxID_K_m: |
42 | 2.44k | case PentaxID_K_x: |
43 | 2.50k | case PentaxID_K_r: |
44 | 2.50k | case PentaxID_K_01: |
45 | 2.50k | case PentaxID_K_3: |
46 | 4.15k | case PentaxID_K_3_II: |
47 | 4.43k | case PentaxID_K_3_III: |
48 | 4.50k | case PentaxID_K_3_III_Mono: |
49 | 4.57k | case PentaxID_K_5: |
50 | 4.67k | case PentaxID_K_5_II: |
51 | 4.74k | case PentaxID_K_5_II_s: |
52 | 4.78k | case PentaxID_K_7: |
53 | 5.00k | case PentaxID_K_30: |
54 | 5.06k | case PentaxID_K_50: |
55 | 5.13k | case PentaxID_K_70: |
56 | 5.20k | case PentaxID_K_500: |
57 | 5.27k | case PentaxID_K_S1: |
58 | 5.34k | case PentaxID_K_S2: |
59 | 5.36k | case PentaxID_KF: |
60 | 5.42k | case PentaxID_KP: |
61 | 5.42k | ilm.CameraMount = LIBRAW_MOUNT_Pentax_K; |
62 | 5.42k | ilm.CameraFormat = LIBRAW_FORMAT_APSC; |
63 | 5.42k | break; |
64 | 260 | case PentaxID_K_1: |
65 | 760 | case PentaxID_K_1_Mark_II: |
66 | 760 | ilm.CameraMount = LIBRAW_MOUNT_Pentax_K; |
67 | 760 | ilm.CameraFormat = LIBRAW_FORMAT_FF; |
68 | 760 | break; |
69 | 0 | case PentaxID_645D: |
70 | 64 | case PentaxID_645Z: |
71 | 64 | ilm.CameraMount = LIBRAW_MOUNT_Pentax_645; |
72 | 64 | ilm.CameraFormat = LIBRAW_FORMAT_CROP645; |
73 | 64 | break; |
74 | 6 | case PentaxID_Q: |
75 | 80 | case PentaxID_Q10: |
76 | 80 | ilm.CameraMount = LIBRAW_MOUNT_Pentax_Q; |
77 | 80 | ilm.CameraFormat = LIBRAW_FORMAT_1div2p3INCH; |
78 | 80 | break; |
79 | 62 | case PentaxID_Q7: |
80 | 138 | case PentaxID_Q_S1: |
81 | 138 | ilm.CameraMount = LIBRAW_MOUNT_Pentax_Q; |
82 | 138 | ilm.CameraFormat = LIBRAW_FORMAT_1div1p7INCH; |
83 | 138 | break; |
84 | 262 | case PentaxID_MX_1: |
85 | 262 | ilm.LensMount = LIBRAW_MOUNT_FixedLens; |
86 | 262 | ilm.CameraMount = LIBRAW_MOUNT_FixedLens; |
87 | 262 | ilm.CameraFormat = LIBRAW_FORMAT_1div1p7INCH; |
88 | 262 | ilm.FocalType = LIBRAW_FT_ZOOM_LENS; |
89 | 262 | break; |
90 | 70 | case PentaxID_GR_III: |
91 | 84 | case PentaxID_GR_IIIx: |
92 | 84 | ilm.CameraMount = LIBRAW_MOUNT_FixedLens; |
93 | 84 | ilm.LensMount = LIBRAW_MOUNT_FixedLens; |
94 | 84 | ilm.CameraFormat = LIBRAW_FORMAT_APSC; |
95 | 84 | ilm.LensFormat = LIBRAW_FORMAT_APSC; |
96 | 84 | ilm.FocalType = LIBRAW_FT_PRIME_LENS; |
97 | 84 | break; |
98 | 11.7k | default: |
99 | 11.7k | ilm.LensMount = LIBRAW_MOUNT_FixedLens; |
100 | 11.7k | ilm.CameraMount = LIBRAW_MOUNT_FixedLens; |
101 | 18.5k | } |
102 | 18.5k | return; |
103 | 18.5k | } |
104 | | |
105 | | void LibRaw::PentaxISO(ushort c) |
106 | 2.72k | { |
107 | 2.72k | int code[] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
108 | 2.72k | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, |
109 | 2.72k | 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, |
110 | 2.72k | 39, 40, 41, 42, 43, 44, 45, 50, 100, 200, 400, 800, |
111 | 2.72k | 1600, 3200, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, |
112 | 2.72k | 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278}; |
113 | 2.72k | double value[] = { |
114 | 2.72k | 50, 64, 80, 100, 125, 160, 200, 250, 320, |
115 | 2.72k | 400, 500, 640, 800, 1000, 1250, 1600, 2000, 2500, |
116 | 2.72k | 3200, 4000, 5000, 6400, 8000, 10000, 12800, 16000, 20000, |
117 | 2.72k | 25600, 32000, 40000, 51200, 64000, 80000, 102400, 128000, 160000, |
118 | 2.72k | 204800, 258000, 325000, 409600, 516000, 650000, 819200, 50, 100, |
119 | 2.72k | 200, 400, 800, 1600, 3200, 50, 70, 100, 140, |
120 | 2.72k | 200, 280, 400, 560, 800, 1100, 1600, 2200, 3200, |
121 | 2.72k | 4500, 6400, 9000, 12800, 18000, 25600, 36000, 51200}; |
122 | 174k | #define numel (sizeof(code) / sizeof(code[0])) |
123 | 2.72k | int i; |
124 | 172k | for (i = 0; i < (int)numel; i++) |
125 | 170k | { |
126 | 170k | if (code[i] == c) |
127 | 568 | { |
128 | 568 | iso_speed = float(value[i]); |
129 | 568 | return; |
130 | 568 | } |
131 | 170k | } |
132 | 2.15k | if (i == numel) |
133 | 2.15k | iso_speed = 65535.0f; |
134 | 2.15k | } |
135 | | #undef numel |
136 | | |
137 | | void LibRaw::PentaxLensInfo(unsigned long long id, unsigned len) // tag 0x0207 |
138 | 10.6k | { |
139 | 10.6k | ushort iLensData = 0; |
140 | 10.6k | uchar *table_buf; |
141 | 10.6k | table_buf = (uchar *)calloc(MAX(len, 128)+1,1); |
142 | 10.6k | fread(table_buf, len, 1, ifp); |
143 | 10.6k | if ((id < PentaxID_K100D) || |
144 | 7.50k | (((id == PentaxID_K100D) || |
145 | 6.77k | (id == PentaxID_K110D) || |
146 | 5.58k | (id == PentaxID_K100D_Super)) && |
147 | 2.01k | ((!table_buf[20] || |
148 | 978 | (table_buf[20] == 0xff))))) |
149 | 4.33k | { |
150 | 4.33k | iLensData = 3; |
151 | 4.33k | if (ilm.LensID == LIBRAW_LENS_NOT_SET) |
152 | 382 | ilm.LensID = (((unsigned)table_buf[0]) << 8) + table_buf[1]; |
153 | 4.33k | } |
154 | 6.30k | else |
155 | 6.30k | switch (len) |
156 | 6.30k | { |
157 | 650 | case 90: // LensInfo3 |
158 | 650 | iLensData = 13; |
159 | 650 | if (ilm.LensID == LIBRAW_LENS_NOT_SET) |
160 | 32 | ilm.LensID = ((unsigned)((table_buf[1] & 0x0f) + table_buf[3]) << 8) + |
161 | 32 | table_buf[4]; |
162 | 650 | break; |
163 | 1.99k | case 91: // LensInfo4 |
164 | 1.99k | iLensData = 12; |
165 | 1.99k | if (ilm.LensID == LIBRAW_LENS_NOT_SET) |
166 | 82 | ilm.LensID = ((unsigned)((table_buf[1] & 0x0f) + table_buf[3]) << 8) + |
167 | 82 | table_buf[4]; |
168 | 1.99k | break; |
169 | 30 | case 80: // LensInfo5 |
170 | 1.51k | case 128: |
171 | 1.51k | iLensData = 15; |
172 | 1.51k | if (ilm.LensID == LIBRAW_LENS_NOT_SET) |
173 | 28 | ilm.LensID = ((unsigned)((table_buf[1] & 0x0f) + table_buf[4]) << 8) + |
174 | 28 | table_buf[5]; |
175 | 1.51k | break; |
176 | 216 | case 168: // Ricoh GR III, id 0x1320e |
177 | 216 | break; |
178 | 1.93k | default: |
179 | 1.93k | if (id >= 0x12b9cULL) // LensInfo2 |
180 | 1.93k | { |
181 | 1.93k | iLensData = 4; |
182 | 1.93k | if (ilm.LensID == LIBRAW_LENS_NOT_SET) |
183 | 22 | ilm.LensID = ((unsigned)((table_buf[0] & 0x0f) + table_buf[2]) << 8) + |
184 | 22 | table_buf[3]; |
185 | 1.93k | } |
186 | 6.30k | } |
187 | 10.6k | if (iLensData) |
188 | 10.4k | { |
189 | 10.4k | if (table_buf[iLensData + 9] && (fabs(ilm.CurFocal) < 0.1f)) |
190 | 906 | ilm.CurFocal = 10.f * (table_buf[iLensData + 9] >> 2) * |
191 | 906 | libraw_powf64l(4.f, float((table_buf[iLensData + 9] & 0x03) - 2.f)); |
192 | 10.4k | if (table_buf[iLensData + 10] & 0xf0) |
193 | 5.14k | ilm.MaxAp4CurFocal = libraw_powf64l( |
194 | 5.14k | 2.0f, (float)((table_buf[iLensData + 10] & 0xf0) >> 4) / 4.0f); |
195 | 10.4k | if (table_buf[iLensData + 10] & 0x0f) |
196 | 5.28k | ilm.MinAp4CurFocal = libraw_powf64l( |
197 | 5.28k | 2.0f, (float)((table_buf[iLensData + 10] & 0x0f) + 10) / 4.0f); |
198 | | |
199 | 10.4k | if (iLensData != 12) |
200 | 8.42k | { |
201 | 8.42k | switch (table_buf[iLensData] & 0x06) |
202 | 8.42k | { |
203 | 4.27k | case 0: |
204 | 4.27k | ilm.MinAp4MinFocal = 22.0f; |
205 | 4.27k | break; |
206 | 924 | case 2: |
207 | 924 | ilm.MinAp4MinFocal = 32.0f; |
208 | 924 | break; |
209 | 1.65k | case 4: |
210 | 1.65k | ilm.MinAp4MinFocal = 45.0f; |
211 | 1.65k | break; |
212 | 1.57k | case 6: |
213 | 1.57k | ilm.MinAp4MinFocal = 16.0f; |
214 | 1.57k | break; |
215 | 8.42k | } |
216 | 8.42k | if (table_buf[iLensData] & 0x70) |
217 | 4.75k | ilm.LensFStops = |
218 | 4.75k | ((float)(((table_buf[iLensData] & 0x70) >> 4) ^ 0x07)) / 2.0f + |
219 | 4.75k | 5.0f; |
220 | | |
221 | 8.42k | ilm.MinFocusDistance = (float)(table_buf[iLensData + 3] & 0xf8); |
222 | 8.42k | ilm.FocusRangeIndex = (float)(table_buf[iLensData + 3] & 0x07); |
223 | | |
224 | 8.42k | if ((table_buf[iLensData + 14] > 1) && (fabs(ilm.MaxAp4CurFocal) < 0.7f)) |
225 | 170 | ilm.MaxAp4CurFocal = libraw_powf64l( |
226 | 170 | 2.0f, (float)((table_buf[iLensData + 14] & 0x7f) - 1) / 32.0f); |
227 | 8.42k | } |
228 | 1.99k | else if ((id != 0x12e76ULL) && // K-5 |
229 | 1.99k | (table_buf[iLensData + 15] > 1) && |
230 | 1.11k | (fabs(ilm.MaxAp4CurFocal) < 0.7f)) |
231 | 114 | { |
232 | 114 | ilm.MaxAp4CurFocal = libraw_powf64l( |
233 | 114 | 2.0f, (float)((table_buf[iLensData + 15] & 0x7f) - 1) / 32.0f); |
234 | 114 | } |
235 | 10.4k | } |
236 | 10.6k | free(table_buf); |
237 | 10.6k | return; |
238 | 10.6k | } |
239 | | |
240 | | void LibRaw::parsePentaxMakernotes(INT64 /*base*/, unsigned tag, unsigned type, |
241 | | unsigned len, unsigned dng_writer) |
242 | 2.08M | { |
243 | | |
244 | 2.08M | int c; |
245 | | // printf ("==>> =%s= tag:0x%x, type: %d, len:%d\n", model, tag, type, len); |
246 | | |
247 | 2.08M | if (tag == 0x0005) |
248 | 18.5k | { |
249 | 18.5k | unique_id = get4(); |
250 | 18.5k | setPentaxBodyFeatures(unique_id); |
251 | 18.5k | } |
252 | 2.06M | else if (tag == 0x0008) |
253 | 5.82k | { /* 4 is raw, 7 is raw w/ pixel shift, 8 is raw w/ dynamic pixel shift */ |
254 | 5.82k | imPentax.Quality = get2(); |
255 | 5.82k | } |
256 | 2.05M | else if (tag == 0x000d) |
257 | 2.08k | { |
258 | 2.08k | imgdata.shootinginfo.FocusMode = imPentax.FocusMode[0] = get2(); |
259 | 2.08k | } |
260 | 2.05M | else if (tag == 0x000e) |
261 | 1.45k | { |
262 | 1.45k | imgdata.shootinginfo.AFPoint = imPentax.AFPointSelected[0] = get2(); |
263 | 1.45k | if (len == 2) |
264 | 124 | imPentax.AFPointSelected_Area = get2(); |
265 | 1.45k | } |
266 | 2.05M | else if (tag == 0x000f) |
267 | 4.04k | { |
268 | 4.04k | if (tagtypeIs(LIBRAW_EXIFTAG_TYPE_LONG)) |
269 | 978 | { |
270 | 978 | imPentax.AFPointsInFocus = get4(); |
271 | 978 | if (!imPentax.AFPointsInFocus) imPentax.AFPointsInFocus = 0xffffffff; |
272 | 450 | else imPentax.AFPointsInFocus_version = 3; |
273 | 978 | } |
274 | 3.07k | else if (tagtypeIs(LIBRAW_EXIFTAG_TYPE_SHORT)) |
275 | 1.27k | { |
276 | 1.27k | imPentax.AFPointsInFocus = (unsigned) get2(); |
277 | 1.27k | if (imPentax.AFPointsInFocus == 0x0000ffff) |
278 | 258 | imPentax.AFPointsInFocus = 0xffffffff; |
279 | 1.01k | else imPentax.AFPointsInFocus_version = 2; |
280 | 1.27k | } |
281 | 4.04k | } |
282 | 2.05M | else if (tag == 0x0010) |
283 | 5.14k | { |
284 | 5.14k | imPentax.FocusPosition = get2(); |
285 | 5.14k | } |
286 | 2.04M | else if (tag == 0x0013) |
287 | 1.41k | { |
288 | 1.41k | ilm.CurAp = (float)get2() / 10.0f; |
289 | 1.41k | } |
290 | 2.04M | else if (tag == 0x0014) |
291 | 2.72k | { |
292 | 2.72k | PentaxISO(get2()); |
293 | 2.72k | } |
294 | 2.04M | else if (tag == 0x0017) |
295 | 2.31k | { |
296 | 2.31k | imgdata.shootinginfo.MeteringMode = get2(); |
297 | 2.31k | } |
298 | 2.04M | else if (tag == 0x001b) { |
299 | 904 | cam_mul[2] = float(get2()) / 256.f; |
300 | 904 | } |
301 | 2.03M | else if (tag == 0x001c) { |
302 | 1.89k | cam_mul[0] = float(get2()) / 256.f; |
303 | 1.89k | } |
304 | 2.03M | else if (tag == 0x001d) |
305 | 1.51k | { |
306 | 1.51k | ilm.CurFocal = (float)get4() / 100.0f; |
307 | 1.51k | } |
308 | 2.03M | else if (tag == 0x0034) |
309 | 2.57k | { |
310 | 2.57k | uchar uc; |
311 | 2.57k | FORC4 |
312 | 10.2k | { |
313 | 10.2k | fread(&uc, 1, 1, ifp); |
314 | 10.2k | imPentax.DriveMode[c] = uc; |
315 | 10.2k | } |
316 | 2.57k | imgdata.shootinginfo.DriveMode = imPentax.DriveMode[0]; |
317 | 2.57k | } |
318 | 2.03M | else if (tag == 0x0037) { |
319 | 2.14k | switch (get2()) { |
320 | 434 | case 0: |
321 | 434 | imCommon.ColorSpace = LIBRAW_COLORSPACE_sRGB; |
322 | 434 | break; |
323 | 1.01k | case 1: |
324 | 1.01k | imCommon.ColorSpace = LIBRAW_COLORSPACE_AdobeRGB; |
325 | 1.01k | break; |
326 | 694 | default: |
327 | 694 | imCommon.ColorSpace = LIBRAW_COLORSPACE_Unknown; |
328 | 694 | break; |
329 | 2.14k | } |
330 | 2.14k | } |
331 | 2.03M | else if (tag == 0x0038) |
332 | 658 | { |
333 | 658 | imgdata.sizes.raw_inset_crops[0].cleft = get2(); |
334 | 658 | imgdata.sizes.raw_inset_crops[0].ctop = get2(); |
335 | 658 | } |
336 | 2.03M | else if (tag == 0x0039) |
337 | 712 | { |
338 | 712 | imgdata.sizes.raw_inset_crops[0].cwidth = get2(); |
339 | 712 | imgdata.sizes.raw_inset_crops[0].cheight = get2(); |
340 | 712 | } |
341 | 2.02M | else if (tag == 0x003c) |
342 | 1.13k | { |
343 | 1.13k | if ((len == 4) && tagtypeIs(LIBRAW_EXIFTAG_TYPE_UNDEFINED)) { |
344 | 356 | imPentax.AFPointsInFocus = get4() & 0x7ff; |
345 | 356 | if (!imPentax.AFPointsInFocus) { |
346 | 284 | imPentax.AFPointsInFocus = 0xffffffff; |
347 | 284 | } |
348 | 72 | else { |
349 | 72 | imPentax.AFPointsInFocus_version = 1; |
350 | 72 | } |
351 | 356 | } |
352 | 1.13k | } |
353 | 2.02M | else if (tag == 0x003f) |
354 | 896 | { |
355 | 896 | unsigned a = unsigned(fgetc(ifp)) << 8; |
356 | 896 | ilm.LensID = a | fgetc(ifp); |
357 | 896 | } |
358 | 2.02M | else if (tag == 0x0047) |
359 | 1.80k | { |
360 | 1.80k | imCommon.CameraTemperature = (float)fgetc(ifp); |
361 | 1.80k | } |
362 | 2.02M | else if (tag == 0x004d) |
363 | 1.26k | { |
364 | 1.26k | if (tagtypeIs(LIBRAW_EXIFTAG_TYPE_SLONG)) |
365 | 68 | imCommon.FlashEC = getrealf(type) / 256.0f; |
366 | 1.19k | else |
367 | 1.19k | imCommon.FlashEC = (float)((signed short)fgetc(ifp)) / 6.0f; |
368 | 1.26k | } |
369 | 2.02M | else if (tag == 0x005c) |
370 | 758 | { |
371 | 758 | fgetc(ifp); |
372 | 758 | imgdata.shootinginfo.ImageStabilization = (short)fgetc(ifp); |
373 | 758 | } |
374 | 2.02M | else if (tag == 0x0069) |
375 | 1.35k | { |
376 | 1.35k | uchar uc; |
377 | 1.35k | FORC4 |
378 | 5.40k | { |
379 | 5.40k | fread(&uc, 1, 1, ifp); |
380 | 5.40k | imPentax.DynamicRangeExpansion[c] = uc; |
381 | 5.40k | } |
382 | 1.35k | } |
383 | 2.02M | else if (tag == 0x0072) |
384 | 474 | { |
385 | 474 | imPentax.AFAdjustment = get2(); |
386 | 474 | } |
387 | 2.02M | else if ((tag == 0x007e) && (dng_writer == nonDNG)) |
388 | 1.96k | { |
389 | 1.96k | imgdata.color.linear_max[0] = imgdata.color.linear_max[1] = |
390 | 1.96k | imgdata.color.linear_max[2] = imgdata.color.linear_max[3] = |
391 | 1.96k | get4(); |
392 | 1.96k | } |
393 | 2.01M | else if (tag == 0x0080) |
394 | 11.0k | { |
395 | 11.0k | short a = (short)fgetc(ifp); |
396 | 11.0k | switch (a) |
397 | 11.0k | { |
398 | 2.68k | case 0: |
399 | 2.68k | imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_4to3; |
400 | 2.68k | break; |
401 | 2.89k | case 1: |
402 | 2.89k | imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_3to2; |
403 | 2.89k | break; |
404 | 646 | case 2: |
405 | 646 | imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_16to9; |
406 | 646 | break; |
407 | 350 | case 3: |
408 | 350 | imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_1to1; |
409 | 350 | break; |
410 | 11.0k | } |
411 | 11.0k | } |
412 | | |
413 | 2.00M | else if ((tag == 0x0200) && (dng_writer == nonDNG)) { // Pentax black level |
414 | 32.7k | FORC4 cblack[RGGB_2_RGBG(c)] = get2(); |
415 | 8.19k | } |
416 | | |
417 | 2.00M | else if ((tag == 0x0201) && (dng_writer == nonDNG)) { // Pentax As Shot WB |
418 | 8.01k | FORC4 cam_mul[RGGB_2_RGBG(c)] = get2(); |
419 | 2.00k | } |
420 | | |
421 | 1.99M | else if ((tag == 0x0203) && (dng_writer == nonDNG)) |
422 | 2.11k | { |
423 | 8.44k | for (int i = 0; i < 3; i++) |
424 | 18.9k | FORC3 cmatrix[i][c] = float((short)get2()) / 8192.f; |
425 | 2.11k | } |
426 | 1.99M | else if (tag == 0x0205) |
427 | 1.03k | { |
428 | 1.03k | if (imCommon.afcount < LIBRAW_AFDATA_MAXCOUNT) |
429 | 196 | { |
430 | 196 | imCommon.afdata[imCommon.afcount].AFInfoData_tag = tag; |
431 | 196 | imCommon.afdata[imCommon.afcount].AFInfoData_order = order; |
432 | 196 | imCommon.afdata[imCommon.afcount].AFInfoData_length = len; |
433 | 196 | imCommon.afdata[imCommon.afcount].AFInfoData = (uchar *)calloc(imCommon.afdata[imCommon.afcount].AFInfoData_length+1,1); |
434 | 196 | fread(imCommon.afdata[imCommon.afcount].AFInfoData, imCommon.afdata[imCommon.afcount].AFInfoData_length, 1, ifp); |
435 | 196 | if ((len < 25) && (len >= 11)) |
436 | 42 | { |
437 | 42 | imPentax.AFPointMode = (imCommon.afdata[imCommon.afcount].AFInfoData[3] >>4) & 0x0f; |
438 | 42 | imPentax.FocusMode[1] = imCommon.afdata[imCommon.afcount].AFInfoData[3] & 0x0f; |
439 | 42 | imPentax.AFPointSelected[1] = sget2(imCommon.afdata[imCommon.afcount].AFInfoData+4); |
440 | | // Pentax K-m has multiexposure set to 8 when no multi-exposure is in effect |
441 | 42 | imPentax.MultiExposure = imCommon.afdata[imCommon.afcount].AFInfoData[10] & 0x0f; |
442 | 42 | } |
443 | 196 | imCommon.afcount++; |
444 | 196 | } |
445 | 1.03k | } |
446 | 1.99M | else if (tag == 0x0207) |
447 | 10.9k | { |
448 | 10.9k | if (len < 65535) // Safety belt |
449 | 10.6k | PentaxLensInfo(ilm.CamID, len); |
450 | 10.9k | } |
451 | 1.98M | else if ((tag >= 0x020d) && (tag <= 0x0214)) |
452 | 3.78k | { |
453 | 15.1k | FORC4 icWBC[Pentax_wb_list1[tag - 0x020d]][RGGB_2_RGBG(c)] = get2(); |
454 | 3.78k | } |
455 | 1.98M | else if ((tag == 0x021d) && (len == 18) && |
456 | 0 | tagtypeIs(LIBRAW_EXIFTAG_TYPE_UNDEFINED) && (dng_writer == nonDNG)) |
457 | 0 | { |
458 | 0 | for (int i = 0; i < 3; i++) |
459 | 0 | FORC3 cmatrix[i][c] = float((short)get2()) / 8192.f; |
460 | 0 | } |
461 | 1.98M | else if (tag == 0x021f) |
462 | 3.10k | { |
463 | 3.10k | if ((unique_id != PentaxID_K_1) && |
464 | 2.86k | (unique_id != PentaxID_K_3) && |
465 | 2.86k | (unique_id != PentaxID_K_3_II) && |
466 | 1.31k | (unique_id != PentaxID_K_1_Mark_II)) |
467 | 832 | { |
468 | 832 | fseek (ifp, 0x0b, SEEK_CUR); |
469 | 832 | imPentax.AFPointsInFocus = (unsigned) fgetc(ifp); |
470 | 832 | if (!imPentax.AFPointsInFocus) imPentax.AFPointsInFocus = 0xffffffff; |
471 | 366 | else imPentax.AFPointsInFocus_version = 4; |
472 | 832 | } |
473 | 3.10k | } |
474 | 1.97M | else if ((tag == 0x0220) && (dng_writer == nonDNG)) { |
475 | 254 | meta_offset = ftell(ifp); |
476 | 254 | } |
477 | 1.97M | else if (tag == 0x0221) |
478 | 2.96k | { |
479 | 2.96k | int nWB = get2(); |
480 | 2.96k | if (nWB > 0 && nWB <= int(sizeof(icWBCCTC) / sizeof(icWBCCTC[0]))) |
481 | 2.09k | FORC(nWB) |
482 | 12.8k | { |
483 | 12.8k | icWBCCTC[c][0] = float((unsigned)0xcfc6 - get2()); |
484 | 12.8k | fseek(ifp, 2, SEEK_CUR); |
485 | 12.8k | icWBCCTC[c][1] = get2(); |
486 | 12.8k | icWBCCTC[c][2] = icWBCCTC[c][4] = 0x2000; |
487 | 12.8k | icWBCCTC[c][3] = get2(); |
488 | 12.8k | } |
489 | 2.96k | } |
490 | 1.97M | else if (tag == 0x0215) |
491 | 352 | { |
492 | 352 | fseek(ifp, 16, SEEK_CUR); |
493 | 352 | sprintf(imgdata.shootinginfo.InternalBodySerial, "%d", get4()); |
494 | 352 | } |
495 | 1.97M | else if (tag == 0x0229) |
496 | 554 | { |
497 | 554 | stmread(imgdata.shootinginfo.BodySerial, len, ifp); |
498 | 554 | } |
499 | 1.97M | else if (tag == 0x022d) |
500 | 412 | { |
501 | 412 | int wb_ind; |
502 | 412 | getc(ifp); |
503 | 4.12k | for (int wb_cnt = 0; wb_cnt < (int)Pentax_wb_list2.size(); wb_cnt++) |
504 | 3.70k | { |
505 | 3.70k | wb_ind = getc(ifp); |
506 | 3.70k | if (wb_ind >= 0 && wb_ind < (int)Pentax_wb_list2.size() ) |
507 | 7.46k | FORC4 icWBC[Pentax_wb_list2[wb_ind]][RGGB_2_RGBG(c)] = get2(); |
508 | 3.70k | } |
509 | 412 | } |
510 | 1.97M | else if (tag == 0x0239) // Q-series lens info (LensInfoQ) |
511 | 264 | { |
512 | 264 | char LensInfo[20]; |
513 | 264 | fseek(ifp, 12, SEEK_CUR); |
514 | 264 | stread(ilm.Lens, 30, ifp); |
515 | 264 | strcat(ilm.Lens, " "); |
516 | 264 | stread(LensInfo, 20, ifp); |
517 | 264 | strcat(ilm.Lens, LensInfo); |
518 | 264 | } |
519 | 1.97M | else if (tag == 0x0245) |
520 | 438 | { |
521 | 438 | if (imCommon.afcount < LIBRAW_AFDATA_MAXCOUNT) { |
522 | 82 | imCommon.afdata[imCommon.afcount].AFInfoData_tag = tag; |
523 | 82 | imCommon.afdata[imCommon.afcount].AFInfoData_order = order; |
524 | 82 | imCommon.afdata[imCommon.afcount].AFInfoData_length = len; |
525 | 82 | imCommon.afdata[imCommon.afcount].AFInfoData = (uchar *)calloc(imCommon.afdata[imCommon.afcount].AFInfoData_length+1,1); |
526 | 82 | fread(imCommon.afdata[imCommon.afcount].AFInfoData, imCommon.afdata[imCommon.afcount].AFInfoData_length, 1, ifp); |
527 | 82 | imCommon.afcount++; |
528 | 82 | } |
529 | 438 | } |
530 | 2.08M | } |
531 | | |
532 | | void LibRaw::parseRicohMakernotes(INT64 /*base*/, unsigned tag, unsigned type, |
533 | | unsigned /*len*/, unsigned /*dng_writer */) |
534 | 724k | { |
535 | 724k | char buffer[17]; |
536 | 724k | if (tag == 0x0005) |
537 | 3.10k | { |
538 | 3.10k | int c; |
539 | 3.10k | int count = 0; |
540 | 3.10k | fread(buffer, 16, 1, ifp); |
541 | 3.10k | buffer[16] = 0; |
542 | 3.10k | FORC(16) |
543 | 20.3k | { |
544 | 20.3k | if ((isspace(buffer[c])) || (buffer[c] == 0x2D) || (isalnum(buffer[c]))) |
545 | 17.8k | count++; |
546 | 2.53k | else |
547 | 2.53k | break; |
548 | 20.3k | } |
549 | 3.10k | if (count == 16) |
550 | 570 | { |
551 | 570 | if (strncmp(model, "GXR", 3)) |
552 | 212 | { |
553 | 212 | sprintf(imgdata.shootinginfo.BodySerial, "%8s", buffer + 8); |
554 | 212 | } |
555 | 570 | buffer[8] = 0; |
556 | 570 | sprintf(imgdata.shootinginfo.InternalBodySerial, "%8s", buffer); |
557 | 570 | } |
558 | 2.53k | else |
559 | 2.53k | { |
560 | 2.53k | sprintf(imgdata.shootinginfo.BodySerial, "%02x%02x%02x%02x", buffer[4], |
561 | 2.53k | buffer[5], buffer[6], buffer[7]); |
562 | 2.53k | sprintf(imgdata.shootinginfo.InternalBodySerial, "%02x%02x%02x%02x", |
563 | 2.53k | buffer[8], buffer[9], buffer[10], buffer[11]); |
564 | 2.53k | } |
565 | 3.10k | } |
566 | 721k | else if ((tag == 0x1001) && tagtypeIs(LIBRAW_EXIFTAG_TYPE_SHORT)) |
567 | 2.33k | { |
568 | 2.33k | ilm.CameraMount = LIBRAW_MOUNT_FixedLens; |
569 | 2.33k | ilm.LensMount = LIBRAW_MOUNT_FixedLens; |
570 | 2.33k | ilm.CameraFormat = LIBRAW_FORMAT_APSC; |
571 | 2.33k | ilm.LensID = LIBRAW_LENS_NOT_SET; |
572 | 2.33k | ilm.FocalType = LIBRAW_FT_PRIME_LENS; |
573 | 2.33k | imgdata.shootinginfo.ExposureProgram = get2(); |
574 | 2.33k | } |
575 | 719k | else if ((tag == 0x1002) && tagtypeIs(LIBRAW_EXIFTAG_TYPE_SHORT)) |
576 | 378 | { |
577 | 378 | imgdata.shootinginfo.DriveMode = get2(); |
578 | 378 | } |
579 | 718k | else if (tag == 0x1006) |
580 | 204 | { |
581 | 204 | imgdata.shootinginfo.FocusMode = get2(); |
582 | 204 | } |
583 | 718k | else if (tag == 0x1007) |
584 | 228 | { |
585 | 228 | imRicoh.AutoBracketing = get2(); |
586 | 228 | } |
587 | 718k | else if (tag == 0x1009) |
588 | 234 | { |
589 | 234 | imRicoh.MacroMode = get2(); |
590 | 234 | } |
591 | 718k | else if (tag == 0x100a) |
592 | 312 | { |
593 | 312 | imRicoh.FlashMode = get2(); |
594 | 312 | } |
595 | 717k | else if (tag == 0x100b) |
596 | 266 | { |
597 | 266 | imRicoh.FlashExposureComp = getreal(type); |
598 | 266 | } |
599 | 717k | else if (tag == 0x100c) |
600 | 480 | { |
601 | 480 | imRicoh.ManualFlashOutput = getreal(type); |
602 | 480 | } |
603 | 717k | else if ((tag == 0x100b) && tagtypeIs(LIBRAW_EXIFTAG_TYPE_SRATIONAL)) |
604 | 0 | { |
605 | 0 | imCommon.FlashEC = getrealf(type); |
606 | 0 | } |
607 | 717k | else if ((tag == 0x1017) && ((imRicoh.WideAdapter = get2()) == 2)) |
608 | 1.96k | { |
609 | 1.96k | strcpy(ilm.Attachment, "Wide-Angle Adapter"); |
610 | 1.96k | } |
611 | 715k | else if (tag == 0x1018) |
612 | 410 | { |
613 | 410 | imRicoh.CropMode = get2(); |
614 | 410 | } |
615 | 714k | else if (tag == 0x1019) |
616 | 540 | { |
617 | 540 | imRicoh.NDFilter = get2(); |
618 | 540 | } |
619 | 714k | else if (tag == 0x1200) |
620 | 1.36k | { |
621 | 1.36k | imRicoh.AFStatus = get2(); |
622 | 1.36k | } |
623 | 712k | else if (tag == 0x1201) |
624 | 4.53k | { |
625 | 4.53k | imRicoh.AFAreaXPosition[1] = get4(); |
626 | 4.53k | } |
627 | 708k | else if (tag == 0x1202) |
628 | 592 | { |
629 | 592 | imRicoh.AFAreaYPosition[1] = get4(); |
630 | 592 | } |
631 | 707k | else if (tag == 0x1203) |
632 | 884 | { |
633 | 884 | imRicoh.AFAreaXPosition[0] = get4(); |
634 | 884 | } |
635 | 706k | else if (tag == 0x1204) |
636 | 1.79k | { |
637 | 1.79k | imRicoh.AFAreaYPosition[0] = get4(); |
638 | 1.79k | } |
639 | 705k | else if (tag == 0x1205) |
640 | 284 | { |
641 | 284 | imRicoh.AFAreaMode = get2(); |
642 | 284 | } |
643 | 704k | else if (tag == 0x1500) |
644 | 472 | { |
645 | 472 | ilm.CurFocal = getrealf(type); |
646 | 472 | } |
647 | 704k | else if (tag == 0x1601) |
648 | 244 | { |
649 | 244 | imRicoh.SensorWidth = get4(); |
650 | 244 | } |
651 | 704k | else if (tag == 0x1602) |
652 | 248 | { |
653 | 248 | imRicoh.SensorHeight = get4(); |
654 | 248 | } |
655 | 703k | else if (tag == 0x1603) |
656 | 232 | { |
657 | 232 | imRicoh.CroppedImageWidth = get4(); |
658 | 232 | } |
659 | 703k | else if (tag == 0x1604) |
660 | 278 | { |
661 | 278 | imRicoh.CroppedImageHeight= get4(); |
662 | 278 | } |
663 | 703k | else if ((tag == 0x2001) && !strncmp(model, "GXR", 3)) |
664 | 2.11k | { |
665 | 2.11k | short cur_tag; |
666 | 2.11k | fseek(ifp, 20, SEEK_CUR); |
667 | 2.11k | /*ntags =*/ get2(); |
668 | 2.11k | cur_tag = get2(); |
669 | 145k | while (cur_tag != 0x002c) |
670 | 143k | { |
671 | 143k | fseek(ifp, 10, SEEK_CUR); |
672 | 143k | if (feof(ifp)) |
673 | 82 | return; |
674 | 143k | cur_tag = get2(); |
675 | 143k | } |
676 | 2.03k | fseek(ifp, 6, SEEK_CUR); |
677 | 2.03k | fseek(ifp, get4(), SEEK_SET); |
678 | 10.1k | for (int i=0; i<4; i++) { |
679 | 8.12k | stread(buffer, 16, ifp); |
680 | 8.12k | if ((buffer[0] == 'S') && (buffer[1] == 'I') && (buffer[2] == 'D')) |
681 | 86 | memcpy(imgdata.shootinginfo.BodySerial, buffer+4, 12); |
682 | 8.03k | else if ((buffer[0] == 'R') && (buffer[1] == 'L')) |
683 | 38 | ilm.LensID = buffer[2] - '0'; |
684 | 7.99k | else if ((buffer[0] == 'L') && (buffer[1] == 'I') && (buffer[2] == 'D')) |
685 | 6 | memcpy(imgdata.lens.LensSerial, buffer+4, 12); |
686 | 8.12k | } |
687 | 2.03k | } |
688 | 724k | } |