Coverage Report

Created: 2026-02-26 07:48

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/exiv2/src/pentaxmn_int.cpp
Line
Count
Source
1
// SPDX-License-Identifier: GPL-2.0-or-later
2
3
#include "pentaxmn_int.hpp"
4
5
// included header files
6
#include "exif.hpp"
7
#include "i18n.h"  // NLS support.
8
#include "image_int.hpp"
9
#include "makernote_int.hpp"
10
#include "tags.hpp"
11
#include "tags_int.hpp"
12
#include "types.hpp"
13
#include "value.hpp"
14
15
#include <iomanip>
16
17
namespace {
18
// Exception thrown by findLensInfo when the lens info can't be found.
19
class LensInfoNotFound : public std::exception {
20
  using std::exception::exception;
21
};
22
}  // namespace
23
24
// *****************************************************************************
25
// class member definitions
26
namespace Exiv2::Internal {
27
/*!
28
  @brief Print function to translate Pentax "combi-values" to a description
29
         by looking up a reference table.
30
 */
31
template <size_t N, const TagDetails (&array)[N], int count, int ignoredcount, int ignoredcountmax>
32
0
static std::ostream& printCombiTag(std::ostream& os, const Value& value, const ExifData* metadata) {
33
0
  static_assert(N > 0, "Passed zero length printCombiTag");
34
0
  std::ios::fmtflags f(os.flags());
35
0
  if ((value.count() != count &&
36
0
       (value.count() < (count + ignoredcount) || value.count() > (count + ignoredcountmax))) ||
37
0
      count > 4) {
38
0
    return printValue(os, value, metadata);
39
0
  }
40
0
  uint32_t l = 0;
41
0
  for (int c = 0; c < count; ++c) {
42
0
    if (value.toInt64(c) < 0 || value.toInt64(c) > 255) {
43
0
      return printValue(os, value, metadata);
44
0
    }
45
0
    l += (value.toUint32(c) << ((count - c - 1) * 8));
46
0
  }
47
48
0
  if (auto td = Exiv2::find(array, l)) {
49
0
    os << _(td->label_);
50
0
  } else {
51
0
    os << _("Unknown") << " (0x" << std::setw(2 * count) << std::setfill('0') << std::hex << l << std::dec << ")";
52
0
  }
53
54
0
  os.flags(f);
55
0
  return os;
56
0
}
Unexecuted instantiation: pentaxmn_int.cpp:_ZN5Exiv28InternalL13printCombiTagILm297ETnRAT__KNS0_10TagDetailsEL_ZNS0_L14pentaxLensTypeEELi2ELi1ELi2EEERNSt3__113basic_ostreamIcNS6_11char_traitsIcEEEESB_RKNS_5ValueEPKNS_8ExifDataE
Unexecuted instantiation: pentaxmn_int.cpp:_ZN5Exiv28InternalL13printCombiTagILm7ETnRAT__KNS0_10TagDetailsEL_ZNS0_L21pentaxImageProcessingEELi4ELi0ELi0EEERNSt3__113basic_ostreamIcNS6_11char_traitsIcEEEESB_RKNS_5ValueEPKNS_8ExifDataE
Unexecuted instantiation: pentaxmn_int.cpp:_ZN5Exiv28InternalL13printCombiTagILm71ETnRAT__KNS0_10TagDetailsEL_ZNS0_L17pentaxPictureModeEELi3ELi0ELi0EEERNSt3__113basic_ostreamIcNS6_11char_traitsIcEEEESB_RKNS_5ValueEPKNS_8ExifDataE
Unexecuted instantiation: pentaxmn_int.cpp:_ZN5Exiv28InternalL13printCombiTagILm20ETnRAT__KNS0_10TagDetailsEL_ZNS0_L15pentaxDriveModeEELi4ELi0ELi0EEERNSt3__113basic_ostreamIcNS6_11char_traitsIcEEEESB_RKNS_5ValueEPKNS_8ExifDataE
Unexecuted instantiation: pentaxmn_int.cpp:_ZN5Exiv28InternalL13printCombiTagILm2ETnRAT__KNS0_10TagDetailsEL_ZNS0_L27pentaxDynamicRangeExpansionEELi4ELi0ELi0EEERNSt3__113basic_ostreamIcNS6_11char_traitsIcEEEESB_RKNS_5ValueEPKNS_8ExifDataE
57
58
//! Shortcut for the printCombiTag template which requires typing the array name only once.
59
#define EXV_PRINT_COMBITAG(array, count, ignoredcount) \
60
  printCombiTag<std::size(array), array, count, ignoredcount, ignoredcount>
61
//! Shortcut for the printCombiTag template which requires typing the array name only once.
62
#define EXV_PRINT_COMBITAG_MULTI(array, count, ignoredcount, ignoredcountmax) \
63
0
  printCombiTag<std::size(array), array, count, ignoredcount, ignoredcountmax>
64
65
//! ShootingMode, tag 0x0001
66
constexpr TagDetails pentaxShootingMode[] = {
67
    {0, N_("Auto")},
68
    {1, N_("Night-Scene")},
69
    {2, N_("Manual")},
70
};
71
72
//! CameraModel, tag 0x0005
73
constexpr TagDetails pentaxModel[] = {
74
    {0x0000d, "Optio 330/430"},
75
    {0x12926, "Optio 230"},
76
    {0x12958, "Optio 330GS"},
77
    {0x12962, "Optio 450/550"},
78
    {0x1296c, "Optio S"},
79
    {0x12971, "Optio S V1.01"},
80
    {0x12994, "*ist D"},
81
    {0x129b2, "Optio 33L"},
82
    {0x129bc, "Optio 33LF"},
83
    {0x129c6, "Optio 33WR/43WR/555"},
84
    {0x129d5, "Optio S4"},
85
    {0x12a02, "Optio MX"},
86
    {0x12a0c, "Optio S40"},
87
    {0x12a16, "Optio S4i"},
88
    {0x12a34, "Optio 30"},
89
    {0x12a52, "Optio S30"},
90
    {0x12a66, "Optio 750Z"},
91
    {0x12a70, "Optio SV"},
92
    {0x12a75, "Optio SVi"},
93
    {0x12a7a, "Optio X"},
94
    {0x12a8e, "Optio S5i"},
95
    {0x12a98, "Optio S50"},
96
    {0x12aa2, "*ist DS"},
97
    {0x12ab6, "Optio MX4"},
98
    {0x12ac0, "Optio S5n"},
99
    {0x12aca, "Optio WP"},
100
    {0x12afc, "Optio S55"},
101
    {0x12b10, "Optio S5z"},
102
    {0x12b1a, "*ist DL"},
103
    {0x12b24, "Optio S60"},
104
    {0x12b2e, "Optio S45"},
105
    {0x12b38, "Optio S6"},
106
    {0x12b4c, "Optio WPi"},
107
    {0x12b56, "BenQ DC X600"},
108
    {0x12b60, "*ist DS2"},
109
    {0x12b62, "Samsung GX-1S"},
110
    {0x12b6a, "Optio A10"},
111
    {0x12b7e, "*ist DL2"},
112
    {0x12b80, "Samsung GX-1L"},
113
    {0x12b9c, "K100D"},
114
    {0x12b9d, "K110D"},
115
    {0x12ba2, "K100D Super"},
116
    {0x12bb0, "Optio T10/T20"},
117
    {0x12be2, "Optio W10"},
118
    {0x12bf6, "Optio M10"},
119
    {0x12c1e, "K10D"},
120
    {0x12c20, "Samsung GX10"},
121
    {0x12c28, "Optio S7"},
122
    {0x12c2d, "Optio L20"},
123
    {0x12c32, "Optio M20"},
124
    {0x12c3c, "Optio W20"},
125
    {0x12c46, "Optio A20"},
126
    {0x12c78, "Optio E30"},
127
    {0x12c7d, "Optio E35"},
128
    {0x12c82, "Optio T30"},
129
    {0x12c8c, "Optio M30"},
130
    {0x12c91, "Optio L30"},
131
    {0x12c96, "Optio W30"},
132
    {0x12ca0, "Optio A30"},
133
    {0x12cb4, "Optio E40"},
134
    {0x12cbe, "Optio M40"},
135
    {0x12cc3, "Optio L40"},
136
    {0x12cc5, "Optio L36"},
137
    {0x12cc8, "Optio Z10"},
138
    {0x12cd2, "K20D"},
139
    {0x12cd4, "Samsung GX20"},
140
    {0x12cdc, "Optio S10"},
141
    {0x12ce6, "Optio A40"},
142
    {0x12cf0, "Optio V10"},
143
    {0x12cfa, "K200D"},
144
    {0x12d04, "Optio S12"},
145
    {0x12d0e, "Optio E50"},
146
    {0x12d18, "Optio M50"},
147
    {0x12d22, "Optio L50"},
148
    {0x12d2c, "Optio V20"},
149
    {0x12d40, "Optio W60"},
150
    {0x12d4a, "Optio M60"},
151
    {0x12d68, "Optio E60/M90"},
152
    {0x12d72, "K2000"},
153
    {0x12d73, "K-m"},
154
    {0x12d86, "Optio P70"},
155
    {0x12d90, "Optio L70"},
156
    {0x12d9a, "Optio E70"},
157
    {0x12dae, "X70"},
158
    {0x12db8, "K-7"},
159
    {0x12dcc, "Optio W80"},
160
    {0x12dea, "Optio P80"},
161
    {0x12df4, "Optio WS80"},
162
    {0x12dfe, "K-x"},
163
    {0x12e08, "645D"},
164
    {0x12e12, "Optio E80"},
165
    {0x12e30, "Optio W90"},
166
    {0x12e3a, "Optio I-10"},
167
    {0x12e44, "Optio H90"},
168
    {0x12e4e, "Optio E90"},
169
    {0x12e58, "X90"},
170
    {0x12e6c, "K-r"},
171
    {0x12e76, "K-5"},
172
    {0x12e8a, "Optio RS1000/RS1500"},
173
    {0x12e94, "Optio RZ10"},
174
    {0x12e9e, "Optio LS1000"},
175
    {0x12ebc, "Optio WG-1 GPS"},
176
    {0x12ed0, "Optio S1"},
177
    {0x12ee4, "Q"},
178
    {0x12ef8, "K-01"},
179
    {0x12f0c, "Optio RZ18"},
180
    {0x12f16, "Optio VS20"},
181
    {0x12f2a, "Optio WG-2 GPS"},
182
    {0x12f48, "Optio LS465"},
183
    {0x12f52, "K-30"},
184
    {0x12f5c, "X-5"},
185
    {0x12f66, "Q10"},
186
    {0x12f70, "K-5 II"},
187
    {0x12f71, "K-5 II s"},
188
    {0x12f7a, "Q7"},
189
    {0x12f84, "MX-1"},
190
    {0x12f8e, "WG-3 GPS"},
191
    {0x12f98, "WG-3"},
192
    {0x12fa2, "WG-10"},
193
    {0x12fb6, "K-50"},
194
    {0x12fc0, "K-3"},
195
    {0x12fca, "K-500"},
196
    {0x12fde, "WG-4 GPS"},
197
    {0x12fe8, "WG-4"},
198
    {0x13006, "WG-20"},
199
    {0x13010, "645Z"},
200
    {0x1301a, "K-S1"},
201
    {0x13024, "K-S2"},
202
    {0x1302e, "Q-S1"},
203
    {0x13056, "WG-30"},
204
    {0x1307e, "WG-30W"},
205
    {0x13088, "WG-5 GPS"},
206
    {0x13092, "K-1"},
207
    {0x1309c, "K-3 II"},
208
    {0x131f0, "WG-M2"},
209
    {0x1320e, "GR III"},
210
    {0x13222, "K-70"},
211
    {0x1322c, "KP"},
212
    {0x13240, "K-1 Mark II"},
213
    {0x13254, "K-3 Mark III"},
214
    {0x13290, "WG-70"},
215
    {0x1329a, "GR IIIx"},
216
    {0x132b8, "KF"},
217
    {0x132d6, "K-3 Mark III Monochrome"},
218
    {0x132e0, "GR IV"},
219
    {0x132e1, "GR IV HDF"},
220
    {0x13330, "GR IV Monochrome"},
221
};
222
223
//! Quality, tag 0x0008
224
constexpr TagDetails pentaxQuality[] = {
225
    {0, N_("Good")}, {1, N_("Better")},  {2, N_("Best")},    {3, N_("TIFF")},
226
    {4, N_("RAW")},  {5, N_("Premium")}, {65535, N_("n/a")},
227
};
228
229
//! Size, tag 0x0009
230
constexpr TagDetails pentaxSize[] = {
231
    {0, "640x480"},
232
    {1, N_("Full")},
233
    {2, "1024x768"},
234
    {3, "1280x960"},
235
    {4, "1600x1200"},
236
    {5, "2048x1536"},
237
    {8, N_("2560x1920 or 2304x1728")},
238
    {9, "3072x2304"},
239
    {10, "3264x2448"},
240
    {19, "320x240"},
241
    {20, "2288x1712"},
242
    {21, "2592x1944"},
243
    {22, N_("2304x1728 or 2592x1944")},
244
    {23, "3056x2296"},
245
    {25, N_("2816x2212 or 2816x2112")},
246
    {27, "3648x2736"},
247
    {29, "4000x3000"},
248
    {30, "4288x3216"},
249
    {31, "4608x3456"},
250
    {129, "1920x1080"},
251
    {135, "4608x2592"},
252
    {257, "3216x3216"},
253
    // not sure what to do with these values:
254
    //    '0 0' = 2304x1728
255
    //    '4 0' = 1600x1200
256
    //    '5 0' = 2048x1536
257
    //    '8 0' = 2560x1920
258
    //    '32 2' = 960x640
259
    //    '33 2' = 1152x768
260
    //    '34 2' = 1536x1024
261
    //    '35 1' = 2400x1600
262
    //    '36 0' = 3008x2008 or 3040x2024
263
    //    '37 0' = 3008x2000
264
};
265
266
//! Flash, tag 0x000c
267
constexpr TagDetails pentaxFlash[] = {
268
    {0x000, N_("Auto, Did not fire")},
269
    {0x001, N_("Off, Did not fire")},
270
    {0x002, N_("Off, Did not fire")},
271
    {0x003, N_("Auto, Did not fire, Red-eye reduction")},
272
    {0x005, N_("On. Did not fire. Wireless (Master)")},
273
    {0x100, N_("Auto, Fired")},
274
    {0x102, N_("On, Fired")},
275
    {0x103, N_("Auto, Fired, Red-eye reduction")},
276
    {0x104, N_("On, Red-eye reduction")},
277
    {0x105, N_("On, Wireless (Master)")},
278
    {0x106, N_("On, Wireless (Control)")},
279
    {0x108, N_("On, Soft")},
280
    {0x109, N_("On, Slow-sync")},
281
    {0x10a, N_("On, Slow-sync, Red-eye reduction")},
282
    {0x10b, N_("On, Trailing-curtain Sync")},
283
    // exiftool recognises 2 values, the values here correspond with Value 0
284
};
285
286
//! Focus, tag 0x000d
287
constexpr TagDetails pentaxFocus[] = {
288
    {0, N_("Normal")},
289
    {1, N_("Macro")},
290
    {2, N_("Infinity")},
291
    {3, N_("Manual")},
292
    {4, N_("Super Macro")},
293
    {5, N_("Pan Focus")},
294
    {16, N_("AF-S")},
295
    {17, N_("AF-C")},
296
    {18, N_("AF-A")},
297
    {32, N_("Contrast-detect")},
298
    {33, N_("Tracking Contrast-detect")},
299
    {288, N_("Face Detect")},
300
};
301
302
//! AFPoint, tag 0x000e
303
constexpr TagDetails pentaxAFPoint[] = {
304
    {0xffff, N_("Auto")},
305
    {0xfffe, N_("Fixed Center")},
306
    {0xfffd, N_("Automatic Tracking AF")},
307
    {0xfffc, N_("Face Recognition AF")},
308
    {0xfffb, N_("AF Select")},
309
    {0, N_("None")},
310
    {1, N_("Upper-left")},
311
    {2, N_("Top")},
312
    {3, N_("Upper-right")},
313
    {4, N_("Left")},
314
    {5, N_("Mid-left")},
315
    {6, N_("Center")},
316
    {7, N_("Mid-right")},
317
    {8, N_("Right")},
318
    {9, N_("Lower-left")},
319
    {10, N_("Bottom")},
320
    {11, N_("Lower-right")},
321
};
322
323
//! AFPointInFocus, tag 0x000f
324
constexpr TagDetails pentaxAFPointFocus[] = {
325
    {0xffff, N_("None")},    {0, N_("Fixed Center or multiple")},
326
    {1, N_("Top-left")},     {2, N_("Top-center")},
327
    {3, N_("Top-right")},    {4, N_("Left")},
328
    {5, N_("Center")},       {6, N_("Right")},
329
    {7, N_("Bottom-left")},  {8, N_("Bottom-center")},
330
    {9, N_("Bottom-right")},
331
};
332
333
//! ISO, tag 0x0014
334
constexpr TagDetails pentaxISO[] = {
335
    {3, "50"},
336
    {4, "64"},
337
    {5, "80"},
338
    {6, "100"},
339
    {7, "125"},
340
    {8, "160"},
341
    {9, "200"},
342
    {10, "250"},
343
    {11, "320"},
344
    {12, "400"},
345
    {13, "500"},
346
    {14, "640"},
347
    {15, "800"},
348
    {16, "1000"},
349
    {17, "1250"},
350
    {18, "1600"},
351
    {19, "2000"},
352
    {20, "2500"},
353
    {21, "3200"},
354
    {22, "4000"},
355
    {23, "5000"},
356
    {24, "6400"},
357
    {25, "8000"},
358
    {26, "10000"},
359
    {27, "12800"},
360
    {28, "16000"},
361
    {29, "20000"},
362
    {30, "25600"},
363
    {31, "32000"},
364
    {32, "40000"},
365
    {33, "51200"},
366
    {34, "64000"},
367
    {35, "80000"},
368
    {36, "102400"},
369
    {37, "128000"},
370
    {38, "160000"},
371
    {39, "204800"},
372
    {40, "256000"},
373
    {41, "320000"},
374
    {42, "409600"},
375
    {43, "512000"},
376
    {44, "640000"},
377
    {45, "819200"},
378
    {50, "50"},
379
    {100, "100"},
380
    {200, "200"},
381
    //        {    268, "200" },
382
    {400, "400"},
383
    {800, "800"},
384
    {1600, "1600"},
385
    {3200, "3200"},
386
    {258, "50"},
387
    {259, "70"},
388
    {260, "100"},
389
    {261, "140"},
390
    {262, "200"},
391
    {263, "280"},
392
    {264, "400"},
393
    {265, "560"},
394
    {266, "800"},
395
    {267, "1100"},
396
    {268, "1600"},
397
    {269, "2200"},
398
    {270, "3200"},
399
    {271, "4500"},
400
    {272, "6400"},
401
    {273, "9000"},
402
    {274, "12800"},
403
    {275, "18000"},
404
    {276, "25600"},
405
    {277, "36000"},
406
    {278, "51200"},
407
    {279, "72000"},
408
    {280, "102400"},
409
    {281, "144000"},
410
    {282, "204800"},
411
    {283, "288000"},
412
    {284, "409600"},
413
    {285, "576000"},
414
    {286, "819200"},
415
};
416
417
//! Generic for Off/On switches
418
constexpr TagDetails pentaxOffOn[] = {
419
    {0, N_("Off")},
420
    {1, N_("On")},
421
};
422
423
//! Generic for Yes/No switches
424
constexpr TagDetails pentaxYesNo[] = {
425
    {0, N_("No")},
426
    {1, N_("Yes")},
427
};
428
429
//! MeteringMode, tag 0x0017
430
constexpr TagDetails pentaxMeteringMode[] = {
431
    {0, N_("Multi Segment")},
432
    {1, N_("Center Weighted")},
433
    {2, N_("Spot")},
434
};
435
436
//! WhiteBalance, tag 0x0019
437
constexpr TagDetails pentaxWhiteBalance[] = {
438
    {0, N_("Auto")},
439
    {1, N_("Daylight")},
440
    {2, N_("Shade")},
441
    {3, N_("Fluorescent")},
442
    {4, N_("Tungsten")},
443
    {5, N_("Manual")},
444
    {6, N_("DaylightFluorescent")},
445
    {7, N_("DaywhiteFluorescent")},
446
    {8, N_("WhiteFluorescent")},
447
    {9, N_("Flash")},
448
    {10, N_("Cloudy")},
449
    {15, N_("Color Temperature Enhancement")},
450
    {17, N_("Kelvin")},
451
    {65534, N_("Unknown")},
452
    {65535, N_("User Selected")},
453
};
454
455
//! WhiteBalance, tag 0x001a
456
constexpr TagDetails pentaxWhiteBalanceMode[] = {
457
    {1, N_("Auto (Daylight)")},
458
    {2, N_("Auto (Shade)")},
459
    {3, N_("Auto (Flash)")},
460
    {4, N_("Auto (Tungsten)")},
461
    {6, N_("Auto (DaylightFluorescent)")},
462
    {7, N_("Auto (DaywhiteFluorescent)")},
463
    {8, N_("Auto (WhiteFluorescent)")},
464
    {10, N_("Auto (Cloudy)")},
465
    {0xffff, N_("User-Selected")},
466
    {0xfffe, N_("Preset (Fireworks?)")},
467
};
468
469
//! Saturation, tag 0x001f
470
constexpr TagDetails pentaxSaturation[] = {
471
    {0, N_("Low")},      {1, N_("Normal")},    {2, N_("High")}, {3, N_("Med Low")}, {4, N_("Med High")},
472
    {5, N_("Very Low")}, {6, N_("Very High")}, {7, N_("-4")},   {8, N_("+4")},      {65535, N_("None")},
473
};
474
475
//! Contrast, tag 0x0020
476
constexpr TagDetails pentaxContrast[] = {
477
    {0, N_("Low")},      {1, N_("Normal")},    {2, N_("High")}, {3, N_("Med Low")}, {4, N_("Med High")},
478
    {5, N_("Very Low")}, {6, N_("Very High")}, {7, N_("-4")},   {8, N_("+4")},
479
};
480
481
//! Sharpness, tag 0x0021
482
constexpr TagDetails pentaxSharpness[] = {
483
    {0, N_("Soft")},      {1, N_("Normal")},    {2, N_("Hard")}, {3, N_("Med Soft")}, {4, N_("Med Hard")},
484
    {5, N_("Very Soft")}, {6, N_("Very Hard")}, {7, N_("-4")},   {8, N_("+4")},
485
};
486
487
//! Location, tag 0x0022
488
constexpr TagDetails pentaxLocation[] = {
489
    {0, N_("Home town")},
490
    {1, N_("Destination")},
491
};
492
493
//! City names, tags 0x0023 and 0x0024
494
constexpr TagDetails pentaxCities[] = {
495
    {0, N_("Pago Pago")},     {1, N_("Honolulu")},      {2, N_("Anchorage")},       {3, N_("Vancouver")},
496
    {4, N_("San Fransisco")}, {5, N_("Los Angeles")},   {6, N_("Calgary")},         {7, N_("Denver")},
497
    {8, N_("Mexico City")},   {9, N_("Chicago")},       {10, N_("Miami")},          {11, N_("Toronto")},
498
    {12, N_("New York")},     {13, N_("Santiago")},     {14, N_("Caracus")},        {15, N_("Halifax")},
499
    {16, N_("Buenos Aires")}, {17, N_("Sao Paulo")},    {18, N_("Rio de Janeiro")}, {19, N_("Madrid")},
500
    {20, N_("London")},       {21, N_("Paris")},        {22, N_("Milan")},          {23, N_("Rome")},
501
    {24, N_("Berlin")},       {25, N_("Johannesburg")}, {26, N_("Istanbul")},       {27, N_("Cairo")},
502
    {28, N_("Jerusalem")},    {29, N_("Moscow")},       {30, N_("Jeddah")},         {31, N_("Tehran")},
503
    {32, N_("Dubai")},        {33, N_("Karachi")},      {34, N_("Kabul")},          {35, N_("Male")},
504
    {36, N_("Delhi")},        {37, N_("Colombo")},      {38, N_("Kathmandu")},      {39, N_("Dacca")},
505
    {40, N_("Yangon")},       {41, N_("Bangkok")},      {42, N_("Kuala Lumpur")},   {43, N_("Vientiane")},
506
    {44, N_("Singapore")},    {45, N_("Phnom Penh")},   {46, N_("Ho Chi Minh")},    {47, N_("Jakarta")},
507
    {48, N_("Hong Kong")},    {49, N_("Perth")},        {50, N_("Beijing")},        {51, N_("Shanghai")},
508
    {52, N_("Manila")},       {53, N_("Taipei")},       {54, N_("Seoul")},          {55, N_("Adelaide")},
509
    {56, N_("Tokyo")},        {57, N_("Guam")},         {58, N_("Sydney")},         {59, N_("Noumea")},
510
    {60, N_("Wellington")},   {61, N_("Auckland")},     {62, N_("Lima")},           {63, N_("Dakar")},
511
    {64, N_("Algiers")},      {65, N_("Helsinki")},     {66, N_("Athens")},         {67, N_("Nairobi")},
512
    {68, N_("Amsterdam")},    {69, N_("Stockholm")},    {70, N_("Lisbon")},         {71, N_("Copenhagen")},
513
    {72, N_("Warsaw")},       {73, N_("Prague")},       {74, N_("Budapest")},
514
};
515
516
//! ImageProcessing, combi-tag 0x0032 (4 bytes)
517
constexpr TagDetails pentaxImageProcessing[] = {
518
    {0x00000000, N_("Unprocessed")},      {0x00000004, N_("Digital Filter")}, {0x01000000, N_("Resized")},
519
    {0x02000000, N_("Cropped")},          {0x04000000, N_("Color Filter")},   {0x06000000, N_("Digital Filter 6")},
520
    {0x10000000, N_("Frame Synthesis?")},
521
};
522
523
//! PictureMode, combi-tag 0x0033 (3 bytes)
524
constexpr TagDetails pentaxPictureMode[] = {
525
    {0x000000, N_("Program")},
526
    {0x000100, N_("Hi-speed Program")},
527
    {0x000200, N_("DOF Program")},
528
    {0x000300, N_("MTF Program")},
529
    {0x000400, N_("Standard")},
530
    {0x000500, N_("Portrait")},
531
    {0x000600, N_("Landscape")},
532
    {0x000700, N_("Macro")},
533
    {0x000800, N_("Sport")},
534
    {0x000900, N_("Night Scene Portrait")},
535
    {0x000a00, N_("No Flash")},
536
    /* SCN modes (menu-selected) */
537
    {0x000b00, N_("Night Scene")},
538
    {0x000c00, N_("Surf & Snow")},
539
    {0x000d00, N_("Text")},
540
    {0x000e00, N_("Sunset")},
541
    {0x000f00, N_("Kids")},
542
    {0x001000, N_("Pet")},
543
    {0x001100, N_("Candlelight")},
544
    {0x001200, N_("Museum")},
545
    {0x001300, N_("Food")},
546
    {0x001400, N_("Stage Lighting")},
547
    {0x001500, N_("Night Snap")},
548
    {0x001700, N_("Blue Sky")},
549
    {0x001800, N_("Sunset")},
550
    {0x001a00, N_("Night Scene HDR")},
551
    {0x001b00, N_("HDR")},
552
    {0x001c00, N_("Quick Macro")},
553
    {0x001d00, N_("Forest")},
554
    {0x001e00, N_("Backlight Silhouette")},
555
    /* AUTO PICT modes (auto-selected) */
556
    {0x010400, N_("Auto PICT (Standard)")},
557
    {0x010500, N_("Auto PICT (Portrait)")},
558
    {0x010600, N_("Auto PICT (Landscape)")},
559
    {0x010700, N_("Auto PICT (Macro)")},
560
    {0x010800, N_("Auto PICT (Sport)")},
561
    /* Manual dial modes */
562
    {0x020000, N_("Program AE")},
563
    {0x030000, N_("Green Mode")},
564
    {0x040000, N_("Shutter Speed Priority")},
565
    {0x050000, N_("Aperture Priority")},
566
    {0x080000, N_("Manual")},
567
    {0x090000, N_("Bulb")},
568
    /* *istD modes */
569
    {0x020001, N_("Program AE")},
570
    {0x020101, N_("Hi-speed Program")},
571
    {0x020201, N_("DOF Program")},
572
    {0x020301, N_("MTF Program")},
573
    {0x021601, N_("Shallow DOF")},
574
    {0x030001, N_("Green Mode")},
575
    {0x040001, N_("Shutter Speed Priority")},
576
    {0x050001, N_("Aperture Priority")},
577
    {0x060001, N_("Program Tv Shift")},
578
    {0x070001, N_("Program Av Shift")},
579
    {0x080001, N_("Manual")},
580
    {0x090001, N_("Bulb")},
581
    {0x0a0001, N_("Aperture Priority (Off-Auto-Aperture)")},
582
    {0x0b0001, N_("Manual (Off-Auto-Aperture)")},
583
    {0x0c0001, N_("Bulb (Off-Auto-Aperture)")},
584
    /* K10D modes */
585
    {0x060000, N_("Shutter Priority")},
586
    {0x0d0000, N_("Shutter & Aperture Priority AE")},
587
    {0x0d0001, N_("Shutter & Aperture Priority AE (1)")},
588
    {0x0f0000, N_("Sensitivity Priority AE")},
589
    {0x0f0001, N_("Sensitivity Priority AE (1)")},
590
    {0x100000, N_("Flash X-Sync Speed AE")},
591
    {0x100001, N_("Flash X-Sync Speed AE (1)")},
592
    {0x120001, N_("Auto Program (Normal)")},
593
    {0x120101, N_("Auto Program (Hi-Speed)")},
594
    {0x120201, N_("Auto Program (DOF)")},
595
    {0x120301, N_("Auto Program (MTF)")},
596
    {0x121601, N_("Auto Program (Shallow DOF)")},
597
    {0x141601, N_("Blur control")},
598
    /* other modes */
599
    {0x000001, N_("Program")},
600
    {0xfe0000, N_("Video (30 fps)")},
601
    {0xff0004, N_("Video (24 fps)")},
602
};
603
604
//! DriveMode, combi-tag 0x0034 (4 bytes)
605
constexpr TagDetails pentaxDriveMode[] = {
606
    {0x00000000, N_("Single-frame")},
607
    {0x01000000, N_("Continuous")},
608
    {0x02000000, N_("Continuous (Hi)")},
609
    {0x03000000, N_("Burst")},
610
    {0xff000000, N_("Video")},
611
    {0x00100000, N_("Single-frame")}, /* on 645D */
612
    {0x00010000, N_("Self-timer (12 sec)")},
613
    {0x00020000, N_("Self-timer (2 sec)")},
614
    {0x000f0000, N_("Video")},
615
    {0x00100000, N_("Mirror Lock-up")},
616
    {0x00000100, N_("Remote Control (3 sec)")},
617
    {0x00000200, N_("Remote Control")},
618
    {0x00000400, N_("Remote Continuous Shooting")},
619
    {0x00000001, N_("Multiple Exposure")},
620
    {0x00000010, N_("HDR")},
621
    {0x00000020, N_("HDR Strong 1")},
622
    {0x00000030, N_("HDR Strong 2")},
623
    {0x00000040, N_("HDR Strong 3")},
624
    {0x000000e0, N_("HDR Auto")},
625
    {0x000000ff, N_("Video")},
626
};
627
628
//! ColorSpace, tag 0x0037
629
constexpr TagDetails pentaxColorSpace[] = {
630
    {0, N_("sRGB")},
631
    {1, N_("Adobe RGB")},
632
};
633
634
//! LensType, combi-tag 0x003f (2 unsigned long)
635
constexpr TagDetails pentaxLensType[] = {
636
    {0x0000, N_("M-42 or No Lens")},
637
    {0x0100, N_("K or M Lens")},
638
    {0x0200, N_("A Series Lens")},
639
    {0x0300, "Sigma Lens"},
640
    {0x0311, "smc PENTAX-FA SOFT 85mm F2.8"},
641
    {0x0312, "smc PENTAX-F 1.7X AF ADAPTER"},
642
    {0x0313, "smc PENTAX-F 24-50mm F4"},
643
    {0x0314, "smc PENTAX-F 35-80mm F4-5.6"},
644
    {0x0315, "smc PENTAX-F 80-200mm F4.7-5.6"},
645
    {0x0316, "smc PENTAX-F FISH-EYE 17-28mm F3.5-4.5"},
646
    {0x0317, "smc PENTAX-F 100-300mm F4.5-5.6"},         // 0
647
    {0x0317, "Sigma AF 28-300mm F3.5-6.3 DG IF Macro"},  // 1
648
    {0x0317, "Tokina 80-200mm F2.8 ATX-Pro"},            // 2
649
    {0x0318, "smc PENTAX-F 35-135mm F3.5-4.5"},
650
    {0x0319, "smc PENTAX-F 35-105mm F4-5.6"},            // 0
651
    {0x0319, "Sigma AF 28-300mm F3.5-5.6 DL IF"},        // 1
652
    {0x0319, "Sigma 55-200mm F4-5.6 DC"},                // 2
653
    {0x0319, "Sigma AF 28-300mm F3.5-5.6 DL IF"},        // 3
654
    {0x0319, "Sigma AF 28-300mm F3.5-6.3 DG IF Macro"},  // 4
655
    {0x0319, "Tokina 80-200mm F2.8 ATX-Pro"},            // 5
656
    {0x0319, "Sigma Zoom 70-210mm F4-5.6 UC-II"},        // 6
657
    {0x031a, "smc PENTAX-F* 250-600mm F5.6 ED[IF]"},
658
    {0x031b, "smc PENTAX-F 28-80mm F3.5-4.5"},        // 0
659
    {0x031b, "Tokina AT-X Pro AF 28-70mm F2.6-2.8"},  // 1
660
    {0x031c, "smc PENTAX-F 35-70mm F3.5-4.5"},        // 0
661
    {0x031c, "Tokina 19-35mm F3.5-4.5 AF"},           // 1
662
    {0x031c, "Tokina AT-X AF 400mm F5.6"},            // 2
663
    {0x031d, "PENTAX-F 28-80mm F3.5-4.5"},            // 0
664
    {0x031d, "Sigma AF 18-125mm F3.5-5.6 DC"},        // 1
665
    {0x031d, "Tokina AT-X PRO 28-70mm F2.6-2.8"},     // 2
666
    {0x031e, "PENTAX-F 70-200mm F4-5.6"},
667
    {0x031f, "smc PENTAX-F 70-210mm F4-5.6"},     // 0
668
    {0x031f, "Tokina AF 730 75-300mm F4.5-5.6"},  // 1
669
    {0x031f, "Takumar-F 70-210mm F4-5.6"},        // 2
670
    {0x0320, "smc PENTAX-F 50mm F1.4"},
671
    {0x0321, "smc PENTAX-F 50mm F1.7"},
672
    {0x0322, "smc PENTAX-F 135mm F2.8 [IF]"},
673
    {0x0323, "smc PENTAX-F 28mm F2.8"},
674
    {0x0324, "Sigma 20mm F1.8 EX DG Aspherical RF"},
675
    {0x0326, "smc PENTAX-F* 300mm F4.5 ED[IF]"},
676
    {0x0327, "smc PENTAX-F* 600mm F4 ED[IF]"},
677
    {0x0328, "smc PENTAX-F Macro 100mm F2.8"},
678
    {0x0329, "smc PENTAX-F Macro 50mm F2.8"},  // 0
679
    {0x0329, "Sigma 50mm F2.8 Macro"},         // 1
680
    {0x032a, "Sigma 300mm F2.8 EX DG APO IF"},
681
    {0x032c, "Tamron 35-90mm F4 AF"},                          // 0
682
    {0x032c, "Sigma AF 10-20mm F4-5.6 EX DC"},                 // 1
683
    {0x032c, "Sigma 12-24mm F4.5-5.6 EX DG"},                  // 2
684
    {0x032c, "Sigma 17-70mm F2.8-4.5 DC Macro"},               // 3
685
    {0x032c, "Sigma 18-50mm F3.5-5.6 DC"},                     // 4
686
    {0x032c, "Sigma 17-35mm F2.8-4 EX DG"},                    // 5
687
    {0x032c, "Sigma AF 18-35mm F3.5-4.5 Aspherical"},          // 6
688
    {0x032e, "Sigma or Samsung Lens"},                         // 0
689
    {0x032e, "Sigma APO 70-200mm F2.8 EX"},                    // 1
690
    {0x032e, "Sigma EX APO 100-300mm F4 IF"},                  // 2
691
    {0x032e, "Samsung/Schneider D-XENON 50-200mm F4-5.6 ED"},  // 3
692
    {0x0332, "smc PENTAX-FA 28-70mm F4 AL"},
693
    {0x0333, "Sigma 28mm F1.8 EX DG Aspherical Macro"},
694
    {0x0334, "smc PENTAX-FA 28-200mm F3.8-5.6 AL[IF]"},                 // 0
695
    {0x0334, "Tamron AF LD 28-200mm F3.8-5.6 [IF] Aspherical (171D)"},  // 1
696
    {0x0335, "smc PENTAX-FA 28-80mm F3.5-5.6 AL"},
697
    {0x03f7, "smc PENTAX-DA FISH-EYE 10-17mm F3.5-4.5 ED[IF]"},
698
    {0x03f8, "smc PENTAX-DA 12-24mm F4 ED AL[IF]"},
699
    {0x03fa, "smc PENTAX-DA 50-200mm F4-5.6 ED"},
700
    {0x03fb, "smc PENTAX-DA 40mm F2.8 Limited"},
701
    {0x03fc, "smc PENTAX-DA 18-55mm F3.5-5.6 AL"},
702
    {0x03fd, "smc PENTAX-DA 14mm F2.8 ED[IF]"},
703
    {0x03fe, "smc PENTAX-DA 16-45mm F4 ED AL"},
704
    {0x03ff, "Sigma Lens"},                             // 0
705
    {0x03ff, "Sigma 18-200mm F3.5-6.3 DC"},             // 1
706
    {0x03ff, "Sigma DL-II 35-80mm F4-5.6"},             // 2
707
    {0x03ff, "Sigma DL Zoom 75-300mm F4-5.6"},          // 3
708
    {0x03ff, "Sigma DF EX Aspherical 28-70mm F2.8"},    // 4
709
    {0x03ff, "Sigma AF Tele 400mm F5.6 Multi-coated"},  // 5
710
    {0x03ff, "Sigma 24-60mm F2.8 EX DG"},               // 6
711
    {0x03ff, "Sigma 70-300mm F4-5.6 Macro"},            // 7
712
    {0x03ff, "Sigma 55-200mm F4-5.6 DC"},               // 8
713
    {0x03ff, "Sigma 18-50mm F2.8 EX DC"},               // 9
714
    {0x03ff, "Sigma 18-50mm F2.8 EX DC Macro"},         // 10
715
    {0x0401, "smc PENTAX-FA SOFT 28mm F2.8"},
716
    {0x0402, "smc PENTAX-FA 80-320mm F4.5-5.6"},
717
    {0x0403, "smc PENTAX-FA 43mm F1.9 Limited"},
718
    {0x0406, "smc PENTAX-FA 35-80mm F4-5.6"},
719
    {0x0407, "Irix 45mm F/1.4"},
720
    {0x0408, "Irix 150mm F/2.8 Macro"},
721
    {0x0409, "Irix 11mm F/4"},
722
    {0x040a, "Irix 15mm F/2.4"},
723
    {0x040c, "smc PENTAX-FA 50mm F1.4"},
724
    {0x040f, "smc PENTAX-FA 28-105mm F4-5.6 [IF]"},
725
    {0x0410, "Tamron AF 80-210mm F4-5.6 (178D)"},
726
    {0x0413, "Tamron SP AF 90mm F2.8 (172E)"},
727
    {0x0414, "smc PENTAX-FA 28-80mm F3.5-5.6"},
728
    {0x0415, "Cosina AF 100-300mm F5.6-6.7"},
729
    {0x0416, "Tokina 28-80mm F3.5-5.6"},
730
    {0x0417, "smc PENTAX-FA 20-35mm F4 AL"},
731
    {0x0418, "smc PENTAX-FA 77mm F1.8 Limited"},
732
    {0x0419, "Tamron SP AF 14mm F2.8"},
733
    {0x041a, "smc PENTAX-FA Macro 100mm F3.5"},  // 0
734
    {0x041a, "Cosina 100mm F3.5 Macro"},         // 1
735
    {0x041b, "Tamron AF28-300mm F/3.5-6.3 LD Aspherical[IF] Macro (185D/285D)"},
736
    {0x041c, "smc PENTAX-FA 35mm F2 AL"},
737
    {0x041d, "Tamron AF 28-200mm F/3.8-5.6 LD Super II Macro (371D)"},
738
    {0x0422, "smc PENTAX-FA 24-90mm F3.5-4.5 AL[IF]"},
739
    {0x0423, "smc PENTAX-FA 100-300mm F4.7-5.8"},
740
    {0x0424, "Tamron AF 70-300mm F/4-5.6 LD Macro 1:2 (572D/A17)"},
741
    {0x0425, "Tamron SP AF 24-135mm F3.5-5.6 AD AL (190D)"},
742
    {0x0426, "smc PENTAX-FA 28-105mm F3.2-4.5 AL[IF]"},
743
    {0x0427, "smc PENTAX-FA 31mm F1.8AL Limited"},
744
    {0x0429, "Tamron AF 28-200mm Super Zoom F3.8-5.6 Aspherical XR [IF] Macro (A03)"},
745
    {0x042b, "smc PENTAX-FA 28-90mm F3.5-5.6"},
746
    {0x042c, "smc PENTAX-FA J 75-300mm F4.5-5.8 AL"},
747
    {0x042d, "Tamron Lens"},                                                 // 0
748
    {0x042d, "Tamron 28-300mm F3.5-6.3 Ultra zoom XR"},                      // 1
749
    {0x042d, "Tamron AF 28-300mm F3.5-6.3 XR Di LD Aspherical [IF] Macro"},  // 2
750
    {0x042e, "smc PENTAX-FA J 28-80mm F3.5-5.6 AL"},
751
    {0x042f, "smc PENTAX-FA J 18-35mm F4-5.6 AL"},
752
    {0x0431, "Tamron SP AF 28-75mm F2.8 XR Di LD Aspherical [IF] Macro (A09)"},
753
    {0x0433, "smc PENTAX-D FA 50mm F2.8 Macro"},
754
    {0x0434, "smc PENTAX-D FA 100mm F2.8 Macro"},
755
    {0x0437, "Samsung/Schneider D-XENOGON 35mm F2"},
756
    {0x0438, "Samsung/Schneider D-XENON 100mm F2.8 Macro"},
757
    {0x044b, "Tamron SP AF 70-200mm F2.8 Di LD [IF] Macro (A001)"},
758
    {0x04d6, "smc PENTAX-DA 35mm F2.4 AL"},
759
    {0x04e5, "smc PENTAX-DA 18-55mm F3.5-5.6 AL II"},
760
    {0x04e6, "Tamron SP AF 17-50mm F2.8 XR Di II"},
761
    {0x04e7, "smc PENTAX-DA 18-250mm F3.5-6.3 ED AL [IF]"},
762
    {0x04ed, "Samsung/Schneider D-XENOGON 10-17mm F3.5-4.5"},
763
    {0x04ef, "Samsung/Schneider D-XENON 12-24mm F4 ED AL [IF]"},
764
    {0x04f2, "smc PENTAX-DA* 16-50mm F2.8 ED AL [IF] SDM (SDM unused)"},
765
    {0x04f3, "smc PENTAX-DA 70mm F2.4 Limited"},
766
    {0x04f4, "smc PENTAX-DA 21mm F3.2 AL Limited"},
767
    {0x04f5, "Samsung/Schneider D-XENON 50-200mm F4-5.6"},
768
    {0x04f6, "Samsung/Schneider D-XENON 18-55mm F3.5-5.6"},
769
    {0x04f7, "smc PENTAX-DA FISH-EYE 10-17mm F3.5-4.5 ED [IF]"},
770
    {0x04f8, "smc PENTAX-DA 12-24mm F4 ED AL [IF]"},
771
    {0x04f9, "Tamron XR DiII 18-200mm F3.5-6.3 (A14)"},
772
    {0x04fa, "smc PENTAX-DA 50-200mm F4-5.6 ED"},
773
    {0x04fb, "smc PENTAX-DA 40mm F2.8 Limited"},
774
    {0x04fc, "smc PENTAX-DA 18-55mm F3.5-5.6 AL"},
775
    {0x04fd, "smc PENTAX-DA 14mm F2.8 ED[IF]"},
776
    {0x04fe, "smc PENTAX-DA 16-45mm F4 ED AL"},
777
    {0x0501, "smc PENTAX-FA* 24mm F2 AL[IF]"},
778
    {0x0502, "smc PENTAX-FA 28mm F2.8 AL"},
779
    {0x0503, "smc PENTAX-FA 50mm F1.7"},
780
    {0x0504, "smc PENTAX-FA 50mm F1.4"},
781
    {0x0505, "smc PENTAX-FA* 600mm F4 ED[IF]"},
782
    {0x0506, "smc PENTAX-FA* 300mm F4.5 ED[IF]"},
783
    {0x0507, "smc PENTAX-FA 135mm F2.8 [IF]"},
784
    {0x0508, "smc PENTAX-FA Macro 50mm F2.8"},
785
    {0x0509, "smc PENTAX-FA Macro 100mm F2.8"},
786
    {0x050a, "smc PENTAX-FA* 85mm F1.4 [IF]"},
787
    {0x050b, "smc PENTAX-FA* 200mm F2.8 ED[IF]"},
788
    {0x050c, "smc PENTAX-FA 28-80mm F3.5-4.7"},
789
    {0x050d, "smc PENTAX-FA 70-200mm F4-5.6"},
790
    {0x050e, "smc PENTAX-FA* 250-600mm F5.6 ED[IF]"},
791
    {0x050f, "smc PENTAX-FA 28-105mm F4-5.6"},
792
    {0x0510, "smc PENTAX-FA 100-300mm F4.5-5.6"},
793
    {0x0562, "smc PENTAX-FA 100-300mm F4.5-5.6"},
794
    {0x0601, "smc PENTAX-FA* 85mm F1.4[IF]"},
795
    {0x0602, "smc PENTAX-FA* 200mm F2.8 ED[IF]"},
796
    {0x0603, "smc PENTAX-FA* 300mm F2.8 ED[IF]"},
797
    {0x0604, "smc PENTAX-FA* 28-70mm F2.8 AL"},
798
    {0x0605, "smc PENTAX-FA* 80-200mm F2.8 ED[IF]"},
799
    {0x0606, "smc PENTAX-FA* 28-70mm F2.8 AL"},
800
    {0x0607, "smc PENTAX-FA* 80-200mm F2.8 ED[IF]"},
801
    {0x0608, "smc PENTAX-FA 28-70mm F4AL"},
802
    {0x0609, "smc PENTAX-FA 20mm F2.8"},
803
    {0x060a, "smc PENTAX-FA* 400mm F5.6 ED[IF]"},
804
    {0x060d, "smc PENTAX-FA* 400mm F5.6 ED[IF]"},
805
    {0x060e, "smc PENTAX-FA* Macro 200mm F4 ED[IF]"},
806
    {0x0700, "smc PENTAX-DA 21mm F3.2 AL Limited"},
807
    {0x073a, "smc PENTAX-D FA Macro 100mm F2.8 WR"},
808
    {0x074b, "Tamron SP AF 70-200mm F2.8 Di LD [IF] Macro (A001)"},
809
    {0x07c9, "smc Pentax-DA L 50-200mm F4-5.6 ED WR"},
810
    {0x07ca, "smc PENTAX-DA L 18-55mm F3.5-5.6 AL WR"},
811
    {0x07cb, "HD PENTAX-DA 55-300mm F4-5.8 ED WR"},
812
    {0x07cc, "HD PENTAX-DA 15mm F4 ED AL Limited"},
813
    {0x07cd, "HD PENTAX-DA 35mm F2.8 Macro Limited"},
814
    {0x07ce, "HD PENTAX-DA 70mm F2.4 Limited"},
815
    {0x07cf, "HD PENTAX-DA 21mm F3.2 ED AL Limited"},
816
    {0x07d0, "HD PENTAX-DA 40mm F2.8 Limited"},
817
    {0x07d4, "smc PENTAX-DA 50mm F1.8"},
818
    {0x07d5, "smc PENTAX-DA 40mm F2.8 XS"},
819
    {0x07d6, "smc PENTAX-DA 35mm F2.4 AL"},
820
    {0x07d8, "smc PENTAX-DA L 55-300mm F4-5.8 ED"},
821
    {0x07d9, "smc PENTAX-DA 50-200mm F4-5.6 ED WR"},
822
    {0x07da, "smc PENTAX-DA 18-55mm F3.5-5.6 AL WR"},
823
    {0x07dc, "Tamron SP AF 10-24mm F3.5-4.5 Di II LD Aspherical [IF]"},
824
    {0x07dd, "smc PENTAX-DA L 50-200mm F4-5.6 ED"},
825
    {0x07de, "smc PENTAX-DA L 18-55mm F3.5-5.6"},
826
    {0x07df, "Samsung/Schneider D-XENON 18-55mm F3.5-5.6 II"},
827
    {0x07e0, "smc PENTAX-DA 15mm F4 ED AL Limited"},
828
    {0x07e1, "Samsung/Schneider D-XENON 18-250mm F3.5-6.3"},
829
    {0x07e2, "smc PENTAX-DA* 55mm F1.4 SDM (SDM unused)"},
830
    {0x07e3, "smc PENTAX-DA* 60-250mm F4 [IF] SDM (SDM unused)"},
831
    {0x07e4, "Samsung 16-45mm F4 ED"},
832
    {0x07e5, "smc PENTAX-DA 18-55mm F3.5-5.6 AL II"},
833
    {0x07e6, "Tamron AF 17-50mm F2.8 XR Di-II LD (Model A16)"},
834
    {0x07e7, "smc PENTAX-DA 18-250mm F3.5-6.3ED AL [IF]"},
835
    {0x07e9, "smc PENTAX-DA 35mm F2.8 Macro Limited"},
836
    {0x07ea, "smc PENTAX-DA* 300 mm F4ED [IF] SDM (SDM not used)"},
837
    {0x07eb, "smc PENTAX-DA* 200mm F2.8 ED [IF] SDM (SDM not used)"},
838
    {0x07ec, "smc PENTAX-DA 55-300mm F4-5.8 ED"},
839
    {0x07ee, "Tamron AF 18-250mm F3.5-6.3 Di II LD Aspherical [IF] Macro"},
840
    {0x07f1, "smc PENTAX-DA* 50-135mm F2.8 ED [IF] SDM (SDM not used)"},
841
    {0x07f2, "smc PENTAX-DA* 16-50mm F2.8 ED AL [IF] SDM (SDM not used)"},
842
    {0x07f3, "smc PENTAX-DA 70mm F2.4 Limited"},
843
    {0x07f4, "smc PENTAX-DA 21mm F3.2 AL Limited"},
844
    {0x0800, "Sigma 50-150mm F2.8 II APO EX DC HSM"},
845
    {0x0803, "Sigma AF 18-125mm F3.5-5.6 DC"},
846
    {0x0804, "Sigma 50mm F1.4 EX DG HSM"},
847
    {0x0807, "Sigma 24-70mm F2.8 IF EX DG HSM"},
848
    {0x0808, "Sigma 18-250mm F3.5-6.3 DC OS HSM"},
849
    {0x080b, "Sigma 10-20mm F3.5 EX DC HSM"},
850
    {0x080c, "Sigma 70-300mm F4-5.6 DG OS"},
851
    {0x080d, "Sigma 120-400mm F4.5-5.6 APO DG OS HSM"},
852
    {0x080e, "Sigma 17-70mm F2.8-4.0 DC Macro OS HSM"},
853
    {0x080f, "Sigma 150-500mm F5-6.3 APO DG OS HSM"},
854
    {0x0810, "Sigma 70-200mm F2.8 EX DG Macro HSM II"},
855
    {0x0811, "Sigma 50-500mm F4.5-6.3 DG OS HSM"},
856
    {0x0812, "Sigma 8-16mm F4.5-5.6 DC HSM"},
857
    {0x0815, "Sigma 17-50mm F2.8 EX DC OS HSM"},
858
    {0x0816, "Sigma 85mm F1.4 EX DG HSM"},
859
    {0x0817, "Sigma 70-200mm F2.8 APO EX DG OS HSM"},
860
    {0x0819, "Sigma 17-50mm F2.8 EX DC HSM"},
861
    {0x081b, "Sigma 18-200mm F3.5-6.3 II DC HSM"},
862
    {0x081c, "Sigma 18-250mm F3.5-6.3 DC Macro HSM"},
863
    {0x081d, "Sigma 35mm F1.4 DG HSM"},
864
    {0x081e, "Sigma 17-70mm F2.8-4 DC Macro HSM | C"},
865
    {0x081f, "Sigma 18-35mm F1.8 DC HSM"},
866
    {0x0820, "Sigma 30mm F1.4 DC HSM | A"},
867
    {0x0822, "Sigma 18-300mm F3.5-6.3 DC Macro HSM"},
868
    {0x083b, "HD PENTAX-D FA 150-450mm F4.5-5.6 ED DC AW"},
869
    {0x083c, "HD PENTAX-D FA* 70-200mm F2.8 ED DC AW"},
870
    {0x083d, "HD PENTAX-D FA 28-105mm F3.5-5.6 ED DC WR"},
871
    {0x083e, "HD PENTAX-D FA 24-70mm F2.8 ED SDM WR"},
872
    {0x083f, "HD PENTAX-D FA 15-30mm F2.8 ED SDM WR"},
873
    {0x0840, "HD PENTAX-D FA* 50mm F1.4 SDM AW"},
874
    {0x0841, "HD PENTAX-D FA 70-210mm F4 ED SDM WR"},
875
    {0x0842, "HD PENTAX-D FA* 85mm F1.4 SDM AW"},
876
    {0x0843, "HD PENTAX-D FA 21mm F2.4 ED Limited DC WR"},
877
    {0x08c3, "HD PENTAX DA* 16-50mm F2.8 ED PLM AW"},
878
    {0x08c4, "HD PENTAX-DA* 11-18mm F2.8 ED DC AW"},
879
    {0x08c5, "HD PENTAX-DA 55-300mm F4.5-6.3 ED PLM WR RE"},
880
    {0x08c6, "smc PENTAX-DA L 18-50mm F4-5.6 DC WR RE"},
881
    {0x08c7, "HD PENTAX-DA 18-50mm F4-5.6 DC WR RE"},
882
    {0x08c8, "HD PENTAX-DA 16-85mm F3.5-5.6 ED DC WR"},
883
    {0x08d1, "HD PENTAX-DA 20-40mm F2.8-4 ED Limited DC WR"},
884
    {0x08d2, "smc PENTAX-DA 18-270mm F3.5-6.3 ED SDM"},
885
    {0x08d3, "HD PENTAX-DA 560mm F5.6 ED AW"},
886
    {0x08d7, "smc PENTAX-DA 18-135mm F3.5-5.6 ED AL [IF] DC WR"},
887
    {0x08e2, "smc PENTAX-DA* 55mm F1.4 SDM"},
888
    {0x08e3, "smc PENTAX DA* 60-250mm F4 [IF] SDM"},
889
    {0x08e8, "smc PENTAX-DA 17-70mm F4 AL [IF] SDM"},
890
    {0x08ea, "smc PENTAX-DA* 300mm F4 ED [IF] SDM"},
891
    {0x08eb, "smc PENTAX-DA* 200mm F2.8 ED [IF] SDM"},
892
    {0x08f1, "smc PENTAX-DA* 50-135mm F2.8 ED [IF] SDM"},
893
    {0x08f2, "smc PENTAX-DA* 16-50mm F2.8 ED AL [IF] SDM"},
894
    {0x08ff, "Sigma Lens"},                                   // 0
895
    {0x08ff, "Sigma 70-200mm F2.8 EX DG Macro HSM II"},       // 1
896
    {0x08ff, "Sigma 150-500mm F5-6.3 DG APO [OS] HSM"},       // 2
897
    {0x08ff, "Sigma 50-150mm F2.8 II APO EX DC HSM"},         // 3
898
    {0x08ff, "Sigma 4.5mm F2.8 EX DC HSM Circular Fisheye"},  // 4
899
    {0x08ff, "Sigma 50-200mm F4-5.6 DC OS"},                  // 5
900
    {0x08ff, "Sigma 24-70mm F2.8 EX DG HSM"},                 // 6
901
    {0x08ff, "Sigma 18-50mm F2.8-4.5 HSM OS"},                // 7
902
    {0x0900, "645 Manual Lens"},
903
    {0x0a00, "645 A Series Lens"},
904
    {0x0b01, "smc PENTAX-FA 645 75mm F2.8"},
905
    {0x0b02, "smc PENTAX-FA 645 45mm F2.8"},
906
    {0x0b03, "smc PENTAX-FA* 645 300mm F4 ED [IF]"},
907
    {0x0b04, "smc PENTAX-FA 645 45mm-85mm F4.5"},
908
    {0x0b05, "smc PENTAX-FA 645 400mm F5.6 ED [IF]"},
909
    {0x0b07, "smc PENTAX-FA 645 Macro 120mm F4"},
910
    {0x0b08, "smc PENTAX-FA 645 80-160mm F4.5"},
911
    {0x0b09, "smc PENTAX-FA 645 200mm F4 [IF]"},
912
    {0x0b0a, "smc PENTAX-FA 645 150mm F2.8 [IF]"},
913
    {0x0b0b, "smc PENTAX-FA 645 35mm F3.5 AL [IF]"},
914
    {0x0b0c, "smc PENTAX-FA 645 300mm F5.6 ED [IF]"},
915
    {0x0b0e, "smc PENTAX-FA 645 55-110mm F5.6"},
916
    {0x0b10, "smc PENTAX-FA 645 33-55mm F4.5 AL"},
917
    {0x0b11, "smc PENTAX-FA 645 150-300mm F5.6 ED [IF]"},
918
    {0x0b15, "HD PENTAX-D FA 645 35mm F3.5 AL [IF]"},
919
    {0x0d12, "smc PENTAX-D FA 645 55mm F2.8 AL [IF] SDM AW"},
920
    {0x0d13, "smc PENTAX-D FA 645 25mm F4 AL [IF] SDM AW"},
921
    {0x0d14, "HD PENTAX-D FA 645 90mm F2.8 ED AW SR"},
922
    {0x0dfd, "HD PENTAX-DA 645 28-45mm F4.5 ED AW SR"},
923
    {0x1500, "Pentax Q Manual Lens"},
924
    {0x1501, "01 Standard Prime 8.5mm F1.9"},
925
    {0x1502, "02 Standard Zoom 5-15mm F2.8-4.5"},
926
    {0x1603, "03 Fish-eye 3.2mm F5.6"},
927
    {0x1604, "04 Toy Lens Wide 6.3mm F7.1"},
928
    {0x1605, "05 Toy Lens Telephoto 18mm F8"},
929
    {0x1506, "06 Telephoto Zoom 15-45mm F2.8"},
930
    {0x1507, "07 Mount Shield 11.5mm F9"},
931
    {0x1508, "08 Wide Zoom 3.8-5.9mm F3.7-4"},
932
    {0x15e9, "Adapter Q for K-mount Lens"},
933
};
934
935
//! ImageTone, tag 0x004f
936
constexpr TagDetails pentaxImageTone[] = {
937
    {0, N_("Natural")},    {1, N_("Bright")}, {2, N_("Portrait")},      {3, N_("Landscape")},     {4, N_("Vibrant")},
938
    {5, N_("Monochrome")}, {6, N_("Muted")},  {7, N_("Reversal film")}, {8, N_("Bleach bypass")}, {9, N_("Radiant")},
939
};
940
941
//! DynamicRangeExpansion, tag 0x0069
942
constexpr TagDetails pentaxDynamicRangeExpansion[] = {
943
    {0, N_("Off")},
944
    {0x1000000, N_("On")},
945
};
946
947
//! HighISONoiseReduction, tag 0x0071
948
constexpr TagDetails pentaxHighISONoiseReduction[] = {
949
    {0, N_("Off")}, {1, N_("Weakest")}, {2, N_("Weak")}, {3, N_("Strong")}, {4, N_("Custom")},
950
};
951
952
0
std::ostream& PentaxMakerNote::printVersion(std::ostream& os, const Value& value, const ExifData*) {
953
0
  std::string val = value.toString();
954
0
  std::replace(val.begin(), val.end(), ' ', '.');
955
0
  os << val;
956
0
  return os;
957
0
}
958
959
0
std::ostream& PentaxMakerNote::printResolution(std::ostream& os, const Value& value, const ExifData*) {
960
0
  std::string val = value.toString();
961
0
  std::replace(val.begin(), val.end(), ' ', 'x');
962
0
  os << val;
963
0
  return os;
964
0
}
965
966
0
std::ostream& PentaxMakerNote::printDate(std::ostream& os, const Value& value, const ExifData*) {
967
  /* I choose same format as is used inside EXIF itself */
968
0
  return os << stringFormat("{}:{:02}:{:02}", ((static_cast<uint16_t>(value.toInt64(0)) << 8) + value.toInt64(1)),
969
0
                            value.toInt64(2), value.toInt64(3));
970
0
}
971
972
0
std::ostream& PentaxMakerNote::printTime(std::ostream& os, const Value& value, const ExifData*) {
973
0
  return os << stringFormat("{:02}:{:02}:{:02}", value.toInt64(0), value.toInt64(1), value.toInt64(2));
974
0
}
975
976
0
std::ostream& PentaxMakerNote::printExposure(std::ostream& os, const Value& value, const ExifData*) {
977
0
  return os << stringFormat("{:g} ms", static_cast<float>(value.toInt64()) / 100);
978
0
}
979
980
0
std::ostream& PentaxMakerNote::printFValue(std::ostream& os, const Value& value, const ExifData*) {
981
0
  return os << stringFormat("F{:.2g}", static_cast<float>(value.toInt64()) / 10);
982
0
}
983
984
0
std::ostream& PentaxMakerNote::printFocalLength(std::ostream& os, const Value& value, const ExifData*) {
985
0
  return os << stringFormat("{:.1f} mm", static_cast<float>(value.toInt64()) / 100);
986
0
}
987
988
0
std::ostream& PentaxMakerNote::printCompensation(std::ostream& os, const Value& value, const ExifData*) {
989
0
  return os << stringFormat("{:.2g} EV", (static_cast<float>(value.toInt64()) - 50) / 10);
990
0
}
991
992
0
std::ostream& PentaxMakerNote::printTemperature(std::ostream& os, const Value& value, const ExifData*) {
993
0
  return os << stringFormat("{} C", value.toInt64());
994
0
}
995
996
0
std::ostream& PentaxMakerNote::printFlashCompensation(std::ostream& os, const Value& value, const ExifData*) {
997
0
  return os << stringFormat("{:.2g} EV", static_cast<float>(value.toInt64()) / 256);
998
0
}
999
1000
0
std::ostream& PentaxMakerNote::printBracketing(std::ostream& os, const Value& value, const ExifData*) {
1001
0
  std::ios::fmtflags f(os.flags());
1002
0
  if (auto l0 = value.toUint32(0); l0 < 10) {
1003
0
    os << std::setprecision(2) << static_cast<float>(l0) / 3 << " EV";
1004
0
  } else {
1005
0
    os << std::setprecision(2) << static_cast<float>(l0) - 9.5F << " EV";
1006
0
  }
1007
1008
0
  if (value.count() == 2) {
1009
0
    const auto l1 = value.toUint32(1);
1010
0
    os << " (";
1011
0
    if (l1 == 0) {
1012
0
      os << _("No extended bracketing");
1013
0
    } else {
1014
0
      auto type = l1 >> 8;
1015
0
      auto range = static_cast<byte>(l1);
1016
0
      switch (type) {
1017
0
        case 1:
1018
0
          os << _("WB-BA");
1019
0
          break;
1020
0
        case 2:
1021
0
          os << _("WB-GM");
1022
0
          break;
1023
0
        case 3:
1024
0
          os << _("Saturation");
1025
0
          break;
1026
0
        case 4:
1027
0
          os << _("Sharpness");
1028
0
          break;
1029
0
        case 5:
1030
0
          os << _("Contrast");
1031
0
          break;
1032
0
        default:
1033
0
          os << _("Unknown ") << type;
1034
0
          break;
1035
0
      }
1036
0
      os << " " << +range;
1037
0
    }
1038
0
    os << ")";
1039
0
  }
1040
0
  os.flags(f);
1041
0
  return os;
1042
0
}
1043
1044
0
std::ostream& PentaxMakerNote::printShutterCount(std::ostream& os, const Value& value, const ExifData* metadata) {
1045
0
  if (!metadata)
1046
0
    return os << "undefined";
1047
1048
0
  auto dateIt = metadata->findKey(ExifKey("Exif.PentaxDng.Date"));
1049
0
  if (dateIt == metadata->end()) {
1050
0
    dateIt = metadata->findKey(ExifKey("Exif.Pentax.Date"));
1051
0
  }
1052
1053
0
  auto timeIt = metadata->findKey(ExifKey("Exif.PentaxDng.Time"));
1054
0
  if (timeIt == metadata->end()) {
1055
0
    timeIt = metadata->findKey(ExifKey("Exif.Pentax.Time"));
1056
0
  }
1057
1058
0
  if (dateIt == metadata->end() || dateIt->size() != 4 || timeIt == metadata->end() || timeIt->size() != 3 ||
1059
0
      value.size() != 4) {
1060
0
    os << "undefined";
1061
0
    return os;
1062
0
  }
1063
0
  const uint32_t date = (dateIt->toUint32(0) << 24) + (dateIt->toUint32(1) << 16) + (dateIt->toUint32(2) << 8) +
1064
0
                        (dateIt->toUint32(3) << 0);
1065
0
  const uint32_t time = (timeIt->toUint32(0) << 24) + (timeIt->toUint32(1) << 16) + (timeIt->toUint32(2) << 8);
1066
0
  const uint32_t countEnc =
1067
0
      (value.toUint32(0) << 24) + (value.toUint32(1) << 16) + (value.toUint32(2) << 8) + (value.toUint32(3) << 0);
1068
  // The shutter count is encoded using date and time values stored
1069
  // in Pentax-specific tags.  The prototype for the encoding/decoding
1070
  // function is taken from Phil Harvey's ExifTool: Pentax.pm file,
1071
  // CryptShutterCount() routine.
1072
0
  const uint32_t count = countEnc ^ date ^ (~time);
1073
0
  os << count;
1074
0
  return os;
1075
0
}
1076
1077
// #1144 begin
1078
0
static std::string getKeyString(const std::string& key, const ExifData* metadata) {
1079
0
  std::string result;
1080
0
  if (metadata->findKey(ExifKey(key)) != metadata->end()) {
1081
0
    result = metadata->findKey(ExifKey(key))->toString();
1082
0
  }
1083
0
  return result;
1084
0
}
1085
1086
0
static long getKeyLong(const std::string& key, const ExifData* metadata) {
1087
0
  long result = -1;
1088
0
  if (metadata->findKey(ExifKey(key)) != metadata->end()) {
1089
0
    result = static_cast<long>(metadata->findKey(ExifKey(key))->toFloat(0));
1090
0
  }
1091
0
  return result;
1092
0
}
1093
1094
// Throws std::exception if the LensInfo can't be found.
1095
0
static ExifData::const_iterator findLensInfo(const ExifData* metadata) {
1096
0
  const auto dngLensInfo = metadata->findKey(ExifKey("Exif.PentaxDng.LensInfo"));
1097
0
  if (dngLensInfo != metadata->end()) {
1098
0
    return dngLensInfo;
1099
0
  }
1100
0
  const auto lensInfo = metadata->findKey(ExifKey("Exif.Pentax.LensInfo"));
1101
0
  if (lensInfo != metadata->end()) {
1102
0
    return lensInfo;
1103
0
  }
1104
0
  throw LensInfoNotFound();
1105
0
}
1106
1107
//! resolveLens0x32c print lens in human format
1108
0
static std::ostream& resolveLens0x32c(std::ostream& os, const Value& value, const ExifData* metadata) {
1109
0
  try {
1110
0
    unsigned long index = 0;
1111
1112
0
    long focalLength = getKeyLong("Exif.Photo.FocalLength", metadata);
1113
0
    bool bFL10_20 = 10 <= focalLength && focalLength <= 20;
1114
1115
    // std::cout << "model,focalLength = " << model << "," << focalLength << '\n';
1116
0
    if (bFL10_20) {
1117
0
      index = 1;
1118
0
    }
1119
1120
0
    if (index > 0) {
1121
0
      const unsigned long lensID = 0x32c;
1122
0
      auto td = Exiv2::find(pentaxLensType, lensID);
1123
0
      return os << _(td[index].label_);
1124
0
    }
1125
0
  } catch (...) {
1126
0
  }
1127
0
  return EXV_PRINT_COMBITAG_MULTI(pentaxLensType, 2, 1, 2)(os, value, metadata);
1128
0
}
1129
// #1144 end
1130
1131
// #816 begin
1132
//! resolveLens0x3ff print lens in human format
1133
static std::ostream& resolveLens0x3ff(std::ostream& os, const Value& value, const ExifData* metadata)
1134
// ----------------------------------------------------------------------
1135
0
{
1136
0
  try {
1137
0
    unsigned long index = 0;
1138
1139
    // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Pentax.html#LensData
1140
0
    const auto lensInfo = findLensInfo(metadata);
1141
0
    if (lensInfo->count() < 5)
1142
0
      return EXV_PRINT_COMBITAG_MULTI(pentaxLensType, 2, 1, 2)(os, value, metadata);
1143
1144
0
    if (value.count() == 2) {
1145
      // http://dev.exiv2.org/attachments/download/326/IMGP4432.PEF
1146
      // exiv2 -pv --grep Lens ~/Downloads/IMGP4432.PEF
1147
      // 0x003f Pentax       LensType  Byte        2 3 255
1148
      // 0x0207 Pentax       LensInfo  Undefined  36 3 255 0 0 40 148 71 152 80 6 241 65 237 153 88 36 1 76
1149
      // 107 251 255 255 255 0 0 80 6 241 0 0 0 0 0 0 0 0
1150
0
      unsigned long base = 1;
1151
1152
0
      unsigned int autoAperture = lensInfo->toUint32(base + 1) & 0x01;
1153
0
      unsigned int minAperture = lensInfo->toUint32(base + 2) & 0x06;
1154
0
      unsigned int minFocusDistance = lensInfo->toUint32(base + 3) & 0xf8;
1155
1156
0
      if (autoAperture == 0x0 && minAperture == 0x0 && minFocusDistance == 0x28 && lensInfo->toUint32(base + 4) == 148)
1157
0
        index = 8;
1158
0
      if (autoAperture == 0x0 && minAperture == 0x0 && minFocusDistance == 0x28 && lensInfo->toUint32(base + 5) == 110)
1159
0
        index = 7;
1160
0
      if (autoAperture == 0x0 && minAperture == 0x0 && minFocusDistance == 0x28 && lensInfo->toUint32(base + 4) == 110)
1161
0
        index = 7;
1162
1163
0
    } else if (value.count() == 3) {
1164
      // http://dev.exiv2.org/attachments/download/858/_IGP9032.DNG
1165
      // $ exiv2 -pv --grep Lens ~/Downloads/_IGP9032.DNG
1166
      // 0x003f PentaxDng    LensType  Byte        3    3 255   0
1167
      // 0x0207 PentaxDng    LensInfo  Undefined  69  131   0   0 255 0  40 148  68 244 ...
1168
      //                                                0   1   2   3 4   5   6
1169
0
      if (lensInfo->toUint32(4) == 0 && lensInfo->toUint32(5) == 40 && lensInfo->toUint32(6) == 148)
1170
0
        index = 8;
1171
1172
0
    } else if (value.count() == 4) {
1173
      // http://dev.exiv2.org/attachments/download/868/IMGP2221.JPG
1174
      // 0x0207 PentaxDng    LensInfo  Undefined 128    0 131 128   0 0 255   1 184   0 0 0 0 0
1175
      //                                                0   1   2   3 4   5   6
1176
0
      if (lensInfo->count() == 128 && lensInfo->toUint32(1) == 131 && lensInfo->toUint32(2) == 128)
1177
0
        index = 8;
1178
      // #1155
1179
0
      if (lensInfo->toUint32(6) == 5)
1180
0
        index = 7;
1181
0
    }
1182
1183
0
    if (index > 0) {
1184
0
      const unsigned long lensID = 0x3ff;
1185
0
      auto td = Exiv2::find(pentaxLensType, lensID);
1186
0
      return os << _(td[index].label_);
1187
0
    }
1188
0
  } catch (...) {
1189
0
  }
1190
0
  return EXV_PRINT_COMBITAG_MULTI(pentaxLensType, 2, 1, 2)(os, value, metadata);
1191
0
}
1192
1193
// #1155
1194
//! resolveLens0x8ff print lens in human format
1195
static std::ostream& resolveLens0x8ff(std::ostream& os, const Value& value, const ExifData* metadata)
1196
// ----------------------------------------------------------------------
1197
0
{
1198
0
  try {
1199
0
    unsigned long index = 0;
1200
1201
0
    const auto lensInfo = findLensInfo(metadata);
1202
0
    if (value.count() == 4) {
1203
0
      std::string model = getKeyString("Exif.Image.Model", metadata);
1204
0
      if (model.starts_with("PENTAX K-3") && lensInfo->count() == 128 && lensInfo->toUint32(1) == 168 &&
1205
0
          lensInfo->toUint32(2) == 144)
1206
0
        index = 7;
1207
0
    }
1208
1209
0
    if (index > 0) {
1210
0
      const unsigned long lensID = 0x8ff;
1211
0
      auto td = Exiv2::find(pentaxLensType, lensID);
1212
0
      return os << _(td[index].label_);
1213
0
    }
1214
0
  } catch (...) {
1215
0
  }
1216
0
  return EXV_PRINT_COMBITAG_MULTI(pentaxLensType, 2, 1, 2)(os, value, metadata);
1217
0
}
1218
1219
// #1155
1220
//! resolveLens0x319 print lens in human format
1221
static std::ostream& resolveLens0x319(std::ostream& os, const Value& value, const ExifData* metadata)
1222
// ----------------------------------------------------------------------
1223
0
{
1224
0
  try {
1225
0
    unsigned long index = 0;
1226
1227
0
    const auto lensInfo = findLensInfo(metadata);
1228
0
    if (value.count() == 4) {
1229
0
      std::string model = getKeyString("Exif.Image.Model", metadata);
1230
0
      if (model.starts_with("PENTAX K-3") && lensInfo->count() == 128 && lensInfo->toUint32(1) == 131 &&
1231
0
          lensInfo->toUint32(2) == 128)
1232
0
        index = 6;
1233
0
    }
1234
0
    if (value.count() == 2) {
1235
0
      std::string model = getKeyString("Exif.Image.Model", metadata);
1236
0
      if (model.starts_with("PENTAX K100D") && lensInfo->count() == 44)
1237
0
        index = 6;
1238
0
      if (model.starts_with("PENTAX *ist DL") && lensInfo->count() == 36)
1239
0
        index = 6;
1240
0
    }
1241
1242
0
    if (index > 0) {
1243
0
      const unsigned long lensID = 0x319;
1244
0
      auto td = Exiv2::find(pentaxLensType, lensID);
1245
0
      return os << _(td[index].label_);
1246
0
    }
1247
0
  } catch (...) {
1248
0
  }
1249
0
  return EXV_PRINT_COMBITAG_MULTI(pentaxLensType, 2, 1, 2)(os, value, metadata);
1250
0
}
1251
1252
//! resolveLensType print lens in human format
1253
0
static std::ostream& resolveLensType(std::ostream& os, const Value& value, const ExifData* metadata) {
1254
0
  return EXV_PRINT_COMBITAG_MULTI(pentaxLensType, 2, 1, 2)(os, value, metadata);
1255
0
}
1256
1257
//! A lens id and a pretty-print function for special treatment of the id.
1258
0
static std::ostream& printLensType(std::ostream& os, const Value& value, const ExifData* metadata) {
1259
  //! List of lens ids which require special treatment using resolveLensType
1260
0
  static constexpr struct LensIdFct {
1261
0
    uint32_t id_;   //!< Lens id
1262
0
    PrintFct fct_;  //!< Pretty-print function
1263
    //! Comparison operator for find template
1264
0
    bool operator==(uint32_t id) const {
1265
0
      return id_ == id;
1266
0
    }
1267
0
  } lensIdFct[] = {
1268
0
      {0x0317, resolveLensType}, {0x0319, resolveLens0x319}, {0x031b, resolveLensType},  {0x031c, resolveLensType},
1269
0
      {0x031d, resolveLensType}, {0x031f, resolveLensType},  {0x0329, resolveLensType},  {0x032c, resolveLens0x32c},
1270
0
      {0x032e, resolveLensType}, {0x0334, resolveLensType},  {0x03ff, resolveLens0x3ff}, {0x041a, resolveLensType},
1271
0
      {0x042d, resolveLensType}, {0x08ff, resolveLens0x8ff},
1272
0
  };
1273
  // #1034
1274
0
  const std::string undefined("undefined");
1275
0
  const std::string section("pentax");
1276
0
  if (Internal::readExiv2Config(section, value.toString(), undefined) != undefined) {
1277
0
    return os << Internal::readExiv2Config(section, value.toString(), undefined);
1278
0
  }
1279
1280
0
  const auto index = (value.toUint32(0) * 256) + value.toUint32(1);
1281
1282
  // std::cout << '\n' << "printLensType value =" << value.toLong() << " index = " << index << '\n';
1283
0
  auto lif = Exiv2::find(lensIdFct, index);
1284
0
  if (!lif)
1285
0
    return EXV_PRINT_COMBITAG_MULTI(pentaxLensType, 2, 1, 2)(os, value, metadata);
1286
0
  if (metadata && lif->fct_)
1287
0
    return lif->fct_(os, value, metadata);
1288
0
  if (value.typeId() != unsignedShort || value.count() == 0)
1289
0
    return os << "(" << value << ")";
1290
0
  return os << value;
1291
0
}
1292
1293
// #816 end
1294
// ----------------------------------------------------------------------
1295
1296
// Pentax MakerNote Tag Info
1297
constexpr TagInfo PentaxMakerNote::tagInfo_[] = {
1298
    {0x0000, "Version", N_("Version"), N_("Pentax Makernote version"), IfdId::pentaxId, SectionId::makerTags, undefined,
1299
     -1, printVersion},
1300
    {0x0001, "Mode", N_("Shooting mode"), N_("Camera shooting mode"), IfdId::pentaxId, SectionId::makerTags,
1301
     unsignedShort, -1, EXV_PRINT_TAG(pentaxShootingMode)},
1302
    {0x0002, "PreviewResolution", N_("Resolution of a preview image"), N_("Resolution of a preview image"),
1303
     IfdId::pentaxId, SectionId::makerTags, undefined, -1, printResolution},
1304
    {0x0003, "PreviewLength", N_("Length of a preview image"), N_("Size of an IFD containing a preview image"),
1305
     IfdId::pentaxId, SectionId::makerTags, undefined, -1, printValue},
1306
    {0x0004, "PreviewOffset", N_("Pointer to a preview image"), N_("Offset to an IFD containing a preview image"),
1307
     IfdId::pentaxId, SectionId::makerTags, undefined, -1, printValue},
1308
    {0x0005, "ModelID", N_("Model identification"), N_("Pentax model identification"), IfdId::pentaxId,
1309
     SectionId::makerTags, unsignedShort, -1, EXV_PRINT_TAG(pentaxModel)},
1310
    {0x0006, "Date", N_("Date"), N_("Date"), IfdId::pentaxId, SectionId::makerTags, undefined, -1, printDate},
1311
    {0x0007, "Time", N_("Time"), N_("Time"), IfdId::pentaxId, SectionId::makerTags, undefined, -1, printTime},
1312
    {0x0008, "Quality", N_("Image quality"), N_("Image quality settings"), IfdId::pentaxId, SectionId::makerTags,
1313
     unsignedShort, -1, EXV_PRINT_TAG(pentaxQuality)},
1314
    {0x0009, "Size", N_("Image size"), N_("Image size settings"), IfdId::pentaxId, SectionId::makerTags, unsignedLong,
1315
     -1, EXV_PRINT_TAG(pentaxSize)},
1316
    /* Some missing ! */
1317
    {0x000c, "Flash", N_("Flash mode"), N_("Flash mode settings"), IfdId::pentaxId, SectionId::makerTags, unsignedLong,
1318
     -1, EXV_PRINT_TAG(pentaxFlash)},
1319
    {0x000d, "Focus", N_("Focus mode"), N_("Focus mode settings"), IfdId::pentaxId, SectionId::makerTags, unsignedLong,
1320
     -1, EXV_PRINT_TAG(pentaxFocus)},
1321
    {0x000e, "AFPoint", N_("AF point"), N_("Selected AF point"), IfdId::pentaxId, SectionId::makerTags, unsignedLong,
1322
     -1, EXV_PRINT_TAG(pentaxAFPoint)},
1323
    {0x000F, "AFPointInFocus", N_("AF point in focus"), N_("AF point in focus"), IfdId::pentaxId, SectionId::makerTags,
1324
     unsignedLong, -1, EXV_PRINT_TAG(pentaxAFPointFocus)},
1325
    /* Some missing ! */
1326
    {0x0012, "ExposureTime", N_("Exposure time"), N_("Exposure time"), IfdId::pentaxId, SectionId::makerTags,
1327
     unsignedLong, -1, printExposure},
1328
    {0x0013, "FNumber", N_("F-Number"), N_("F-Number"), IfdId::pentaxId, SectionId::makerTags, unsignedLong, -1,
1329
     printFValue},
1330
    {0x0014, "ISO", N_("ISO sensitivity"), N_("ISO sensitivity settings"), IfdId::pentaxId, SectionId::makerTags,
1331
     unsignedLong, -1, EXV_PRINT_TAG(pentaxISO)},
1332
    /* Some missing ! */
1333
    {0x0016, "ExposureCompensation", N_("Exposure compensation"), N_("Exposure compensation"), IfdId::pentaxId,
1334
     SectionId::makerTags, unsignedLong, -1, printCompensation},
1335
    /* Some missing ! */
1336
    {0x0017, "MeteringMode", N_("MeteringMode"), N_("MeteringMode"), IfdId::pentaxId, SectionId::makerTags, undefined,
1337
     -1, EXV_PRINT_TAG(pentaxMeteringMode)},
1338
    {0x0018, "AutoBracketing", N_("AutoBracketing"), N_("AutoBracketing"), IfdId::pentaxId, SectionId::makerTags,
1339
     undefined, -1, printBracketing},
1340
    {0x0019, "WhiteBalance", N_("White balance"), N_("White balance"), IfdId::pentaxId, SectionId::makerTags, undefined,
1341
     -1, EXV_PRINT_TAG(pentaxWhiteBalance)},
1342
    {0x001a, "WhiteBalanceMode", N_("White balance mode"), N_("White balance mode"), IfdId::pentaxId,
1343
     SectionId::makerTags, undefined, -1, EXV_PRINT_TAG(pentaxWhiteBalanceMode)},
1344
    {0x001b, "BlueBalance", N_("Blue balance"), N_("Blue color balance"), IfdId::pentaxId, SectionId::makerTags,
1345
     unsignedLong, -1, printValue},
1346
    {0x001c, "RedBalance", N_("Red balance"), N_("Red color balance"), IfdId::pentaxId, SectionId::makerTags,
1347
     unsignedLong, -1, printValue},
1348
    {0x001d, "FocalLength", N_("FocalLength"), N_("FocalLength"), IfdId::pentaxId, SectionId::makerTags, undefined, -1,
1349
     printFocalLength},
1350
    {0x001e, "DigitalZoom", N_("Digital zoom"), N_("Digital zoom"), IfdId::pentaxId, SectionId::makerTags, unsignedLong,
1351
     -1, printValue},
1352
    {0x001f, "Saturation", N_("Saturation"), N_("Saturation"), IfdId::pentaxId, SectionId::makerTags, undefined, -1,
1353
     EXV_PRINT_TAG(pentaxSaturation)},
1354
    {0x0020, "Contrast", N_("Contrast"), N_("Contrast"), IfdId::pentaxId, SectionId::makerTags, undefined, -1,
1355
     EXV_PRINT_TAG(pentaxContrast)},
1356
    {0x0021, "Sharpness", N_("Sharpness"), N_("Sharpness"), IfdId::pentaxId, SectionId::makerTags, undefined, -1,
1357
     EXV_PRINT_TAG(pentaxSharpness)},
1358
    {0x0022, "Location", N_("Location"), N_("Location"), IfdId::pentaxId, SectionId::makerTags, undefined, -1,
1359
     EXV_PRINT_TAG(pentaxLocation)},
1360
    {0x0023, "Hometown", N_("Hometown"), N_("Home town"), IfdId::pentaxId, SectionId::makerTags, undefined, -1,
1361
     EXV_PRINT_TAG(pentaxCities)},
1362
    {0x0024, "Destination", N_("Destination"), N_("Destination"), IfdId::pentaxId, SectionId::makerTags, undefined, -1,
1363
     EXV_PRINT_TAG(pentaxCities)},
1364
    {0x0025, "HometownDST", N_("Hometown DST"), N_("Whether day saving time is active in home town"), IfdId::pentaxId,
1365
     SectionId::makerTags, undefined, -1, EXV_PRINT_TAG(pentaxYesNo)},
1366
    {0x0026, "DestinationDST", N_("Destination DST"), N_("Whether day saving time is active in destination"),
1367
     IfdId::pentaxId, SectionId::makerTags, undefined, -1, EXV_PRINT_TAG(pentaxYesNo)},
1368
    {0x0027, "DSPFirmwareVersion", N_("DSPFirmwareVersion"), N_("DSPFirmwareVersion"), IfdId::pentaxId,
1369
     SectionId::makerTags, unsignedByte, -1, printValue}, /* TODO: Decoding missing */
1370
    {0x0028, "CPUFirmwareVersion", N_("CPUFirmwareVersion"), N_("CPUFirmwareVersion"), IfdId::pentaxId,
1371
     SectionId::makerTags, unsignedByte, -1, printValue}, /* TODO: Decoding missing */
1372
    {0x0029, "FrameNumber", N_("Frame number"), N_("Frame number"), IfdId::pentaxId, SectionId::makerTags, undefined,
1373
     -1, printValue},
1374
    /* Some missing ! */
1375
    {0x002d, "EffectiveLV", N_("Light value"), N_("Camera calculated light value, includes exposure compensation"),
1376
     IfdId::pentaxId, SectionId::makerTags, unsignedShort, -1, printValue},
1377
    /* Some missing ! */
1378
    {0x0032, "ImageProcessing", N_("Image processing"), N_("Image processing"), IfdId::pentaxId, SectionId::makerTags,
1379
     undefined, -1, EXV_PRINT_COMBITAG(pentaxImageProcessing, 4, 0)},
1380
    {0x0033, "PictureMode", N_("Picture mode"), N_("Picture mode"), IfdId::pentaxId, SectionId::makerTags, undefined,
1381
     -1, EXV_PRINT_COMBITAG(pentaxPictureMode, 3, 0)},
1382
    {0x0034, "DriveMode", N_("Drive mode"), N_("Drive mode"), IfdId::pentaxId, SectionId::makerTags, undefined, -1,
1383
     EXV_PRINT_COMBITAG(pentaxDriveMode, 4, 0)},
1384
    /* Some missing ! */
1385
    {0x0037, "ColorSpace", N_("Color space"), N_("Color space"), IfdId::pentaxId, SectionId::makerTags, unsignedShort,
1386
     -1, EXV_PRINT_TAG(pentaxColorSpace)},
1387
    {0x0038, "ImageAreaOffset", N_("Image area offset"), N_("Image area offset"), IfdId::pentaxId, SectionId::makerTags,
1388
     unsignedLong, -1, printValue},
1389
    {0x0039, "RawImageSize", N_("Raw image size"), N_("Raw image size"), IfdId::pentaxId, SectionId::makerTags,
1390
     unsignedLong, -1, printValue},
1391
    /* Some missing ! */
1392
    {0x003e, "PreviewImageBorders", N_("Preview image borders"), N_("Preview image borders"), IfdId::pentaxId,
1393
     SectionId::makerTags, unsignedByte, -1, printValue},
1394
    {0x003f, "LensType", N_("Lens type"), N_("Lens type"), IfdId::pentaxId, SectionId::makerTags, unsignedByte, -1,
1395
     printLensType},  // #816
1396
    {0x0040, "SensitivityAdjust", N_("Sensitivity adjust"), N_("Sensitivity adjust"), IfdId::pentaxId,
1397
     SectionId::makerTags, unsignedLong, -1, printValue},
1398
    {0x0041, "DigitalFilter", N_("Digital filter"), N_("Digital filter"), IfdId::pentaxId, SectionId::makerTags,
1399
     unsignedShort, -1, EXV_PRINT_TAG(pentaxOffOn)},
1400
    /* Some missing ! */
1401
    {0x0047, "Temperature", N_("Temperature"), N_("Camera temperature"), IfdId::pentaxId, SectionId::makerTags,
1402
     signedByte, -1, printTemperature},
1403
    {0x0048, "AELock", N_("AE lock"), N_("AE lock"), IfdId::pentaxId, SectionId::makerTags, unsignedShort, -1,
1404
     EXV_PRINT_TAG(pentaxOffOn)},
1405
    {0x0049, "NoiseReduction", N_("Noise reduction"), N_("Noise reduction"), IfdId::pentaxId, SectionId::makerTags,
1406
     unsignedShort, -1, EXV_PRINT_TAG(pentaxOffOn)},
1407
    /* Some missing ! */
1408
    {0x004d, "FlashExposureCompensation", N_("Flash exposure compensation"), N_("Flash exposure compensation"),
1409
     IfdId::pentaxId, SectionId::makerTags, signedLong, -1, printFlashCompensation},
1410
    /* Some missing ! */
1411
    {0x004f, "ImageTone", N_("Image tone"), N_("Image tone"), IfdId::pentaxId, SectionId::makerTags, unsignedShort, -1,
1412
     EXV_PRINT_TAG(pentaxImageTone)},
1413
    {0x0050, "ColorTemperature", N_("Color temperature"), N_("Color temperature"), IfdId::pentaxId,
1414
     SectionId::makerTags, unsignedShort, -1, printValue},
1415
    /* Some missing ! */
1416
    {0x005c, "ShakeReduction", N_("Shake reduction"), N_("Shake reduction information"), IfdId::pentaxId,
1417
     SectionId::makerTags, undefined, -1, printValue},
1418
    {0x005d, "ShutterCount", N_("Shutter count"), N_("Shutter count"), IfdId::pentaxId, SectionId::makerTags, undefined,
1419
     -1, printShutterCount},
1420
    {0x0069, "DynamicRangeExpansion", N_("Dynamic range expansion"), N_("Dynamic range expansion"), IfdId::pentaxId,
1421
     SectionId::makerTags, undefined, -1, EXV_PRINT_COMBITAG(pentaxDynamicRangeExpansion, 4, 0)},
1422
    {0x0071, "HighISONoiseReduction", N_("High ISO noise reduction"), N_("High ISO noise reduction"), IfdId::pentaxId,
1423
     SectionId::makerTags, unsignedByte, -1, EXV_PRINT_TAG(pentaxHighISONoiseReduction)},
1424
    {0x0072, "AFAdjustment", N_("AF Adjustment"), N_("AF Adjustment"), IfdId::pentaxId, SectionId::makerTags, undefined,
1425
     -1, printValue},
1426
    /* Many missing ! */
1427
    {0x0200, "BlackPoint", N_("Black point"), N_("Black point"), IfdId::pentaxId, SectionId::makerTags, undefined, -1,
1428
     printValue},
1429
    {0x0201, "WhitePoint", N_("White point"), N_("White point"), IfdId::pentaxId, SectionId::makerTags, undefined, -1,
1430
     printValue},
1431
    /* Some missing ! */
1432
    {0x0205, "ShotInfo", N_("ShotInfo"), N_("ShotInfo"), IfdId::pentaxId, SectionId::makerTags, undefined, -1,
1433
     printValue}, /* TODO: Decoding missing */
1434
    {0x0206, "AEInfo", N_("AEInfo"), N_("AEInfo"), IfdId::pentaxId, SectionId::makerTags, undefined, -1,
1435
     printValue}, /* TODO: Decoding missing */
1436
    {0x0207, "LensInfo", N_("LensInfo"), N_("LensInfo"), IfdId::pentaxId, SectionId::makerTags, undefined, -1,
1437
     printValue}, /* TODO: Decoding missing */
1438
    {0x0208, "FlashInfo", N_("FlashInfo"), N_("FlashInfo"), IfdId::pentaxId, SectionId::makerTags, undefined, -1,
1439
     printValue}, /* TODO: Decoding missing */
1440
    {0x0209, "AEMeteringSegments", N_("AEMeteringSegments"), N_("AEMeteringSegments"), IfdId::pentaxId,
1441
     SectionId::makerTags, undefined, -1, printValue}, /* TODO: Decoding missing */
1442
    {0x020a, "FlashADump", N_("FlashADump"), N_("FlashADump"), IfdId::pentaxId, SectionId::makerTags, undefined, -1,
1443
     printValue}, /* TODO: Decoding missing */
1444
    {0x020b, "FlashBDump", N_("FlashBDump"), N_("FlashBDump"), IfdId::pentaxId, SectionId::makerTags, undefined, -1,
1445
     printValue}, /* TODO: Decoding missing */
1446
    /* Some missing ! */
1447
    {0x020d, "WB_RGGBLevelsDaylight", N_("WB_RGGBLevelsDaylight"), N_("WB_RGGBLevelsDaylight"), IfdId::pentaxId,
1448
     SectionId::makerTags, undefined, -1, printValue}, /* TODO: Decoding missing */
1449
    {0x020e, "WB_RGGBLevelsShade", N_("WB_RGGBLevelsShade"), N_("WB_RGGBLevelsShade"), IfdId::pentaxId,
1450
     SectionId::makerTags, undefined, -1, printValue}, /* TODO: Decoding missing */
1451
    {0x020f, "WB_RGGBLevelsCloudy", N_("WB_RGGBLevelsCloudy"), N_("WB_RGGBLevelsCloudy"), IfdId::pentaxId,
1452
     SectionId::makerTags, undefined, -1, printValue}, /* TODO: Decoding missing */
1453
    {0x0210, "WB_RGGBLevelsTungsten", N_("WB_RGGBLevelsTungsten"), N_("WB_RGGBLevelsTungsten"), IfdId::pentaxId,
1454
     SectionId::makerTags, undefined, -1, printValue}, /* TODO: Decoding missing */
1455
    {0x0211, "WB_RGGBLevelsFluorescentD", N_("WB_RGGBLevelsFluorescentD"), N_("WB_RGGBLevelsFluorescentD"),
1456
     IfdId::pentaxId, SectionId::makerTags, undefined, -1, printValue}, /* TODO: Decoding missing */
1457
    {0x0212, "WB_RGGBLevelsFluorescentN", N_("WB_RGGBLevelsFluorescentN"), N_("WB_RGGBLevelsFluorescentN"),
1458
     IfdId::pentaxId, SectionId::makerTags, undefined, -1, printValue}, /* TODO: Decoding missing */
1459
    {0x0213, "WB_RGGBLevelsFluorescentW", N_("WB_RGGBLevelsFluorescentW"), N_("WB_RGGBLevelsFluorescentW"),
1460
     IfdId::pentaxId, SectionId::makerTags, undefined, -1, printValue}, /* TODO: Decoding missing */
1461
    {0x0214, "WB_RGGBLevelsFlash", N_("WB_RGGBLevelsFlash"), N_("WB_RGGBLevelsFlash"), IfdId::pentaxId,
1462
     SectionId::makerTags, undefined, -1, printValue}, /* TODO: Decoding missing */
1463
    {0x0215, "CameraInfo", N_("CameraInfo"), N_("CameraInfo"), IfdId::pentaxId, SectionId::makerTags, undefined, -1,
1464
     printValue}, /* TODO: Decoding missing */
1465
    {0x0216, "BatteryInfo", N_("BatteryInfo"), N_("BatteryInfo"), IfdId::pentaxId, SectionId::makerTags, undefined, -1,
1466
     printValue}, /* TODO: Decoding missing */
1467
    {0x021f, "AFInfo", N_("AFInfo"), N_("AFInfo"), IfdId::pentaxId, SectionId::makerTags, undefined, -1,
1468
     printValue}, /* TODO: Decoding missing */
1469
    {0x0222, "ColorInfo", N_("ColorInfo"), N_("ColorInfo"), IfdId::pentaxId, SectionId::makerTags, undefined, -1,
1470
     printValue}, /* TODO: Decoding missing */
1471
    {0x0229, "SerialNumber", N_("Serial Number"), N_("Serial Number"), IfdId::pentaxId, SectionId::makerTags,
1472
     asciiString, -1, printValue},
1473
    // End of list marker
1474
    {0xffff, "(UnknownPentaxMakerNoteTag)", "(UnknownPentaxMakerNoteTag)", N_("Unknown PentaxMakerNote tag"),
1475
     IfdId::pentaxId, SectionId::makerTags, asciiString, -1, printValue},
1476
};
1477
1478
}  // namespace Exiv2::Internal