Coverage Report

Created: 2026-08-25 06:40

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/exiv2/src/sonymn_int.cpp
Line
Count
Source
1
// SPDX-License-Identifier: GPL-2.0-or-later
2
3
// included header files
4
#include "sonymn_int.hpp"
5
6
#include "error.hpp"
7
#include "exif.hpp"
8
#include "i18n.h"  // NLS support.
9
#include "image_int.hpp"
10
#include "minoltamn_int.hpp"
11
#include "tags.hpp"
12
#include "tags_int.hpp"
13
#include "tiffcomposite_int.hpp"
14
#include "utils.hpp"
15
#include "value.hpp"
16
17
#include <array>
18
#include <cmath>
19
#include <iomanip>
20
21
// *****************************************************************************
22
// class member definitions
23
namespace Exiv2::Internal {
24
// -- Standard Sony Makernotes tags ---------------------------------------------------------------
25
26
//! Lookup table to translate Sony image quality values to readable labels
27
constexpr TagDetails sonyImageQuality[] = {
28
    {0, N_("RAW")},
29
    {1, N_("Super Fine")},
30
    {2, N_("Fine")},
31
    {3, N_("Standard")},
32
    {4, N_("Economy")},
33
    {5, N_("Extra Fine")},
34
    {6, N_("RAW + JPEG/HEIF")},
35
    {7, N_("Compressed RAW")},
36
    {8, N_("Compressed RAW + JPEG")},
37
    {9, N_("Light")},
38
    {0xffffffff, N_("n/a")},
39
};
40
41
//! Lookup table to translate Sony white balance (main group) values to readable labels
42
constexpr TagDetails sonyWhiteBalanceStd[] = {
43
    {0x00, N_("Auto")},     {0x01, N_("Color Temperature/Color Filter")},
44
    {0x10, N_("Daylight")}, {0x20, N_("Cloudy")},
45
    {0x30, N_("Shade")},    {0x40, N_("Tungsten")},
46
    {0x50, N_("Flash")},    {0x60, N_("Fluorescent")},
47
    {0x70, N_("Custom")},   {0x80, N_("Underwater")},
48
};
49
50
//! Lookup table to translate Sony auto HDR (part 1) values to readable labels
51
constexpr TagDetails sonyHDRStdPart1[] = {
52
    {0x00, N_("Off")}, {0x01, N_("Auto")}, {0x10, "1.0 EV"}, {0x11, "1.5 EV"}, {0x12, "2.0 EV"},
53
    {0x13, "2.5 EV"},  {0x14, "3.0 EV"},   {0x15, "3.5 EV"}, {0x16, "4.0 EV"}, {0x17, "4.5 EV"},
54
    {0x18, "5.0 EV"},  {0x19, "5.5 EV"},   {0x1a, "6.0 EV"},
55
};
56
57
//! Lookup table to translate Sony auto HDR (part 2) values to readable labels
58
constexpr TagDetails sonyHDRStdPart2[] = {
59
    {0, N_("Uncorrected image")},
60
    {1, N_("HDR image (good)")},
61
    {2, N_("HDR (fail 1)")},
62
    {3, N_("HDR (fail 2)")},
63
};
64
65
//! Lookup table to translate Sony off/on/(n/a) (1) values to readable labels
66
constexpr TagDetails sonyOffOnNA1[] = {
67
    {0, N_("Off")},
68
    {1, N_("On")},
69
    {256, N_("n/a")},
70
};
71
72
//! Lookup table to translate Sony off/on/(n/a) (2) values to readable labels
73
constexpr TagDetails sonyOffOnNA2[] = {
74
    {0, N_("Off")},
75
    {1, N_("On")},
76
    {0xffffffff, N_("n/a")},
77
};
78
79
//! Lookup table to translate Sony no/yes values to readable labels
80
constexpr TagDetails sonyNoYes[] = {
81
    {0, N_("No")},
82
    {1, N_("Yes")},
83
};
84
85
//! Lookup table to translate Sony picture effect values to readable labels
86
constexpr TagDetails sonyPictureEffect[] = {
87
    {0, N_("Off")},
88
    {1, N_("Toy Camera")},
89
    {2, N_("Pop Color")},
90
    {3, N_("Posterization")},
91
    {4, N_("Posterization B/W")},
92
    {5, N_("Retro Photo")},
93
    {6, N_("Soft High Key")},
94
    {7, N_("Partial Color (red)")},
95
    {8, N_("Partial Color (green)")},
96
    {9, N_("Partial Color (blue)")},
97
    {10, N_("Partial Color (yellow)")},
98
    {13, N_("High Contrast Monochrome")},
99
    {16, N_("Toy Camera (normal)")},
100
    {17, N_("Toy Camera (cool)")},
101
    {18, N_("Toy Camera (warm)")},
102
    {19, N_("Toy Camera (green)")},
103
    {20, N_("Toy Camera (magenta)")},
104
    {32, N_("Soft Focus (low)")},
105
    {33, N_("Soft Focus")},
106
    {34, N_("Soft Focus (high)")},
107
    {48, N_("Miniature (auto)")},
108
    {49, N_("Miniature (top)")},
109
    {50, N_("Miniature (middle horizontal)")},
110
    {51, N_("Miniature (bottom)")},
111
    {52, N_("Miniature (left)")},
112
    {53, N_("Miniature (middle vertical)")},
113
    {54, N_("Miniature (right)")},
114
    {64, N_("HDR Painting (low)")},
115
    {65, N_("HDR Painting")},
116
    {66, N_("HDR Painting (high)")},
117
    {80, N_("Rich-tone Monochrome")},
118
    {97, N_("Watercolor")},
119
    {98, N_("Watercolor 2")},
120
    {112, N_("Illustration (low)")},
121
    {113, N_("Illustration")},
122
    {114, N_("Illustration (high)")},
123
};
124
125
//! Lookup table to translate Sony soft skin effect values to readable labels
126
constexpr TagDetails sonySoftSkinEffect[] = {
127
    {0, N_("Off")}, {1, N_("Low")}, {2, N_("Mid")}, {3, N_("High")}, {0xffffffff, N_("n/a")},
128
};
129
130
//! Lookup table to translate Sony vignetting correction values to readable labels
131
constexpr TagDetails sonyVignettingCorrection[] = {
132
    {0, N_("Off")},
133
    {2, N_("Auto")},
134
    {0xffffffff, N_("n/a")},
135
};
136
137
//! Lookup table to translate Sony lateral chromatic aberration values to readable labels
138
constexpr TagDetails sonyLateralChromaticAberration[] = {
139
    {0, N_("Off")},
140
    {2, N_("Auto")},
141
    {0xffffffff, N_("n/a")},
142
};
143
144
//! Lookup table to translate Sony distortion correction settings values to readable labels
145
constexpr TagDetails sonyDistortionCorrectionSettings[] = {
146
    {0, N_("Off")},
147
    {2, N_("Auto")},
148
    {0xffffffff, N_("n/a")},
149
};
150
151
//! Lookup table to translate Sony flash action values to readable labels
152
constexpr TagDetails sonyFlashAction[] = {
153
    {0, N_("Did not fire")},
154
    {1, N_("Flash fired")},
155
    {2, N_("External flash fired")},
156
    {3, N_("Wireless controlled flash fired")},
157
};
158
159
//! Lookup table to translate Sony auto focus point selected (set 1) values to readable labels
160
constexpr TagDetails sonyAFPointSelectedSet1[] = {
161
    {0, N_("Auto")},
162
    {1, N_("Center")},
163
    {2, N_("Top")},
164
    {3, N_("Upper-right")},
165
    {4, N_("Right")},
166
    {5, N_("Lower-right")},
167
    {6, N_("Bottom")},
168
    {7, N_("Lower-left")},
169
    {8, N_("Left")},
170
    {9, N_("Upper-left")},
171
    {10, N_("Far Right")},
172
    {11, N_("Far Left")},
173
    {12, N_("Upper-middle")},
174
    {13, N_("Near Right")},
175
    {14, N_("Lower-middle")},
176
    {15, N_("Near Left")},
177
    {16, N_("Upper Far Right")},
178
    {17, N_("Lower Far Right")},
179
    {18, N_("Lower Far Left")},
180
    {19, N_("Upper Far Left")},
181
};
182
183
//! Lookup table to translate Sony auto focus point selected (set 2) values to readable labels
184
constexpr TagDetails sonyAFPointSelectedSet2[] = {
185
    {0, N_("Auto")}, {1, "A6"},   {2, "A7"},   {3, "B2"},   {4, "B3"},
186
    {5, "B4"},       {6, "B5"},   {7, "B6"},   {8, "B7"},   {9, "B8"},
187
    {10, "B9"},      {11, "B10"}, {12, "C1"},  {13, "C2"},  {14, "C3"},
188
    {15, "C4"},      {16, "C5"},  {17, "C6"},  {18, "C7"},  {19, "C8"},
189
    {20, "C9"},      {21, "C10"}, {22, "C11"}, {23, "D1"},  {24, "D2"},
190
    {25, "D3"},      {26, "D4"},  {27, "D5"},  {28, "D6"},  {29, "D7"},
191
    {30, "D8"},      {31, "D9"},  {32, "D10"}, {33, "D11"}, {34, "E1"},
192
    {35, "E2"},      {36, "E3"},  {37, "E4"},  {38, "E5"},  {39, N_("E6 (Center)")},
193
    {40, "E7"},      {41, "E8"},  {42, "E9"},  {43, "E10"}, {44, "E11"},
194
    {45, "F1"},      {46, "F2"},  {47, "F3"},  {48, "F4"},  {49, "F5"},
195
    {50, "F6"},      {51, "F7"},  {52, "F8"},  {53, "F9"},  {54, "F10"},
196
    {55, "F11"},     {56, "G1"},  {57, "G2"},  {58, "G3"},  {59, "G4"},
197
    {60, "G5"},      {61, "G6"},  {62, "G7"},  {63, "G8"},  {64, "G9"},
198
    {65, "G10"},     {66, "G11"}, {67, "H2"},  {68, "H3"},  {69, "H4"},
199
    {70, "H5"},      {71, "H6"},  {72, "H7"},  {73, "H8"},  {74, "H9"},
200
    {75, "H10"},     {76, "I5"},  {77, "I6"},  {78, "I7"},  {128, N_("Auto")},
201
};
202
203
//! Lookup table to translate Sony auto focus point selected (set 3) values to readable labels
204
constexpr TagDetails sonyAFPointSelectedSet3[] = {
205
    {0, N_("Auto")},
206
    {93, "A5"},
207
    {94, "A6"},
208
    {95, "A7"},
209
    {106, "B2"},
210
    {107, "B3"},
211
    {108, "B4"},
212
    {110, "B5"},
213
    {111, "B6"},
214
    {112, "B7"},
215
    {114, "B8"},
216
    {115, "B9"},
217
    {116, "B10"},
218
    {122, "C1"},
219
    {123, "C2"},
220
    {124, "C3"},
221
    {215, "C4"},
222
    {127, "C5"},
223
    {128, "C6"},
224
    {129, "C7"},
225
    {131, "C8"},
226
    {132, "C9"},
227
    {133, "C10"},
228
    {134, "C11"},
229
    {139, "D1"},
230
    {140, "D2"},
231
    {141, "D3"},
232
    {142, "D4"},
233
    {144, "D5"},
234
    {145, "D6"},
235
    {146, "D7"},
236
    {148, "D8"},
237
    {149, "D9"},
238
    {150, "D10"},
239
    {151, "D11"},
240
    {156, "E1"},
241
    {157, "E2"},
242
    {158, "E3"},
243
    {159, "E4"},
244
    {161, "E5"},
245
    {162, N_("E6 (Center")},
246
    {163, "E7"},
247
    {165, "E8"},
248
    {166, "E9"},
249
    {167, "E10"},
250
    {168, "E11"},
251
    {173, "F1"},
252
    {174, "F2"},
253
    {175, "F3"},
254
    {176, "F4"},
255
    {178, "F5"},
256
    {179, "F6"},
257
    {180, "F7"},
258
    {182, "F8"},
259
    {183, "F9"},
260
    {184, "F10"},
261
    {185, "F11"},
262
    {190, "G1"},
263
    {191, "G2"},
264
    {192, "G3"},
265
    {193, "G4"},
266
    {195, "G5"},
267
    {196, "G6"},
268
    {197, "G7"},
269
    {199, "G8"},
270
    {200, "G9"},
271
    {201, "G10"},
272
    {202, "G11"},
273
    {208, "H2"},
274
    {209, "H3"},
275
    {210, "H4"},
276
    {212, "H5"},
277
    {213, "H6"},
278
    {214, "H7"},
279
    {216, "H8"},
280
    {217, "H9"},
281
    {218, "H10"},
282
    {229, "I5"},
283
    {230, "I6"},
284
    {231, "I7"},
285
};
286
287
//! Lookup table to translate Sony auto focus point selected (set 4) values to readable labels
288
constexpr TagDetails sonyAFPointSelectedSet4[] = {
289
    {0, N_("n/a")},         {1, N_("Top Left Zone")},     {2, N_("Top Zone")},   {3, N_("Top Right Zone")},
290
    {4, N_("Left Zone")},   {5, N_("Center Zone")},       {6, N_("Right Zone")}, {7, N_("Bottom Left Zone")},
291
    {8, N_("Bottom Zone")}, {9, N_("Bottom Right Zone")},
292
};
293
294
//! Lookup table to translate Sony auto focus point selected (set 5) values to readable labels
295
constexpr TagDetails sonyAFPointSelectedSet5[] = {
296
    {0, N_("n/a")},           {1, N_("Center Zone")},    {2, N_("Top Zone")},          {3, N_("Right Zone")},
297
    {4, N_("Left Zone")},     {5, N_("Bottom Zone")},    {6, N_("Bottom Right Zone")}, {7, N_("Bottom Left Zone")},
298
    {8, N_("Top Left Zone")}, {9, N_("Top Right Zone")},
299
};
300
301
//! Lookup table to translate Sony auto focus points used (set 1) values to readable labels
302
constexpr TagDetailsBitlistSorted sonyAFPointsUsedSet1[] = {
303
    {0, N_("Center")},           {1, N_("Top")},
304
    {2, N_("Upper-right")},      {3, N_("Right")},
305
    {4, N_("Lower-right")},      {5, N_("Bottom")},
306
    {6, N_("Lower-left")},       {7, N_("Left")},
307
    {8, N_("Upper-left")},       {9, N_("Far right")},
308
    {10, N_("Far left")},        {11, N_("Upper-middle")},
309
    {12, N_("Near right")},      {13, N_("Lower-middle")},
310
    {14, N_("Near left")},       {15, N_("Upper far right")},
311
    {16, N_("Lower far right")}, {17, N_("Lower far left")},
312
    {18, N_("Upper far left")},
313
};
314
315
//! Lookup table to translate Sony auto focus points used (set 2) values to readable labels
316
constexpr TagDetailsBitlistSorted sonyAFPointsUsedSet2[] = {
317
    {0, "A5"},   {1, "A6"},   {2, "A7"},   {3, "B2"},   {4, "B3"},   {5, "B4"},   {6, "B5"},   {7, "B6"},
318
    {8, "B7"},   {9, "B8"},   {10, "B9"},  {11, "B10"}, {12, "C1"},  {13, "C2"},  {14, "C3"},  {15, "C4"},
319
    {16, "C5"},  {17, "C6"},  {18, "C7"},  {19, "C8"},  {20, "C9"},  {21, "C10"}, {22, "C11"}, {23, "D1"},
320
    {24, "D2"},  {25, "D3"},  {26, "D4"},  {27, "D5"},  {28, "D6"},  {29, "D7"},  {30, "D8"},  {31, "D9"},
321
    {32, "D10"}, {33, "D11"}, {34, "E1"},  {35, "E2"},  {36, "E3"},  {37, "E4"},  {38, "E5"},  {39, N_("E6")},
322
    {40, "E7"},  {41, "E8"},  {42, "E9"},  {43, "E10"}, {44, "E11"}, {45, "F1"},  {46, "F2"},  {47, "F3"},
323
    {48, "F4"},  {49, "F5"},  {50, "F6"},  {51, "F7"},  {52, "F8"},  {53, "F9"},  {54, "F10"}, {55, "F11"},
324
    {56, "G1"},  {57, "G2"},  {58, "G3"},  {59, "G4"},  {60, "G5"},  {61, "G6"},  {62, "G7"},  {63, "G8"},
325
    {64, "G9"},  {65, "G10"}, {66, "G11"}, {67, "H2"},  {68, "H3"},  {69, "H4"},  {70, "H5"},  {71, "H6"},
326
    {72, "H7"},  {73, "H8"},  {74, "H9"},  {75, "H10"}, {76, "I5"},  {77, "I6"},  {78, "I7"},  {128, N_("Auto")},
327
};
328
329
//! Lookup table to translate Sony focus mode 2 values to readable labels
330
constexpr TagDetails sonyFocusMode2[] = {
331
    {0, N_("Manual")}, {2, N_("AF-S")}, {3, N_("AF-C")}, {4, N_("AF-A")}, {6, N_("DMF")}, {7, N_("AF-D")},
332
};
333
334
//! Lookup table to translate Sony auto focus area mode setting (set 1) values to readable labels
335
constexpr TagDetails sonyAFAreaModeSettingSet1[] = {
336
    {0, N_("Wide")},
337
    {4, N_("Local")},
338
    {8, N_("Zone")},
339
    {9, N_("Spot")},
340
};
341
342
//! Lookup table to translate Sony auto focus area mode setting (set 2) values to readable labels
343
constexpr TagDetails sonyAFAreaModeSettingSet2[] = {
344
    {0, N_("Wide")},
345
    {1, N_("Center")},
346
    {3, N_("Flexible Spot")},
347
    {4, N_("Flexible Spot (LA-EA4)")},
348
    {9, N_("Center (LA-EA4)")},
349
    {11, N_("Zone")},
350
    {12, N_("Expanded flexible spot")},
351
};
352
353
//! Lookup table to translate Sony auto focus area mode setting (set 3) values to readable labels
354
constexpr TagDetails sonyAFAreaModeSettingSet3[] = {
355
    {0, N_("Wide")}, {4, N_("Flexible spot")}, {8, N_("Zone")}, {9, N_("Center")}, {12, N_("Expanded flexible spot")},
356
};
357
358
//! Lookup table to translate Sony auto focus tracking values to readable labels
359
constexpr TagDetails sonyAFTracking[] = {
360
    {0, N_("Off")},
361
    {1, N_("Face tracking")},
362
    {2, N_("Lock on AF")},
363
};
364
365
//! Lookup table to translate Sony multi-frame noise reduction effect values to readable labels
366
constexpr TagDetails sonyMultiFrameNREffect[] = {
367
    {0, N_("Normal")},
368
    {1, N_("High")},
369
};
370
371
//! Lookup table to translate Sony variable low pass filter values to readable labels
372
constexpr StringTagDetails sonyVariableLowPassFilter[] = {
373
    {"0 0", N_("n/a")}, {"1 0", N_("Off")}, {"1 1", N_("Standard")}, {"1 2", N_("High")}, {"65535 65535", N_("n/a")},
374
};
375
376
//! Lookup table to translate Sony RAW file type values to readable labels
377
constexpr TagDetails sonyRAWFileType[] = {
378
    {0, N_("Compressed RAW")},   {1, N_("Uncompressed RAW")}, {2, N_("Lossless Compressed RAW")},
379
    {3, N_("Compressed RAW 2")}, {0xffff, N_("n/a")},
380
};
381
382
//! Lookup table to translate Sony metering mode 2 values to readable labels
383
constexpr TagDetails sonyMeteringMode2[] = {
384
    {0x100, N_("Multi-segment")},   {0x200, N_("Center-weighted average")},
385
    {0x301, N_("Spot (Standard)")}, {0x302, N_("Spot (Large)")},
386
    {0x400, N_("Average")},         {0x500, N_("Highlight")},
387
};
388
389
//! Lookup table to translate Sony priority set in automatic white balance values to readable labels
390
constexpr TagDetails sonyPrioritySetInAWB[] = {
391
    {0, N_("Standard")},
392
    {1, N_("Ambience")},
393
    {2, N_("White")},
394
};
395
396
//! Lookup table to translate Sony quality 2 (main group) values to readable labels
397
constexpr StringTagDetails sonyQuality2Std[] = {
398
    {"0 0", N_("n/a")},
399
    {"0 1", N_("Standard")},
400
    {"0 2", N_("Fine")},
401
    {"0 3", N_("Extra fine")},
402
    {"0 4", N_("Light")},
403
    {"1 0", N_("RAW")},
404
    {"1 1", N_("RAW + standard")},
405
    {"1 2", N_("RAW + fine")},
406
    {"1 3", N_("RAW + extra fine")},
407
    {"1 4", N_("RAW + light")},
408
    {"2 0", N_("S-size RAW")},
409
    {"2 1", N_("S-size RAW + standard")},
410
    {"2 2", N_("S-size RAW + fine")},
411
    {"2 3", N_("S-size RAW + extra fine")},
412
    {"2 4", N_("S-size RAW + light")},
413
    {"3 0", N_("M-size RAW")},
414
    {"3 1", N_("M-size RAW + standard")},
415
    {"3 2", N_("M-size RAW + fine")},
416
    {"3 3", N_("M-size RAW + extra fine")},
417
    {"3 4", N_("M-size RAW + light")},
418
    {"4 0", N_("Compressed RAW")},
419
    {"4 1", N_("Compressed RAW + standard")},
420
    {"4 2", N_("Compressed RAW + fine")},
421
    {"4 3", N_("Compressed RAW + extra fine")},
422
    {"4 4", N_("Compressed RAW + light")},
423
    {"5 0", N_("Compressed (HQ) RAW")},
424
    {"5 1", N_("Compressed (HQ) RAW + standard")},
425
    {"5 2", N_("Compressed (HQ) RAW + fine")},
426
    {"5 3", N_("Compressed (HQ) RAW + extra fine")},
427
    {"5 4", N_("Compressed (HQ) RAW + light")},
428
};
429
430
//! Lookup table to translate Sony JPEG/HEIF switch values to readable labels
431
constexpr TagDetails sonyJPEGHEIFSwitch[] = {
432
    {0, "JPEG"},
433
    {1, "HEIF"},
434
    {0xffff, N_("n/a")},
435
};
436
437
//! Lookup table to translate Sony model ID values to readable labels
438
//  FORMAT: Uses a space before alternative models and caveats
439
//  NOTE:   Keep the array format in sync with the getModel() function
440
constexpr TagDetails sonyModelId[] = {
441
    {0, N_("Multiple camera models")},
442
    {2, "DSC-R1"},
443
    {256, "DSLR-A100"},
444
    {257, "DSLR-A900"},
445
    {258, "DSLR-A700"},
446
    {259, "DSLR-A200"},
447
    {260, "DSLR-A350"},
448
    {261, "DSLR-A300"},
449
    {262, "DSLR-A900 (APS-C mode)"},
450
    {263, "DSLR-A380 / DSLR-A390"},
451
    {264, "DSLR-A330"},
452
    {265, "DSLR-A230"},
453
    {266, "DSLR-A290"},
454
    {269, "DSLR-A850"},
455
    {270, "DSLR-A850 (APS-C mode)"},
456
    {273, "DSLR-A550"},
457
    {274, "DSLR-A500"},
458
    {275, "DSLR-A450"},
459
    {278, "NEX-5"},
460
    {279, "NEX-3"},
461
    {280, "SLT-A33"},
462
    {281, "SLT-A55 / SLT-A55V"},
463
    {282, "DSLR-A560"},
464
    {283, "DSLR-A580"},
465
    {284, "NEX-C3"},
466
    {285, "SLT-A35"},
467
    {286, "SLT-A65 / SLT-A65V"},
468
    {287, "SLT-A77 / SLT-A77V"},
469
    {288, "NEX-5N"},
470
    {289, "NEX-7"},
471
    {290, "NEX-VG20E"},
472
    {291, "SLT-A37"},
473
    {292, "SLT-A57"},
474
    {293, "NEX-F3"},
475
    {294, "SLT-A99 / SLT-A99V"},
476
    {295, "NEX-6"},
477
    {296, "NEX-5R"},
478
    {297, "DSC-RX100"},
479
    {298, "DSC-RX1"},
480
    {299, "NEX-VG900"},
481
    {300, "NEX-VG30E"},
482
    {302, "ILCE-3000 / ILCE-3500"},
483
    {303, "SLT-A58"},
484
    {305, "NEX-3N"},
485
    {306, "ILCE-7"},
486
    {307, "NEX-5T"},
487
    {308, "DSC-RX100M2"},
488
    {309, "DSC-RX10"},
489
    {310, "DSC-RX1R"},
490
    {311, "ILCE-7R"},
491
    {312, "ILCE-6000"},
492
    {313, "ILCE-5000"},
493
    {317, "DSC-RX100M3"},
494
    {318, "ILCE-7S"},
495
    {319, "ILCA-77M2"},
496
    {339, "ILCE-5100"},
497
    {340, "ILCE-7M2"},
498
    {341, "DSC-RX100M4"},
499
    {342, "DSC-RX10M2"},
500
    {344, "DSC-RX1RM2"},
501
    {346, "ILCE-QX1"},
502
    {347, "ILCE-7RM2"},
503
    {350, "ILCE-7SM2"},
504
    {353, "ILCA-68"},
505
    {354, "ILCA-99M2"},
506
    {355, "DSC-RX10M3"},
507
    {356, "DSC-RX100M5"},
508
    {357, "ILCE-6300"},
509
    {358, "ILCE-9"},
510
    {360, "ILCE-6500"},
511
    {362, "ILCE-7RM3"},
512
    {363, "ILCE-7M3"},
513
    {364, "DSC-RX0"},
514
    {365, "DSC-RX10M4"},
515
    {366, "DSC-RX100M6"},
516
    {367, "DSC-HX99"},
517
    {369, "DSC-RX100M5A"},
518
    {371, "ILCE-6400"},
519
    {372, "DSC-RX0M2"},
520
    {373, "DSC-HX95"},
521
    {374, "DSC-RX100M7"},
522
    {375, "ILCE-7RM4"},
523
    {376, "ILCE-9M2"},
524
    {378, "ILCE-6600"},
525
    {379, "ILCE-6100"},
526
    {380, "ZV-1"},
527
    {381, "ILCE-7C"},
528
    {382, "ZV-E10"},
529
    {383, "ILCE-7SM3"},
530
    {384, "ILCE-1"},
531
    {385, "ILME-FX3"},
532
    {386, "ILCE-7RM3A"},
533
    {387, "ILCE-7RM4A"},
534
    {388, "ILCE-7M4"},
535
    {389, "ZV-1F"},
536
    {390, "ILCE-7RM5"},
537
    {391, "ILME-FX30"},
538
    {392, "ILCE-9M3"},
539
    {393, "ZV-E1"},
540
    {394, "ILCE-6700"},
541
    {395, "ZV-1M2"},
542
    {396, "ILCE-7CR"},
543
    {397, "ILCE-7CM2"},
544
    {398, "ILX-LR1"},
545
    {399, "ZV-E10M2"},
546
    {400, "ILCE-1M2"},
547
    {401, "DSC-RX1RM3"},
548
    {402, "ILCE-6400A"},
549
    {403, "ILCE-6100A"},
550
    {404, "DSC-RX100M7A"},
551
    {406, "ILME-FX2"},
552
    {407, "ILCE-7M5"},
553
    {408, "ZV-1A"},
554
    {410, "ILCE-7RM6"},
555
    {411, "DSC-RX10M5"},
556
};
557
558
//! Lookup table to translate Sony creative style (main group) values to readable labels
559
constexpr StringTagDetails sonyCreativeStyleStd[] = {
560
    {"AdobeRGB", N_("Adobe RGB")},
561
    {"Autumnleaves", N_("Autumn leaves")},
562
    {"BW", N_("Black and White")},
563
    {"Clear", N_("Clear")},
564
    {"Deep", N_("Deep")},
565
    {"FL", N_("FL")},
566
    {"IN", "IN"},
567
    {"Landscape", N_("Landscape")},
568
    {"Light", N_("Light")},
569
    {"Neutral", N_("Neutral")},
570
    {"None", N_("None")},
571
    {"Portrait", N_("Portrait")},
572
    {"Real", N_("Real")},
573
    {"SH", N_("SH")},
574
    {"Sepia", N_("Sepia")},
575
    {"Standard", N_("Standard")},
576
    {"Sunset", N_("Sunset")},
577
    {"Vivid", N_("Vivid")},
578
    {"VV2", N_("VV2")},
579
};
580
581
//! Lookup table to translate Sony file format values to readable labels
582
constexpr StringTagDetails sonyFileFormat[] = {
583
    {"0 0 0 2", "JPEG"},      {"1 0 0 0", "SR2 1.0"},   {"2 0 0 0", "ARW 1.0"},   {"3 0 0 0", "ARW 2.0"},
584
    {"3 1 0 0", "ARW 2.1"},   {"3 2 0 0", "ARW 2.2"},   {"3 3 0 0", "ARW 2.3"},   {"3 3 1 0", "ARW 2.3.1"},
585
    {"3 3 2 0", "ARW 2.3.2"}, {"3 3 3 0", "ARW 2.3.3"}, {"3 3 5 0", "ARW 2.3.5"}, {"4 0 0 0", "ARW 4.0"},
586
    {"4 0 1 0", "ARW 4.0.1"}, {"5 0 0 0", "ARW 5.0.0"}, {"5 0 1 0", "ARW 5.0.1"}, {"6 0 0 0", "ARW 6.0.0"},
587
};
588
589
//! Lookup table to translate Sony dynamic range optimizer values to readable labels
590
constexpr TagDetails print0xb025[] = {
591
    {0, N_("Off")},
592
    {1, N_("Standard")},
593
    {2, N_("Advanced Auto")},
594
    {3, N_("Auto")},
595
    {8, N_("Advanced Lv1")},
596
    {9, N_("Advanced Lv2")},
597
    {10, N_("Advanced Lv3")},
598
    {11, N_("Advanced Lv4")},
599
    {12, N_("Advanced Lv5")},
600
    {16, "Lv1"},
601
    {17, "Lv2"},
602
    {18, "Lv3"},
603
    {19, "Lv4"},
604
    {20, "Lv5"},
605
};
606
607
//! Lookup table to translate Sony color mode values to readable labels
608
constexpr TagDetails sonyColorMode[] = {
609
    {0, N_("Standard")},       {1, N_("Vivid")},        {2, N_("Portrait")},
610
    {3, N_("Landscape")},      {4, N_("Sunset")},       {5, N_("Night View/Portrait")},
611
    {6, N_("Black & White")},  {7, N_("Adobe RGB")},    {12, N_("Neutral")},
612
    {13, N_("Clear")},         {14, N_("Deep")},        {15, N_("Light")},
613
    {16, N_("Autumn leaves")}, {17, N_("Sepia")},       {18, N_("FL")},
614
    {19, N_("Vivid 2")},       {20, N_("IN")},          {21, N_("SH")},
615
    {100, N_("Neutral")},      {101, N_("Clear")},      {102, N_("Deep")},
616
    {103, N_("Light")},        {104, N_("Night view")}, {105, N_("Autumn leaves")},
617
    {255, N_("Off")},          {0xffffffff, N_("n/a")},
618
};
619
620
//! Lookup table to translate Sony exposure mode values to readable labels
621
constexpr TagDetails sonyExposureMode[] = {
622
    {0, N_("Program AE")},
623
    {1, N_("Portrait")},
624
    {2, N_("Beach")},
625
    {3, N_("Sports")},
626
    {4, N_("Snow")},
627
    {5, N_("Landscape")},
628
    {6, N_("Auto")},
629
    {7, N_("Aperture-priority AE")},
630
    {8, N_("Shutter speed priority AE")},
631
    {9, N_("Night Scene/Twilight")},
632
    {10, N_("Hi-Speed Shutter")},
633
    {11, N_("Twilight Portrait")},
634
    {12, N_("Soft Snap/Portrait")},
635
    {13, N_("Fireworks")},
636
    {14, N_("Smile Shutter")},
637
    {15, N_("Manual")},
638
    {18, N_("High Sensitivity")},
639
    {19, N_("Macro")},
640
    {20, N_("Advanced Sports Shooting")},
641
    {29, N_("Underwater")},
642
    {33, N_("Food")},
643
    {34, N_("Sweep Panorama")},
644
    {35, N_("Handheld Night Shot")},
645
    {36, N_("Anti Motion Blur")},
646
    {37, N_("Pet")},
647
    {38, N_("Backlight Correction HDR")},
648
    {39, N_("Superior Auto")},
649
    {40, N_("Background Defocus")},
650
    {41, N_("Soft Skin")},
651
    {42, N_("3D Image")},
652
    {0xffff, N_("n/a")},
653
};
654
655
//! Lookup table to translate Sony JPEG quality values to readable labels
656
constexpr TagDetails sonyJPEGQuality[] = {
657
    {0, N_("Standard")},
658
    {1, N_("Fine")},
659
    {2, N_("Extra Fine")},
660
    {0xffff, N_("n/a")},
661
};
662
663
//! Lookup table to translate Sony anti-blur values to readable labels
664
constexpr TagDetails sonyAntiBlur[] = {
665
    {0, N_("Off")},
666
    {1, N_("On (Continuous)")},
667
    {2, N_("On (Shooting)")},
668
    {0xffff, N_("n/a")},
669
};
670
671
//! Lookup table to translate Sony dynamic range optimizer 2 values to readable labels
672
constexpr TagDetails print0xb04f[] = {
673
    {0, N_("Off")},
674
    {1, N_("Standard")},
675
    {2, N_("Plus")},
676
};
677
678
//! Lookup table to translate Sony intelligent auto values to readable labels
679
constexpr TagDetails sonyIntelligentAuto[] = {
680
    {0, N_("Off")},
681
    {1, N_("On")},
682
    {2, N_("Advanced")},
683
};
684
685
//! Lookup table to translate Sony white balance 2 values to readable labels
686
constexpr TagDetails sonyWhiteBalance2[] = {
687
    {0, N_("Auto")},
688
    {4, N_("Manual")},
689
    {5, N_("Daylight")},
690
    {6, N_("Cloudy")},
691
    {7, N_("Cool White Fluorescent")},
692
    {8, N_("Day White Fluorescent")},
693
    {9, N_("Daylight Fluorescent")},
694
    {10, N_("Incandescent2")},
695
    {11, N_("Warm White Fluorescent")},
696
    {14, N_("Incandescent")},
697
    {15, N_("Flash")},
698
    {17, N_("Underwater 1 (Blue Water)")},
699
    {18, N_("Underwater 2 (Green Water)")},
700
    {19, N_("Underwater Auto")},
701
};
702
703
//! Lookup table to translate Sony focus mode values to readable labels
704
constexpr TagDetails sonyFocusMode[] = {
705
    {1, "AF-S"},
706
    {2, "AF-C"},
707
    {4, N_("Permanent-AF")},
708
    {0xffff, N_("n/a")},
709
};
710
711
//! Lookup table to translate Sony auto focus mode (set 1) values to readable labels
712
constexpr TagDetails sonyAFModeSet1[] = {
713
    {0, N_("Default")}, {1, N_("Multi")},     {2, N_("Center")},         {3, N_("Spot")},     {4, N_("Flexible Spot")},
714
    {6, N_("Touch")},   {14, N_("Tracking")}, {15, N_("Face Detected")}, {0xffff, N_("n/a")},
715
};
716
717
//! Lookup table to translate Sony auto focus mode (set 2) values to readable labels
718
constexpr TagDetails sonyAFModeSet2[] = {
719
    {0, N_("Multi")},
720
    {1, N_("Center")},
721
    {2, N_("Spot")},
722
    {3, N_("Flexible spot")},
723
    {10, N_("Selective (for miniature effect)")},
724
    {14, N_("Tracking")},
725
    {15, N_("Face tracking")},
726
    {255, N_("Manual")},
727
};
728
729
//! Lookup table to translate Sony auto focus illuminator values to readable labels
730
constexpr TagDetails sonyAFIlluminator[] = {
731
    {0, N_("Off")},
732
    {1, N_("Auto")},
733
    {0xffff, N_("n/a")},
734
};
735
736
//! Lookup table to translate Sony macro values to readable labels
737
constexpr TagDetails sonyMacro[] = {
738
    {0, N_("Off")},
739
    {1, N_("On")},
740
    {2, N_("Close Focus")},
741
    {0xffff, N_("n/a")},
742
};
743
744
//! Lookup table to translate Sony flash level values to readable labels
745
constexpr TagDetails sonyFlashLevel[] = {
746
    {-32768, N_("Low")}, {-9, "-3.0 EV"}, {-8, "-2.7 EV"},  {-7, "-2.3 EV"},     {-6, "-2.0 EV"},   {-5, "-1.7 EV"},
747
    {-4, "-1.3 EV"},     {-3, "-1.0 EV"}, {-2, "-0.7 EV"},  {-1, "-0.3 EV"},     {0, N_("Normal")}, {1, "+0.3 EV"},
748
    {2, "+0.7 EV"},      {3, "+1.0 EV"},  {4, "+1.3 EV"},   {5, "+1.7 EV"},      {6, "+2.0 EV"},    {7, "+2.3 EV"},
749
    {8, "+2.7 EV"},      {9, "+3.0 EV"},  {128, N_("n/a")}, {32767, N_("High")},
750
};
751
752
//! Lookup table to translate Sony release mode values to readable labels
753
constexpr TagDetails sonyReleaseMode[] = {
754
    {0, N_("Normal")},
755
    {2, N_("Continuous")},
756
    {5, N_("Exposure Bracketing")},
757
    {6, N_("White Balance Bracketing")},
758
    {8, N_("DRO Bracketing")},
759
    {0xffff, N_("n/a")},
760
};
761
762
//! Lookup table to translate Sony sequence number values to readable labels
763
constexpr TagDetails sonySequenceNumber[] = {
764
    {0, N_("Single")},
765
    {0xffff, N_("n/a")},
766
};
767
768
//! Lookup table to translate Sony focus mode 3 values to readable labels
769
constexpr TagDetails sonyFocusMode3[] = {
770
    {0, N_("Manual")}, {2, N_("AF-S")}, {3, N_("AF-C")}, {5, N_("Semi-manual")}, {6, N_("DMF")},
771
};
772
773
//! Lookup table to translate Sony high ISO noise reduction 2 values to readable labels
774
constexpr TagDetails sonyHighISONoiseReduction2[] = {
775
    {0, N_("Normal")}, {1, N_("High")}, {2, N_("Low")}, {3, N_("Off")}, {0xffff, N_("n/a")},
776
};
777
778
//! Lookup table to translate Sony release mode 2 values to readable labels
779
constexpr TagDetails sonyReleaseMode2[] = {
780
    {0, N_("Normal")},
781
    {1, N_("Continuous")},
782
    {2, N_("Continuous - Exposure Bracketing")},
783
    {3, N_("DRO or White Balance Bracketing")},
784
    {5, N_("Continuous - Burst")},
785
    {6, N_("Single Frame - Capture During Movie")},
786
    {7, N_("Continuous - Sweep Panorama")},
787
    {8, N_("Continuous - Anti-Motion Blur, Hand-held Twilight")},
788
    {9, N_("Continuous - HDR")},
789
    {10, N_("Continuous - Background defocus")},
790
    {13, N_("Continuous - 3D Sweep Panorama")},
791
    {15, N_("Continuous - High Resolution Sweep Panorama")},
792
    {16, N_("Continuous - 3D Image")},
793
    {17, N_("Continuous - Burst 2")},
794
    {18, N_("Normal - iAuto+")},
795
    {19, N_("Continuous - Speed/Advance Priority")},
796
    {20, N_("Continuous - Multi-Frame NR")},
797
    {23, N_("Single-frame - Exposure Bracketing")},
798
    {26, N_("Continuous Low")},
799
    {27, N_("Continuous - High Sensitivity")},
800
    {28, N_("Smile Shutter")},
801
    {29, N_("Continuous - Tele-zoom Advance Priority")},
802
    {146, N_("Single Frame - Movie Capture")},
803
};
804
805
//! Lookup table to translate Sony long exposure noise reduction values to readable labels
806
constexpr TagDetails sonyLongExposureNoiseReduction[] = {
807
    {0x00000000, N_("Off")},         {0x00000001, N_("On (unused)")}, {0x00010001, N_("On (dark subtracted)")},
808
    {0xffff0000, N_("Off (65535)")}, {0xffff0001, N_("On (65535)")},  {0xffffffff, N_("n/a")},
809
};
810
811
//! Lookup table to translate Sony high ISO Noise reduction values to readable labels
812
constexpr TagDetails sonyHighISONoiseReductionStd[] = {
813
    {0, N_("Off")}, {1, N_("Low")}, {2, N_("Normal")}, {3, N_("High")}, {256, N_("Auto")}, {0xffff, N_("n/a")},
814
};
815
816
0
static auto getModel(const ExifData* metadata, std::string& val) {
817
0
  auto pos = metadata->findKey(ExifKey("Exif.Image.Model"));
818
0
  if (pos != metadata->end() && pos->size() != 0 && pos->typeId() == asciiString) {
819
0
    val = pos->toString(0);
820
0
    return true;
821
0
  }
822
823
  // NOTE: As using the translated SonyModelID value, need to be synchronized with the array format
824
0
  pos = metadata->findKey(ExifKey("Exif.Sony1.SonyModelID"));
825
0
  if (pos != metadata->end() && pos->size() != 0 && pos->typeId() == unsignedShort) {
826
0
    if (auto temp = pos->print(metadata); !Internal::contains(temp, ' ')) {
827
0
      val = std::move(temp);
828
0
      return true;
829
0
    }
830
0
    val = "";
831
0
    return false;
832
0
  }
833
0
  pos = metadata->findKey(ExifKey("Exif.Sony2.SonyModelID"));
834
0
  if (pos != metadata->end() && pos->size() != 0 && pos->typeId() == unsignedShort) {
835
0
    if (auto temp = pos->print(metadata); !Internal::contains(temp, ' ')) {
836
0
      val = std::move(temp);
837
0
      return true;
838
0
    }
839
0
    val = "";
840
0
    return false;
841
0
  }
842
843
0
  val = "";
844
0
  return false;
845
0
}
846
847
0
static auto getAFAreaModeSetting(const ExifData* metadata, uint32_t& val) {
848
0
  auto pos = metadata->findKey(ExifKey("Exif.Sony1.AFAreaModeSetting"));
849
0
  if (pos != metadata->end() && pos->size() != 0 && pos->typeId() == unsignedByte) {
850
0
    std::ostringstream oss;
851
0
    pos->write(oss, metadata);
852
0
    if (oss.str() == _("n/a")) {
853
0
      val = 0;
854
0
      return false;
855
0
    }
856
857
0
    val = pos->toUint32(0);
858
0
    return true;
859
0
  }
860
0
  pos = metadata->findKey(ExifKey("Exif.Sony2.AFAreaModeSetting"));
861
0
  if (pos != metadata->end() && pos->size() != 0 && pos->typeId() == unsignedByte) {
862
0
    std::ostringstream oss;
863
0
    pos->write(oss, metadata);
864
0
    if (oss.str() == _("n/a")) {
865
0
      val = 0;
866
0
      return false;
867
0
    }
868
869
0
    val = pos->toUint32(0);
870
0
    return true;
871
0
  }
872
873
0
  val = 0;
874
0
  return false;
875
0
}
876
877
0
static auto getMetaVersion(const ExifData* metadata, std::string& val) {
878
0
  const auto pos = metadata->findKey(ExifKey("Exif.SonySInfo1.MetaVersion"));
879
880
0
  if (pos != metadata->end() && pos->typeId() == asciiString) {
881
0
    std::string temp = pos->toString();
882
0
    if (!temp.empty()) {
883
0
      val = std::move(temp);
884
0
      return true;
885
0
    }
886
0
  }
887
0
  val = "";
888
0
  return false;
889
0
}
890
891
0
static auto getFocusMode2(const ExifData* metadata, uint32_t& val) {
892
0
  auto pos = metadata->findKey(ExifKey("Exif.Sony1.FocusMode2"));
893
894
0
  if (pos != metadata->end() && pos->size() != 0 && pos->typeId() == unsignedByte) {
895
0
    std::ostringstream oss;
896
0
    pos->write(oss, metadata);
897
0
    if (oss.str() == _("n/a")) {
898
0
      val = 0;
899
0
      return false;
900
0
    }
901
902
0
    val = pos->toUint32(0);
903
0
    return true;
904
0
  }
905
0
  pos = metadata->findKey(ExifKey("Exif.Sony2.FocusMode2"));
906
0
  if (pos != metadata->end() && pos->size() != 0 && pos->typeId() == unsignedByte) {
907
0
    std::ostringstream oss;
908
0
    pos->write(oss, metadata);
909
0
    if (oss.str() == _("n/a")) {
910
0
      val = 0;
911
0
      return false;
912
0
    }
913
0
    val = pos->toUint32(0);
914
0
    return true;
915
0
  }
916
917
0
  val = 0;
918
0
  return false;
919
0
}
920
921
0
std::ostream& SonyMakerNote::printWhiteBalanceFineTune(std::ostream& os, const Value& value, const ExifData*) {
922
0
  if (value.count() != 1 || value.typeId() != unsignedLong)
923
0
    return os << "(" << value << ")";
924
925
  // Sony writes the tag as an unsignedLong but treat it as a signedLong. Source:
926
  // https://github.com/exiftool/exiftool/blob/1e17485cbb372a502e5b9d052d01303db735e6fa/lib/Image/ExifTool/Sony.pm#L681
927
0
  return os << static_cast<int32_t>(value.toUint32(0));
928
0
}
929
930
0
std::ostream& SonyMakerNote::printMultiBurstMode(std::ostream& os, const Value& value, const ExifData* metadata) {
931
0
  if (value.count() != 1 || value.typeId() != undefined)
932
0
    return os << "(" << value << ")";
933
934
  // Some cameras do not set the type to undefined. Source:
935
  // https://github.com/exiftool/exiftool/blob/1e17485cbb372a502e5b9d052d01303db735e6fa/lib/Image/ExifTool/Sony.pm#L763
936
937
0
  return printMinoltaSonyBoolValue(os, value, metadata);
938
0
}
939
940
0
std::ostream& SonyMakerNote::printMultiBurstSize(std::ostream& os, const Value& value, const ExifData*) {
941
0
  if (value.count() != 1 || value.typeId() != unsignedShort)
942
0
    return os << "(" << value << ")";
943
944
  // Some cameras do not set the type to unsignedShort. Source:
945
  // https://github.com/exiftool/exiftool/blob/1e17485cbb372a502e5b9d052d01303db735e6fa/lib/Image/ExifTool/Sony.pm#L771
946
947
0
  return os << value.toUint32(0);
948
0
}
949
950
0
std::ostream& SonyMakerNote::printAutoHDRStd(std::ostream& os, const Value& value, const ExifData* metadata) {
951
0
  if (value.count() != 1 || value.typeId() != unsignedLong)
952
0
    return os << "(" << value << ")";
953
954
  // Sony writes the tag as an unsignedLong but treat it as 2 unsignedShort values. Source:
955
  // https://github.com/exiftool/exiftool/blob/1e17485cbb372a502e5b9d052d01303db735e6fa/lib/Image/ExifTool/Sony.pm#L887
956
957
0
  const auto v0 = value.toUint32(0);
958
0
  EXV_PRINT_TAG(sonyHDRStdPart1)(os, (v0 & 0x00ff), metadata);
959
0
  os << ", ";
960
0
  EXV_PRINT_TAG(sonyHDRStdPart2)(os, (v0 >> 16), metadata);
961
962
0
  return os;
963
0
}
964
965
0
std::ostream& SonyMakerNote::printWBShiftABGM(std::ostream& os, const Value& value, const ExifData*) {
966
0
  if (value.count() != 2 || value.typeId() != signedLong)
967
0
    return os << "(" << value << ")";
968
969
  // Examples of Output:
970
  // 1. "A/B: 0, G/M: 0"
971
  // 2. "A/B: 1B, G/M: 2M"
972
973
0
  const auto v0 = value.toInt64(0);
974
0
  const auto v1 = value.toInt64(1);
975
976
0
  os << "A/B: ";
977
0
  if (v0 == 0) {
978
0
    os << 0;
979
0
  } else if (v0 < 0) {
980
0
    os << "A" << -v0;
981
0
  } else {
982
0
    os << "B" << v0;
983
0
  }
984
985
0
  os << ", G/M: ";
986
0
  if (v1 == 0)
987
0
    return os << 0;
988
989
0
  if (v1 < 0)
990
0
    return os << "G" << -v1;
991
992
0
  return os << "M" << v1;
993
0
}
994
995
0
std::ostream& SonyMakerNote::printFocusMode2(std::ostream& os, const Value& value, const ExifData* metadata) {
996
0
  if (value.count() != 1 || value.typeId() != unsignedByte || !metadata)
997
0
    return os << "(" << value << ")";
998
999
  // Tag only valid for certain camera models. See
1000
  // https://github.com/exiftool/exiftool/blob/1e17485cbb372a502e5b9d052d01303db735e6fa/lib/Image/ExifTool/Sony.pm#L1123
1001
0
  std::string model;
1002
0
  if (!getModel(metadata, model))
1003
0
    return os << "(" << value << ")";
1004
1005
0
  const auto v0 = value.toUint32(0);
1006
1007
0
  constexpr std::array models{"DSC-RX10M4", "DSC-RX100M6", "DSC-RX100M7", "DSC-RX100M5A", "DSC-HX99", "DSC-RX0M2"};
1008
0
  if (!model.starts_with("DSC-") ||
1009
0
      std::any_of(models.begin(), models.end(), [&model](auto m) { return model.starts_with(m); }))
1010
0
    return EXV_PRINT_TAG(sonyFocusMode2)(os, v0, metadata);
1011
1012
0
  return os << _("n/a");
1013
0
}
1014
1015
0
std::ostream& SonyMakerNote::printAFAreaModeSetting(std::ostream& os, const Value& value, const ExifData* metadata) {
1016
0
  if (value.count() != 1 || value.typeId() != unsignedByte || !metadata)
1017
0
    return os << "(" << value << ")";
1018
1019
  // Tag only valid for certain camera models. See
1020
  // https://github.com/exiftool/exiftool/blob/1e17485cbb372a502e5b9d052d01303db735e6fa/lib/Image/ExifTool/Sony.pm#L1139
1021
0
  std::string model;
1022
0
  if (!getModel(metadata, model))
1023
0
    return os << "(" << value << ")";
1024
1025
0
  const auto v0 = value.toUint32(0);
1026
1027
0
  for (auto m : {"SLT-", "HV"})
1028
0
    if (model.starts_with(m))
1029
0
      return EXV_PRINT_TAG(sonyAFAreaModeSettingSet1)(os, v0, metadata);
1030
1031
0
  constexpr std::array models2{
1032
0
      "NEX-", "ILCE-", "ILME-", "DSC-RX10M4", "DSC-RX100M6", "DSC-RX100M7", "DSC-RX100M5A", "DSC-HX99", "DSC-RX0M2",
1033
0
  };
1034
0
  if (std::any_of(models2.begin(), models2.end(), [&model](auto m) { return model.starts_with(m); }))
1035
0
    return EXV_PRINT_TAG(sonyAFAreaModeSettingSet2)(os, v0, metadata);
1036
1037
0
  if (model.starts_with("ILCA-"))
1038
0
    return EXV_PRINT_TAG(sonyAFAreaModeSettingSet3)(os, v0, metadata);
1039
1040
0
  return os << _("n/a");
1041
0
}
1042
1043
0
std::ostream& SonyMakerNote::printFlexibleSpotPosition(std::ostream& os, const Value& value, const ExifData* metadata) {
1044
0
  if (value.count() != 2 || value.typeId() != unsignedShort || !metadata)
1045
0
    return os << "(" << value << ")";
1046
1047
  // Tag only valid for certain camera models. See
1048
  // https://github.com/exiftool/exiftool/blob/1e17485cbb372a502e5b9d052d01303db735e6fa/lib/Image/ExifTool/Sony.pm#L1189
1049
0
  std::string model;
1050
0
  if (!getModel(metadata, model))
1051
0
    return os << "(" << value << ")";
1052
1053
0
  constexpr std::array models{
1054
0
      "NEX-", "ILCE-", "ILME-", "DSC-RX10M4", "DSC-RX100M6", "DSC-RX100M7", "DSC-RX100M5A", "DSC-HX99", "DSC-RX0M2",
1055
0
  };
1056
0
  if (std::any_of(models.begin(), models.end(), [&model](auto m) { return model.starts_with(m); }))
1057
0
    return os << value.toUint32(0) << ", " << value.toUint32(1);
1058
1059
0
  return os << _("n/a");
1060
0
}
1061
1062
0
std::ostream& SonyMakerNote::printAFPointSelected(std::ostream& os, const Value& value, const ExifData* metadata) {
1063
0
  if (value.count() != 1 || value.typeId() != unsignedByte || !metadata)
1064
0
    return os << "(" << value << ")";
1065
1066
  // Tag only valid for certain camera models. See
1067
  // https://github.com/exiftool/exiftool/blob/1e17485cbb372a502e5b9d052d01303db735e6fa/lib/Image/ExifTool/Sony.pm#L1203
1068
0
  std::string model;
1069
0
  if (!getModel(metadata, model))
1070
0
    return os << "(" << value << ")";
1071
1072
0
  uint32_t aFAreaModeSetting = 0;
1073
0
  const auto status = getAFAreaModeSetting(metadata, aFAreaModeSetting);
1074
1075
0
  for (auto m : {"SLT-", "HV-"})
1076
0
    if (model.starts_with(m))
1077
0
      return EXV_PRINT_TAG(sonyAFPointSelectedSet1)(os, value.toUint32(0), metadata);
1078
1079
0
  for (auto m : {"ILCE-", "ILME-"})
1080
0
    if (model.starts_with(m) && status && aFAreaModeSetting == 4)
1081
0
      return EXV_PRINT_TAG(sonyAFPointSelectedSet1)(os, value.toUint32(0), metadata);
1082
1083
0
  for (auto m : {"ILCA-68", "ILCA-77M2"})
1084
0
    if (model.starts_with(m) && status && aFAreaModeSetting != 8)
1085
0
      return EXV_PRINT_TAG(sonyAFPointSelectedSet2)(os, value, metadata);
1086
1087
0
  if (model.starts_with("ILCA-99M2") && status && aFAreaModeSetting != 8)
1088
0
    return EXV_PRINT_TAG(sonyAFPointSelectedSet3)(os, value, metadata);
1089
1090
0
  if (model.starts_with("ILCA-") && status && aFAreaModeSetting == 8)
1091
0
    return EXV_PRINT_TAG(sonyAFPointSelectedSet4)(os, value.toUint32(0), metadata);
1092
1093
0
  for (auto m : {"NEX-", "ILCE-", "ILME-"})
1094
0
    if (model.starts_with(m))
1095
0
      return EXV_PRINT_TAG(sonyAFPointSelectedSet5)(os, value.toUint32(0), metadata);
1096
1097
0
  return os << _("n/a");
1098
0
}
1099
1100
0
std::ostream& SonyMakerNote::printAFPointsUsed(std::ostream& os, const Value& value, const ExifData* metadata) {
1101
0
  if (value.typeId() != unsignedByte || !metadata)
1102
0
    return os << "(" << value << ")";
1103
1104
0
  std::string model;
1105
0
  if (!getModel(metadata, model))
1106
0
    return os << "(" << value << ")";
1107
1108
0
  constexpr std::array models1{"ILCA-", "DSC-"};
1109
0
  if (std::none_of(models1.begin(), models1.end(), [&model](auto m) { return model.starts_with(m); }))
1110
0
    return EXV_PRINT_TAG_BITLIST_ALL_LE(sonyAFPointsUsedSet1)(os, value, metadata);
1111
1112
0
  for (auto m : {"ILCA-68", "ILCA-77M2"})
1113
0
    if (model.starts_with(m))
1114
0
      return EXV_PRINT_TAG_BITLIST_ALL_LE(sonyAFPointsUsedSet2)(os, value, metadata);
1115
1116
0
  return os << _("n/a");
1117
0
}
1118
1119
0
std::ostream& SonyMakerNote::printAFTracking(std::ostream& os, const Value& value, const ExifData* metadata) {
1120
0
  if (value.count() != 1 || value.typeId() != unsignedByte || !metadata)
1121
0
    return os << "(" << value << ")";
1122
1123
  // Tag only valid for certain camera models. See
1124
  // https://github.com/exiftool/exiftool/blob/1e17485cbb372a502e5b9d052d01303db735e6fa/lib/Image/ExifTool/Sony.pm#L1353
1125
0
  std::string model;
1126
0
  if (!getModel(metadata, model))
1127
0
    return os << "(" << value << ")";
1128
1129
0
  constexpr std::array models{"DSC-RX10M4", "DSC-RX100M6", "DSC-RX100M7", "DSC-RX100M5A", "DSC-HX99", "DSC-RX0M2"};
1130
0
  if (!model.starts_with("DSC-") ||
1131
0
      std::any_of(models.begin(), models.end(), [&model](auto m) { return model.starts_with(m); }))
1132
0
    return EXV_PRINT_TAG(sonyAFTracking)(os, value.toUint32(0), metadata);
1133
1134
0
  return os << _("n/a");
1135
0
}
1136
1137
0
std::ostream& SonyMakerNote::printFocalPlaneAFPointsUsed(std::ostream& os, const Value& value, const ExifData*) {
1138
0
  if (value.typeId() != unsignedByte)
1139
0
    return os << "(" << value << ")";
1140
1141
0
  if (value.toUint32(0) == 0)
1142
0
    return os << _("None");
1143
1144
0
  return os << "(" << value << ")";
1145
0
}
1146
1147
0
std::ostream& SonyMakerNote::printWBShiftABGMPrecise(std::ostream& os, const Value& value, const ExifData*) {
1148
0
  if (value.count() != 2 || value.typeId() != signedLong)
1149
0
    return os << "(" << value << ")";
1150
1151
0
  std::ios::fmtflags f(os.flags());
1152
1153
0
  const auto temp0 = static_cast<double>(value.toInt64(0)) / 1000.0;
1154
0
  const auto temp1 = static_cast<double>(value.toInt64(1)) / 1000.0;
1155
1156
0
  os << "A/B: ";
1157
0
  if (temp0 == 0) {
1158
0
    os << 0;
1159
0
  } else if (temp0 < 0) {
1160
0
    os << "A" << std::fixed << std::setprecision(2) << -temp0;
1161
0
  } else {
1162
0
    os << "B" << std::fixed << std::setprecision(2) << temp0;
1163
0
  }
1164
0
  os << ", G/M: ";
1165
0
  if (temp1 == 0) {
1166
0
    os << 0;
1167
0
  } else if (temp1 < 0) {
1168
0
    os << "G" << std::fixed << std::setprecision(2) << -temp1;
1169
0
  } else {
1170
0
    os << "M" << std::fixed << std::setprecision(2) << temp1;
1171
0
  }
1172
1173
0
  os.flags(f);
1174
0
  return os;
1175
0
}
1176
1177
0
std::ostream& SonyMakerNote::printExposureStandardAdjustment(std::ostream& os, const Value& value, const ExifData*) {
1178
0
  if (value.count() != 1 || value.typeId() != signedRational) {
1179
0
    return os << "(" << value << ")";
1180
0
  }
1181
1182
0
  const auto [r, s] = value.toRational();
1183
0
  return os << stringFormat("{:.1f}", static_cast<double>(r) / static_cast<double>(s));
1184
0
}
1185
1186
0
std::ostream& SonyMakerNote::printPixelShiftInfo(std::ostream& os, const Value& value, const ExifData*) {
1187
0
  if (value.count() != 6 || value.typeId() != undefined)
1188
0
    return os << "(" << value << ")";
1189
1190
  // Tag format:
1191
  // https://github.com/exiftool/exiftool/blob/1e17485cbb372a502e5b9d052d01303db735e6fa/lib/Image/ExifTool/Sony.pm#L1504
1192
0
  if (value.toString() == "0 0 0 0 0 0")
1193
0
    return os << _("n/a");
1194
1195
  // Convert from little endian format
1196
0
  auto groupID = (value.toUint32(3) << 24) + (value.toUint32(2) << 16) + (value.toUint32(1) << 8) + value.toUint32(0);
1197
1198
0
  return os << stringFormat("Group {:02}{:02}{:02}{:02}, Shot {}/{} (0x{:x})", (groupID >> 17) & 0x1f,
1199
0
                            (groupID >> 12) & 0x1f, (groupID >> 6) & 0x3f, groupID & 0x3f, value.toUint32(4),
1200
0
                            value.toUint32(5), (groupID >> 22));
1201
0
}
1202
1203
0
std::ostream& SonyMakerNote::printFocusFrameSize(std::ostream& os, const Value& value, const ExifData*) {
1204
0
  if (value.count() != 6 || value.typeId() != undefined)
1205
0
    return os << "(" << value << ")";
1206
1207
  // Tag is written as undefined type but is used as unsignedShort. See
1208
  // https://github.com/exiftool/exiftool/blob/1e17485cbb372a502e5b9d052d01303db735e6fa/lib/Image/ExifTool/Sony.pm#L1578
1209
1210
0
  if (value.toUint32(4) == 0 && value.toUint32(5) == 0)
1211
0
    return os << _("n/a");
1212
1213
  // Convert from little endian format
1214
0
  return os << ((value.toUint32(1) << 8) + value.toUint32(0)) << "x" << ((value.toUint32(3) << 8) + value.toUint32(2));
1215
0
}
1216
1217
0
std::ostream& SonyMakerNote::printColorTemperature(std::ostream& os, const Value& value, const ExifData*) {
1218
0
  if (value.count() != 1 || value.typeId() != unsignedLong)
1219
0
    return os << "(" << value << ")";
1220
1221
0
  auto v0 = value.toUint32(0);
1222
0
  if (v0 == 0)
1223
0
    return os << _("Auto");
1224
1225
0
  if (v0 == 0xffffffff)
1226
0
    return os << _("n/a");
1227
1228
0
  return os << v0 << " K";
1229
0
}
1230
1231
0
std::ostream& SonyMakerNote::printColorCompensationFilter(std::ostream& os, const Value& value, const ExifData*) {
1232
0
  if (value.count() != 1 || value.typeId() != unsignedLong)
1233
0
    return os << "(" << value << ")";
1234
1235
  // Tag is written as an unsignedLong but used as a signedLong. See
1236
  // https://github.com/exiftool/exiftool/blob/1e17485cbb372a502e5b9d052d01303db735e6fa/lib/Image/ExifTool/Sony.pm#L2093
1237
1238
0
  int64_t temp = static_cast<int32_t>(value.toUint32(0));
1239
0
  os << "G/M: ";
1240
0
  if (temp == 0)
1241
0
    return os << "0";
1242
1243
0
  if (temp < 0)
1244
0
    return os << "G" << -temp;
1245
1246
0
  return os << "M" << temp;
1247
0
}
1248
1249
0
static void findLensSpecFlags(const Value& value, std::string& flagsStart, std::string& flagsEnd) {
1250
0
  static constexpr struct LensSpecFlags {
1251
0
    int64_t mask;  // Contains all the bits set in the flags.val_ array values
1252
0
    TagDetails flags[4];
1253
0
    bool prepend;
1254
0
  } lSFArray[] = {
1255
0
      {0x4000, {{0x4000, "PZ"}}, true},
1256
0
      {0x0300, {{0x0100, "DT"}, {0x0200, "FE"}, {0x0300, "E"}}, true},
1257
0
      {0x00e0, {{0x0020, "STF"}, {0x0040, N_("Reflex")}, {0x0060, N_("Macro")}, {0x0080, N_("Fisheye")}}, false},
1258
0
      {0x000c, {{0x0004, "ZA"}, {0x0008, "G"}}, false},
1259
0
      {0x0003, {{0x0001, "SSM"}, {0x0002, "SAM"}}, false},
1260
0
      {0x8000, {{0x8000, "OSS"}}, false},
1261
0
      {0x2000, {{0x2000, "LE"}}, false},
1262
0
      {0x0800, {{0x0800, "II"}}, false},
1263
0
  };
1264
1265
  // When processing, a bitwise 'AND' selects a compatible LensSpecFlags entry,
1266
  // then search inside the 'flags' array for one match.
1267
  //
1268
  // See
1269
  // https://github.com/exiftool/exiftool/blob/1e17485cbb372a502e5b9d052d01303db735e6fa/lib/Image/ExifTool/Sony.pm#L10545
1270
1271
0
  const auto joinedV0V7 = ((value.toUint32(0) << 8) + value.toUint32(7));
1272
0
  for (const auto& i : lSFArray) {
1273
0
    if (auto temp = i.mask & joinedV0V7) {  // Check if a flag matches in the current LensSpecFlags
1274
0
      if (auto f = Exiv2::find(i.flags, temp)) {
1275
0
        if (i.prepend)
1276
0
          flagsStart = flagsStart.empty() ? f->label_ : stringFormat("{} {}", f->label_, flagsStart);
1277
0
        else
1278
0
          flagsEnd = flagsEnd.empty() ? f->label_ : stringFormat("{} {}", flagsEnd, f->label_);
1279
0
        continue;
1280
0
      }
1281
      // Should never get in here. LensSpecFlags.mask should contain all the
1282
      // bits in all the LensSpecFlags.flags.val_ entries
1283
0
      throw Error(ErrorCode::kerErrorMessage, "LensSpecFlags mask doesn't match the bits in the flags array");
1284
0
    }
1285
0
  }
1286
0
}
1287
1288
0
std::ostream& SonyMakerNote::printLensSpec(std::ostream& os, const Value& value, const ExifData*) {
1289
0
  if (value.count() != 8 || value.typeId() != unsignedByte)
1290
0
    return os << "(" << value << ")";
1291
1292
  // Tag uses 8 bytes in the format:
1293
  // <Flgs 1> <Flgs 2> <Focal len min> <Focal len max 1> <Focal len max 2> <Aperture min> <Aperture max> <Flags
1294
  // 3>
1295
  //   (0)       (1)         (2)              (3)               (4)             (5)            (6)          (7)
1296
  //
1297
  // Bytes 2-6 are each interpreted as 2 nibbles which are used as decimal. Nibbles have a value less than 10.
1298
  // e.g., 36 == 0x24, converts to "2" and "4".
1299
  // Optional elements (==0) are <Flgs 1>, <Flgs 2>, <Focal len max 1>, <Focal len max 2>, <Aperture max> and
1300
  // <Flgs 3>
1301
  //
1302
  // Values for the tag are only set with compatible lenses, otherwise all 8 are set to 0.
1303
  //
1304
  // Examples of final output:
1305
  // 1. "FE 90mm F2.8 Macro G OSS"
1306
  // 2. "E PZ 16-50mm F3.5-5.6 OSS"
1307
  // 3. "DT 18-55mm F3.5-5.6 SAM"
1308
  // 4. "28-100mm F1.8-4.9"
1309
  // 5. "35mm F2.0"
1310
  //
1311
  // See:
1312
  // https://github.com/exiftool/exiftool/blob/1e17485cbb372a502e5b9d052d01303db735e6fa/lib/Image/ExifTool/Sony.pm#L2170
1313
1314
0
  const auto focalLenMin = value.toUint32(2);
1315
0
  const auto focalLenMax1 = value.toUint32(3);
1316
0
  const auto focalLenMax2 = value.toUint32(4);
1317
0
  const auto appertureMin = value.toUint32(5);
1318
0
  const auto apertureMax = value.toUint32(6);
1319
1320
0
  if (value.toString() == "0 0 0 0 0 0 0 0" || focalLenMin == 0 || appertureMin == 0)
1321
0
    return os << _("Unknown");
1322
1323
0
  std::string flagsStart;
1324
0
  std::string flagsEnd;
1325
0
  findLensSpecFlags(value, flagsStart, flagsEnd);
1326
1327
  // Output <Flgs 1>
1328
0
  if (!flagsStart.empty())
1329
0
    os << flagsStart << " ";
1330
1331
  // Output <Focal len min>
1332
0
  auto temp = ((focalLenMin >> 4) & 0x0f);
1333
0
  if (temp != 0)  // Remove leading zero
1334
0
    os << temp;
1335
1336
0
  os << (focalLenMin & 0x0f);
1337
1338
0
  if (focalLenMax1 != 0 || focalLenMax2 != 0) {
1339
0
    os << "-";
1340
0
  }
1341
1342
0
  if (focalLenMax1 != 0) {
1343
    // Output <Focal len max 1>
1344
0
    temp = ((focalLenMax1 >> 4) & 0x0f);
1345
0
    if (temp != 0)  // Remove leading zero
1346
0
      os << temp;
1347
0
    os << (focalLenMax1 & 0x0f);
1348
1349
    // Output <Focal len max 2>
1350
0
    os << ((focalLenMax2 >> 4) & 0x0f) << (focalLenMax2 & 0x0f);
1351
0
  } else {
1352
    // Output <Focal len max 2>
1353
0
    if (focalLenMax2 != 0)
1354
0
      os << ((focalLenMax2 >> 4) & 0x0f) << (focalLenMax2 & 0x0f);
1355
0
  }
1356
1357
0
  os << "mm";
1358
1359
  // Output <Aperture min>
1360
0
  os << " F" << ((appertureMin >> 4) & 0x0f) << "." << (appertureMin & 0x0f);
1361
1362
  // Output <Aperture max>
1363
0
  if (apertureMax != 0)
1364
0
    os << "-" << ((apertureMax >> 4) & 0x0f) << "." << (apertureMax & 0x0f);
1365
1366
  // Output <Flags 3>
1367
0
  if (!flagsEnd.empty())
1368
0
    os << " " << flagsEnd;
1369
0
  return os;
1370
0
}
1371
1372
0
std::ostream& SonyMakerNote::printImageSize(std::ostream& os, const Value& value, const ExifData*) {
1373
0
  if (value.count() != 2 || value.typeId() != unsignedLong)
1374
0
    return os << "(" << value << ")";
1375
1376
  // Values are stored as Height then Width
1377
0
  return os << value.toString(1) << " x " << value.toString(0);
1378
0
}
1379
1380
0
std::ostream& SonyMakerNote::printFocusMode(std::ostream& os, const Value& value, const ExifData* metadata) {
1381
0
  if (value.count() != 1 || value.typeId() != unsignedShort || !metadata)
1382
0
    return os << "(" << value << ")";
1383
1384
  // Only valid for certain models of camera. See
1385
  // https://github.com/exiftool/exiftool/blob/1e17485cbb372a502e5b9d052d01303db735e6fa/lib/Image/ExifTool/Sony.pm#L2255
1386
1387
0
  if (std::string metaVersion; !getMetaVersion(metadata, metaVersion) || metaVersion != "DC7303320222000")
1388
0
    return EXV_PRINT_TAG(sonyFocusMode)(os, value.toUint32(0), metadata);
1389
1390
0
  return os << _("n/a");
1391
0
}
1392
1393
0
std::ostream& SonyMakerNote::printAFMode(std::ostream& os, const Value& value, const ExifData* metadata) {
1394
0
  if (value.count() != 1 || value.typeId() != unsignedShort || !metadata)
1395
0
    return os << "(" << value << ")";
1396
1397
  // Only valid for certain models of camera. See
1398
  // https://github.com/exiftool/exiftool/blob/1e17485cbb372a502e5b9d052d01303db735e6fa/lib/Image/ExifTool/Sony.pm#L2275
1399
0
  if (std::string metaVersion; !getMetaVersion(metadata, metaVersion) || metaVersion != "DC7303320222000")
1400
0
    return EXV_PRINT_TAG(sonyAFModeSet1)(os, value.toUint32(0), metadata);
1401
1402
0
  if (uint32_t focusMode2 = 0; getFocusMode2(metadata, focusMode2) && focusMode2 != 0)
1403
0
    return EXV_PRINT_TAG(sonyAFModeSet2)(os, value.toUint32(0), metadata);
1404
1405
0
  return os << _("n/a");
1406
0
}
1407
1408
0
std::ostream& SonyMakerNote::printFocusMode3(std::ostream& os, const Value& value, const ExifData* metadata) {
1409
0
  if (value.count() != 1 || value.typeId() != unsignedShort || !metadata)
1410
0
    return os << "(" << value << ")";
1411
1412
  // Only valid for certain models of camera. See
1413
  // https://github.com/exiftool/exiftool/blob/1e17485cbb372a502e5b9d052d01303db735e6fa/lib/Image/ExifTool/Sony.pm#L2411
1414
0
  if (std::string metaVersion; getMetaVersion(metadata, metaVersion) && metaVersion == "DC7303320222000")
1415
0
    return EXV_PRINT_TAG(sonyFocusMode3)(os, value.toUint32(0), metadata);
1416
1417
0
  return os << _("n/a");
1418
0
}
1419
1420
std::ostream& SonyMakerNote::printHighISONoiseReduction2(std::ostream& os, const Value& value,
1421
0
                                                         const ExifData* metadata) {
1422
0
  if (value.count() != 1 || value.typeId() != unsignedShort || !metadata)
1423
0
    return os << "(" << value << ")";
1424
1425
  // Only valid for certain models of camera. See
1426
  // https://github.com/exiftool/exiftool/blob/1e17485cbb372a502e5b9d052d01303db735e6fa/lib/Image/ExifTool/Sony.pm#L2437
1427
0
  std::string model;
1428
0
  if (!getModel(metadata, model))
1429
0
    return os << "(" << value << ")";
1430
1431
0
  if (model.starts_with("DSC-") || model.starts_with("Stellar"))
1432
0
    return EXV_PRINT_TAG(sonyHighISONoiseReduction2)(os, value.toUint32(0), metadata);
1433
1434
0
  return os << _("n/a");
1435
0
}
1436
1437
// Sony MakerNote Tag Info
1438
constexpr TagInfo SonyMakerNote::tagInfo_[] = {
1439
    {0x0102, "Quality", N_("Quality"), N_("Image quality"), IfdId::sony1Id, SectionId::makerTags, unsignedLong, -1,
1440
     EXV_PRINT_TAG(sonyImageQuality)},
1441
    {0x0104, "FlashExposureComp", N_("Flash Exposure Compensation"), N_("Flash exposure compensation in EV"),
1442
     IfdId::sony1Id, SectionId::makerTags, signedRational, -1, print0x9204},
1443
    {0x0105, "Teleconverter", N_("Teleconverter Model"), N_("Teleconverter Model"), IfdId::sony1Id,
1444
     SectionId::makerTags, unsignedLong, -1, printMinoltaSonyTeleconverterModel},
1445
    {0x0112, "WhiteBalanceFineTune", N_("White Balance Fine Tune"), N_("White Balance Fine Tune"), IfdId::sony1Id,
1446
     SectionId::makerTags, unsignedLong, -1, printWhiteBalanceFineTune},
1447
    {0x0115, "WhiteBalance", N_("White balance"), N_("White balance"), IfdId::sony1Id, SectionId::makerTags,
1448
     unsignedLong, -1, EXV_PRINT_TAG(sonyWhiteBalanceStd)},
1449
    {0x1000, "MultiBurstMode", N_("Multi Burst Mode"), N_("Multi Burst Mode"), IfdId::sony1Id, SectionId::makerTags,
1450
     undefined, -1, printMultiBurstMode},
1451
    {0x1001, "MultiBurstImageWidth", N_("Multi Burst Image Width"), N_("Multi Burst Image Width"), IfdId::sony1Id,
1452
     SectionId::makerTags, unsignedShort, -1, printMultiBurstSize},
1453
    {0x1002, "MultiBurstImageHeight", N_("Multi Burst Image Height"), N_("Multi Burst Image Height"), IfdId::sony1Id,
1454
     SectionId::makerTags, unsignedShort, -1, printMultiBurstSize},
1455
    {0x2001, "PreviewImage", N_("Preview Image"), N_("JPEG preview image"), IfdId::sony1Id, SectionId::makerTags,
1456
     undefined, -1, printValue},
1457
    {0x2002, "Rating", "Rating", N_("Rating"), IfdId::sony1Id, SectionId::makerTags, unsignedLong, -1, printValue},
1458
    {0x2004, "Contrast", "Contrast", N_("Contrast"), IfdId::sony1Id, SectionId::makerTags, signedLong, -1, printValue},
1459
    {0x2005, "Saturation", "Saturation", N_("Saturation"), IfdId::sony1Id, SectionId::makerTags, signedLong, -1,
1460
     printValue},
1461
    {0x2006, "Sharpness", "Sharpness", N_("Sharpness"), IfdId::sony1Id, SectionId::makerTags, signedLong, -1,
1462
     printValue},
1463
    {0x2007, "Brightness", "Brightness", N_("Brightness"), IfdId::sony1Id, SectionId::makerTags, signedLong, -1,
1464
     printValue},
1465
    {0x2008, "LongExposureNoiseReduction", "Long exposure noise reduction", N_("Long exposure noise reduction"),
1466
     IfdId::sony1Id, SectionId::makerTags, unsignedLong, -1, EXV_PRINT_TAG(sonyLongExposureNoiseReduction)},
1467
    {0x2009, "HighISONoiseReduction", "High ISO noise reduction", N_("High ISO noise reduction"), IfdId::sony1Id,
1468
     SectionId::makerTags, unsignedShort, -1, EXV_PRINT_TAG(sonyHighISONoiseReductionStd)},
1469
    {0x200a, "AutoHDR", N_("Auto high dynamic range mode"), N_("Auto high dynamic range mode"), IfdId::sony1Id,
1470
     SectionId::makerTags, unsignedLong, -1, printAutoHDRStd},
1471
    {0x200b, "MultiFrameNoiseReduction", N_("Multi frame noise reduction"), N_("Multi frame noise reduction"),
1472
     IfdId::sony1Id, SectionId::makerTags, unsignedLong, -1, EXV_PRINT_TAG(sonyOffOnNA1)},
1473
    {0x200e, "PictureEffect", N_("Picture effect"), N_("Picture effect"), IfdId::sony1Id, SectionId::makerTags,
1474
     unsignedShort, -1, EXV_PRINT_TAG(sonyPictureEffect)},
1475
    {0x200f, "SoftSkinEffect", N_("Soft skin effect"), N_("Soft skin effect"), IfdId::sony1Id, SectionId::makerTags,
1476
     unsignedLong, -1, EXV_PRINT_TAG(sonySoftSkinEffect)},
1477
    {0x2011, "VignettingCorrection", N_("Vignetting correction"), N_("Vignetting correction"), IfdId::sony1Id,
1478
     SectionId::makerTags, unsignedLong, -1, EXV_PRINT_TAG(sonyVignettingCorrection)},
1479
    {0x2012, "LateralChromaticAberration", N_("Lateral chromatic aberration"), N_("Lateral chromatic aberration"),
1480
     IfdId::sony1Id, SectionId::makerTags, unsignedLong, -1, EXV_PRINT_TAG(sonyLateralChromaticAberration)},
1481
    {0x2013, "DistortionCorrectionSetting", N_("Distortion correction setting"), N_("Distortion correction setting"),
1482
     IfdId::sony1Id, SectionId::makerTags, unsignedLong, -1, EXV_PRINT_TAG(sonyDistortionCorrectionSettings)},
1483
    {0x2014, "WBShiftABGM", N_("White balance Shift (amber/blue, green/magenta)"),
1484
     N_("First number is amber/blue, second is green/magenta"), IfdId::sony1Id, SectionId::makerTags, signedLong, 2,
1485
     printWBShiftABGM},
1486
    {0x2016, "AutoPortraitFramed", N_("Auto portrait framed"), N_("Indicates if the Portrait Framing feature was used"),
1487
     IfdId::sony1Id, SectionId::makerTags, unsignedShort, -1, EXV_PRINT_TAG(sonyNoYes)},
1488
    {0x2017, "FlashAction", N_("Flash action"), N_("Flash action"), IfdId::sony1Id, SectionId::makerTags, unsignedLong,
1489
     -1, EXV_PRINT_TAG(sonyFlashAction)},
1490
    {0x201a, "ElectronicFrontCurtainShutter", N_("Electronic front curtain shutter"),
1491
     N_("Electronic front curtain shutter"), IfdId::sony1Id, SectionId::makerTags, unsignedLong, -1,
1492
     printMinoltaSonyBoolValue},
1493
    {0x201b, "FocusMode2", N_("Focus mode 2"), N_("Focus mode 2"), IfdId::sony1Id, SectionId::makerTags, unsignedByte,
1494
     -1, printFocusMode2},
1495
    {0x201c, "AFAreaModeSetting", N_("Auto focus area mode setting"), N_("Auto focus area mode setting"),
1496
     IfdId::sony1Id, SectionId::makerTags, unsignedByte, -1, printAFAreaModeSetting},
1497
    {0x201d, "FlexibleSpotPosition", N_("Flexible spot position"),
1498
     N_("X and Y co-ordinates or the auto focus point. Only valid when AFAreaModeSetting is Flexible"), IfdId::sony1Id,
1499
     SectionId::makerTags, unsignedShort, 2, printFlexibleSpotPosition},
1500
    {0x201e, "AFPointSelected", N_("Auto focus point selected"), N_("Auto focus point selected"), IfdId::sony1Id,
1501
     SectionId::makerTags, unsignedByte, -1, printAFPointSelected},
1502
    {0x2020, "AFPointsUsed", N_("Auto focus points used"), N_("Auto focus points used"), IfdId::sony1Id,
1503
     SectionId::makerTags, unsignedByte, -1, printAFPointsUsed},
1504
    {0x2021, "AFTracking", N_("Auto focus tracking"), N_("Auto focus tracking"), IfdId::sony1Id, SectionId::makerTags,
1505
     unsignedByte, -1, printAFTracking},
1506
    {0x2022, "FocalPlaneAFPointsUsed", N_("Focal plane auto focus points used"),
1507
     N_("Focal plane auto focus points used"), IfdId::sony1Id, SectionId::makerTags, unsignedByte, -1,
1508
     printFocalPlaneAFPointsUsed},
1509
    {0x2023, "MultiFrameNREffect", N_("Multi frame noise reduction effect"), N_("Multi frame noise reduction effect"),
1510
     IfdId::sony1Id, SectionId::makerTags, unsignedLong, -1, EXV_PRINT_TAG(sonyMultiFrameNREffect)},
1511
    {0x2026, "WBShiftABGMPrecise", N_("White balance shift (amber/blue, green/magenta) precise"),
1512
     N_("First number is amber/blue, second is green/magenta"), IfdId::sony1Id, SectionId::makerTags, signedLong, 2,
1513
     printWBShiftABGMPrecise},
1514
    {0x2027, "FocusLocation", N_("Focus location"),
1515
     N_("Location in the image where the camera focused, used for Playback Zoom. Origin is top left with the first "
1516
        "co-ordinate to the right and the second co-ordinate down. If focus location information cannot be obtained, "
1517
        "the center of the image is used"),
1518
     IfdId::sony1Id, SectionId::makerTags, unsignedShort, -1, printValue},
1519
    {0x2028, "VariableLowPassFilter", N_("Variable low pass filter"), N_("Variable low pass filter"), IfdId::sony1Id,
1520
     SectionId::makerTags, unsignedShort, -1, EXV_PRINT_STRING_TAG_2(sonyVariableLowPassFilter)},
1521
    {0x2029, "RAWFileType", N_("RAW file type"), N_("RAW file type"), IfdId::sony1Id, SectionId::makerTags,
1522
     unsignedShort, -1, EXV_PRINT_TAG(sonyRAWFileType)},
1523
    {0x202b, "PrioritySetInAWB", N_("Priority set in automatic white balance"),
1524
     N_("Priority set in automatic white balance"), IfdId::sony1Id, SectionId::makerTags, unsignedByte, -1,
1525
     EXV_PRINT_TAG(sonyPrioritySetInAWB)},
1526
    {0x202c, "MeteringMode2", N_("Metering mode 2"), N_("Metering mode 2"), IfdId::sony1Id, SectionId::makerTags,
1527
     unsignedShort, -1, EXV_PRINT_TAG(sonyMeteringMode2)},
1528
    {0x202d, "ExposureStandardAdjustment", N_("Exposure standard adjustment"), N_("Exposure standard adjustment"),
1529
     IfdId::sony1Id, SectionId::makerTags, signedRational, -1, printExposureStandardAdjustment},
1530
    {0x202e, "Quality2", N_("Quality 2"), N_("Image quality 2"), IfdId::sony1Id, SectionId::makerTags, unsignedShort, 2,
1531
     EXV_PRINT_STRING_TAG_2(sonyQuality2Std)},
1532
    {0x202f, "PixelShiftInfo", N_("Pixel shift info"),
1533
     N_("Pixel shift information consisting of the group ID and shot number"), IfdId::sony1Id, SectionId::makerTags,
1534
     undefined, -1, printPixelShiftInfo},
1535
    {0x2031, "SerialNumber", N_("Serial number"), N_("Serial number"), IfdId::sony1Id, SectionId::makerTags,
1536
     asciiString, -1, printValue},
1537
    {0x2032, "Shadows", N_("Shadows"), N_("Shadows"), IfdId::sony1Id, SectionId::makerTags, signedLong, -1, printValue},
1538
    {0x2033, "Highlights", N_("Highlights"), N_("Highlights"), IfdId::sony1Id, SectionId::makerTags, signedLong, -1,
1539
     printValue},
1540
    {0x2034, "Fade", N_("Fade"), N_("Fade"), IfdId::sony1Id, SectionId::makerTags, signedLong, -1, printValue},
1541
    {0x2035, "SharpnessRange", N_("Sharpness range"), N_("Sharpness range"), IfdId::sony1Id, SectionId::makerTags,
1542
     signedLong, -1, printValue},
1543
    {0x2036, "Clarity", N_("Clarity"), N_("Clarity"), IfdId::sony1Id, SectionId::makerTags, signedLong, -1, printValue},
1544
    {0x2037, "FocusFrameSize", N_("Focus frame size"),
1545
     N_("Width and height of the focus frame, centered on FocusLocation"), IfdId::sony1Id, SectionId::makerTags,
1546
     undefined, -1, printFocusFrameSize},
1547
    {0x2039, "JPEGHEIFSwitch", N_("JPEG/HEIF switch"), N_("JPEG/HEIF switch"), IfdId::sony1Id, SectionId::makerTags,
1548
     unsignedShort, -1, EXV_PRINT_TAG(sonyJPEGHEIFSwitch)},
1549
    {0xb000, "FileFormat", N_("File Format"), N_("File Format"), IfdId::sony1Id, SectionId::makerTags, unsignedByte, -1,
1550
     EXV_PRINT_STRING_TAG_4(sonyFileFormat)},
1551
    {0xb001, "SonyModelID", N_("Sony Model ID"),
1552
     N_("Similar to Exif.Image.Model but can contain multiple entries or conditions"), IfdId::sony1Id,
1553
     SectionId::makerTags, unsignedShort, -1, EXV_PRINT_TAG(sonyModelId)},
1554
    {0xb020, "CreativeStyle", N_("Creative style"), N_("Creative style"), IfdId::sony1Id, SectionId::makerTags,
1555
     asciiString, -1, EXV_PRINT_STRING_TAG_1(sonyCreativeStyleStd)},
1556
    {0xb021, "ColorTemperature", N_("Color Temperature"), N_("Color Temperature"), IfdId::sony1Id, SectionId::makerTags,
1557
     unsignedLong, -1, printColorTemperature},
1558
    {0xb022, "ColorCompensationFilter", N_("Color Compensation Filter"),
1559
     N_("Color Compensation Filter, (green/magenta)"), IfdId::sony1Id, SectionId::makerTags, unsignedLong, -1,
1560
     printColorCompensationFilter},
1561
    {0xb023, "SceneMode", N_("Scene Mode"), N_("Scene Mode"), IfdId::sony1Id, SectionId::makerTags, unsignedLong, -1,
1562
     printMinoltaSonySceneMode},
1563
    {0xb024, "ZoneMatching", N_("Zone Matching"), N_("Zone Matching"), IfdId::sony1Id, SectionId::makerTags,
1564
     unsignedLong, -1, printMinoltaSonyZoneMatching},
1565
    {0xb025, "DynamicRangeOptimizer", N_("Dynamic Range Optimizer"), N_("Dynamic Range Optimizer"), IfdId::sony1Id,
1566
     SectionId::makerTags, unsignedLong, -1, EXV_PRINT_TAG(print0xb025)},
1567
    {0xb026, "ImageStabilization", N_("Image stabilization"), N_("Image stabilization"), IfdId::sony1Id,
1568
     SectionId::makerTags, unsignedLong, -1, EXV_PRINT_TAG(sonyOffOnNA2)},
1569
    {0xb027, "LensID", N_("Lens ID"), N_("Lens ID"), IfdId::sony1Id, SectionId::makerTags, unsignedLong, -1,
1570
     printMinoltaSonyLensID},
1571
    {0xb029, "ColorMode", N_("Color Mode"), N_("Color Mode"), IfdId::sony1Id, SectionId::makerTags, unsignedLong, -1,
1572
     EXV_PRINT_TAG(sonyColorMode)},
1573
    {0xb02a, "LensSpec", N_("Lens specification"),
1574
     N_("Similar to Exif.Photo.LensModel but includes optional additional flags before and after (e.g., DT, Macro). "
1575
        "Works with most Sony cameras"),
1576
     IfdId::sony1Id, SectionId::makerTags, unsignedByte, -1, printLensSpec},
1577
    {0xb02b, "FullImageSize", N_("Full Image Size"), N_("Full image Size (width x height)"), IfdId::sony1Id,
1578
     SectionId::makerTags, unsignedLong, -1, printImageSize},
1579
    {0xb02c, "PreviewImageSize", N_("Preview image Size"), N_("Preview image size (width x height)"), IfdId::sony1Id,
1580
     SectionId::makerTags, unsignedLong, -1, printImageSize},
1581
    {0xb040, "Macro", N_("Macro"), N_("Macro"), IfdId::sony1Id, SectionId::makerTags, unsignedShort, -1,
1582
     EXV_PRINT_TAG(sonyMacro)},
1583
    {0xb041, "ExposureMode", N_("Exposure Mode"), N_("Exposure Mode"), IfdId::sony1Id, SectionId::makerTags,
1584
     unsignedShort, -1, EXV_PRINT_TAG(sonyExposureMode)},
1585
    {0xb042, "FocusMode", N_("Focus Mode"), N_("Focus Mode"), IfdId::sony1Id, SectionId::makerTags, unsignedShort, -1,
1586
     printFocusMode},
1587
    {0xb043, "AFMode", N_("Auto focus area mode"), N_("Auto focus area mode"), IfdId::sony1Id, SectionId::makerTags,
1588
     unsignedShort, -1, printAFMode},
1589
    {0xb044, "AFIlluminator", N_("Auto focus illuminator"), N_("Auto focus illuminator"), IfdId::sony1Id,
1590
     SectionId::makerTags, unsignedShort, -1, EXV_PRINT_TAG(sonyAFIlluminator)},
1591
    {0xb047, "JPEGQuality", N_("JPEG Quality"), N_("JPEG Quality"), IfdId::sony1Id, SectionId::makerTags, unsignedShort,
1592
     -1, EXV_PRINT_TAG(sonyJPEGQuality)},
1593
    {0xb048, "FlashLevel", N_("Flash Level"), N_("Flash Level"), IfdId::sony1Id, SectionId::makerTags, signedShort, -1,
1594
     EXV_PRINT_TAG(sonyFlashLevel)},
1595
    {0xb049, "ReleaseMode", N_("Release Mode"), N_("Release Mode"), IfdId::sony1Id, SectionId::makerTags, unsignedShort,
1596
     -1, EXV_PRINT_TAG(sonyReleaseMode)},
1597
    {0xb04a, "SequenceNumber", N_("Sequence Number"), N_("Shot number in continuous burst mode"), IfdId::sony1Id,
1598
     SectionId::makerTags, unsignedShort, -1, EXV_PRINT_TAG_NO_ERROR(sonySequenceNumber)},
1599
    {0xb04b, "AntiBlur", N_("Anti-Blur"), N_("Anti-Blur"), IfdId::sony1Id, SectionId::makerTags, unsignedShort, -1,
1600
     EXV_PRINT_TAG(sonyAntiBlur)},
1601
    {0xb04e, "FocusMode3", N_("Focus mode 3"), N_("Focus mode 3"), IfdId::sony1Id, SectionId::makerTags, unsignedShort,
1602
     -1, printFocusMode3},
1603
    {0xb04f, "DynamicRangeOptimizer2", N_("Dynamic Range Optimizer 2"), N_("Dynamic Range Optimizer 2"), IfdId::sony1Id,
1604
     SectionId::makerTags, unsignedShort, -1, EXV_PRINT_TAG(print0xb04f)},
1605
    {0xb050, "HighISONoiseReduction2", N_("High ISO noise reduction 2"), N_("High ISO noise reduction 2"),
1606
     IfdId::sony1Id, SectionId::makerTags, unsignedShort, -1, printHighISONoiseReduction2},
1607
    {0xb052, "IntelligentAuto", N_("Intelligent Auto"), N_("Intelligent Auto"), IfdId::sony1Id, SectionId::makerTags,
1608
     unsignedShort, -1, EXV_PRINT_TAG(sonyIntelligentAuto)},
1609
    {0xb054, "WhiteBalance2", N_("White balance 2"),
1610
     N_("White balance 2. Decoding the Fluorescent settings matches the EXIF standard, which is different from "
1611
        "the names used by Sony for some models"),
1612
     IfdId::sony1Id, SectionId::makerTags, unsignedShort, -1, EXV_PRINT_TAG(sonyWhiteBalance2)},
1613
    // End of list marker
1614
    {0xffff, "(UnknownSony1MakerNoteTag)", "(UnknownSony1MakerNoteTag)", N_("Unknown Sony1MakerNote tag"),
1615
     IfdId::sony1Id, SectionId::makerTags, asciiString, -1, printValue},
1616
};
1617
1618
// -- Sony camera settings ---------------------------------------------------------------
1619
1620
//! Lookup table to translate Sony camera settings drive mode values to readable labels
1621
constexpr TagDetails sonyDriveModeStd[] = {
1622
    {0x01, N_("Single Frame")},
1623
    {0x02, N_("Continuous High")},
1624
    {0x04, N_("Self-timer 10 sec")},
1625
    {0x05, N_("Self-timer 2 sec, Mirror Lock-up")},
1626
    {0x06, N_("Single-frame Bracketing")},
1627
    {0x07, N_("Continuous Bracketing")},
1628
    {0x0a, N_("Remote Commander")},
1629
    {0x0b, N_("Mirror Lock-up")},
1630
    {0x12, N_("Continuous Low")},
1631
    {0x18, N_("White Balance Bracketing Low")},
1632
    {0x19, N_("D-Range Optimizer Bracketing Low")},
1633
    {0x28, N_("White Balance Bracketing High")},
1634
    {0x29, N_("D-Range Optimizer Bracketing High")},
1635
};
1636
1637
//! Lookup table to translate Sony camera settings focus mode values to readable labels
1638
constexpr TagDetails sonyCSFocusMode[] = {
1639
    {0, N_("Manual")},
1640
    {1, "AF-S"},
1641
    {2, "AF-C"},
1642
    {3, "AF-A"},
1643
};
1644
1645
//! Lookup table to translate Sony camera settings metering mode values to readable labels
1646
constexpr TagDetails sonyMeteringMode[] = {
1647
    {1, N_("Multi-segment")},
1648
    {2, N_("Center weighted average")},
1649
    {4, N_("Spot")},
1650
};
1651
1652
//! Lookup table to translate Sony camera settings creative style values to readable labels
1653
constexpr TagDetails sonyCreativeStyle[] = {
1654
    {1, N_("Standard")},      {2, N_("Vivid")},     {3, N_("Portrait")},
1655
    {4, N_("Landscape")},     {5, N_("Sunset")},    {6, N_("Night View/Portrait")},
1656
    {8, N_("Black & White")}, {9, N_("Adobe RGB")}, {11, N_("Neutral")},
1657
    {12, N_("Clear")},        {13, N_("Deep")},     {14, N_("Light")},
1658
    {15, N_("Autumn")},       {16, N_("Sepia")},
1659
};
1660
1661
//! Lookup table to translate Sony camera settings flash mode values to readable labels
1662
constexpr TagDetails sonyFlashMode[] = {
1663
    {0, N_("ADI")},
1664
    {1, N_("TTL")},
1665
};
1666
1667
//! Lookup table to translate Sony AF illuminator values to readable labels
1668
constexpr TagDetails sonyAFIlluminatorCS[] = {
1669
    {0, N_("Auto")},
1670
    {1, N_("Off")},
1671
    {0xffff, N_("n/a")},
1672
};
1673
1674
//! Lookup table to translate Sony camera settings image style values to readable labels
1675
constexpr TagDetails sonyImageStyle[] = {
1676
    {1, N_("Standard")},    {2, N_("Vivid")},       {3, N_("Portrait")},
1677
    {4, N_("Landscape")},   {5, N_("Sunset")},      {7, N_("Night View/Portrait")},
1678
    {8, N_("B&W")},         {9, N_("Adobe RGB")},   {11, N_("Neutral")},
1679
    {129, N_("StyleBox1")}, {130, N_("StyleBox2")}, {131, N_("StyleBox3")},
1680
    {132, N_("StyleBox4")}, {133, N_("StyleBox5")}, {134, N_("StyleBox6")},
1681
};
1682
1683
//! Lookup table to translate Sony camera settings exposure program values to readable labels
1684
constexpr TagDetails sonyExposureProgram[] = {
1685
    {0, N_("Auto")},
1686
    {1, N_("Manual")},
1687
    {2, N_("Program AE")},
1688
    {3, N_("Aperture-priority AE")},
1689
    {4, N_("Shutter speed priority AE")},
1690
    {8, N_("Program Shift A")},
1691
    {9, N_("Program Shift S")},
1692
    {16, N_("Portrait")},
1693
    {17, N_("Sports")},
1694
    {18, N_("Sunset")},
1695
    {19, N_("Night Portrait")},
1696
    {20, N_("Landscape")},
1697
    {21, N_("Macro")},
1698
    {35, N_("Auto No Flash")},
1699
};
1700
1701
//! Lookup table to translate Sony camera settings image size values to readable labels
1702
constexpr TagDetails sonyImageSize[] = {
1703
    {1, N_("Large")},
1704
    {2, N_("Medium")},
1705
    {3, N_("Small")},
1706
};
1707
1708
//! Lookup table to translate Sony aspect ratio values to readable labels
1709
constexpr TagDetails sonyAspectRatio[] = {
1710
    {1, "3:2"},
1711
    {2, "16:9"},
1712
};
1713
1714
//! Lookup table to translate Sony exposure level increments values to readable labels
1715
constexpr TagDetails sonyExposureLevelIncrements[] = {
1716
    {33, "1/3 EV"},
1717
    {50, "1/2 EV"},
1718
};
1719
1720
// Sony Camera Settings Tag Info
1721
// NOTE: all are for A200, A230, A300, A350, A700, A850 and A900 Sony model excepted
1722
// some entries which are only relevant with A700.
1723
1724
// Warnings: Exiftool database give a list of tags shorted in decimal mode, not hexadecimal.
1725
1726
constexpr TagInfo SonyMakerNote::tagInfoCs_[] = {
1727
    // NOTE: A700 only
1728
    {0x0004, "DriveMode", N_("Drive Mode"), N_("Drive Mode"), IfdId::sony1CsId, SectionId::makerTags, unsignedShort, 1,
1729
     EXV_PRINT_TAG(sonyDriveModeStd)},
1730
    // NOTE: A700 only
1731
    {0x0006, "WhiteBalanceFineTune", N_("White Balance Fine Tune"), N_("White Balance Fine Tune"), IfdId::sony1CsId,
1732
     SectionId::makerTags, signedShort, 1, printValue},
1733
    {0x0010, "FocusMode", N_("Focus Mode"), N_("Focus Mode"), IfdId::sony1CsId, SectionId::makerTags, unsignedShort, 1,
1734
     EXV_PRINT_TAG(sonyCSFocusMode)},
1735
    {0x0011, "AFAreaMode", N_("AF Area Mode"), N_("AF Area Mode"), IfdId::sony1CsId, SectionId::makerTags,
1736
     unsignedShort, 1, printMinoltaSonyAFAreaMode},
1737
    {0x0012, "LocalAFAreaPoint", N_("Local AF Area Point"), N_("Local AF Area Point"), IfdId::sony1CsId,
1738
     SectionId::makerTags, unsignedShort, 1, printMinoltaSonyLocalAFAreaPoint},
1739
    {0x0015, "MeteringMode", N_("Metering Mode"), N_("Metering Mode"), IfdId::sony1CsId, SectionId::makerTags,
1740
     unsignedShort, 1, EXV_PRINT_TAG(sonyMeteringMode)},
1741
    {0x0016, "ISOSetting", N_("ISO Setting"), N_("ISO Setting"), IfdId::sony1CsId, SectionId::makerTags, unsignedShort,
1742
     1, printValue},
1743
    {0x0018, "DynamicRangeOptimizerMode", N_("Dynamic Range Optimizer Mode"), N_("Dynamic Range Optimizer Mode"),
1744
     IfdId::sony1CsId, SectionId::makerTags, unsignedShort, 1, printMinoltaSonyDynamicRangeOptimizerMode},
1745
    {0x0019, "DynamicRangeOptimizerLevel", N_("Dynamic Range Optimizer Level"), N_("Dynamic Range Optimizer Level"),
1746
     IfdId::sony1CsId, SectionId::makerTags, unsignedShort, 1, printValue},
1747
    {0x001A, "CreativeStyle", N_("Creative Style"), N_("Creative Style"), IfdId::sony1CsId, SectionId::makerTags,
1748
     unsignedShort, 1, EXV_PRINT_TAG(sonyCreativeStyle)},
1749
    {0x001C, "Sharpness", N_("Sharpness"), N_("Sharpness"), IfdId::sony1CsId, SectionId::makerTags, unsignedShort, 1,
1750
     printValue},
1751
    {0x001D, "Contrast", N_("Contrast"), N_("Contrast"), IfdId::sony1CsId, SectionId::makerTags, unsignedShort, 1,
1752
     printValue},
1753
    {0x001E, "Saturation", N_("Saturation"), N_("Saturation"), IfdId::sony1CsId, SectionId::makerTags, unsignedShort, 1,
1754
     printValue},
1755
    {0x001F, "ZoneMatchingValue", N_("Zone Matching Value"), N_("Zone Matching Value"), IfdId::sony1CsId,
1756
     SectionId::makerTags, unsignedShort, 1, printValue},
1757
    {0x0022, "Brightness", N_("Brightness"), N_("Brightness"), IfdId::sony1CsId, SectionId::makerTags, unsignedShort, 1,
1758
     printValue},
1759
    {0x0023, "FlashMode", N_("FlashMode"), N_("FlashMode"), IfdId::sony1CsId, SectionId::makerTags, unsignedShort, 1,
1760
     EXV_PRINT_TAG(sonyFlashMode)},
1761
    // NOTE: A700 only
1762
    {0x0028, "PrioritySetupShutterRelease", N_("Priority Setup Shutter Release"), N_("Priority Setup Shutter Release"),
1763
     IfdId::sony1CsId, SectionId::makerTags, unsignedShort, 1, printMinoltaSonyPrioritySetupShutterRelease},
1764
    // NOTE: A700 only
1765
    {0x0029, "AFIlluminator", N_("AF Illuminator"), N_("AF Illuminator"), IfdId::sony1CsId, SectionId::makerTags,
1766
     unsignedShort, 1, EXV_PRINT_TAG(sonyAFIlluminatorCS)},
1767
    // NOTE: A700 only
1768
    {0x002A, "AFWithShutter", N_("AF With Shutter"), N_("AF With Shutter"), IfdId::sony1CsId, SectionId::makerTags,
1769
     unsignedShort, 1, printMinoltaSonyBoolInverseValue},
1770
    // NOTE: A700 only
1771
    {0x002B, "LongExposureNoiseReduction", N_("Long Exposure Noise Reduction"), N_("Long Exposure Noise Reduction"),
1772
     IfdId::sony1CsId, SectionId::makerTags, unsignedShort, 1, printMinoltaSonyBoolValue},
1773
    // NOTE: A700 only
1774
    {0x002C, "HighISONoiseReduction", N_("High ISO Noise Reduction"), N_("High ISO Noise Reduction"), IfdId::sony1CsId,
1775
     SectionId::makerTags, unsignedShort, 1, printValue},
1776
    // NOTE: A700 only
1777
    {0x002D, "ImageStyle", N_("Image Style"), N_("Image Style"), IfdId::sony1CsId, SectionId::makerTags, unsignedShort,
1778
     1, EXV_PRINT_TAG(sonyImageStyle)},
1779
    {0x003C, "ExposureProgram", N_("Exposure Program"), N_("Exposure Program"), IfdId::sony1CsId, SectionId::makerTags,
1780
     unsignedShort, 1, EXV_PRINT_TAG(sonyExposureProgram)},
1781
    {0x003D, "ImageStabilization", N_("Image Stabilization"), N_("Image Stabilization"), IfdId::sony1CsId,
1782
     SectionId::makerTags, unsignedShort, 1, printMinoltaSonyBoolValue},
1783
    {0x003F, "Rotation", N_("Rotation"), N_("Rotation"), IfdId::sony1CsId, SectionId::makerTags, unsignedShort, 1,
1784
     printMinoltaSonyRotation},
1785
    {0x0054, "SonyImageSize", N_("Sony Image Size"), N_("Sony Image Size"), IfdId::sony1CsId, SectionId::makerTags,
1786
     unsignedShort, 1, EXV_PRINT_TAG(sonyImageSize)},
1787
    {0x0055, "AspectRatio", N_("Aspect Ratio"), N_("Aspect Ratio"), IfdId::sony1CsId, SectionId::makerTags,
1788
     unsignedShort, 1, EXV_PRINT_TAG(sonyAspectRatio)},
1789
    {0x0056, "Quality", N_("Quality"), N_("Quality"), IfdId::sony1CsId, SectionId::makerTags, unsignedShort, 1,
1790
     printMinoltaSonyQualityCs},
1791
    {0x0058, "ExposureLevelIncrements", N_("Exposure Level Increments"), N_("Exposure Level Increments"),
1792
     IfdId::sony1CsId, SectionId::makerTags, unsignedShort, 1, EXV_PRINT_TAG(sonyExposureLevelIncrements)},
1793
    // End of list marker
1794
    {0xffff, "(UnknownSony1CsTag)", "(UnknownSony1CsTag)", N_("Unknown Sony1 Camera Settings tag"), IfdId::sony1CsId,
1795
     SectionId::makerTags, unsignedShort, 1, printValue},
1796
};
1797
1798
// -- Sony camera settings 2 ---------------------------------------------------------------
1799
1800
// Sony Camera Settings Tag Version 2 Info
1801
// NOTE: for A330, A380, A450, A500, A550 Sony model
1802
1803
// Warnings: Exiftool database give a list of tags shorted in decimal mode, not hexadecimal.
1804
1805
constexpr TagInfo SonyMakerNote::tagInfoCs2_[] = {
1806
    {0x0010, "FocusMode", N_("Focus Mode"), N_("Focus Mode"), IfdId::sony1Cs2Id, SectionId::makerTags, unsignedShort, 1,
1807
     EXV_PRINT_TAG(sonyCSFocusMode)},
1808
    {0x0011, "AFAreaMode", N_("AF Area Mode"), N_("AF Area Mode"), IfdId::sony1Cs2Id, SectionId::makerTags,
1809
     unsignedShort, 1, printMinoltaSonyAFAreaMode},
1810
    {0x0012, "LocalAFAreaPoint", N_("Local AF Area Point"), N_("Local AF Area Point"), IfdId::sony1Cs2Id,
1811
     SectionId::makerTags, unsignedShort, 1, printMinoltaSonyLocalAFAreaPoint},
1812
    {0x0013, "MeteringMode", N_("Metering Mode"), N_("Metering Mode"), IfdId::sony1Cs2Id, SectionId::makerTags,
1813
     unsignedShort, 1, EXV_PRINT_TAG(sonyMeteringMode)},
1814
    {0x0014, "ISOSetting", N_("ISO Setting"), N_("ISO Setting"), IfdId::sony1Cs2Id, SectionId::makerTags, unsignedShort,
1815
     1, printValue},
1816
    {0x0016, "DynamicRangeOptimizerMode", N_("Dynamic Range Optimizer Mode"), N_("Dynamic Range Optimizer Mode"),
1817
     IfdId::sony1Cs2Id, SectionId::makerTags, unsignedShort, 1, printMinoltaSonyDynamicRangeOptimizerMode},
1818
    {0x0017, "DynamicRangeOptimizerLevel", N_("Dynamic Range Optimizer Level"), N_("Dynamic Range Optimizer Level"),
1819
     IfdId::sony1Cs2Id, SectionId::makerTags, unsignedShort, 1, printValue},
1820
    {0x0018, "CreativeStyle", N_("Creative Style"), N_("Creative Style"), IfdId::sony1Cs2Id, SectionId::makerTags,
1821
     unsignedShort, 1, EXV_PRINT_TAG(sonyCreativeStyle)},
1822
    {0x0019, "Sharpness", N_("Sharpness"), N_("Sharpness"), IfdId::sony1Cs2Id, SectionId::makerTags, unsignedShort, 1,
1823
     printValue},
1824
    {0x001A, "Contrast", N_("Contrast"), N_("Contrast"), IfdId::sony1Cs2Id, SectionId::makerTags, unsignedShort, 1,
1825
     printValue},
1826
    {0x001B, "Saturation", N_("Saturation"), N_("Saturation"), IfdId::sony1Cs2Id, SectionId::makerTags, unsignedShort,
1827
     1, printValue},
1828
    {0x0023, "FlashMode", N_("FlashMode"), N_("FlashMode"), IfdId::sony1Cs2Id, SectionId::makerTags, unsignedShort, 1,
1829
     EXV_PRINT_TAG(sonyFlashMode)},
1830
    {0x003C, "ExposureProgram", N_("Exposure Program"), N_("Exposure Program"), IfdId::sony1Cs2Id, SectionId::makerTags,
1831
     unsignedShort, 1, EXV_PRINT_TAG(sonyExposureProgram)},
1832
    {0x003F, "Rotation", N_("Rotation"), N_("Rotation"), IfdId::sony1Cs2Id, SectionId::makerTags, unsignedShort, 1,
1833
     printMinoltaSonyRotation},
1834
    {0x0054, "SonyImageSize", N_("Sony Image Size"), N_("Sony Image Size"), IfdId::sony1Cs2Id, SectionId::makerTags,
1835
     unsignedShort, 1, EXV_PRINT_TAG(sonyImageSize)},
1836
    // End of list marker
1837
    {0xffff, "(UnknownSony1Cs2Tag)", "(UnknownSony1Cs2Tag)", N_("Unknown Sony1 Camera Settings 2 tag"),
1838
     IfdId::sony1Cs2Id, SectionId::makerTags, unsignedShort, 1, printValue},
1839
};
1840
1841
//! Lookup table to translate Sony2Fp AF Area Mode values to readable labels
1842
constexpr TagDetails sony2FpAFAreaMode[] = {
1843
    {0, N_("Multi")},
1844
    {1, N_("Center")},
1845
    {2, N_("Spot")},
1846
    {3, N_("Flexible Spot")},
1847
    {10, N_("Selective (for Miniature effect)")},
1848
    {11, N_("Zone")},
1849
    {12, N_("Expanded Flexible Spot")},
1850
    {14, N_("Tracking")},
1851
    {15, N_("Face Tracking")},
1852
    {20, N_("Animal Eye Tracking")},
1853
    {255, N_("Manual")},
1854
};
1855
1856
//! Sony Tag 9402 Sony2Fp (FocusPosition)
1857
constexpr TagInfo SonyMakerNote::tagInfoFp_[] = {
1858
    {0x04, "AmbientTemperature", N_("Ambient temperature"), N_("Temperature of the surroundings (in degrees Celsius)"),
1859
     IfdId::sony2FpId, SectionId::makerTags, signedByte, 1, printSony2FpAmbientTemperature},
1860
    {0x16, "FocusMode", N_("Focus mode"), N_("Focus mode"), IfdId::sony2FpId, SectionId::makerTags, unsignedByte, 1,
1861
     printSony2FpFocusMode},
1862
    {0x17, "AFAreaMode", N_("AF area mode"), N_("Auto focus area mode"), IfdId::sony2FpId, SectionId::makerTags,
1863
     unsignedByte, 1, EXV_PRINT_TAG(sony2FpAFAreaMode)},
1864
    {0x2d, "FocusPosition2", N_("Focus position 2"), N_("Focus position 2"), IfdId::sony2FpId, SectionId::makerTags,
1865
     unsignedByte, 1, printSony2FpFocusPosition2},
1866
    // End of list marker
1867
    {0xffff, "(UnknownSony2FpTag)", "(Unknown Sony2Fp tag)", "(Unknown Sony2Fp tag)", IfdId::sony2FpId,
1868
     SectionId::makerTags, unsignedByte, 1, printValue},
1869
};
1870
1871
std::ostream& SonyMakerNote::printSony2FpAmbientTemperature(std::ostream& os, const Value& value,
1872
0
                                                            const ExifData* metadata) {
1873
0
  if (value.count() != 1 || !metadata)
1874
0
    return os << "(" << value << ")";
1875
1876
0
  auto pos = metadata->findKey(ExifKey("Exif.Sony2Fp.0x0002"));
1877
0
  if (pos != metadata->end() && pos->count() == 1 && pos->toInt64() == 255)
1878
0
    return os << value << " °C";
1879
1880
0
  return os << N_("n/a");
1881
0
}
1882
1883
0
std::ostream& SonyMakerNote::printSony2FpFocusMode(std::ostream& os, const Value& value, const ExifData*) {
1884
0
  if (value.count() != 1)
1885
0
    return os << value;
1886
1887
0
  const auto val = (value.toInt64() & 0x7F);
1888
0
  switch (val) {
1889
0
    case 0:
1890
0
      return os << N_("Manual");
1891
0
    case 2:
1892
0
      return os << N_("AF-S");
1893
0
    case 3:
1894
0
      return os << N_("AF-C");
1895
0
    case 4:
1896
0
      return os << N_("AF-A");
1897
0
    case 6:
1898
0
      return os << N_("DMF");
1899
0
  }
1900
1901
0
  return os << "(" << val << ")";
1902
0
}
1903
1904
std::ostream& SonyMakerNote::printSony2FpFocusPosition2(std::ostream& os, const Value& value,
1905
0
                                                        const ExifData* metadata) {
1906
0
  if (value.count() != 1 || !metadata)
1907
0
    return os << "(" << value << ")";
1908
1909
0
  std::string model;
1910
0
  if (!getModel(metadata, model))
1911
0
    return os << "(" << value << ")";
1912
1913
  // Ranges of models that do not support this tag
1914
0
  for (const auto& m : {"DSC-", "Stellar"})
1915
0
    if (model.starts_with(m))
1916
0
      return os << N_("n/a");
1917
1918
0
  const auto val = value.toInt64();
1919
0
  if (val == 255)
1920
0
    return os << N_("Infinity");
1921
1922
0
  return os << val;
1923
0
}
1924
1925
//! Sony Tag 9403 SonyMisc1
1926
constexpr TagInfo SonyMakerNote::tagInfoSonyMisc1_[] = {
1927
    {0x05, "CameraTemperature", N_("Camera temperature"), N_("Internal camera temperature (in degrees Celsius)"),
1928
     IfdId::sonyMisc1Id, SectionId::makerTags, signedByte, -1, printSonyMisc1CameraTemperature},
1929
    // End of list marker
1930
    {0xffff, "(UnknownSonyMisc1Tag)", "(UnknownSonyMisc1Tag)", "(UnknownSonyMisc1Tag)", IfdId::sonyMisc1Id,
1931
     SectionId::makerTags, unsignedByte, -1, printValue},
1932
};
1933
1934
std::ostream& SonyMakerNote::printSonyMisc1CameraTemperature(std::ostream& os, const Value& value,
1935
0
                                                             const ExifData* metadata) {
1936
0
  if (value.count() != 1 || !metadata)
1937
0
    return os << "(" << value << ")";
1938
1939
0
  auto pos = metadata->findKey(ExifKey("Exif.SonyMisc1.0x0004"));
1940
0
  if (pos != metadata->end() && pos->count() == 1 && pos->toInt64() != 0 && pos->toInt64() < 100)
1941
0
    return os << value << " °C";
1942
1943
0
  return os << N_("n/a");
1944
0
}
1945
1946
//! Lookup table to translate Sony Exposure Program 3 values to readable labels
1947
constexpr TagDetails sonyExposureProgram3[] = {
1948
    {0, N_("Program AE")},
1949
    {1, N_("Aperture-priority AE")},
1950
    {2, N_("Shutter speed priority AE")},
1951
    {3, N_("Manual")},
1952
    {4, N_("Auto")},
1953
    {5, N_("iAuto")},
1954
    {6, N_("Superior Auto")},
1955
    {7, N_("iAuto+")},
1956
    {8, N_("Portrait")},
1957
    {9, N_("Landscape")},
1958
    {10, N_("Twilight")},
1959
    {11, N_("Twilight Portrait")},
1960
    {12, N_("Sunset")},
1961
    {14, N_("Action (High speed)")},
1962
    {16, N_("Sports")},
1963
    {17, N_("Handheld Night Shot")},
1964
    {18, N_("Anti Motion Blur")},
1965
    {19, N_("High Sensitivity")},
1966
    {21, N_("Beach")},
1967
    {22, N_("Snow")},
1968
    {23, N_("Fireworks")},
1969
    {26, N_("Underwater")},
1970
    {27, N_("Gourmet")},
1971
    {28, N_("Pet")},
1972
    {29, N_("Macro")},
1973
    {30, N_("Backlight Correction HDR")},
1974
    {33, N_("Sweep Panorama")},
1975
    {36, N_("Background Defocus")},
1976
    {37, N_("Soft Skin")},
1977
    {42, N_("3D Image")},
1978
    {43, N_("Cont. Priority AE")},
1979
    {45, N_("Document")},
1980
    {46, N_("Party")},
1981
};
1982
1983
//! Sony Tag 9404b SonyMisc2b tags
1984
constexpr TagInfo SonyMakerNote::tagInfoSonyMisc2b_[] = {
1985
    {12, "ExposureProgram", N_("Exposure program"), N_("Exposure program"), IfdId::sonyMisc2bId, SectionId::makerTags,
1986
     unsignedByte, -1, EXV_PRINT_TAG(sonyExposureProgram3)},
1987
    {14, "IntelligentAuto", N_("Intelligent auto"), N_("Whether intelligent auto was used"), IfdId::sonyMisc2bId,
1988
     SectionId::makerTags, unsignedByte, -1, printMinoltaSonyBoolValue},
1989
    {30, "LensZoomPosition", N_("Lens zoom position"), N_("Lens zoom position (in %)"), IfdId::sonyMisc2bId,
1990
     SectionId::makerTags, unsignedShort, -1, printSonyMisc2bLensZoomPosition},
1991
    {32, "FocusPosition2", N_("Focus position 2"), N_("Focus position 2"), IfdId::sonyMisc2bId, SectionId::makerTags,
1992
     unsignedByte, -1, printSonyMisc2bFocusPosition2},
1993
    // End of list marker
1994
    {0xffff, "(UnknownSonyMisc2bTag)", "(Unknown SonyMisc2b tag)", "(Unknown SonyMisc2b tag)", IfdId::sonyMisc2bId,
1995
     SectionId::makerTags, unsignedByte, -1, printValue},
1996
};
1997
1998
std::ostream& SonyMakerNote::printSonyMisc2bLensZoomPosition(std::ostream& os, const Value& value,
1999
0
                                                             const ExifData* metadata) {
2000
0
  if (value.count() != 1 || !metadata)
2001
0
    return os << "(" << value << ")";
2002
2003
0
  std::string model;
2004
0
  if (!getModel(metadata, model))
2005
0
    return os << "(" << value << ")";
2006
2007
  // Models that do not support this tag
2008
0
  for (auto m : {"SLT-", "HV", "ILCA-"})
2009
0
    if (Internal::contains(model, m))
2010
0
      return os << N_("n/a");
2011
2012
0
  return os << stringFormat("{}%", std::lround(value.toInt64() / 10.24));
2013
0
}
2014
2015
std::ostream& SonyMakerNote::printSonyMisc2bFocusPosition2(std::ostream& os, const Value& value,
2016
0
                                                           const ExifData* metadata) {
2017
0
  if (value.count() != 1 || !metadata)
2018
0
    return os << "(" << value << ")";
2019
2020
0
  std::string model;
2021
0
  if (!getModel(metadata, model))
2022
0
    return os << "(" << value << ")";
2023
2024
  // Models that do not support this tag
2025
0
  for (auto m : {"SLT-", "HV", "ILCA-"})
2026
0
    if (Internal::contains(model, m))
2027
0
      return os << N_("n/a");
2028
2029
0
  return os << value;
2030
0
}
2031
2032
//! Lookup table to translate Sony camera SonyMisc3c sequence length 1 values to readable labels
2033
constexpr TagDetails sonyMisc3cSequenceLength1[] = {
2034
    {0, N_("Continuous")},
2035
    {1, N_("1 shot")},
2036
    {2, N_("2 shots")},
2037
    {3, N_("3 shots")},
2038
    {4, N_("4 shots")},
2039
    {5, N_("5 shots")},
2040
    {6, N_("6 shots")},
2041
    {7, N_("7 shots")},
2042
    {9, N_("9 shots")},
2043
    {10, N_("10 shots")},
2044
    {12, N_("12 shots")},
2045
    {16, N_("16 shots")},
2046
    {100, N_("Continuous - iSweep Panorama")},
2047
    {200, N_("Continuous - Sweep Panorama")},
2048
};
2049
2050
//! Lookup table to translate Sony camera SonyMisc3c sequence length 2 values to readable labels
2051
constexpr TagDetails sonyMisc3cSequenceLength2[] = {
2052
    {0, N_("Continuous")}, {1, N_("1 file")},  {2, N_("2 files")}, {3, N_("3 files")},
2053
    {5, N_("5 files")},    {7, N_("7 files")}, {9, N_("9 files")}, {10, N_("10 files")},
2054
};
2055
2056
//! Lookup table to translate Sony camera SonyMisc3c, camera orientation values to readable labels
2057
constexpr TagDetails sonyMisc3cCameraOrientation[] = {
2058
    {1, N_("Horizontal (normal)")},
2059
    {3, N_("Rotate 180°")},
2060
    {6, N_("Rotate 90° CW")},
2061
    {8, N_("Rotate 270° CW")},
2062
};
2063
2064
//! Lookup table to translate SonyMisc3c Quality2 (a) values to readable labels
2065
constexpr TagDetails sonyMisc3cQuality2a[] = {
2066
    {1, "JPEG"}, {2, "Raw"}, {3, "Raw + JPEG"}, {4, "HEIF"}, {6, "Raw + HEIF"},
2067
};
2068
2069
//! Lookup table to translate SonyMisc3c Quality2 (b) values to readable labels
2070
constexpr TagDetails sonyMisc3cQuality2b[] = {
2071
    {0, "JPEG"},
2072
    {1, "Raw"},
2073
    {2, "Raw + JPEG"},
2074
    {3, "Raw + MPO"},
2075
};
2076
2077
//! SonyMisc3c tags (Tag 9400c)
2078
constexpr TagInfo SonyMakerNote::tagInfoSonyMisc3c_[] = {
2079
    {9, "ReleaseMode2", N_("Release mode 2"), N_("Release mode 2"), IfdId::sonyMisc3cId, SectionId::makerTags,
2080
     unsignedByte, -1, EXV_PRINT_TAG(sonyReleaseMode2)},
2081
    {10, "ShotNumberSincePowerUp", N_("Shot number since power up"),
2082
     N_("Number of photos taken since the camera was powered up"), IfdId::sonyMisc3cId, SectionId::makerTags,
2083
     unsignedLong, -1, printSonyMisc3cShotNumberSincePowerUp},
2084
    {18, "SequenceImageNumber", N_("Sequence image number"), N_("Number of images captured in burst sequence"),
2085
     IfdId::sonyMisc3cId, SectionId::makerTags, unsignedLong, -1, printSonyMisc3cSequenceNumber},
2086
    // In Exiftool, "SequenceLength1" is called "SequenceLength (22). Renamed due to clash of names."
2087
    {22, "SequenceLength1", N_("Sequence length 1"), N_("Length of the sequence of photos taken"), IfdId::sonyMisc3cId,
2088
     SectionId::makerTags, unsignedByte, -1, EXV_PRINT_TAG(sonyMisc3cSequenceLength1)},
2089
    {26, "SequenceFileNumber", N_("Sequence file number"), N_("File number in burst sequence"), IfdId::sonyMisc3cId,
2090
     SectionId::makerTags, unsignedLong, -1, printSonyMisc3cSequenceNumber},
2091
    // In Exiftool, "SequenceLength2" is called "SequenceLength" (30). Renamed due to clash of names."
2092
    {30, "SequenceLength2", N_("Sequence length 2"), N_("Length of the sequence of photos taken"), IfdId::sonyMisc3cId,
2093
     SectionId::makerTags, unsignedByte, -1, EXV_PRINT_TAG(sonyMisc3cSequenceLength2)},
2094
    {41, "CameraOrientation", N_("Camera orientation"), N_("Orientation of the camera when the photo was taken"),
2095
     IfdId::sonyMisc3cId, SectionId::makerTags, unsignedByte, -1, EXV_PRINT_TAG(sonyMisc3cCameraOrientation)},
2096
    {42, "Quality2", N_("Quality 2"), N_("Quality 2"), IfdId::sonyMisc3cId, SectionId::makerTags, unsignedByte, -1,
2097
     printSonyMisc3cQuality2},
2098
    {71, "SonyImageHeight", N_("Sony image height"), N_("Height of the image"), IfdId::sonyMisc3cId,
2099
     SectionId::makerTags, unsignedShort, -1, printSonyMisc3cSonyImageHeight},
2100
    {83, "ModelReleaseYear", N_("Model release year"), N_("Year that the model of camera was released"),
2101
     IfdId::sonyMisc3cId, SectionId::makerTags, unsignedByte, -1, printSonyMisc3cModelReleaseYear},
2102
    // End of list marker
2103
    {0xffff, "(UnknownSonyMisc3c)", "(Unknown SonyMisc3c Tag)", N_("Unknown SonyMisc23 tag"), IfdId::sonyMisc3cId,
2104
     SectionId::makerTags, asciiString, -1, printValue},
2105
};
2106
2107
std::ostream& SonyMakerNote::printSonyMisc3cShotNumberSincePowerUp(std::ostream& os, const Value& value,
2108
0
                                                                   const ExifData* metadata) {
2109
0
  if (value.count() != 1 || value.typeId() != unsignedLong || !metadata)
2110
0
    return os << "(" << value << ")";
2111
2112
0
  std::string model;
2113
0
  if (!getModel(metadata, model))
2114
0
    return os << "(" << value << ")";
2115
2116
  // Tag only valid for certain camera models. See
2117
  // https://github.com/exiftool/exiftool/blob/7368629751669ba170511419b3d1e05bf0076d0e/lib/Image/ExifTool/Sony.pm#L8170
2118
0
  static constexpr const char* models[] = {
2119
0
      "ILCA-68",     "ILCA-77M2",   "ILCA-99M2",   "ILCE-5000",  "ILCE-5100", "ILCE-6000",  "ILCE-6300",
2120
0
      "ILCE-6500",   "ILCE-7",      "ILCE-7M2",    "ILCE-7R",    "ILCE-7RM2", "ILCE-7S",    "ILCE-7SM2",
2121
0
      "ILCE-7SM5",   "ILCE-QX1",    "DSC-HX350",   "DSC-HX400V", "DSC-HX60V", "DSC-HX80",   "DSC-HX90",
2122
0
      "DSC-HX90V",   "DSC-QX30",    "DSC-RX0",     "DSC-RX1RM2", "DSC-RX10",  "DSC-RX10M2", "DSC-RX10M3",
2123
0
      "DSC-RX100M3", "DSC-RX100M4", "DSC-RX100M5", "DSC-WX220",  "DSC-WX350", "DSC-WX500",
2124
0
  };
2125
2126
0
  if (Exiv2::find(models, model))
2127
0
    return os << value.toInt64();
2128
2129
0
  return os << N_("n/a");
2130
0
}
2131
2132
0
std::ostream& SonyMakerNote::printSonyMisc3cSequenceNumber(std::ostream& os, const Value& value, const ExifData*) {
2133
0
  return (value.count() != 1 || value.typeId() != unsignedLong) ? os << "(" << value << ")"
2134
0
                                                                : os << (value.toInt64() + 1);
2135
0
}
2136
2137
0
std::ostream& SonyMakerNote::printSonyMisc3cQuality2(std::ostream& os, const Value& value, const ExifData* metadata) {
2138
0
  if (value.count() != 1 || value.typeId() != unsignedByte || !metadata)
2139
0
    return os << "(" << value << ")";
2140
2141
0
  std::string model;
2142
0
  if (!getModel(metadata, model))
2143
0
    return os << "(" << value << ")";
2144
2145
0
  const auto val = value.toInt64();
2146
2147
  // Tag only valid for certain camera models. See
2148
  // https://github.com/exiftool/exiftool/blob/7368629751669ba170511419b3d1e05bf0076d0e/lib/Image/ExifTool/Sony.pm#L8219
2149
0
  constexpr const char* models[] = {"ILCE-1", "ILCE-7M4", "ILCE-7RM5", "ILCE-7SM3", "ILME-FX3"};
2150
2151
0
  if (Exiv2::find(models, model))
2152
0
    return EXV_PRINT_TAG(sonyMisc3cQuality2a)(os, val, metadata);
2153
2154
0
  return EXV_PRINT_TAG(sonyMisc3cQuality2b)(os, val, metadata);
2155
0
}
2156
2157
std::ostream& SonyMakerNote::printSonyMisc3cSonyImageHeight(std::ostream& os, const Value& value,
2158
0
                                                            const ExifData* metadata) {
2159
0
  if (value.count() != 1 || value.typeId() != unsignedShort || !metadata)
2160
0
    return os << "(" << value << ")";
2161
2162
0
  std::string model;
2163
0
  if (!getModel(metadata, model))
2164
0
    return os << "(" << value << ")";
2165
2166
  // Tag only valid for certain camera models. See
2167
  // https://github.com/exiftool/exiftool/blob/7368629751669ba170511419b3d1e05bf0076d0e/lib/Image/ExifTool/Sony.pm#L8239
2168
0
  constexpr const char* models[] = {"ILCE-1", "ILCE-7M4", "ILCE-7RM5", "ILCE-7SM3", "ILME-FX3"};
2169
2170
0
  if (Exiv2::find(models, model))
2171
0
    return os << N_("n/a");
2172
2173
0
  const auto val = value.toInt64();
2174
0
  if (val > 0)
2175
0
    return os << (8 * val);
2176
0
  return os << N_("n/a");
2177
0
}
2178
2179
std::ostream& SonyMakerNote::printSonyMisc3cModelReleaseYear(std::ostream& os, const Value& value,
2180
0
                                                             const ExifData* metadata) {
2181
0
  if (value.count() != 1 || value.typeId() != unsignedByte || !metadata)
2182
0
    return os << "(" << value << ")";
2183
2184
0
  std::string model;
2185
0
  if (!getModel(metadata, model))
2186
0
    return os << "(" << value << ")";
2187
2188
  // Tag only valid for certain camera models. See
2189
  // https://github.com/exiftool/exiftool/blob/7368629751669ba170511419b3d1e05bf0076d0e/lib/Image/ExifTool/Sony.pm#L8245
2190
0
  constexpr const char* models[] = {"ILCE-1", "ILCE-7M4", "ILCE-7RM5", "ILCE-7SM3", "ILME-FX3"};
2191
2192
0
  if (Exiv2::find(models, model)) {
2193
0
    return os << N_("n/a");
2194
0
  }
2195
2196
0
  const auto val = value.toInt64();
2197
0
  if (val > 99)
2198
0
    return os << "(" << val << ")";
2199
2200
0
  if (val == 0)
2201
0
    return os << "2000";
2202
2203
0
  return os << "20" << val;
2204
0
}
2205
2206
//! Sony SInfo1 tags (ShotInfo - Tag 3000)
2207
constexpr TagInfo SonyMakerNote::tagInfoSonySInfo1_[] = {
2208
    // TODO: As "FaceInfo1" (72) and "FaceInfo2" (94) are not added, including
2209
    //       "FaceInfoOffset" (2) and "FaceInfoLength" (50) does not make sense.
2210
    //       The values are all connected and changing one without the rest will
2211
    //       corrupt the data.
2212
    {6, "SonyDateTime", N_("Sony date/time"), N_("Date and time when the photo was captured"), IfdId::sonySInfo1Id,
2213
     SectionId::makerTags, asciiString, -1, printValue},
2214
    {26, "SonyImageHeight", N_("Sony image height"), N_("Height of the image"), IfdId::sonySInfo1Id,
2215
     SectionId::makerTags, unsignedShort, -1, printValue},
2216
    {28, "SonyImageWidth", N_("Sony image width"), N_("Width of the image"), IfdId::sonySInfo1Id, SectionId::makerTags,
2217
     unsignedShort, -1, printValue},
2218
    {48, "FacesDetected", N_("Faces detected"), N_("Number of faces detected in the image"), IfdId::sonySInfo1Id,
2219
     SectionId::makerTags, unsignedShort, -1, printValue},
2220
    {52, "MetaVersion", N_("Meta version"), N_("Sony meta version"), IfdId::sonySInfo1Id, SectionId::makerTags,
2221
     asciiString, -1, printValue},
2222
    // TODO: Add FaceInfo1 (72) and FaceInfo2 (94) which are sub-groups of tags.
2223
    // End of list marker
2224
    {0xffff, "(UnknownsonySInfo1Tag)", "(Unknown SonySInfo1 Tag)", "(Unknown SonySInfo1 Tag)", IfdId::sonySInfo1Id,
2225
     SectionId::makerTags, unsignedByte, -1, printValue},
2226
};
2227
2228
//! Sony Tag 2010 Sony2010 (Miscellaneous)
2229
constexpr TagInfo SonyMakerNote::tagInfo2010e_[] = {
2230
    {0, "SequenceImageNumber", N_("Sequence Image Number"), N_("Sequence Image Number"), IfdId::sony2010eId,
2231
     SectionId::makerTags, unsignedLong, 1, printValue},
2232
    {4, "SequenceFileNumber", N_("SequenceFileNumber"), N_("SequenceFileNumber"), IfdId::sony2010eId,
2233
     SectionId::makerTags, unsignedLong, 1, printValue},
2234
    {8, "ReleaseMode2", N_("ReleaseMode2"), N_("ReleaseMode2"), IfdId::sony2010eId, SectionId::makerTags, unsignedLong,
2235
     1, printValue},
2236
    {540, "DigitalZoomRatio", N_("DigitalZoomRatio"), N_("DigitalZoomRatio"), IfdId::sony2010eId, SectionId::makerTags,
2237
     unsignedByte, 1, printValue},
2238
    {556, "SonyDateTime", N_("SonyDateTime"), N_("SonyDateTime"), IfdId::sony2010eId, SectionId::makerTags, undefined,
2239
     1, printValue},
2240
    {808, "DynamicRangeOptimizer", N_("DynamicRangeOptimizer"), N_("DynamicRangeOptimizer"), IfdId::sony2010eId,
2241
     SectionId::makerTags, unsignedByte, 1, printValue},
2242
    {1208, "MeterInfo", N_("MeterInfo"), N_("MeterInfo"), IfdId::sony2010eId, SectionId::makerTags, undefined, 1,
2243
     printValue},
2244
    {4444, "ReleaseMode3", N_("ReleaseMode3"), N_("ReleaseMode3"), IfdId::sony2010eId, SectionId::makerTags,
2245
     unsignedByte, 1, printValue},
2246
    {4448, "ReleaseMode4", N_("ReleaseMode4"), N_("ReleaseMode4"), IfdId::sony2010eId, SectionId::makerTags,
2247
     unsignedByte, 1, printValue},
2248
    {4456, "SelfTimer", N_("SelfTimer"), N_("SelfTimer"), IfdId::sony2010eId, SectionId::makerTags, unsignedByte, 1,
2249
     printValue},
2250
    {4460, "FlashMode", N_("FlashMode"), N_("FlashMode"), IfdId::sony2010eId, SectionId::makerTags, unsignedByte, 1,
2251
     printValue},
2252
    {4466, "StopsAboveBaseISO", N_("StopsAboveBaseISO"), N_("StopsAboveBaseISO"), IfdId::sony2010eId,
2253
     SectionId::makerTags, unsignedShort, 1, printValue},
2254
    {4468, "BrightnessValue", N_("BrightnessValue"), N_("BrightnessValue"), IfdId::sony2010eId, SectionId::makerTags,
2255
     unsignedShort, 1, printValue},
2256
    {4472, "DynamicRangeOptimizer2", N_("DynamicRangeOptimizer 2"), N_("DynamicRangeOptimizer 2"), IfdId::sony2010eId,
2257
     SectionId::makerTags, unsignedByte, 1, printValue},
2258
    {4476, "HDRSetting", N_("HDRSetting"), N_("HDRSetting"), IfdId::sony2010eId, SectionId::makerTags, unsignedByte, 1,
2259
     printValue},
2260
    {4480, "ExposureCompensation", N_("ExposureCompensation"), N_("ExposureCompensation"), IfdId::sony2010eId,
2261
     SectionId::makerTags, signedShort, 1, printValue},
2262
    {4502, "PictureProfile", N_("PictureProfile"), N_("PictureProfile"), IfdId::sony2010eId, SectionId::makerTags,
2263
     unsignedByte, 1, printValue},
2264
    {4503, "PictureProfile2", N_("PictureProfile2"), N_("PictureProfile2"), IfdId::sony2010eId, SectionId::makerTags,
2265
     unsignedByte, 1, printValue},
2266
    {4507, "PictureEffect2", N_("PictureEffect2"), N_("PictureEffect2"), IfdId::sony2010eId, SectionId::makerTags,
2267
     unsignedByte, 1, printValue},
2268
    {4520, "Quality2", N_("Quality2"), N_("Quality2"), IfdId::sony2010eId, SectionId::makerTags, unsignedByte, 1,
2269
     printValue},
2270
    {4524, "MeteringMode", N_("MeteringMode"), N_("MeteringMode"), IfdId::sony2010eId, SectionId::makerTags,
2271
     unsignedByte, 1, printValue},
2272
    {4525, "ExposureProgram", N_("ExposureProgram"), N_("ExposureProgram"), IfdId::sony2010eId, SectionId::makerTags,
2273
     unsignedByte, 1, printValue},
2274
    {4532, "WB_RGBLevels", N_("WB_RGBLevels"), N_("WB_RGBLevels"), IfdId::sony2010eId, SectionId::makerTags,
2275
     unsignedShort, 3, printValue},
2276
    {4692, "SonyISO", N_("SonyISO"), N_("SonyISO"), IfdId::sony2010eId, SectionId::makerTags, unsignedShort, 1,
2277
     printValue},
2278
    {4696, "SonyISO2", N_("SonyISO2"), N_("SonyISO2"), IfdId::sony2010eId, SectionId::makerTags, unsignedShort, 1,
2279
     printValue},
2280
    {4728, "FocalLength", N_("FocalLength"), N_("FocalLength"), IfdId::sony2010eId, SectionId::makerTags, unsignedShort,
2281
     1, printValue},
2282
    {4730, "MinFocalLength", N_("MinFocalLength"), N_("MinFocalLength"), IfdId::sony2010eId, SectionId::makerTags,
2283
     unsignedShort, 1, printValue},
2284
    {4732, "MaxFocalLength", N_("MaxFocalLength"), N_("MaxFocalLength"), IfdId::sony2010eId, SectionId::makerTags,
2285
     unsignedShort, 1, printValue},
2286
    {4736, "SonyISO3", N_("SonyISO3"), N_("SonyISO3"), IfdId::sony2010eId, SectionId::makerTags, unsignedShort, 1,
2287
     printValue},
2288
    {6256, "DistortionCorrParams", N_("DistortionCorrParams"), N_("DistortionCorrParams"), IfdId::sony2010eId,
2289
     SectionId::makerTags, signedShort, 16, printValue},
2290
    {6289, "LensFormat", N_("LensFormat"), N_("LensFormat"), IfdId::sony2010eId, SectionId::makerTags, unsignedByte, 1,
2291
     printValue},
2292
    {6290, "LensMount", N_("LensMount"), N_("LensMount"), IfdId::sony2010eId, SectionId::makerTags, unsignedByte, 1,
2293
     printValue},
2294
    {6291, "LensType2", N_("LensType2"), N_("LensType2"), IfdId::sony2010eId, SectionId::makerTags, unsignedShort, 1,
2295
     printValue},
2296
    {6294, "LensType", N_("LensType"), N_("LensType"), IfdId::sony2010eId, SectionId::makerTags, unsignedShort, 1,
2297
     printValue},
2298
    {6296, "DistortionCorrParamsPresent", N_("DistortionCorrParamsPresent"), N_("DistortionCorrParamsPresent"),
2299
     IfdId::sony2010eId, SectionId::makerTags, unsignedByte, 1, printValue},
2300
    {6297, "DistortionCorrParamsNumber", N_("DistortionCorrParamsNumber"), N_("DistortionCorrParamsNumber"),
2301
     IfdId::sony2010eId, SectionId::makerTags, unsignedByte, 1, printValue},
2302
    // End of list marker
2303
    {0xffff, "(UnknownSony2010eTag)", "(UnknownSony2010eTag)", "(UnknownSony2010eTag)", IfdId::sony2010eId,
2304
     SectionId::makerTags, unsignedByte, 1, printValue},
2305
};
2306
2307
// https://github.com/Exiv2/exiv2/pull/906#issuecomment-504338797
2308
static DataBuf sonyTagCipher(uint16_t /* tag */, const byte* bytes, size_t size, const TiffComponent* /*object*/,
2309
0
                             bool bDecipher) {
2310
0
  DataBuf b(bytes, size);  // copy the data
2311
2312
  // initialize the code table
2313
0
  byte code[256];
2314
0
  for (uint32_t i = 0; i < 249; i++) {
2315
0
    if (bDecipher) {
2316
0
      code[(i * i * i) % 249] = static_cast<byte>(i);
2317
0
    } else {
2318
0
      code[i] = (i * i * i) % 249;
2319
0
    }
2320
0
  }
2321
0
  for (uint32_t i = 249; i < 256; i++) {
2322
0
    code[i] = static_cast<byte>(i);
2323
0
  }
2324
2325
  // code byte-by-byte
2326
0
  for (uint32_t i = 0; i < size; i++) {
2327
0
    b.write_uint8(i, code[bytes[i]]);
2328
0
  }
2329
2330
0
  return b;
2331
0
}
2332
2333
0
DataBuf sonyTagDecipher(uint16_t tag, const byte* bytes, size_t size, TiffComponent* object) {
2334
0
  return sonyTagCipher(tag, bytes, size, object, true);
2335
0
}
2336
0
DataBuf sonyTagEncipher(uint16_t tag, const byte* bytes, size_t size, TiffComponent* object) {
2337
0
  return sonyTagCipher(tag, bytes, size, object, false);
2338
0
}
2339
2340
}  // namespace Exiv2::Internal