File Coverage

blib/lib/Image/ExifTool/Sony.pm
Criterion Covered Total %
statement 83 471 17.6
branch 15 238 6.3
condition 5 160 3.1
subroutine 13 27 48.1
pod 0 20 0.0
total 116 916 12.6


line stmt bran cond sub pod time code
1             #------------------------------------------------------------------------------
2             # File: Sony.pm
3             #
4             # Description: Sony EXIF Maker Notes tags
5             #
6             # Revisions: 04/06/2004 - P. Harvey Created
7             #
8             # References: 1) http://www.cybercom.net/~dcoffin/dcraw/
9             # 2) http://homepage3.nifty.com/kamisaka/makernote/makernote_sony.htm (2006/08/06)
10             # 3) Thomas Bodenmann private communication
11             # 4) Philippe Devaux private communication (A700)
12             # 5) Marcus Holland-Moritz private communication (A700)
13             # 6) Andrey Tverdokhleb private communication
14             # 7) Rudiger Lange private communication (A700)
15             # 8) Igal Milchtaich private communication
16             # 9) Michael Reitinger private communication (DSC-TX7,RX100)
17             # 10) http://www.klingebiel.com/tempest/hd/pmp.html
18             # 11) Mike Battilana private communication
19             # 13) http://www.mi-fo.de/forum/index.php?showtopic=33239
20             # http://www.dyxum.com/dforum/the-alpha-shutter-count-tool_topic97489_page4.html
21             # 14) Albert Shan private communication (A7M3)
22             # IB) Iliah Borg private communication (LibRaw)
23             # JD) Jens Duttke private communication
24             # JR) Jos Roost private communication
25             #
26             # NC = Not Confirmed
27             #------------------------------------------------------------------------------
28              
29             package Image::ExifTool::Sony;
30              
31 26     26   6114 use strict;
  26         81  
  26         1088  
32 26     26   198 use vars qw($VERSION %sonyLensTypes %sonyLensTypes2);
  26         80  
  26         1572  
33 26     26   197 use Image::ExifTool qw(:DataAccess :Utils);
  26         94  
  26         5790  
34 26     26   1543 use Image::ExifTool::Exif;
  26         79  
  26         806  
35 26     26   6431 use Image::ExifTool::Minolta;
  26         228  
  26         575869  
36              
37             $VERSION = '3.59';
38              
39             sub ProcessSRF($$$);
40             sub ProcessSR2($$$);
41             sub ProcessSonyPIC($$$);
42             sub ProcessMoreInfo($$$);
43             sub Process_rtmd($$$);
44             sub Decipher($;$);
45             sub ProcessEnciphered($$$);
46             sub WriteEnciphered($$$);
47             sub WriteSR2($$$);
48             sub ConvLensSpec($);
49             sub ConvInvLensSpec($);
50             sub PrintLensSpec($);
51             sub PrintInvLensSpec($;$$);
52              
53             # (%sonyLensTypes is filled in based on Minolta LensType's)
54              
55             # Sony E-mount lenses
56             # (NOTE: these should be kept in sync with the 65535 entries in %minoltaLensTypes)
57             %sonyLensTypes2 = (
58             Notes => 'Lens type numbers for Sony E-mount lenses used by NEX/ILCE models.',
59             0 => 'Unknown E-mount lens or other lens',
60             0.1 => 'Sigma 19mm F2.8 [EX] DN',
61             0.2 => 'Sigma 30mm F2.8 [EX] DN',
62             0.3 => 'Sigma 60mm F2.8 DN',
63             0.4 => 'Sony E 18-200mm F3.5-6.3 OSS LE', # (firmware Ver.01)
64             0.5 => 'Tamron 18-200mm F3.5-6.3 Di III VC', # (Model B011)
65             0.6 => 'Tokina FiRIN 20mm F2 FE AF', # (firmware Ver.00) samples from Tokina, May 2018
66             0.7 => 'Tokina FiRIN 20mm F2 FE MF', # samples from Tokina, 16-12-2016, DC-watch 01-02-2017
67             0.8 => 'Zeiss Touit 12mm F2.8', # (firmware Ver.00)
68             0.9 => 'Zeiss Touit 32mm F1.8', # (firmware Ver.00)
69             '0.10' => 'Zeiss Touit 50mm F2.8 Macro', # (firmware Ver.00)
70             '0.11' => 'Zeiss Loxia 50mm F2', # (firmware Ver.01)
71             '0.12' => 'Zeiss Loxia 35mm F2', # (firmware Ver.01)
72             1 => 'Sony LA-EA1 or Sigma MC-11 Adapter', # MC-11 with not-supported lenses
73             2 => 'Sony LA-EA2 Adapter',
74             3 => 'Sony LA-EA3 Adapter',
75             6 => 'Sony LA-EA4 Adapter',
76             7 => 'Sony LA-EA5 Adapter', #JR
77             # 27 => Venus Optics Laowa 12mm f2.8 Zero-D or 105mm f2 (T3.2) Smooth Trans Focus (ref IB)
78             44 => 'Metabones Canon EF Smart Adapter', #JR
79             78 => 'Metabones Canon EF Smart Adapter Mark III or Other Adapter', #PH/JR (also Mark IV, Fotodiox and Viltrox)
80             184 => 'Metabones Canon EF Speed Booster Ultra', #JR ('Green' mode, LensMount reported as A-mount)
81             234 => 'Metabones Canon EF Smart Adapter Mark IV', #JR (LensMount reported as A-mount)
82             239 => 'Metabones Canon EF Speed Booster', #JR
83             24593 => 'LA-EA4r MonsterAdapter',
84             # Sony VX product code: (http://www.mi-fo.de/forum/index.php?s=7df1c8d3b1cd675f2abf4f4442e19cf2&showtopic=35035&view=findpost&p=303746)
85             32784 => 'Sony E 16mm F2.8', # VX9100
86             32785 => 'Sony E 18-55mm F3.5-5.6 OSS', # VX9101
87             32786 => 'Sony E 55-210mm F4.5-6.3 OSS', # VX9102
88             32787 => 'Sony E 18-200mm F3.5-6.3 OSS', # VX9103
89             32788 => 'Sony E 30mm F3.5 Macro', # VX9104
90             32789 => 'Sony E 24mm F1.8 ZA or Samyang AF 50mm F1.4', # VX9105
91             32789.1 => 'Samyang AF 50mm F1.4',
92             32790 => 'Sony E 50mm F1.8 OSS or Samyang AF 14mm F2.8', # VX9106
93             32790.1 => 'Samyang AF 14mm F2.8',
94             32791 => 'Sony E 16-70mm F4 ZA OSS', # VX9107
95             32792 => 'Sony E 10-18mm F4 OSS', # VX9108
96             32793 => 'Sony E PZ 16-50mm F3.5-5.6 OSS', # VX9109
97             32794 => 'Sony FE 35mm F2.8 ZA or Samyang Lens', # VX9110
98             32794.1 => 'Samyang AF 24mm F2.8', #JR
99             32794.2 => 'Samyang AF 35mm F2.8', #IB (also 51505)
100             32795 => 'Sony FE 24-70mm F4 ZA OSS', # VX9111
101             32796 => 'Sony FE 85mm F1.8 or Viltrox PFU RBMH 85mm F1.8', #JR
102             32796.1 => 'Viltrox PFU RBMH 85mm F1.8', #JR (MF)
103             32797 => 'Sony E 18-200mm F3.5-6.3 OSS LE', # VX9113 (firmware Ver.02)
104             32798 => 'Sony E 20mm F2.8', # VX9114
105             32799 => 'Sony E 35mm F1.8 OSS', # VX9115
106             32800 => 'Sony E PZ 18-105mm F4 G OSS', #JR # VX9116
107             32801 => 'Sony FE 12-24mm F4 G', #JR
108             32802 => 'Sony FE 90mm F2.8 Macro G OSS', # VX?
109             32803 => 'Sony E 18-50mm F4-5.6',
110             32804 => 'Sony FE 24mm F1.4 GM', #IB
111             32805 => 'Sony FE 24-105mm F4 G OSS', #IB # VX9121
112              
113             32807 => 'Sony E PZ 18-200mm F3.5-6.3 OSS', # VX9123
114             32808 => 'Sony FE 55mm F1.8 ZA', # VX9124
115              
116             32810 => 'Sony FE 70-200mm F4 G OSS', #JR # VX9126
117             32811 => 'Sony FE 16-35mm F4 ZA OSS', #JR # VX9127
118             32812 => 'Sony FE 50mm F2.8 Macro', #JR
119             32813 => 'Sony FE 28-70mm F3.5-5.6 OSS', # VX9129
120             32814 => 'Sony FE 35mm F1.4 ZA', # VX?
121             32815 => 'Sony FE 24-240mm F3.5-6.3 OSS', # VX?
122             32816 => 'Sony FE 28mm F2', #JR # VX?
123             32817 => 'Sony FE PZ 28-135mm F4 G OSS',#JR # VX?
124              
125             32819 => 'Sony FE 100mm F2.8 STF GM OSS', #JR (appears to use 33076 when switched to macro mode)
126             32820 => 'Sony E PZ 18-110mm F4 G OSS', #JR
127             32821 => 'Sony FE 24-70mm F2.8 GM', #JR/IB
128             32822 => 'Sony FE 50mm F1.4 ZA', #JR
129             32823 => 'Sony FE 85mm F1.4 GM or Samyang AF 85mm F1.4', #JR/IB
130             32823.1 => 'Samyang AF 85mm F1.4', #IB
131             32824 => 'Sony FE 50mm F1.8', #JR (Sony code 'SEL50F18F' with trailing "F" as compared to 'SEL50F18' for 32790)
132              
133             32826 => 'Sony FE 21mm F2.8 (SEL28F20 + SEL075UWC)', #JR # (+ Ultra-wide converter)
134             32827 => 'Sony FE 16mm F3.5 Fisheye (SEL28F20 + SEL057FEC)', #JR # (+ Fisheye converter)
135             32828 => 'Sony FE 70-300mm F4.5-5.6 G OSS', #JR
136             32829 => 'Sony FE 100-400mm F4.5-5.6 GM OSS', #JR
137             32830 => 'Sony FE 70-200mm F2.8 GM OSS', #JR
138             32831 => 'Sony FE 16-35mm F2.8 GM', #JR
139             32848 => 'Sony FE 400mm F2.8 GM OSS', #IB
140             32849 => 'Sony E 18-135mm F3.5-5.6 OSS', #JR
141             32850 => 'Sony FE 135mm F1.8 GM', #IB
142             32851 => 'Sony FE 200-600mm F5.6-6.3 G OSS', #IB
143             32852 => 'Sony FE 600mm F4 GM OSS', #IB
144             32853 => 'Sony E 16-55mm F2.8 G', #IB/JR
145             32854 => 'Sony E 70-350mm F4.5-6.3 G OSS', #IB/JR
146             32855 => 'Sony FE C 16-35mm T3.1 G', #JR (SELC1635G) (max aperture is 2.8)
147             32858 => 'Sony FE 35mm F1.8', #JR/IB
148             32859 => 'Sony FE 20mm F1.8 G', #IB/JR
149             32860 => 'Sony FE 12-24mm F2.8 GM', #JR/IB
150             32862 => 'Sony FE 50mm F1.2 GM', #IB/JR
151             32863 => 'Sony FE 14mm F1.8 GM', #IB
152             32864 => 'Sony FE 28-60mm F4-5.6', #JR
153             32865 => 'Sony FE 35mm F1.4 GM', #IB/JR
154             32866 => 'Sony FE 24mm F2.8 G', #IB
155             32867 => 'Sony FE 40mm F2.5 G', #IB
156             32868 => 'Sony FE 50mm F2.5 G', #IB
157             32871 => 'Sony FE PZ 16-35mm F4 G', #JR
158             32873 => 'Sony E PZ 10-20mm F4 G', #JR
159             32874 => 'Sony FE 70-200mm F2.8 GM OSS II', #IB
160             32875 => 'Sony FE 24-70mm F2.8 GM II', #JR
161             32876 => 'Sony E 11mm F1.8', #JR
162             32877 => 'Sony E 15mm F1.4 G', #JR
163             32878 => 'Sony FE 20-70mm F4 G', #JR
164              
165             # (comment this out so LensID will report the LensModel, which is more useful)
166             # 32952 => 'Metabones Canon EF Speed Booster Ultra', #JR (corresponds to 184, but 'Advanced' mode, LensMount reported as E-mount)
167             # 33002 => 'Metabones Canon EF Smart Adapter with Ver.5x', #PH/JR (corresponds to 234, but LensMount reported as E-mount)
168              
169             33072 => 'Sony FE 70-200mm F2.8 GM OSS + 1.4X Teleconverter', #JR
170             33073 => 'Sony FE 70-200mm F2.8 GM OSS + 2X Teleconverter', #JR
171             33076 => 'Sony FE 100mm F2.8 STF GM OSS (macro mode)', #JR (with macro switching ring set to "0.57m - 1.0m")
172             33077 => 'Sony FE 100-400mm F4.5-5.6 GM OSS + 1.4X Teleconverter', #JR
173             33078 => 'Sony FE 100-400mm F4.5-5.6 GM OSS + 2X Teleconverter', #JR
174             33079 => 'Sony FE 400mm F2.8 GM OSS + 1.4X Teleconverter', #IB
175             33080 => 'Sony FE 400mm F2.8 GM OSS + 2X Teleconverter', #JR
176             33081 => 'Sony FE 200-600mm F5.6-6.3 G OSS + 1.4X Teleconverter', #JR
177             33082 => 'Sony FE 200-600mm F5.6-6.3 G OSS + 2X Teleconverter', #JR
178             33083 => 'Sony FE 600mm F4 GM OSS + 1.4X Teleconverter', #JR (NC)
179             33084 => 'Sony FE 600mm F4 GM OSS + 2X Teleconverter', #JR
180              
181             49201 => 'Zeiss Touit 12mm F2.8', #JR (lens firmware Ver.02)
182             49202 => 'Zeiss Touit 32mm F1.8', #JR (lens firmware Ver.02)
183             49203 => 'Zeiss Touit 50mm F2.8 Macro', #JR (lens firmware Ver.02)
184             49216 => 'Zeiss Batis 25mm F2', #JR
185             49217 => 'Zeiss Batis 85mm F1.8', #JR
186             49218 => 'Zeiss Batis 18mm F2.8', #IB
187             49219 => 'Zeiss Batis 135mm F2.8', #IB
188             49220 => 'Zeiss Batis 40mm F2 CF', #IB
189             49232 => 'Zeiss Loxia 50mm F2', #JR (lens firmware Ver.02)
190             49233 => 'Zeiss Loxia 35mm F2', #JR (lens firmware Ver.02)
191             49234 => 'Zeiss Loxia 21mm F2.8', #PH
192             49235 => 'Zeiss Loxia 85mm F2.4', #JR
193             49236 => 'Zeiss Loxia 25mm F2.4', #JR
194              
195             49456 => 'Tamron E 18-200mm F3.5-6.3 Di III VC', #FrancoisPiette
196             49457 => 'Tamron 28-75mm F2.8 Di III RXD', #JR (Model A036)
197             49458 => 'Tamron 17-28mm F2.8 Di III RXD', #JR (Model A046)
198             49459 => 'Tamron 35mm F2.8 Di III OSD M1:2', #IB (Model F053)
199             49460 => 'Tamron 24mm F2.8 Di III OSD M1:2', #JR (Model F051)
200             49461 => 'Tamron 20mm F2.8 Di III OSD M1:2', #JR (Model F050)
201             49462 => 'Tamron 70-180mm F2.8 Di III VXD', #JR (Model A056)
202             49463 => 'Tamron 28-200mm F2.8-5.6 Di III RXD', #JR (Model A071)
203             49464 => 'Tamron 70-300mm F4.5-6.3 Di III RXD', #JR (Model A047)
204             49465 => 'Tamron 17-70mm F2.8 Di III-A VC RXD', #JR (Model B070)
205             49466 => 'Tamron 150-500mm F5-6.7 Di III VC VXD', #JR (Model A057)
206             49467 => 'Tamron 11-20mm F2.8 Di III-A RXD', #JR (Model B060)
207             49468 => 'Tamron 18-300mm F3.5-6.3 Di III-A VC VXD', #JR (Model B061)
208             49469 => 'Tamron 35-150mm F2-F2.8 Di III VXD', #JR (Model A058)
209             49470 => 'Tamron 28-75mm F2.8 Di III VXD G2', #JR (Model A063)
210             49471 => 'Tamron 50-400mm F4.5-6.3 Di III VC VXD', #JR (Model A067)
211             49472 => 'Tamron 20-40mm F2.8 Di III VXD', #JR (Model A062)
212              
213             49473 => 'Tokina atx-m 85mm F1.8 FE or Viltrox lens', #JR
214             49473.1 => 'Viltrox 23mm F1.4 E', #JR
215             49473.2 => 'Viltrox 56mm F1.4 E', #JR
216             49712 => 'Tokina FiRIN 20mm F2 FE AF', # (firmware Ver.01)
217             49713 => 'Tokina FiRIN 100mm F2.8 FE MACRO', # (firmware Ver.01)
218             49714 => 'Tokina atx-m 11-18mm F2.8 E', #JR
219              
220             50480 => 'Sigma 30mm F1.4 DC DN | C', #IB/JR (016)
221             50481 => 'Sigma 50mm F1.4 DG HSM | A', #JR (014 + MC-11 or 018)
222             50482 => 'Sigma 18-300mm F3.5-6.3 DC MACRO OS HSM | C + MC-11', #JR (014)
223             50483 => 'Sigma 18-35mm F1.8 DC HSM | A + MC-11', #JR (013)
224             50484 => 'Sigma 24-35mm F2 DG HSM | A + MC-11', #JR (015)
225             50485 => 'Sigma 24mm F1.4 DG HSM | A + MC-11', #JR (015)
226             50486 => 'Sigma 150-600mm F5-6.3 DG OS HSM | C + MC-11', #JR (015)
227             50487 => 'Sigma 20mm F1.4 DG HSM | A + MC-11', #JR (015)
228             50488 => 'Sigma 35mm F1.4 DG HSM | A', #JR (012 + MC-11 or 018)
229             50489 => 'Sigma 150-600mm F5-6.3 DG OS HSM | S + MC-11', #JR (014)
230             50490 => 'Sigma 120-300mm F2.8 DG OS HSM | S + MC-11', #JR (013)
231             50492 => 'Sigma 24-105mm F4 DG OS HSM | A + MC-11', #JR (013)
232             50493 => 'Sigma 17-70mm F2.8-4 DC MACRO OS HSM | C + MC-11', #JR (013)
233             50495 => 'Sigma 50-100mm F1.8 DC HSM | A + MC-11', #JR (016)
234             50499 => 'Sigma 85mm F1.4 DG HSM | A', #JR (018)
235             50501 => 'Sigma 100-400mm F5-6.3 DG OS HSM | C + MC-11', #JR (017)
236             50503 => 'Sigma 16mm F1.4 DC DN | C', #JR (017)
237             50507 => 'Sigma 105mm F1.4 DG HSM | A', #IB (018)
238             50508 => 'Sigma 56mm F1.4 DC DN | C', #JR (018)
239             50512 => 'Sigma 70-200mm F2.8 DG OS HSM | S + MC-11', #IB (018) (JR added "+ MC-11")
240             50513 => 'Sigma 70mm F2.8 DG MACRO | A', #JR (018)
241             50514 => 'Sigma 45mm F2.8 DG DN | C', #IB/JR (019)
242             50515 => 'Sigma 35mm F1.2 DG DN | A', #IB/JR (019)
243             50516 => 'Sigma 14-24mm F2.8 DG DN | A', #IB/JR (019)
244             50517 => 'Sigma 24-70mm F2.8 DG DN | A', #JR (019)
245             50518 => 'Sigma 100-400mm F5-6.3 DG DN OS | C', #JR (020)
246             50521 => 'Sigma 85mm F1.4 DG DN | A', #JR (020)
247             50522 => 'Sigma 105mm F2.8 DG DN MACRO | A', #JR (020)
248             50523 => 'Sigma 65mm F2 DG DN | C', #IB (020)
249             50524 => 'Sigma 35mm F2 DG DN | C', #IB (020)
250             50525 => 'Sigma 24mm F3.5 DG DN | C', #JR (021)
251             50526 => 'Sigma 28-70mm F2.8 DG DN | C', #JR (021)
252             50527 => 'Sigma 150-600mm F5-6.3 DG DN OS | S', #JR (021)
253             50528 => 'Sigma 35mm F1.4 DG DN | A', #IB/JR (021)
254             50529 => 'Sigma 90mm F2.8 DG DN | C', #JR (021)
255             50530 => 'Sigma 24mm F2 DG DN | C', #JR (021)
256             50531 => 'Sigma 18-50mm F2.8 DC DN | C', #IB/JR (021)
257             50532 => 'Sigma 20mm F2 DG DN | C', #JR (022)
258             50533 => 'Sigma 16-28mm F2.8 DG DN | C', #JR (022)
259             50534 => 'Sigma 20mm F1.4 DG DN | A', #JR (022)
260             50535 => 'Sigma 24mm F1.4 DG DN | A', #JR (022)
261             50536 => 'Sigma 60-600mm F4.5-6.3 DG DN OS | S', #JR (023)
262             50539 => 'Sigma 50mm F1.4 DG DN | A', #JR (023)
263              
264             50992 => 'Voigtlander SUPER WIDE-HELIAR 15mm F4.5 III', #JR
265             50993 => 'Voigtlander HELIAR-HYPER WIDE 10mm F5.6', #IB
266             50994 => 'Voigtlander ULTRA WIDE-HELIAR 12mm F5.6 III', #IB
267             50995 => 'Voigtlander MACRO APO-LANTHAR 65mm F2 Aspherical', #JR
268             50996 => 'Voigtlander NOKTON 40mm F1.2 Aspherical', #JR
269             50997 => 'Voigtlander NOKTON classic 35mm F1.4', #JR
270             50998 => 'Voigtlander MACRO APO-LANTHAR 110mm F2.5', #JR
271             50999 => 'Voigtlander COLOR-SKOPAR 21mm F3.5 Aspherical', #IB
272             51000 => 'Voigtlander NOKTON 50mm F1.2 Aspherical', #JR
273             51001 => 'Voigtlander NOKTON 21mm F1.4 Aspherical', #JR
274             51002 => 'Voigtlander APO-LANTHAR 50mm F2 Aspherical', #JR
275             51003 => 'Voigtlander NOKTON 35mm F1.2 Aspherical SE', #JR
276             51006 => 'Voigtlander APO-LANTHAR 35mm F2 Aspherical', #JR
277              
278             # lenses listed in the Sigma MC-11 list, but not yet seen:
279             # 504xx => 'Sigma 18-200mm F3.5-6.3 DC MACRO OS HSM | C + MC-11', # (014)
280             # 504xx => 'Sigma 30mm F1.4 DC HSM | A + MC-11', # (013)
281              
282             # Note: For Samyang lenses, the "FE" designation isn't written to
283             # EXIF:LensModel, so it isn't included in these strings either - JR/PH
284             51504 => 'Samyang AF 50mm F1.4', #IB
285             51505 => 'Samyang AF 14mm F2.8 or Samyang AF 35mm F2.8', #forum3833
286             51505.1 => 'Samyang AF 35mm F2.8', #PH (also 32794)
287             51507 => 'Samyang AF 35mm F1.4', #IB
288             51508 => 'Samyang AF 45mm F1.8',
289             51510 => 'Samyang AF 18mm F2.8 or Samyang AF 35mm F1.8', #JR
290             51510.1 => 'Samyang AF 35mm F1.8', #JR
291             51512 => 'Samyang AF 75mm F1.8', #IB/JR
292             51513 => 'Samyang AF 35mm F1.8', #JR
293             51514 => 'Samyang AF 24mm F1.8', #IB
294             51515 => 'Samyang AF 12mm F2.0', #JR
295             51516 => 'Samyang AF 24-70mm F2.8', #JR
296             51517 => 'Samyang AF 50mm F1.4 II', #JR
297             51518 => 'Samyang AF 135mm F1.8', #JR
298             );
299              
300             # ExposureProgram values (ref PH, mainly decoded from A200)
301             my %sonyExposureProgram = (
302             0 => 'Auto', # (same as 'Program AE'?)
303             1 => 'Manual',
304             2 => 'Program AE',
305             3 => 'Aperture-priority AE',
306             4 => 'Shutter speed priority AE',
307             8 => 'Program Shift A', #7
308             9 => 'Program Shift S', #7
309             16 => 'Portrait', # (A330)
310             17 => 'Sports', # (A330)
311             18 => 'Sunset', # (A330)
312             19 => 'Night Portrait', # (A330)
313             20 => 'Landscape', # (A330)
314             21 => 'Macro', # (A330)
315             35 => 'Auto No Flash', # (A330)
316             );
317              
318             # ExposureProgram values in CameraSettings3 (ref JR)
319             my %sonyExposureProgram2 = ( # A580 Mode Dial setting:
320             1 => 'Program AE', # P
321             2 => 'Aperture-priority AE', # A
322             3 => 'Shutter speed priority AE', # S
323             4 => 'Manual', # M
324             5 => 'Cont. Priority AE', # (A35)
325             16 => 'Auto', # AUTO
326             17 => 'Auto (no flash)', # "flash strike-out" symbol
327             18 => 'Auto+', #PH (A33)
328             49 => 'Portrait', # SCN
329             50 => 'Landscape', # SCN
330             51 => 'Macro', # SCN
331             52 => 'Sports', # SCN
332             53 => 'Sunset', # SCN
333             54 => 'Night view', # SCN
334             55 => 'Night view/portrait', # SCN
335             56 => 'Handheld Night Shot', # SCN (also called "Hand-held Twilight")
336             57 => '3D Sweep Panorama', # "Panorama" symbol
337             64 => 'Auto 2', #PH (A33 AUTO)
338             65 => 'Auto 2 (no flash)', #JR (NC, A35)
339             80 => 'Sweep Panorama', # "Panorama" symbol
340             96 => 'Anti Motion Blur', #PH (NEX-5)
341             # 128-138 are A35 picture effects (combined SCN/Picture effect mode dial position)
342             128 => 'Toy Camera',
343             129 => 'Pop Color',
344             130 => 'Posterization',
345             131 => 'Posterization B/W',
346             132 => 'Retro Photo',
347             133 => 'High-key',
348             134 => 'Partial Color Red',
349             135 => 'Partial Color Green',
350             136 => 'Partial Color Blue',
351             137 => 'Partial Color Yellow',
352             138 => 'High Contrast Monochrome',
353             );
354              
355             # ExposureProgram values in Tags 2010 and 94xx (ref JR)
356             my %sonyExposureProgram3 = (
357             0 => 'Program AE',
358             1 => 'Aperture-priority AE',
359             2 => 'Shutter speed priority AE',
360             3 => 'Manual',
361             4 => 'Auto',
362             5 => 'iAuto',
363             6 => 'Superior Auto',
364             7 => 'iAuto+',
365             8 => 'Portrait',
366             9 => 'Landscape',
367             10 => 'Twilight',
368             11 => 'Twilight Portrait',
369             12 => 'Sunset',
370             14 => 'Action (High speed)', #PH (RX100)
371             16 => 'Sports',
372             17 => 'Handheld Night Shot',
373             18 => 'Anti Motion Blur',
374             19 => 'High Sensitivity',
375             21 => 'Beach',
376             22 => 'Snow',
377             23 => 'Fireworks',
378             26 => 'Underwater',
379             27 => 'Gourmet',
380             28 => 'Pet',
381             29 => 'Macro',
382             30 => 'Backlight Correction HDR',
383             # 32 => 'Night ... ???', # seen for HDR-CX360E
384             33 => 'Sweep Panorama',
385             36 => 'Background Defocus',
386             37 => 'Soft Skin',
387             42 => '3D Image',
388             43 => 'Cont. Priority AE',
389             45 => 'Document',
390             46 => 'Party',
391             );
392              
393             # WhiteBalanceSetting values (ref JR)
394             my %whiteBalanceSetting = (
395             0x10 => 'Auto (-3)', #(NC)
396             0x11 => 'Auto (-2)', #(NC)
397             0x12 => 'Auto (-1)', #(NC)
398             0x13 => 'Auto (0)',
399             0x14 => 'Auto (+1)', #(NC)
400             0x15 => 'Auto (+2)', #(NC)
401             0x16 => 'Auto (+3)', #(NC)
402             0x20 => 'Daylight (-3)',
403             0x21 => 'Daylight (-2)', #(NC)
404             0x22 => 'Daylight (-1)', #(NC)
405             0x23 => 'Daylight (0)',
406             0x24 => 'Daylight (+1)',
407             0x25 => 'Daylight (+2)',
408             0x26 => 'Daylight (+3)',
409             0x30 => 'Shade (-3)', #(NC)
410             0x31 => 'Shade (-2)', #(NC)
411             0x32 => 'Shade (-1)', #(NC)
412             0x33 => 'Shade (0)',
413             0x34 => 'Shade (+1)', #(NC)
414             0x35 => 'Shade (+2)', #(NC)
415             0x36 => 'Shade (+3)',
416             0x40 => 'Cloudy (-3)', #(NC)
417             0x41 => 'Cloudy (-2)', #(NC)
418             0x42 => 'Cloudy (-1)', #(NC)
419             0x43 => 'Cloudy (0)',
420             0x44 => 'Cloudy (+1)', #(NC)
421             0x45 => 'Cloudy (+2)', #(NC)
422             0x46 => 'Cloudy (+3)', #(NC)
423             0x50 => 'Tungsten (-3)', #(NC)
424             0x51 => 'Tungsten (-2)', #(NC)
425             0x52 => 'Tungsten (-1)', #(NC)
426             0x53 => 'Tungsten (0)',
427             0x54 => 'Tungsten (+1)', #(NC)
428             0x55 => 'Tungsten (+2)', #(NC)
429             0x56 => 'Tungsten (+3)', #(NC)
430             0x60 => 'Fluorescent (-3)', #(NC)
431             0x61 => 'Fluorescent (-2)', #(NC)
432             0x62 => 'Fluorescent (-1)', #(NC)
433             0x63 => 'Fluorescent (0)',
434             0x64 => 'Fluorescent (+1)', #(NC)
435             0x65 => 'Fluorescent (+2)', #(NC)
436             0x66 => 'Fluorescent (+3)', #(NC)
437             0x70 => 'Flash (-3)', #(NC)
438             0x71 => 'Flash (-2)', #(NC)
439             0x72 => 'Flash (-1)', #(NC)
440             0x73 => 'Flash (0)',
441             0x74 => 'Flash (+1)', #(NC)
442             0x75 => 'Flash (+2)', #(NC)
443             0x76 => 'Flash (+3)', #(NC)
444             0xa3 => 'Custom',
445             0xf3 => 'Color Temperature/Color Filter',
446             );
447              
448             # AF points for cameras with 15-point AF (ref JR)
449             my %afPoint15 = (
450             0 => 'Upper-left',
451             1 => 'Left',
452             2 => 'Lower-left',
453             3 => 'Far Left',
454             4 => 'Top (horizontal)',
455             5 => 'Near Right',
456             6 => 'Center (horizontal)',
457             7 => 'Near Left',
458             8 => 'Bottom (horizontal)',
459             9 => 'Top (vertical)',
460             10 => 'Center (vertical)',
461             11 => 'Bottom (vertical)',
462             12 => 'Far Right',
463             13 => 'Upper-right',
464             14 => 'Right',
465             15 => 'Lower-right',
466             16 => 'Upper-middle',
467             17 => 'Lower-middle',
468             );
469              
470             # AF points for cameras with 19-point AF (ref PH)
471             # (verified for A77 firmware 1.07)
472             my %afPoint19 = (
473             0 => 'Upper Far Left',
474             1 => 'Upper-left (horizontal)',
475             2 => 'Far Left (horizontal)',
476             3 => 'Left (horizontal)',
477             4 => 'Lower Far Left',
478             5 => 'Lower-left (horizontal)',
479             6 => 'Upper-left (vertical)',
480             7 => 'Left (vertical)',
481             8 => 'Lower-left (vertical)',
482             9 => 'Far Left (vertical)',
483             10 => 'Top (horizontal)',
484             11 => 'Near Right',
485             12 => 'Center (horizontal)',
486             13 => 'Near Left',
487             14 => 'Bottom (horizontal)',
488             15 => 'Top (vertical)',
489             16 => 'Upper-middle',
490             17 => 'Center (vertical)',
491             18 => 'Lower-middle',
492             19 => 'Bottom (vertical)',
493             20 => 'Upper Far Right',
494             21 => 'Upper-right (horizontal)',
495             22 => 'Far Right (horizontal)',
496             23 => 'Right (horizontal)',
497             24 => 'Lower Far Right',
498             25 => 'Lower-right (horizontal)',
499             26 => 'Far Right (vertical)',
500             27 => 'Upper-right (vertical)',
501             28 => 'Right (vertical)',
502             29 => 'Lower-right (vertical)',
503             );
504              
505             # 79 AF point layout and indices for ILCA-68/77M2, numbered 0-78 for direct look-up from BITMASK in 0x2020,
506             # E6 = Center (ref JR)
507             my %afPoints79 = (
508             0=>'A5', 1=>'A6', 2=>'A7',
509             3=>'B2', 4=>'B3', 5=>'B4', 6=>'B5', 7=>'B6', 8=>'B7', 9=>'B8', 10=>'B9', 11=>'B10',
510             12=>'C1', 13=>'C2', 14=>'C3', 15=>'C4', 16=>'C5', 17=>'C6', 18=>'C7', 19=>'C8', 20=>'C9', 21=>'C10', 22=>'C11',
511             23=>'D1', 24=>'D2', 25=>'D3', 26=>'D4', 27=>'D5', 28=>'D6', 29=>'D7', 30=>'D8', 31=>'D9', 32=>'D10', 33=>'D11',
512             34=>'E1', 35=>'E2', 36=>'E3', 37=>'E4', 38=>'E5', 39=>'E6', 40=>'E7', 41=>'E8', 42=>'E9', 43=>'E10', 44=>'E11',
513             45=>'F1', 46=>'F2', 47=>'F3', 48=>'F4', 49=>'F5', 50=>'F6', 51=>'F7', 52=>'F8', 53=>'F9', 54=>'F10', 55=>'F11',
514             56=>'G1', 57=>'G2', 58=>'G3', 59=>'G4', 60=>'G5', 61=>'G6', 62=>'G7', 63=>'G8', 64=>'G9', 65=>'G10', 66=>'G11',
515             67=>'H2', 68=>'H3', 69=>'H4', 70=>'H5', 71=>'H6', 72=>'H7', 73=>'H8', 74=>'H9', 75=>'H10',
516             76=>'I5', 77=>'I6', 78=>'I7',
517             );
518              
519             # AFPoint and AFStatus tags in AFInfo(Tag940e) use numbers 0 to 94 for the 79 positions + 15 cross + 1 F2.8
520             my %afPoints79_940e = (
521             59=>'A5', 50=>'A6', 41=>'A7',
522             14=>'B2', 7=>'B3', 0=>'B4', 60=>'B5', 51=>'B6', 42=>'B7', 87=>'B8', 80=>'B9', 73=>'B10',
523             21=>'C1', 15=>'C2', 8=>'C3', 1=>'C4', 61=>'C5', 52=>'C6', 43=>'C7', 88=>'C8', 81=>'C9', 74=>'C10', 68=>'C11',
524             22=>'D1', 16=>'D2', 9=>'D3', 2=>'D4', 62=>'D5', 53=>'D6', 44=>'D7', 89=>'D8', 82=>'D9', 75=>'D10', 69=>'D11',
525             23=>'E1', 17=>'E2', 10=>'E3', 3=>'E4', 63=>'E5', 54=>'E6 Center', 45=>'E7', 90=>'E8', 83=>'E9', 76=>'E10', 70=>'E11',
526             24=>'F1', 18=>'F2', 11=>'F3', 4=>'F4', 64=>'F5', 55=>'F6', 46=>'F7', 91=>'F8', 84=>'F9', 77=>'F10', 71=>'F11',
527             25=>'G1', 19=>'G2', 12=>'G3', 5=>'G4', 65=>'G5', 56=>'G6', 47=>'G7', 92=>'G8', 85=>'G9', 78=>'G10', 72=>'G11',
528             20=>'H2', 13=>'H3', 6=>'H4', 66=>'H5', 57=>'H6', 48=>'H7', 93=>'H8', 86=>'H9', 79=>'H10',
529             67=>'I5', 58=>'I6', 49=>'I7',
530              
531             28=>'A5 Vertical', 27=>'A6 Vertical', 26=>'A7 Vertical',
532             31=>'C5 Vertical', 30=>'C6 Vertical', 29=>'C7 Vertical',
533             34=>'E5 Vertical', 33=>'E6 Center Vertical', 32=>'E7 Vertical',
534             37=>'G5 Vertical', 36=>'G6 Vertical', 35=>'G7 Vertical',
535             40=>'I5 Vertical', 39=>'I6 Vertical', 38=>'I7 Vertical',
536              
537             94=>'E6 Center F2.8',
538             );
539              
540             # ILCA-99M2 has dedicated 79 point Phase Detection AF sensor with similar layout as ILCA-68 and ILCA-77M2.
541             # ILCA-99M2 has also 399 Focal Plane Phase-Detection AF Points in 19 rows of 21 points, same as ILCE-7RM2.
542             # Of these 399 points, 323 points are selectable: 19 rows of 17 points (2 left-most and right-most columns not selectable).
543             # The 79 Focal Plane points that overlap with the 79 points of the dedicated sensor provide for Hybrid Phase AF Points.
544             # Tag 0x201e gives value 162 for the Center AF point, and 162 is exactly the center of 323 points...
545             # The below table lists the selectable AF points that correspond to the 79 points of the dedicated sensor. (ref JR)
546             my %afPoints99M2 = (
547             93=>'A5 (93)', 94=>'A6 (94)', 95=>'A7 (95)',
548             106=>'B2 (106)', 107=>'B3 (107)', 108=>'B4 (108)', 110=>'B5 (110)', 111=>'B6 (111)', 112=>'B7 (112)', 114=>'B8 (114)', 115=>'B9 (115)', 116=>'B10 (116)',
549             122=>'C1 (122)', 123=>'C2 (123)', 124=>'C3 (124)', 125=>'C4 (125)', 127=>'C5 (127)', 128=>'C6 (128)', 129=>'C7 (129)', 131=>'C8 (131)', 132=>'C9 (132)', 133=>'C10 (133)', 134=>'C11 (134)',
550             139=>'D1 (139)', 140=>'D2 (140)', 141=>'D3 (141)', 142=>'D4 (142)', 144=>'D5 (144)', 145=>'D6 (145)', 146=>'D7 (146)', 148=>'D8 (148)', 149=>'D9 (149)', 150=>'D10 (150)', 151=>'D11 (151)',
551             156=>'E1 (156)', 157=>'E2 (157)', 158=>'E3 (158)', 159=>'E4 (159)', 161=>'E5 (161)', 162=>'E6 (162)', 163=>'E7 (163)', 165=>'E8 (165)', 166=>'E9 (166)', 167=>'E10 (167)', 168=>'E11 (168)',
552             173=>'F1 (173)', 174=>'F2 (174)', 175=>'F3 (175)', 176=>'F4 (176)', 178=>'F5 (178)', 179=>'F6 (179)', 180=>'F7 (180)', 182=>'F8 (182)', 183=>'F9 (183)', 184=>'F10 (184)', 185=>'F11 (185)',
553             190=>'G1 (190)', 191=>'G2 (191)', 192=>'G3 (192)', 193=>'G4 (193)', 195=>'G5 (195)', 196=>'G6 (196)', 197=>'G7 (197)', 199=>'G8 (199)', 200=>'G9 (200)', 201=>'G10 (201)', 202=>'G11 (202)',
554             208=>'H2 (208)', 209=>'H3 (209)', 210=>'H4 (210)', 212=>'H5 (212)', 213=>'H6 (213)', 214=>'H7 (214)', 216=>'H8 (216)', 217=>'H9 (217)', 218=>'H10 (218)',
555             229=>'I5 (229)', 230=>'I6 (230)', 231=>'I7 (231)',
556             );
557              
558             my %binaryDataAttrs = (
559             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
560             WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
561             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
562             WRITABLE => 1,
563             FIRST_ENTRY => 0,
564             );
565              
566             # tagInfo attributes for unknown cipher block tags
567             my %unknownCipherData = (
568             Unknown => 1, # require Unknown option
569             Hidden => 1, # doesn't appear in Tag Name documentation
570             RawConv => sub { Decipher(\$_[0]); return $_[0] },
571             ValueConv => 'PrintHex($val)', # print as hex
572             PrintConv => 'length($val) > 65 ? substr($val,0,60) . "[...]" : $val', # limit length
573             );
574              
575             my %meterInfo1 = (
576             Format => 'int32u[27]',
577             PrintConv => 'sprintf("%19d %4d %6d" . " %3d %4d %6d" x 8, split(" ",$val))',
578             PrintConvInv => '$val',
579             );
580             my %meterInfo2 = (
581             Format => 'int32u[33]',
582             PrintConv => 'sprintf("%3d %4d %6d" . " %3d %4d %6d" x 10, split(" ",$val))',
583             PrintConvInv => '$val',
584             );
585             my %meterInfo1b = (
586             Format => 'undef[90]',
587             ValueConv => \&ConvMeter1,
588             PrintConv => 'sprintf("%19d %4d %6d" . " %3d %4d %6d" x 8, split(" ",$val))',
589             );
590             my %meterInfo2b = (
591             Format => 'undef[110]',
592             ValueConv => \&ConvMeter2,
593             PrintConv => 'sprintf("%3d %4d %6d" . " %3d %4d %6d" x 10, split(" ",$val))',
594             );
595              
596             my %hidUnk = ( Hidden => 1, Unknown => 1 );
597              
598             # Sony maker notes tags (some elements in common with %Image::ExifTool::Minolta::Main)
599             %Image::ExifTool::Sony::Main = (
600             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
601             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
602             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
603             NOTES => q{
604             The following information has been decoded from the MakerNotes of Sony
605             cameras. Some of these tags have been inherited from the Minolta
606             MakerNotes.
607             },
608             0x0010 => [ #PH
609             # appears to contain mostly AF related information;
610             # for SLT-A77V and newer, similar info is found in 0x940e AFInfo" (ref JR)
611             {
612             Name => 'CameraInfo',
613             # count: A700=368, A850/A900=5478
614             Condition => '$count == 368 or $count == 5478',
615             SubDirectory => {
616             TagTable => 'Image::ExifTool::Sony::CameraInfo',
617             ByteOrder => 'BigEndian',
618             },
619             },{
620             Name => 'CameraInfo2',
621             # count: A200/A300/A350=5506, A230/A290/A330/A380/A390=6118
622             Condition => '$count == 5506 or $count == 6118',
623             SubDirectory => {
624             TagTable => 'Image::ExifTool::Sony::CameraInfo2',
625             ByteOrder => 'LittleEndian',
626             },
627             },{
628             Name => 'CameraInfo3',
629             # count: A33/A35/A55V/A450/A500/A550/A560/A580/NEX3/5/5C/C3/VG10E=15360
630             Condition => '$count == 15360',
631             SubDirectory => {
632             TagTable => 'Image::ExifTool::Sony::CameraInfo3',
633             ByteOrder => 'LittleEndian',
634             },
635             },{
636             Name => 'CameraInfoUnknown',
637             SubDirectory => { TagTable => 'Image::ExifTool::Sony::CameraInfoUnknown' },
638             },
639             ],
640             # 0x0018 - starts with "GYRO" for sweep panorama images (ref JR)
641             # - contains ImageStabilization information for Minolta
642             0x0020 => [
643             # similar to WBInfoA100 in Minolta.pm.
644             # appears to contain various types of information, as in MoreInfo. (ref JR)
645             {
646             Name => 'FocusInfo', #PH
647             # count: A200/A230/A290/A300/A330/A350/A380/A390==19154, A700/A850/A900=19148
648             Condition => '$count == 19154 or $count == 19148',
649             SubDirectory => {
650             TagTable => 'Image::ExifTool::Sony::FocusInfo',
651             ByteOrder => 'LittleEndian',
652             },
653             },{
654             Name => 'MoreInfo', #JR
655             # count: A450/A500/A550/A560/A580/A33/A35/A55/NEX-3/5/C3/VG10E==20480
656             SubDirectory => {
657             TagTable => 'Image::ExifTool::Sony::MoreInfo',
658             ByteOrder => 'LittleEndian',
659             },
660             },
661             ],
662             0x0102 => { #5/JD
663             Name => 'Quality',
664             Writable => 'int32u',
665             PrintConv => {
666             0 => 'RAW',
667             1 => 'Super Fine',
668             2 => 'Fine',
669             3 => 'Standard',
670             4 => 'Economy',
671             5 => 'Extra Fine',
672             6 => 'RAW + JPEG/HEIF',
673             7 => 'Compressed RAW',
674             8 => 'Compressed RAW + JPEG',
675             9 => 'Light', #JR
676             0xffffffff => 'n/a', #PH (SLT-A57 panorama)
677             },
678             },
679             0x0104 => { #5/JD
680             Name => 'FlashExposureComp',
681             Description => 'Flash Exposure Compensation',
682             Writable => 'rational64s',
683             },
684             0x0105 => { #5/JD (models since mid-2014, ILCA-77M2, ILCE-7M2/7RM2/7SM2, do not report this tag anymore, ref JR)
685             Name => 'Teleconverter',
686             Writable => 'int32u',
687             PrintHex => 1,
688             PrintConv => \%Image::ExifTool::Minolta::minoltaTeleconverters,
689             },
690             0x0112 => { #JD
691             Name => 'WhiteBalanceFineTune',
692             Format => 'int32s',
693             Writable => 'int32u',
694             },
695             0x0114 => [ #PH
696             {
697             Name => 'CameraSettings',
698             # count: A200/A300/A350/A700=280, A850/A900=364
699             Condition => '$count == 280 or $count == 364',
700             SubDirectory => {
701             TagTable => 'Image::ExifTool::Sony::CameraSettings',
702             ByteOrder => 'BigEndian',
703             },
704             },{
705             Name => 'CameraSettings2',
706             # count: A230/A290/A330/A380/A390=332
707             Condition => '$count == 332',
708             SubDirectory => {
709             TagTable => 'Image::ExifTool::Sony::CameraSettings2',
710             ByteOrder => 'BigEndian',
711             },
712             },{
713             Name => 'CameraSettings3',
714             # count: A560/A580/A33/A35/A55/NEX3/5/5C/C3/VG10E=1536, A450/A500/A550=2048
715             Condition => '$count == 1536 || $count == 2048',
716             SubDirectory => {
717             TagTable => 'Image::ExifTool::Sony::CameraSettings3',
718             ByteOrder => 'LittleEndian',
719             },
720             },{
721             Name => 'CameraSettingsUnknown',
722             SubDirectory => {
723             TagTable => 'Image::ExifTool::Sony::CameraSettingsUnknown',
724             ByteOrder => 'BigEndian',
725             },
726             },
727             ],
728             0x0115 => { #JD
729             Name => 'WhiteBalance',
730             Writable => 'int32u',
731             Priority => 2, # (more reliable for the RX100)
732             PrintHex => 1,
733             PrintConv => {
734             0x00 => 'Auto',
735             0x01 => 'Color Temperature/Color Filter',
736             0x10 => 'Daylight',
737             0x20 => 'Cloudy',
738             0x30 => 'Shade',
739             0x40 => 'Tungsten',
740             0x50 => 'Flash',
741             0x60 => 'Fluorescent',
742             0x70 => 'Custom',
743             0x80 => 'Underwater',
744             },
745             },
746             # Tag 0x0116: extra hardware info (ref JR)
747             # (tag not present for A100, A200, A300, A350, A700, nor for A37, A57, A65, A77)
748             0x0116 => [ #JR
749             {
750             Name => 'ExtraInfo',
751             Condition => '$$self{Model} =~ /^DSLR-A(850|900)\b/',
752             SubDirectory => {
753             TagTable => 'Image::ExifTool::Sony::ExtraInfo',
754             ByteOrder => 'BigEndian',
755             },
756             },{
757             Name => 'ExtraInfo2',
758             Condition => '$$self{Model} =~ /^DSLR-A(230|290|330|380|390)\b/',
759             SubDirectory => { TagTable => 'Image::ExifTool::Sony::ExtraInfo2' },
760             },{
761             Name => 'ExtraInfo3',
762             # for DSLR-A450/500/550/560/580, SLT-A33/35/55 and NEX-3/5/5C.
763             SubDirectory => { TagTable => 'Image::ExifTool::Sony::ExtraInfo3' },
764             }
765             ],
766             0x0e00 => {
767             Name => 'PrintIM',
768             Description => 'Print Image Matching',
769             SubDirectory => { TagTable => 'Image::ExifTool::PrintIM::Main' },
770             },
771             # the next 3 tags have a different meaning for some models (with format int32u)
772             0x1000 => { #9 (F88, multi burst mode only)
773             Name => 'MultiBurstMode',
774             Condition => '$format eq "undef"',
775             Notes => 'MultiBurst tags valid only for models with this feature, like the F88',
776             Writable => 'undef',
777             Format => 'int8u',
778             PrintConv => { 0 => 'Off', 1 => 'On' },
779             },
780             0x1001 => { #9 (F88, multi burst mode only)
781             Name => 'MultiBurstImageWidth',
782             Condition => '$format eq "int16u"',
783             Writable => 'int16u',
784             },
785             0x1002 => { #9 (F88, multi burst mode only)
786             Name => 'MultiBurstImageHeight',
787             Condition => '$format eq "int16u"',
788             Writable => 'int16u',
789             },
790             0x1003 => { #9 (64 bytes, contains Panorama info for various DSC, NEX, SLT and DSLR models)
791             Name => 'Panorama',
792             # panorama: first 4 bytes '1 1 0 0' (little-endian) or '0 0 1 1' (big-endian)
793             # non-panorama: all bytes are '0' (ref JR)
794             Condition => '$$self{Panorama} = ($$valPt =~ /^(\0\0)?\x01\x01/)', # (little- or big-endian int32u = 257)
795             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Panorama' },
796             },
797             # 0x2000 - undef[1]
798             0x2001 => { #PH (JPEG images from all DSLR's except the A100)
799             Name => 'PreviewImage',
800             Groups => { 2 => 'Preview' },
801             Writable => 'undef',
802             DataTag => 'PreviewImage',
803             Notes => 'HD-size preview in JPEG images from almost all DSLR/SLT/ILCA/NEX/ILCE.',
804             # Note: the preview data starts with a 32-byte proprietary Sony header
805             # first 8 bytes after 32-byte header:
806             # \x00\xd8\xff\xe1\x00\x27\xff\xff for JPEG files from A33/35/55V/450/500/550/560/580, NEX-3/5/5C/C3/VG10
807             # \x00\xd8\xff\xdb\x00\x84\x00\x01 for JPEG files from all other models
808             # ( \xff\xd8\xff\xdb\x00\x84\x00\x01 corresponding bytes for all ARW files )
809             #
810             # DSLR-A700/A850/A900 and DSLR-A200/A300/A350:
811             # - no MPImage2
812             # DSLR-A230/A290/A330/A380/A390:
813             # - PreviewImage start-offset is at 110 bytes inside MPImage2
814             # DSLR-A450/A500/A550/A560/A580, SLT-A33/A35/A55V, NEX-3/5/5C/C3/VG10/VG10E:
815             # - PreviewImage start-offset is at 106 bytes inside MPImage2
816             # - different first bytes after 32-byte header
817             # SLT-A37/A57/A58/A65V/A77V/A99V, ILCA-77M2, NEX-3N/5N/5R/5T/6/7/F3, ILCE-3000/3500/5000/6000/7/7R/7S:
818             # - PreviewImage start-offset is at 130 bytes inside MPImage2
819             # NEX-VG20E/VG30E/VG900, ILCE-QX1: 0x2001 not present
820             # ILCE-5100/ILCE-7M2/7RM2/7SM2 : 0x2001 present but Size 0 and Offset 0
821             #
822             WriteCheck => 'return $val=~/^(none|.{32}\xff\xd8\xff)/s ? undef : "Not a valid image"',
823             RawConv => q{
824             return \$val if $val =~ /^Binary/;
825             $val = substr($val,0x20) if length($val) > 0x20;
826             # return \$val if $val =~ s/^.(\xd8\xff\xdb)/\xff$1/s;
827             return \$val if $val =~ s/^.(\xd8\xff[\xdb\xe1])/\xff$1/s;
828             $$self{PreviewError} = 1 unless $val eq 'none' or $val eq '';
829             return undef;
830             },
831             # must construct 0x20-byte header which contains length, width and height
832             ValueConvInv => q{
833             return 'none' unless $val;
834             my $e = new Image::ExifTool;
835             my $info = $e->ImageInfo(\$val,'ImageWidth','ImageHeight');
836             return undef unless $$info{ImageWidth} and $$info{ImageHeight};
837             my $size = Set32u($$info{ImageWidth}) . Set32u($$info{ImageHeight});
838             return Set32u(length $val) . $size . ("\0" x 8) . $size . ("\0" x 4) . $val;
839             },
840             },
841             0x2002 => { #JR (written by Sony IDC)
842             Name => 'Rating',
843             Writable => 'int32u', # (0-5 stars) (4294967295 for an HX9V iSweep Panorama, ref JR)
844             },
845             # 0x2003 - string[256]: all 0 for DSLR, SLT, NEX; data for DSC-HX9V
846             0x2004 => { #PH (NEX-5)
847             Name => 'Contrast',
848             Writable => 'int32s',
849             PrintConv => '$val > 0 ? "+$val" : $val',
850             PrintConvInv => '$val',
851             },
852             0x2005 => { #PH (NEX-5)
853             Name => 'Saturation',
854             Writable => 'int32s',
855             PrintConv => '$val > 0 ? "+$val" : $val',
856             PrintConvInv => '$val',
857             },
858             0x2006 => { #PH
859             Name => 'Sharpness',
860             Writable => 'int32s',
861             PrintConv => '$val > 0 ? "+$val" : $val',
862             PrintConvInv => '$val',
863             },
864             0x2007 => { #PH
865             Name => 'Brightness',
866             Writable => 'int32s',
867             PrintConv => '$val > 0 ? "+$val" : $val',
868             PrintConvInv => '$val',
869             },
870             0x2008 => { #PH
871             Name => 'LongExposureNoiseReduction',
872             Writable => 'int32u',
873             PrintHex => 1,
874             PrintConv => {
875             0 => 'Off',
876             1 => 'On (unused)',
877             0x10001 => 'On (dark subtracted)', # (NEX-C3)
878             0xffff0000 => 'Off (65535)',
879             0xffff0001 => 'On (65535)',
880             0xffffffff => 'n/a',
881             },
882             },
883             0x2009 => { #PH
884             Name => 'HighISONoiseReduction',
885             Writable => 'int16u',
886             PrintConv => {
887             0 => 'Off',
888             1 => 'Low',
889             2 => 'Normal',
890             3 => 'High',
891             256 => 'Auto',
892             # it seems that all DSC models except DSC-RX models give n/a here (ref JR)
893             65535 => 'n/a',
894             },
895             },
896             0x200a => { #PH (A550)
897             Name => 'HDR',
898             Writable => 'int32u',
899             Format => 'int16u',
900             Count => 2,
901             Notes => 'stored as a 32-bit integer, but read as two 16-bit integers',
902             PrintHex => 1,
903             PrintConv => [{
904             0x0 => 'Off',
905             0x01 => 'Auto',
906             0x10 => '1.0 EV',
907             0x11 => '1.5 EV',
908             0x12 => '2.0 EV',
909             0x13 => '2.5 EV',
910             0x14 => '3.0 EV',
911             0x15 => '3.5 EV',
912             0x16 => '4.0 EV',
913             0x17 => '4.5 EV',
914             0x18 => '5.0 EV',
915             0x19 => '5.5 EV',
916             0x1a => '6.0 EV',
917             },{ #JR (A580)
918             0 => 'Uncorrected image', # A580 stores 2 images: uncorrected and HDR
919             1 => 'HDR image (good)',
920             2 => 'HDR image (fail 1)', # alignment problem?
921             3 => 'HDR image (fail 2)', # contrast problem?
922             }],
923             },
924             0x200b => { #PH
925             Name => 'MultiFrameNoiseReduction',
926             Writable => 'int32u',
927             Notes => 'may not be valid for RS100', # (RS100 sample was 0 when this feature was turned on)
928             PrintConv => {
929             0 => 'Off',
930             1 => 'On',
931             255 => 'n/a',
932             },
933             },
934             # 0x200c - int32u[3]: '0 0 0'; seen '2 1 0' for HX9V 3D-Image (in both JPG and MPO image)
935             # 0x200d - rational64u: 10/10, seen 2.5 for DSC-TX300V, 8 for DSC-HX100V/RX10
936             0x200e => { #PH (HX20V)
937             Name => 'PictureEffect',
938             Writable => 'int16u',
939             PrintConv => {
940             0 => 'Off',
941             1 => 'Toy Camera', #JR (A35)
942             2 => 'Pop Color', # (also A35/NEX-C3, ref JR)
943             3 => 'Posterization', #JR (A35)
944             4 => 'Posterization B/W', #JR (A35)
945             5 => 'Retro Photo', #JR (A35, NEX-5)
946             6 => 'Soft High Key', # (also A65V, A35/NEX-C3 call this "High-key", ref JR)
947             7 => 'Partial Color (red)', #JR (A35)
948             8 => 'Partial Color (green)', #JR (A35, NEX-5)
949             9 => 'Partial Color (blue)', #JR (A35)
950             10 => 'Partial Color (yellow)', #JR (A35, NEX-5)
951             13 => 'High Contrast Monochrome', #JR (A35)
952             16 => 'Toy Camera (normal)', # (also A65, ref JR)
953             17 => 'Toy Camera (cool)', # (RX100)
954             18 => 'Toy Camera (warm)', # (RX100)
955             19 => 'Toy Camera (green)', # (RX100)
956             20 => 'Toy Camera (magenta)', # (RX100)
957             32 => 'Soft Focus (low)', #JR (RX100)
958             33 => 'Soft Focus', #JR (A65V)
959             34 => 'Soft Focus (high)', # (RX100)
960             48 => 'Miniature (auto)', #JR (A65V/NEX-7, horizontal)
961             49 => 'Miniature (top)', # (RX100)
962             50 => 'Miniature (middle horizontal)', # (WX100/HX20V, horizontal)
963             51 => 'Miniature (bottom)', # (WX100, rotate 90 CW)
964             52 => 'Miniature (left)', # (RX100)
965             53 => 'Miniature (middle vertical)', # (RX100)
966             54 => 'Miniature (right)', # (RX100)
967             64 => 'HDR Painting (low)', # (RX100)
968             65 => 'HDR Painting', # (also A65V, ref JR)
969             66 => 'HDR Painting (high)', # (RX100)
970             80 => 'Rich-tone Monochrome', # (also A65V, ref JR)
971             97 => 'Water Color', # (HX200V)
972             98 => 'Water Color 2',
973             112 => 'Illustration (low)', # (RX100)
974             113 => 'Illustration', # (RX100)
975             114 => 'Illustration (high)', # (RX100)
976             },
977             },
978             0x200f => { #PH (RX100)
979             Name => 'SoftSkinEffect',
980             Writable => 'int32u',
981             PrintConv => {
982             0 => 'Off',
983             1 => 'Low',
984             2 => 'Mid',
985             3 => 'High',
986             # 0x10001 - seen (ref JR)
987             # 0x10002 - seen for landscape and portrait flash (ref JR)
988             # 0x10003 - seen (ref JR)
989             0xffffffff => 'n/a', # (A35)
990             },
991             },
992             0x2010 => [ #JR
993             # different camera models have similar content but at different offsets, appears to correlate with:
994             # 0x1206 - 0x1207 deciphered (0x1205 changes with firmware version):
995             # ad c3 - NEX-5N
996             # 0x0192 - 0x0193 deciphered (0x0191 changes with firmware version):
997             # 91 c3 - NEX-VG20E
998             # 93 c3 - NEX-7, SLT-A65V/A77V
999             # 94 c3 - Hasselblad Lunar
1000             # 0x0012 - 0x0013 deciphered (0x0011 changes with firmware version):
1001             # 94 c3 - SLT-A37/A57, NEX-F3
1002             # 95 d3 - DSC-WX50, WX70
1003             # 98 c3 - DSC-HX200V, HX20V, HX30V, TX200V, TX300V
1004             # 98 d3 - DSC-HX10V, TX66, WX100, WX150
1005             # 9a c3 - DSC-RX1, RX1R
1006             # 9b c3 - SLT-A99V, Hasselblad HV
1007             # 9c c3 - NEX-VG30E
1008             # 9d c3 - DSC-RX100, Hasselblad Stellar
1009             # 9e c3 - NEX-VG900, SLT-A58
1010             # a1 d3 - DSC-TX30
1011             # a2 d3 - DSC-WX60, WX80, WX200, WX300
1012             # a3 c3 - NEX-6, DSC-HX300, HX50V
1013             # a4 c3 - NEX-3N/5R/5T, ILCE-3000/3500
1014             # unknown offsets or values for DSC-TX20/TX55/WX30
1015             # unknown offsets or values for DSC-HX60V/HX350/HX400V/QX10/QX30/QX100/RX10/RX100M2/RX100M3/WX220/WX350,
1016             # ILCA-68/77M2, ILCE-5000/5100/6000/7/7M2/7R/7S/QX1, Stellar2, Lusso
1017             # unknown offsets or values for DSC-HX80/HX90V/RX0/RX1RM2/RX10M2/RX10M3/RX100M4/RX100M5/WX500, ILCE-6300/6500/7RM2/7SM2, ILCA-99M2
1018             # unknown offsets or values for ILCE-6100/6400/6600/7C/7M3/7RM3/7RM4/9/9M2, DSC-RX0M2/RX10M4/RX100M6/RX100M5A/RX100M7/HX99
1019             # July 2020: ILCE-7SM3 doesn't write this tag anymore
1020             {
1021             Name => 'Tag2010a', # ad
1022             Condition => '$$self{Model} =~ /^NEX-5N$/',
1023             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag2010a' },
1024             },{
1025             Name => 'Tag2010b', # 91, 93
1026             Condition => '$$self{Model} =~ /^(SLT-A(65|77)V?|NEX-(7|VG20E)|Lunar)$/',
1027             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag2010b' },
1028             },{
1029             Name => 'Tag2010c', # 94
1030             Condition => '$$self{Model} =~ /^(SLT-A(37|57)|NEX-F3)$/',
1031             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag2010c' },
1032             },{
1033             Name => 'Tag2010d', # 95, 98
1034             Condition => q{
1035             $$self{Model} =~ /^(DSC-(HX10V|HX20V|HX30V|HX200V|TX66|TX200V|TX300V|WX50|WX70|WX100|WX150))$/ and
1036             not $$self{Panorama}
1037             },
1038             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag2010d' },
1039             },{
1040             Name => 'Tag2010e', # 9a, 9b, 9c, 9d, 9e, a1, a2, a3, a4
1041             Condition => q{
1042             $$self{Model} =~ /^(SLT-A99V?|HV|SLT-A58|ILCE-(3000|3500)|NEX-(3N|5R|5T|6|VG900|VG30E)|DSC-(RX100|RX1|RX1R)|Stellar)$/ or
1043             ($$self{Model} =~ /^(DSC-(HX300|HX50|HX50V|TX30|WX60|WX80|WX200|WX300))$/ and not $$self{Panorama})
1044             },
1045             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag2010e' },
1046             },{
1047             Name => 'Tag2010f', # ?
1048             Condition => '$$self{Model} =~ /^(DSC-(RX100M2|QX10|QX100))$/',
1049             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag2010f' },
1050             },{
1051             Name => 'Tag2010g', # ?
1052             Condition => '$$self{Model} =~ /^(DSC-(QX30|RX10|RX100M3|HX60V|HX350|HX400V|WX220|WX350)|ILCE-(7(R|S|M2)?|[56]000|5100|QX1)|ILCA-(68|77M2))\b/',
1053             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag2010g' },
1054             },{
1055             Name => 'Tag2010h', # ?
1056             Condition => '$$self{Model} =~ /^(DSC-(RX0|RX1RM2|RX10M2|RX10M3|RX100M4|RX100M5|HX80|HX90V?|WX500)|ILCE-(6300|6500|7RM2|7SM2)|ILCA-99M2)\b/',
1057             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag2010h' },
1058             },{
1059             Name => 'Tag2010i', # ?
1060             Condition => '$$self{Model} =~ /^(ILCE-(6100|6400|6600|7C|7M3|7RM3A?|7RM4A?|9|9M2)|DSC-(RX10M4|RX100M6|RX100M5A|RX100M7|HX99|RX0M2)|ZV-(1F?|E10))\b/',
1061             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag2010i' },
1062             },{
1063             Name => 'Tag_0x2010',
1064             %unknownCipherData,
1065             }],
1066             0x2011 => { #PH (A77, NEX-5N)
1067             Name => 'VignettingCorrection',
1068             Writable => 'int32u',
1069             PrintConv => {
1070             0 => 'Off',
1071             2 => 'Auto',
1072             0xffffffff => 'n/a', # (RX100)
1073             },
1074             },
1075             0x2012 => { #PH (A77, NEX-5N)
1076             Name => 'LateralChromaticAberration',
1077             Writable => 'int32u',
1078             PrintConv => {
1079             0 => 'Off',
1080             2 => 'Auto',
1081             0xffffffff => 'n/a', # (RX100)
1082             },
1083             },
1084             0x2013 => { #PH (A77, NEX-5N) ("Setting"; application of such correction is indicated in Tag9405 - ref JR)
1085             Name => 'DistortionCorrectionSetting',
1086             Writable => 'int32u',
1087             PrintConv => {
1088             0 => 'Off',
1089             2 => 'Auto',
1090             0xffffffff => 'n/a', # (RX100)
1091             },
1092             },
1093             0x2014 => { #JR/9
1094             Name => 'WBShiftAB_GM',
1095             Writable => 'int32s',
1096             Count => 2,
1097             Notes => q{
1098             2 numbers: 1. positive is a shift toward amber, 2. positive is a shift
1099             toward magenta
1100             },
1101             },
1102             # 0x2015 - int16u: 65535, also for 'normal' HDR images; 0 for HDR-paint and Rich-tone Monochrome effect images
1103             0x2016 => { #PH (RX100)
1104             Name => 'AutoPortraitFramed',
1105             Writable => 'int16u',
1106             Notes => '"Yes" if this image was created by the Auto Portrait Framing feature',
1107             PrintConv => { 0 => 'No', 1 => 'Yes' },
1108             },
1109             # 0x2017 - int32u: flash mode. 0=off, 1=fired, 2=red-eye (PH, NEX-6) (also in A99, RX1, NEX-5R)
1110             0x2017 => { #JR
1111             Name => 'FlashAction',
1112             Writable => 'int32u',
1113             PrintConv => {
1114             0 => 'Did not fire',
1115             1 => 'Flash Fired',
1116             2 => 'External Flash Fired',
1117             3 => 'Wireless Controlled Flash Fired', # (NC) seen for ILCE-9 and ILCE-7M3 images
1118             # 5 => 'External Flash ???', # seen for ILCE-7RM4
1119             },
1120             },
1121             # 0x2018 - something with external flash: seen 1 only when 0x2017 = 2
1122             # 0x2019 - 0 or 1 (seen 1 for ILCA-77M2, ILCE-7M2/7RM2)
1123             # 0x201a - 0 or 1
1124             0x201a => { #JR
1125             Name => 'ElectronicFrontCurtainShutter',
1126             Writable => 'int32u',
1127             PrintConv => {
1128             0 => 'Off',
1129             1 => 'On',
1130             },
1131             },
1132             0x201b => { #PH
1133             # FocusMode for SLT/HV/ILCA and NEX/ILCE; doesn't seem to apply to DSC models (always 0)
1134             # from 2018: at least DSC-RX10M4 and RX100M6 also use this tag
1135             Name => 'FocusMode',
1136             Condition => '($$self{Model} !~ /^DSC-/) or ($$self{Model} =~ /^DSC-(RX10M4|RX100M6|RX100M7|RX100M5A|HX99|RX0M2)/)',
1137             Writable => 'int8u',
1138             Priority => 0,
1139             PrintConv => {
1140             0 => 'Manual',
1141             2 => 'AF-S',
1142             3 => 'AF-C',
1143             4 => 'AF-A',
1144             6 => 'DMF', # "Direct Manual Focus"
1145             7 => 'AF-D', # "Depth Map Assist Continuous AF"
1146             },
1147             },
1148             0x201c => [ #JR
1149             # AFAreaModeSetting for SLT/HV/ILCA and NEX/ILCE; doesn't seem to apply to DSC models (always 0)
1150             # from 2018: at least DSC-RX10M4 and RX100M6 also use this tag
1151             # all DSLR/SLT/HV Wide Zone Spot Local
1152             # all NEX and ILCE-3000 Multi Center FlexibleSpot
1153             # all ILCE and ILCA Wide Zone Center FlexibleSpot ExpandedFlexibleSpot
1154             # (actual AFAreaMode used may be different as camera can override this under certain conditions)
1155             {
1156             Name => 'AFAreaModeSetting',
1157             Condition => '$$self{Model} =~ /^(SLT-|HV)/',
1158             Notes => 'SLT models',
1159             Writable => 'int8u',
1160             PrintConv => {
1161             0 => 'Wide',
1162             4 => 'Local',
1163             8 => 'Zone', #PH
1164             9 => 'Spot',
1165             },
1166             },{
1167             Name => 'AFAreaModeSetting',
1168             Condition => '$$self{Model} =~ /^(NEX-|ILCE-|ILME-|DSC-(RX10M4|RX100M6|RX100M7|RX100M5A|HX99|RX0M2))/',
1169             Notes => 'NEX, ILCE and some DSC models',
1170             RawConv => '$$self{AFAreaILCE} = $val',
1171             DataMember => 'AFAreaILCE',
1172             Writable => 'int8u',
1173             PrintConv => {
1174             0 => 'Wide', # all NEX and ILCE-3000/3500 use the name 'Multi'
1175             1 => 'Center',
1176             3 => 'Flexible Spot',
1177             4 => 'Flexible Spot (LA-EA4)', # seen for ILCE-7RM2 with LA-EA4
1178             9 => 'Center (LA-EA4)', # seen for ILCE-7RM2 with LA-EA4
1179             11 => 'Zone',
1180             12 => 'Expanded Flexible Spot',
1181             },
1182             },{
1183             Name => 'AFAreaModeSetting',
1184             Condition => '$$self{Model} =~ /^ILCA-/',
1185             Notes => 'ILCA models',
1186             RawConv => '$$self{AFAreaILCA} = $val',
1187             DataMember => 'AFAreaILCA',
1188             Writable => 'int8u',
1189             PrintConv => {
1190             0 => 'Wide',
1191             4 => 'Flexible Spot',
1192             8 => 'Zone',
1193             9 => 'Center',
1194             12 => 'Expanded Flexible Spot',
1195             },
1196             },
1197             ],
1198             0x201d => { #JR
1199             # Flexible Spot position for NEX/ILCE, non-zero only when AFAreaMode='Flexible Spot'
1200             # from 2018: at least DSC-RX10M4 and RX100M6 also use this tag
1201             # observed values in range (0 0) to (640 480), with center (320 240) often seen
1202             # for NEX-5R/6, positions appear to be in an 11x9 grid
1203             Name => 'FlexibleSpotPosition',
1204             Condition => '$$self{Model} =~ /^(NEX-|ILCE-|ILME-|DSC-(RX10M4|RX100M6|RX100M7|RX100M5A|HX99|RX0M2))/',
1205             Writable => 'int16u',
1206             Count => 2,
1207             Notes => q{
1208             X and Y coordinates of the AF point, valid only when AFAreaMode is Flexible
1209             Spot
1210             },
1211             },
1212             0x201e => [{ #PH (A99)
1213             # Selected AF Point for SLT/HV/ILCA or ILCE with LA-EA2/EA4
1214             # Selected AF Zone for NEX/ILCE/ILCA when AFAreaMode = 'Zone',
1215             # but also with Expanded Flexible Spot for ILCE-7RM2/7SM2/9 ...
1216             # doesn't seem to apply to DSC models (always 0)
1217             Name => 'AFPointSelected',
1218             Condition => q{
1219             ($$self{Model} =~ /^(SLT-|HV)/) or ($$self{Model} =~ /^(ILCE-|ILME-)/ and
1220             defined $$self{AFAreaILCE} and $$self{AFAreaILCE} == 4)
1221             },
1222             Notes => 'SLT models or ILCE with LA-EA2/EA4',
1223             Writable => 'int8u',
1224             PrintConvColumns => 2,
1225             PrintConv => {
1226             0 => 'Auto', #(NC)
1227             1 => 'Center',
1228             2 => 'Top',
1229             3 => 'Upper-right',
1230             4 => 'Right',
1231             5 => 'Lower-right',
1232             6 => 'Bottom',
1233             7 => 'Lower-left',
1234             8 => 'Left',
1235             9 => 'Upper-left',
1236             10 => 'Far Right',
1237             11 => 'Far Left',
1238             12 => 'Upper-middle',
1239             13 => 'Near Right',
1240             14 => 'Lower-middle',
1241             15 => 'Near Left',
1242             16 => 'Upper Far Right',
1243             17 => 'Lower Far Right',
1244             18 => 'Lower Far Left',
1245             19 => 'Upper Far Left',
1246             },
1247             },{
1248             Name => 'AFPointSelected',
1249             Condition => '$$self{Model} =~ /^ILCA-(68|77M2)/ and defined $$self{AFAreaILCA} and $$self{AFAreaILCA} != 8',
1250             Notes => 'ILCA-68 and ILCA-77M2',
1251             Writable => 'int8u',
1252             ValueConv => '$val - 1', # to get the same numbers as from the BITMASK in 0x2020
1253             ValueConvInv => '$val + 1',
1254             PrintConvColumns => 5,
1255             PrintConv => {
1256             -1 => 'Auto',
1257             %afPoints79,
1258             39 => 'E6 (Center)', # (add " (Center)" to central point)
1259             },
1260             },{
1261             Name => 'AFPointSelected',
1262             Condition => '($$self{Model} =~ /^ILCA-99M2/ and defined $$self{AFAreaILCA} and $$self{AFAreaILCA} != 8)',
1263             Notes => 'ILCA-99M2 when AFAreaModeSetting is not Zone',
1264             # (appears to indicate the number of the selectable Focal Plane AF Point)
1265             Writable => 'int8u',
1266             PrintConvColumns => 4,
1267             PrintConv => {
1268             0 => 'Auto', # seen for AFAreaModeSetting = Center, Wide
1269             %afPoints99M2, # for selected AFPoints corresponding to the 79 dedicated AF points
1270             162 => 'E6 (162, Center)', # add " (Center)" to central point
1271             OTHER => sub { shift }, # pass other values straight through
1272             },
1273             },{
1274             Name => 'AFPointSelected',
1275             Condition => '($$self{Model} =~ /^ILCA-/ and defined $$self{AFAreaILCA} and $$self{AFAreaILCA} == 8)',
1276             Notes => 'ILCA models when AFAreaModeSetting is set to Zone',
1277             # ILCA-68 and 77M2 have 9 Zones: numbers/locations verified for ILCA-77M2
1278             # ILCA-99M2 has 15 Zones in Hybrid-AF and 9 Zones in dedicated Phase AF Area, so may not be valid for ILCA-99M2...
1279             Writable => 'int8u',
1280             PrintConv => {
1281             0 => 'n/a',
1282             1 => 'Top Left Zone',
1283             2 => 'Top Zone',
1284             3 => 'Top Right Zone',
1285             4 => 'Left Zone',
1286             5 => 'Center Zone',
1287             6 => 'Right Zone',
1288             7 => 'Bottom Left Zone',
1289             8 => 'Bottom Zone',
1290             9 => 'Bottom Right Zone',
1291             #14 => ' ??? ', # seen for ILCA-99M2
1292             },
1293             },{
1294             Name => 'AFPointSelected',
1295             # non-zero only when AFAreaMode is 'Zone', and 'Expanded-Flexible-Spot' for ILCE-6300/7RM2/7SM2
1296             # each Zone has 3x3 AF Areas --> 9 positions within 5x5 total Contrast AF Areas
1297             Condition => '$$self{Model} =~ /^(NEX-|ILCE-|ILME-)/',
1298             Notes => 'NEX and ILCE models',
1299             Writable => 'int8u',
1300             PrintConv => {
1301             0 => 'n/a',
1302             1 => 'Center Zone',
1303             2 => 'Top Zone',
1304             3 => 'Right Zone',
1305             4 => 'Left Zone',
1306             5 => 'Bottom Zone',
1307             6 => 'Bottom Right Zone',
1308             7 => 'Bottom Left Zone',
1309             8 => 'Top Left Zone',
1310             9 => 'Top Right Zone',
1311             },
1312             }],
1313             # 0x201f - 0 0 0 0 for SLT and DSC; 4 values for NEX/ILCE with 4th value always 0:
1314             # possibly bits relating to the 25 AF-Contrast-areas ???
1315             # 0x2020 - 10 values; for SLT/ILCA and NEX/ILCE with A-mount lens: relates to (phase-detect) AFPoints
1316             # but not used by ILCA-99M2 anymore ... ?
1317             0x2020 => [{
1318             Name => 'AFPointsUsed',
1319             Condition => '$$self{Model} !~ /^(ILCA-|DSC-)/', # (doesn't seem to apply to DSC-models)
1320             Notes => 'SLT models, or NEX/ILCE with A-mount lenses',
1321             BitsPerWord => 8,
1322             BitsTotal => 80,
1323             PrintConvColumns => 2,
1324             PrintConv => {
1325             0 => '(none)',
1326             BITMASK => {
1327             0 => 'Center',
1328             1 => 'Top',
1329             2 => 'Upper-right',
1330             3 => 'Right',
1331             4 => 'Lower-right',
1332             5 => 'Bottom',
1333             6 => 'Lower-left',
1334             7 => 'Left',
1335             8 => 'Upper-left',
1336             9 => 'Far Right',
1337             10 => 'Far Left',
1338             11 => 'Upper-middle',
1339             12 => 'Near Right',
1340             13 => 'Lower-middle',
1341             14 => 'Near Left',
1342             15 => 'Upper Far Right',
1343             16 => 'Lower Far Right',
1344             17 => 'Lower Far Left',
1345             18 => 'Upper Far Left',
1346             },
1347             },
1348             },{
1349             Name => 'AFPointsUsed',
1350             Condition => '$$self{Model} =~ /^ILCA-(68|77M2)/',
1351             Notes => 'ILCA models',
1352             BitsPerWord => 8,
1353             BitsTotal => 80,
1354             PrintConvColumns => 4,
1355             PrintConv => {
1356             0 => '(none)',
1357             BITMASK => { %afPoints79 },
1358             },
1359             }],
1360             # 0x2021 - 0 for DSC; 0, 1 or 2 for SLT/ILCA and NEX/ILCE: 1=Face, 2=object-tracking ?
1361             # from 2018: at least DSC-RX10M4 and RX100M6 also use this tag
1362             0x2021 => { #JR
1363             Name => 'AFTracking',
1364             Condition => '($$self{Model} !~ /^DSC-/) or ($$self{Model} =~ /^DSC-(RX10M4|RX100M6|RX100M7|RX100M5A|HX99|RX0M2)/)',
1365             Writable => 'int8u',
1366             PrintConv => {
1367             0 => 'Off',
1368             1 => 'Face tracking',
1369             2 => 'Lock On AF',
1370             },
1371             },
1372             # 0x2022 - 13 bytes (104 bits) for SLT-A58/A99V, NEX-3N/5R/5T/6/VG30E/VG900, ILCE-3000/3500/5000/7/7R
1373             # 26 bytes (208 bits) for ILCA-77M2, ILCE-5100/6000/7M2/7S/QX1 (7M2 has 117, 5100/6000 have 179 PhaseAFPoints)
1374             # 52 bytes (416 bits) for ILCE-7RM2 (which has 399 PhaseAFPoints) and ILCE-7SM2
1375             # Only seen non-zero values for ILCE-5100/6000/7M2/7RM2 in AF-C mode: maybe FocalPlaneAFPointsUsed ???
1376             # (Similar number of bytes for contemporary DSC models, but mostly all non-zero values.)
1377             # ILCE-6300 does not write this tag anymore, but writes 0x202a ...
1378             0x2022 => [{
1379             Name => 'FocalPlaneAFPointsUsed',
1380             Condition => '$$self{Model} =~ /^(ILCE-(5100|6000|7M2))/',
1381             Notes => 'On-sensor/focal-plane phase AF points for ILCE with hybrid AF',
1382             BitsPerWord => 8,
1383             BitsTotal => 208, # 26 words
1384             PrintConv => {
1385             0 => '(none)',
1386             BITMASK => { },
1387             },
1388             },{
1389             Name => 'FocalPlaneAFPointsUsed',
1390             Condition => '$$self{Model} =~ /^ILCE-7RM2/',
1391             # ILCE-7RM2 has 399 points in 19 rows of 21 points, numbered [0] to [398], [199] is Center
1392             BitsPerWord => 8,
1393             BitsTotal => 416, # 52 words
1394             PrintConv => {
1395             0 => '(none)',
1396             BITMASK => { },
1397             },
1398             }],
1399             0x2023 => { #JR
1400             Name => 'MultiFrameNREffect',
1401             Writable => 'int32u',
1402             PrintConv => {
1403             0 => 'Normal',
1404             1 => 'High', # seen this only for ILCA-77M2 MFNR-12 images
1405             },
1406             },
1407             # 0x2024 - 96 byte data block, very similar to 0x3000 ShotInfo, seen in Xperia Z5
1408             # 0x2025 - n1 n2 0 0 DSC-RX100M3/RX100M4/RX10M2/HX90V/WX500, ILCA-77M2, ILCE-5100/7M2/7RM2/7S/QX1
1409             # seen n1=0,2,4,5,7 and n2=0,1,3, very often: 7 3 0 0
1410              
1411             # 0x2026 - 2 values: more precise WB Shift: AB in steps of 0.50, GM in steps of 0.25 (ILCE-7RM2 onwards)
1412             0x2026 => { #JR
1413             Name => 'WBShiftAB_GM_Precise',
1414             Writable => 'int32s',
1415             Count => 2,
1416             Notes => q{
1417             2 numbers: 1. positive is a shift toward amber, 2. positive is a shift
1418             toward magenta
1419             },
1420             PrintConv => 'my @v=split(" ",$val); $_/=1000 foreach @v; sprintf("%.2f %.2f",$v[0],$v[1])',
1421             },
1422             # 0x2027 - W H W/2 H/2 or W H val1 val2 (0 0 0 0 for Panorama images)
1423             # Probably location of focus for Playback Zoom.
1424             # Origin appears to be top-left, i.e. 1st coord to the right, 2nd coord. pointing down.
1425             0x2027 => { #JR
1426             Name => 'FocusLocation', #(NC)
1427             Writable => 'int16u',
1428             Count => 4,
1429             NOTES => q{
1430             Location in the image where the camera focused, used for Playback Zoom.
1431             If the focus location information cannot be obtained, the centre of the
1432             image will be used.
1433             },
1434             },
1435             # 0x2028 - 0 0 for DSC-RX100M4/RX10M2, ILCE-7RM2/7SM2; seen non-zero values only for DSC-RX1RM2
1436             0x2028 => { #JR
1437             Name => 'VariableLowPassFilter',
1438             Writable => 'int16u',
1439             Count => 2,
1440             PrintConv => {
1441             '0 0' => 'n/a',
1442             '1 0' => 'Off',
1443             '1 1' => 'Standard',
1444             '1 2' => 'High',
1445             '65535 65535' => 'n/a', # ILCE-7SM3
1446             },
1447             },
1448             0x2029 => { # uncompressed 14-bit RAW file type setting introduced 2015
1449             Name => 'RAWFileType',
1450             Writable => 'int16u',
1451             PrintConv => {
1452             0 => 'Compressed RAW',
1453             1 => 'Uncompressed RAW',
1454             2 => 'Lossless Compressed RAW', #JR (NC) seen for ILCE-1
1455             65535 => 'n/a', # seen for ILCE-7SM3 JPEG-only
1456             },
1457             },
1458             # 0x202a - first seen for ILCE-6300: 66 bytes
1459             # possibly a 'replacement' for Tag2022 FocalPlaneAFPointsUsed,
1460             # but now indicating locations in a 640x428 grid (3:2 part of LCD ?)
1461             # first byte value 1 for ILCE-6300/6500/9, ILCA-99M2
1462             # values 110,137, ... for DSC-RX10M3, therefore limit to first byte = 1 for now
1463             0x202a => {
1464             Name => 'Tag202a',
1465             Condition => '$$valPt =~ /^\x01/',
1466             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag202a' },
1467             },
1468             0x202b => { #JR (ILCA-99M2, ILCE-6500/7M3/7RM3/9, DSC-RX10M4/RX100M5 and newer)
1469             Name => 'PrioritySetInAWB',
1470             Writable => 'int8u',
1471             PrintConv => {
1472             0 => 'Standard',
1473             1 => 'Ambience',
1474             2 => 'White',
1475             },
1476             },
1477             0x202c => { #JR
1478             Name => 'MeteringMode2',
1479             Writable => 'int16u',
1480             PrintHex => 1,
1481             PrintConv => {
1482             0x100 => 'Multi-segment',
1483             0x200 => 'Center-weighted average',
1484             0x301 => 'Spot (Standard)',
1485             0x302 => 'Spot (Large)',
1486             0x400 => 'Average',
1487             0x500 => 'Highlight',
1488             },
1489             },
1490             0x202d => { #JR first seen for ILCA-99M2, ILCE-6500, DSC-RX100M5
1491             Name => 'ExposureStandardAdjustment',
1492             Writable => 'rational64s',
1493             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
1494             PrintConvInv => '$val',
1495             },
1496             0x202e => { #JR (ILCE-7M3/7RM3 and newer)
1497             Name => 'Quality',
1498             Writable => 'int16u',
1499             Count => 2,
1500             PrintConv => {
1501             '0 0' => 'n/a',
1502             '0 1' => 'Standard',
1503             '0 2' => 'Fine',
1504             '0 3' => 'Extra Fine',
1505             '0 4' => 'Light', #JR
1506             '1 0' => 'RAW',
1507             '1 1' => 'RAW + Standard',
1508             '1 2' => 'RAW + Fine',
1509             '1 3' => 'RAW + Extra Fine',
1510             '1 4' => 'RAW + Light', #JR
1511             },
1512             },
1513             0x202f => { #JR (ILCE-7RM3)
1514             Name => 'PixelShiftInfo',
1515             Writable => 'undef',
1516             # 6 bytes, all 0 for non-PixelShift images
1517             # first 4 bytes: GroupID, read as int32u
1518             # the ID displayed by Sony ImageDataConverter appears to be based on the lower 22 bits:
1519             # 5 bits, 5 bits, 6 bits, 6 bits
1520             # last 2 bytes: ShotNumber: (1 4) to (4 4) and (1 16) to (16 16) are the 4 or 16 source images,
1521             # (0 4) is the combined image for 4-shot PixelShift mode
1522             # (0 16) is the combined image for 16-shot PixelShift mode (ILCE-7RM4)
1523             RawConv => q{
1524             my ($a,$b,$c) = (Get32u(\$val,0), Get8u(\$val,4), Get8u(\$val,5));
1525             sprintf("%.2d%.2d%.2d%.2d %d %d 0x%x",($a>>17)&0x1f,($a>>12)&0x1f,($a>>6)&0x3f,$a&0x3f,$b,$c,$a>>22);
1526             },
1527             RawConvInv => q{
1528             my ($a,$b,$c,$d) = split ' ', $val;
1529             my @a = $a =~ /../g;
1530             return undef unless @a == 4;
1531             return Set32u((hex($d)<<22) | ($a[0]<<17) | ($a[1]<<12) | ($a[2]<<6) | $a[3]) . chr($b & 0xff) . chr($c & 0xff);
1532             },
1533             PrintConv => {
1534             '00000000 0 0 0x0' => 'n/a',
1535             OTHER => sub {
1536             my ($val, $inv) = @_;
1537             if ($inv) {
1538             $val =~ s{Composed (\d+)-shot}{Shot 0/$1}i;
1539             $val =~ s{^(?:Group)?\s*(\d+)[, ]+(?:Shot\s*)?(\d+)[/ ](\d+)\s*\(?(\w+)\)?}{$1 $2 $3 $4}i or return undef;
1540             } else {
1541             $val =~ s{(\d+) (\d+) (\d+) (\w+)}{Group $1, Shot $2/$3 ($4)} or return undef;
1542             $val =~ s{Shot 0+/0*(\d+)\b}{Composed $1-shot}i;
1543             }
1544             return $val;
1545             },
1546             },
1547             },
1548             0x2031 => { #JR (only for ILCE-9 v2.00; ILCE-9 v2.10 and higher have "option" to write into EXIF tag 0xa431 )
1549             Name => 'SerialNumber',
1550             Writable => 'string',
1551             ValueConv => '$val=~s/(\d{2})(\d{2})(\d{2})(\d{2})/$4$3$2$1/; $val=~s/^0//; $val',
1552             ValueConvInv => '$val="0$val" if length($val)==7; $val=~s/(\d{2})(\d{2})(\d{2})(\d{2})/$4$3$2$1/; $val',
1553             PrintConv => 'sprintf("%.8d",$val)',
1554             PrintConvInv => '$val',
1555             },
1556             # 0x2032 - 0x2039: from July 2020 for ILCE-7SM3, ILCE-1, ILME-FX3 and newer
1557             0x2032 => {
1558             Name => 'Shadows',
1559             Writable => 'int32s',
1560             PrintConv => '$val > 0 ? "+$val" : $val',
1561             PrintConvInv => '$val',
1562             },
1563             0x2033 => {
1564             Name => 'Highlights',
1565             Writable => 'int32s',
1566             PrintConv => '$val > 0 ? "+$val" : $val',
1567             PrintConvInv => '$val',
1568             },
1569             0x2034 => {
1570             Name => 'Fade',
1571             Writable => 'int32s',
1572             PrintConv => '$val > 0 ? "+$val" : $val',
1573             PrintConvInv => '$val',
1574             },
1575             0x2035 => {
1576             Name => 'SharpnessRange',
1577             Writable => 'int32s',
1578             PrintConv => '$val > 0 ? "+$val" : $val',
1579             PrintConvInv => '$val',
1580             },
1581             0x2036 => {
1582             Name => 'Clarity',
1583             Writable => 'int32s',
1584             PrintConv => '$val > 0 ? "+$val" : $val',
1585             PrintConvInv => '$val',
1586             },
1587             0x2037 => {
1588             Name => 'FocusFrameSize',
1589             Format => 'int16u',
1590             Count => '3',
1591             Notes => 'width and height of FocusFrame, centered on FocusLocation',
1592             PrintConv => q{
1593             my @a = split ' ', $val;
1594             return $a[2] ? sprintf('%3dx%3d', $a[0], $a[1]) : 'n/a';
1595             },
1596             PrintConvInv => '$val =~ /(\d+)x(\d+)/ ? "$1 $2 257" : "0 0 0"',
1597             },
1598             0x2039 => { #JR
1599             Name => 'JPEG-HEIFSwitch', # (name used in camera menus)
1600             Writable => 'int16u',
1601             PrintConv => {
1602             0 => 'JPEG',
1603             1 => 'HEIF',
1604             65535 => 'n/a',
1605             },
1606             },
1607             # 0x203a - 0x2041: first seen October 2021 for ILCE-7M4
1608             0x3000 => {
1609             Name => 'ShotInfo',
1610             SubDirectory => { TagTable => 'Image::ExifTool::Sony::ShotInfo' },
1611             },
1612             # 0x3000: data block that includes DateTimeOriginal string
1613             # 0x5001 - 0
1614             # 0x5002 - 128
1615             #
1616             # at least some data for tags 0x2010, 0x9050 and 0x94xx is encrypted - PH
1617             # (This is certainly true for at least parts of 0x2010, 0x9050, 0x9400, 0x9402 and 0x9403,
1618             # but hasn't been verified for other tags -- just to be thorough, decipher all of them)
1619             # Note: "(e)" in a comment indicates an enciphered value, all other values are deciphered
1620             #
1621             # 0x900b - 1st byte 0xae: face detection info for A450/500/550/560/580, A33/35/55, NEX-3/5/5C/C3/VG10
1622             # - other 1st byte values for some DSC-models
1623             # - seen many 1,8,27,64... values: assume encrypted like other 9xxx tags
1624             0x900b => {
1625             Name => 'Tag900b',
1626             Condition => '$$valPt =~ /^\xae/',
1627             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag900b' },
1628             },
1629             0x9050 => [
1630             # 944 bytes for A37, A57, A99, NEX-F3, NEX-5R, NEX-6, DSC-RX1, DSC-RX100
1631             # 3072 bytes for A65, A77, NEX-5N, NEX-7, NEX-VG20 (ref JR)
1632             # not valid for DSC/Stellar models
1633             # from mid-2015: ILCE-7RM2/7SM2/6300 and newer models use different offsets
1634             {
1635             Name => 'Tag9050a',
1636             Condition => '$$self{Model} !~ /^(DSC-|Stellar|ILCE-(1|6100|6300|6400|6500|6600|7C|7M3|7M4|7RM2|7RM3A?|7RM4A?|7RM5|7SM2|7SM3|9|9M2)|ILCA-99M2|ILME-FX3|ZV-)/',
1637             SubDirectory => {
1638             TagTable => 'Image::ExifTool::Sony::Tag9050a',
1639             ByteOrder => 'LittleEndian',
1640             },
1641             },{
1642             Name => 'Tag9050b',
1643             Condition => '$$self{Model} =~ /^(ILCE-(6100|6300|6400|6500|6600|7C|7M3|7RM2|7RM3A?|7RM4A?|7SM2|9|9M2)|ILCA-99M2|ZV-E10)/',
1644             SubDirectory => {
1645             TagTable => 'Image::ExifTool::Sony::Tag9050b',
1646             ByteOrder => 'LittleEndian',
1647             },
1648             },{
1649             Name => 'Tag9050c',
1650             Condition => '$$self{Model} =~ /^(ILCE-(1|7M4|7RM5|7SM3)|ILME-FX3)/',
1651             SubDirectory => {
1652             TagTable => 'Image::ExifTool::Sony::Tag9050c',
1653             ByteOrder => 'LittleEndian',
1654             },
1655             },{
1656             Name => 'Sony_0x9050',
1657             %unknownCipherData,
1658             }],
1659             0x9400 => [
1660             # first byte:
1661             # 0x07 (e) for DSC-HX7V/HX9V/HX100V/TX10/TX100/TX100V/WX7/WX9/WX10, HDR-CX../PJ..
1662             # 0x09 (e) for DSC-TX20/TX55/WX30
1663             # 0x0a (e) for SLT-A37/A57/A65V/A77V/A99V, NEX-F3/5N/5R/5T/6/7/VG20E, DSC-RX100/RX1/RX1R/HX10V/HX20V/HX30V/HX200V/TX200V/TX300V/TX66/WX50/WX100/WX150, Lunar/Stellar/HV
1664             # 0x0c (e) for ILCE-3000/3500, NEX-3N, SLT-A58, DSC-HX50V/HX300/RX100M2/TX30/WX60/WX80/WX200/WX300, DSC-QX10/QX100
1665             # 0xd0 (e) H90, W650, W690: tag9400 decoding appears not valid/different
1666             # 0x23 (e) for DSC-RX10/HX60V/HX350/HX400V/WX220/WX350, ILCE-7/7R/5000/6000, ILCA-68/77M2
1667             # 0x24 (e) for ILCA-99M2,ILCE-5100/6300/6500/7M2/7RM2/7S/7SM2/QX1, DSC-HX80/HX90V/QX30/RX0/RX100M3/RX100M4/RX100M5/RX10M2/RX10M3/RX1RM2/WX500
1668             # 0x26 (e) for ILCE-6100/6400/6600/7M3/7RM3/9, DSC-RX0M2/RX10M4/RX100M5A/RX100M6/HX99
1669             # 0x28 (e) for ILCE-7RM4/9M2, DSC-RX100M7, ZV-1/E10
1670             # 0x31 (e) for ILCE-1/7M4/7SM3, ILME-FX3
1671             # 0x32 (e) for ILCE-7RM5, ILME-FX30
1672             # first byte decoded: 40, 204, 202, 27, 58, 62, 48, 215, 28, 106, 89 respectively
1673             {
1674             Name => 'Tag9400a',
1675             Condition => q{
1676             $$valPt =~ /^[\x07\x09\x0a]/ or
1677             ($$valPt =~ /^[\x5e\xe7\x04]/ and $$self{DoubleCipher} = 1)
1678             },
1679             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag9400a' },
1680             },{
1681             Name => 'Tag9400b',
1682             Condition => '$$valPt =~ /^\x0c/',
1683             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag9400b' },
1684             },{
1685             Name => 'Tag9400c',
1686             Condition => '$$valPt =~ /^[\x23\x24\x26\x28\x31\x32]/',
1687             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag9400c' },
1688             },{
1689             Name => 'Sony_0x9400',
1690             %unknownCipherData,
1691             }],
1692             0x9401 => {
1693             Name => 'Tag9401',
1694             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag9401' },
1695             # notes for data in this block (ref PH/JR):
1696             # 0x02-0x03 appear to have some relation to start-offset of data...
1697             # 0x00 - 0x03 Metering
1698             # Mode
1699             # f4 00 00 03 - - DSC-H90/W650/W690
1700             # cf 0b 9f 0f 0x09bc (a) DSC-WX9
1701             # 1c 00 ac 0f 0x09c9 (b) HDR-CX130E/CX160E/CX360E/CX560E/CX700E/PJ10E/PJ30E
1702             # b7 0f f7 0f 0x09dd (c) DSC-HX7V/TX10/WX7/WX10
1703             # b7 0f fa 0f 0x09e0 (d) DSC-HX9V/HX100V/TX100/TX100V
1704             # 27 00 fd 0f 0x09e7 (e) DSC-TX20/TX55/WX30
1705             # 69 1f ff 0f 0x09e9 (f) NEX-5N
1706             # 21 2b cf 0f 0x09e9 (f) NEX-7/VG20E, SLT-A65V/A77V, Lunar
1707             # 2d 00 d5 0d 0x09a2 (g) DSC-HX10V/HX20V/HX30V/HX200V/TX66/TX200V/TX300V/WX50/WX70/WX100/WX150
1708             # 2f 00 d6 0d 0x09a3 (h) NEX-F3, SLT-A37/A57
1709             # 30 00 d8 0d 0x09a5 (i) HDR-AS15
1710             # 32 00 e2 0d 0x09ac (j) DSC-RX100, Stellar
1711             # 33 00 e2 0d 0x09ac (j) NEX-5R/5T/6, NEX-VG900/VG30E
1712             # 33 50 e2 0d 0x09ac (j) SLT-A99V, HV
1713             # 33 40 0d 0e 0x09d7 (k) DSC-RX1 v0.01
1714             # 33 41 0d 0e 0x09d7 (k) DSC-RX1, DSC-RX1R
1715             # 38 00 32 0e 0x09fc (l) SLT-A58, ILCE-3000/3500, NEX-3N, DSC-HX300/HX50V/WX200/WX300/WX60/WX80/TX30
1716             # 3a 10 3a 0e 0x0a01 (m) DSC-QX10/QX100
1717             # 3a 20 47 0e 0x0a01 (m) DSC-RX100M2
1718             # 43 00 66 0e 0x0a1b (n) ILCE-7/7R v0.xx/v1.00/v1.01, ILCE-5000, DSC-RX10
1719             # 43 10 66 0e 0x0a1b (n) ILCE-7/7R v1.02/v1.10
1720             # 43 30 6c 0e 0x0a1b (n) ILCE-7/7R v1.20-v3.20
1721             # 44 00 9c 0e 0x0a39 (o) ILCE-6000 v1.00/v1.10, DSC-HX60V/HX350/HX400V/WX220/WX350 (also DSC-QX30 samples from sony.net)
1722             # 44 10 a2 0e 0x0a39 (o) ILCE-6000 v1.20/v1.21
1723             # 44 20 a2 0e 0x0a39 (o) ILCE-6000 v2.00-v3.20
1724             # 49 00 b0 0e 0x0a3b (p) ILCA-68 v1.00, ILCA-77M2 V1.00/v1.01/v2.00 (also DSC-RX100M3 samples from sony.net)
1725             # 4a 00 b3 0e 0x0a3d (q) ILCE-7S v1.00, ILCE-5100 v1.00/v1.10, ILCE-QX1, DSC-QX30/RX100M3
1726             # 4a 20 b9 0e 0x0a3d (q) ILCE-7S v1.20-v3.20
1727             # 4e 10 d0 0e 0x0a5a (r) ILCE-7M2 v1.00/v1.10
1728             # 4e 30 d6 0e 0x0a5a (r) ILCE-7M2 v1.20-v4.00
1729             # 5a 00 14 0f 0x0a85 (s) DSC-HX80/HX90V/WX500
1730             # 5d 00 56 0f 0x0ac7 (t) DSC-RX10M2/RX100M4, ILCE-7RM2/7SM2 v1.00-v2.20 (also DSC-RX1RM2 samples from Sony)
1731             # 5d 1d 58 0f 0x0ac7 (t) ILCE-7RM2 v3.00-v4.00
1732             # 5d 1e 57 0f 0x0ac7 (t) DSC-RX1RM2 v1.00
1733             # 5d 10 56 0f 0x0ac7 (t) ILCE-6300 v1.00 (samples from Sony)
1734             # 5d 20 58 0f 0x0ac7 (t) ILCE-6300 v1.00/v1.10
1735             # 5e 00 56 0f 0x0ac7 (t) DSC-RX10M3 v1.00
1736             # 64 00 a8 0f 0x0b15 (u) DSC-RX100M5 v1.00
1737             # 67 00 f9 0f 0x0b66 (v) ILCA-99M2 v1.00, ILCE-6500 v1.00-v1.05, DSC-RX0 v1.00
1738             # 7c 00 fe 0f 0x0adb (w) ILCE-9 v0.01-v2.00
1739             # 7d 00 fe 0f 0x0adb (w) ILCE-9 v2.10-v4.10
1740             # 7f 00 fa 0f 0x0add (x) DSC-RX10M4 v1.00
1741             # 80 00 fa 0f 0x0add (x) ILCE-7M3/7RM3 v1.00-v3.01
1742             # 82 00 fc 0f 0x0ad9 (y) DSC-RX100M5A v1.00, DSC-RX100M6 v1.00
1743             # 90 00 fe 0f 0x098f? (z) DSC-HX99 v1.00
1744             # 92 10 ff 0f 0x0990 (za) ILCE-6100/6400/6600 v1.00
1745             # 94 00 ce 0b 0x0879 (zb) ILCE-9 v5.00-v6.00, DSC-RX0M2
1746             # 98 00 db 0c 0x088a (zc) ILCE-7RM4 v1.00
1747             # 9a 00 e3 0c 0x088a (zc) DSC-RX100M7 v1.00, ILCE-9M2 v1.00
1748             #
1749             # 0x0004 - (RX100: 0 or 1. subsequent data valid only if 1 - PH)
1750             # 0x0007 => {
1751             # Name => 'DynamicRangeOptimizer_9401',
1752             # PrintConv => {
1753             # 0 => 'Disabled', # seen for Panorama images
1754             # 1 => 'Auto',
1755             # 3 => 'Lv1', #(NC)
1756             # 4 => 'Lv2', #(NC)
1757             # 5 => 'Lv3',
1758             # 6 => 'Lv4',
1759             # 7 => 'Lv5',
1760             # # 8 - seen for VG20E and some other models - PH
1761             # 255 => 'Off',
1762             # },
1763             # },
1764             },
1765             0x9402 => [{
1766             Name => 'Tag9402',
1767             # first 2 bytes deciphered:
1768             # 0x00 0x00 SLT-A37/A57/A65/A77
1769             # 0x0e 0x00 DSC-H90/HX7V/HX9V/HX100V/TX10/TX100/TX100V/TX20/TX55/W650/W690/W730/WX10/WX30/WX7/WX9, but also seen:
1770             # 0x0e 0x01 for a few DSC-W650/W690 samples ...
1771             # 0x0f 0x01 NEX-5N/7/VG20, Lunar
1772             # 0x10 0x01 DSC-HX10V/HX200V/HX20V/HX300/HX30V/HX50V/TX200V/TX30/TX300V/TX66/RX100/RX1/RX1R/WX100/WX150/WX200/WX300/WX50/WX60/WX70/WX80, Stellar,
1773             # ILCE-3000/3500, NEX-F3/3N/5R/5T/6/VG30/VG900
1774             # 0x11 0x01 DSC-RX100M2/QX10/QX100
1775             # 0x13 0x01 ILCE-5000/7/7R, DSC-RX10, but also seen:
1776             # 0x12 0x01 for ILCE-7/7R and DSC-RX10 samples from Sony.net ...
1777             # 0x15 0x01 for a few ILCE-7/7R ...
1778             # 0x14 0x01 ILCE-6000, DSC-HX60V/HX350/HX400V/WX220/WX350
1779             # 0x17 0x01 ILCE-7S/7M2/5100/QX1, DSC-QX30/RX100M3
1780             # 0x19 0x01 DSC-HX80/HX90V/RX1RM2/RX10M2/RX100M4/WX500, ILCE-6300/7RM2/7SM2
1781             # 0x1a 0x01 DSC-RX0/RX10M3/RX100M5, ILCE-6500
1782             # 0x1c 0x01 ILCE-9
1783             # 0x1d 0x01 DSC-RX10M4
1784             # 0x1e 0x01 ILCE-7M3/7RM3, DSC-RX100M5A/RX100M6
1785             # 0x1f 0x01 DSC-HX99
1786             # 0x20 0x01 ILCE-6100/6400/6600/7RM4/9M2, ILCE-9 v5.00-v6.00, DSC-RX0M2/RX100M7
1787             # var var SLT-A58/A99V, HV, ILCA-68/77M2/99M2
1788             # only valid when first byte 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x17, 0x19, 0x1a, 0x1c (enciphered 0x8a, 0x70, 0xb6, 0x69, 0x88, 0x20, 0x30, 0xd7, 0xbb, 0x92, 0x28)
1789             # Condition => '$$self{DoubleCipher} ? $$valPt =~ /^[\x7e\x46\x1d\x18\x3a\x95\x24\x26\xd6]\x01/ : $$valPt =~ /^[\x8a\x70\xb6\x69\x88\x20\x30\xd7\xbb\x92\x28]\x01/',
1790             # alternative simpler Condition:
1791             # not valid for SLT/HV/ILCA models, and not valid for first byte 0x0e or 0xff (enciphered 0x05 or 0xff)
1792             Condition => '$$self{Model} !~ /^(SLT-|HV|ILCA-)/ and $$valPt !~ /^[\x05\xff]/',
1793             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag9402' },
1794             },{
1795             Name => 'Sony_0x9402',
1796             %unknownCipherData,
1797             }],
1798             0x9403 => {
1799             Name => 'Tag9403',
1800             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag9403' },
1801             },
1802             # 0x9404 first 5 bytes (deciphered):
1803             # 4 0 163 1 2 SLT-A65V/A77V, NEX-5N/7, Lunar, DSC-HX7V/HX9V/HX100V/TX10/TX20/TX55/TX100/TX100V/WX9/WX10/WX30...
1804             # 5 0 172 1 2 DSC-HX10V/HX200V/HX20V/HX30V/TX66/TX200V/TX300V/WX50/WX70/WX100/WX150...
1805             # 9 0 38 2 2 SLT-A37/A57/A99V, NEX-5R/5T/6/F3/VG30E/VG900, DSC-RX1/RX1R/RX100, Stellar
1806             # 12 0 8 2 2 SLT-A58, NEX-3N, ILCE-3000/3500, DSC-HX300/HX50V/WX60/WX80/WX300/TX30...
1807             # 13 0 9 2 2 DSC-QX10/QX100/RX100M2
1808             # 15 0 35 2 2 ILCA-68/77M2, ILCE-5000/5100/6000/7/7R/7S/7M2/QX1, DSC-HX60V/HX350/HX400V/QX30/RX10/RX100M3/WX220/WX350
1809             # 16 0 85 2 2 DSC-HX80/HX90V/WX500
1810             # 17 0 232 1 2 DSC-RX0/RX0M2/RX1RM2/RX10M2/RX10M3/RX10M4/RX100M4/RX100M5/RX100M5A/RX100M6/RX100M7/HX99, ILCE-6100/6300/6400/6500/6600/7C/7M3/7RM2/7RM3/7RM4/7SM2/9/9M2, ILCA-99M2, ZV-1
1811             # 18 0 20 0 164 ILCE-7SM3
1812             # other values for Panorama images and several other models
1813             0x9404 => [{
1814             Name => 'Tag9404a',
1815             # first byte must be 4 or 5 and 4th byte must be 1 (deciphered)
1816             Condition => '$$valPt =~ /^[\x40\x7d]..\x01/',
1817             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag9404a' },
1818             },{
1819             Name => 'Tag9404b',
1820             # first byte must be 9 or 12 or 13 or 15 or 16 and 4th byte must be 2 (deciphered)
1821             Condition => '$$valPt =~ /^[\xe7\xea\xcd\x8a\x70]..\x08/',
1822             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag9404b' },
1823             },{
1824             Name => 'Tag9404c',
1825             # first byte must be 17 and 4th byte must be 1 (deciphered)
1826             Condition => '$$valPt =~ /^\xb6..\x01/',
1827             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag9404c' },
1828             },{
1829             Name => 'Sony_0x9404',
1830             %unknownCipherData,
1831             }],
1832             # 0x9405 first 2 bytes:
1833             # 0 0 (0x00 = 0 0 enc.) DSC-H90
1834             # 2 0 (0x08 = 8 0 enc.) DSC and HDR of HX9V generation
1835             # 3 0 (0x1b = 27 0 enc.) SLT, NEX, ILCE-3000/3500, DSC-RX100/RX1 + other DSC of same generation, also QX10 and QX100
1836             # 4 0 (0x40 = 64 0 enc.) DSC-RX1R
1837             # 5 0 (0x7d = 125 0 enc.) DSC-RX100M2
1838             # 136 var (0x3a = 58 var enc.) ILCE-7/7R/5000/6000, DSC-HX60V/HX350/HX400V/RX10/WX220/WX350
1839             # 137 var (0xb3 = 179 var enc.) ILCA-68/77M2, DSC-RX100M3 - appears to go with 136
1840             # 138 var (0x7e = 126 var enc.) ILCE-7S/5100/QX1, DSC-QX30 - appears to go with 136
1841             # 139 var (0x9a = 154 var enc.) ILCE-7M2
1842             # 142 var (0x25 = 37 var enc.) DSC-HX80/HX90V/RX1RM2/RX10M2/RX10M3/RX100M4/WX500, ILCE-6300/7RM2/7SM2
1843             # 144 var (0xe1 = 225 var enc.) DSC-RX100M5
1844             # 145 var (0x76 = 118 var enc.) ILCA-99M2, ILCE-6500, DSC-RX0
1845             # 163 var (0x8b = 139 var enc.) ILCE-6100/6400/6600/7C/7M3/7RM3/7RM4/9/9M2, DSC-RX0M2/RX10M4/RX100M5A/RX100M6/RX100M7/HX99, ZV-1/E10
1846             # July 2020: ILCE-7SM3 doesn't write this tag anymore, but writes 0x9416
1847             0x9405 => [{
1848             Name => 'Tag9405a',
1849             # first byte must be 0x1b or 0x40 or 0x7d
1850             Condition => '$$valPt =~ /^[\x1b\x40\x7d]/',
1851             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag9405a' },
1852             },{
1853             Name => 'Tag9405b',
1854             # first byte must be 0x3a, 0xb3, 0x7e, 0x9a, 0x25, 0xe1, 0x76 or 0x8b
1855             Condition => '$$valPt =~ /^[\x3a\xb3\x7e\x9a\x25\xe1\x76\x8b]/',
1856             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag9405b' },
1857             },{
1858             Name => 'Sony_0x9405',
1859             %unknownCipherData,
1860             }],
1861             0x9406 => [{
1862             Name => 'Tag9406',
1863             # - first byte must be 0x01 or 0x02 (enciphered 0x01 or 0x08),
1864             # or 0x03 (enc. 0x1b) for ILCE-6100/6300/6400/6500/6600/7M3/7RM2/7RM3/7RM4/7SM2/9/9M2, and ILCA-99M2
1865             # third byte must be 0x02 or 0x03 (enciphered 0x08 or 0x1b) - ref JR
1866             # (applies to most SLT/ILCA and NEX/ILCE models, but no DSC models)
1867             Condition => '$$valPt =~ /^[\x01\x08\x1b].[\x08\x1b]/s',
1868             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag9406' },
1869             },{
1870             Name => 'Sony_0x9406',
1871             %unknownCipherData,
1872             }],
1873             0x9407 => {
1874             Name => 'Sony_0x9407',
1875             %unknownCipherData,
1876             },
1877             0x9408 => {
1878             Name => 'Sony_0x9408',
1879             %unknownCipherData,
1880             },
1881             0x9409 => {
1882             Name => 'Sony_0x9409',
1883             %unknownCipherData,
1884             },
1885             0x940a => [{
1886             Name => 'Tag940a',
1887             Condition => '$$self{Model} =~ /^(SLT-|HV)/', # but appears not valid for ILCA models ...
1888             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag940a' },
1889             },{
1890             Name => 'Sony_0x940a',
1891             %unknownCipherData,
1892             }],
1893             0x940b => {
1894             Name => 'Sony_0x940b',
1895             %unknownCipherData,
1896             },
1897             0x940c => [{
1898             Name => 'Tag940c',
1899             Condition => '$$self{Model} =~ /^(NEX-|ILCE-|ILME-|Lunar|ZV-E10)\b/',
1900             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag940c' },
1901             },{
1902             Name => 'Sony_0x940c',
1903             %unknownCipherData,
1904             }],
1905             0x940d => {
1906             Name => 'Sony_0x940d',
1907             %unknownCipherData,
1908             },
1909             # 0x940e: 2nd byte = 0: no AFInfo, default for NEX/ILCE
1910             # 2nd byte = 1: AFInfo for SLT/ILCA models (but also seen 1 for DSC-HX20W/HX300/WX70 ...)
1911             # 2nd byte = 2: AFInfo for NEX/ILCE with LA-EA2/EA4 Phase-detect AF Adapter
1912             0x940e => [{
1913             Name => 'AFInfo',
1914             Condition => '$$self{Model} =~ /^(SLT-|HV|ILCA-)/',
1915             SubDirectory => { TagTable => 'Image::ExifTool::Sony::AFInfo' },
1916             },{
1917             Name => 'Tag940e',
1918             Condition => '$$self{Model} =~ /^(NEX-|ILCE-|Lunar)/',
1919             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag940e' },
1920             },{
1921             Name => 'Sony_0x940e',
1922             %unknownCipherData,
1923             }],
1924             0x940f => {
1925             Name => 'Sony_0x940f',
1926             %unknownCipherData,
1927             },
1928             0x9411 => {
1929             Name => 'Sony_0x9411',
1930             %unknownCipherData,
1931             # 0x02 - int32u?: 1,3,5,7,9 (A77)
1932             },
1933             0x9416 => { # replaces 0x9405 for the Sony ILCE-7SM3, from July 2020
1934             Name => 'Sony_0x9416',
1935             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Tag9416' },
1936             },
1937             0xb000 => { #8
1938             Name => 'FileFormat',
1939             Writable => 'int8u',
1940             Count => 4,
1941             # dynamically set the file type to SR2 because we could have assumed ARW up till now
1942             RawConv => q{
1943             $self->OverrideFileType($$self{TIFF_TYPE} = 'SR2') if $val eq '1 0 0 0';
1944             return $val;
1945             },
1946             PrintConvColumns => 2,
1947             PrintConv => {
1948             '0 0 0 2' => 'JPEG',
1949             '1 0 0 0' => 'SR2',
1950             '2 0 0 0' => 'ARW 1.0',
1951             '3 0 0 0' => 'ARW 2.0',
1952             '3 1 0 0' => 'ARW 2.1',
1953             '3 2 0 0' => 'ARW 2.2', #PH (NEX-5)
1954             '3 3 0 0' => 'ARW 2.3', #PH (SLT-A65,SLT-A77)
1955             '3 3 1 0' => 'ARW 2.3.1', #PH/JR (DSC-RX1R/RX100M2/Stellar2)
1956             '3 3 2 0' => 'ARW 2.3.2', #JR (DSC-RX1RM2,ILCE-7SM2 - support for uncompressed 14-bit RAW)
1957             '3 3 3 0' => 'ARW 2.3.3', #JR (ILCE-9)
1958             '3 3 5 0' => 'ARW 2.3.5', #JR (DSC-HX99)
1959             '4 0 0 0' => 'ARW 4.0', # (ILCE-7SM3)
1960             '4 0 1 0' => 'ARW 4.0.1', #github#195 (ZV-E1)
1961             # what about cRAW images?
1962             },
1963             },
1964             0xb001 => { # ref http://forums.dpreview.com/forums/read.asp?forum=1037&message=33609644
1965             # (ARW and SR2 images only until the SLT-A65V started writing them to JPEG too)
1966             Name => 'SonyModelID',
1967             Writable => 'int16u',
1968             PrintConvColumns => 2,
1969             PrintConv => {
1970             #0 => 'DSC-HX80', #PH (and several other DSC models)
1971             2 => 'DSC-R1',
1972             256 => 'DSLR-A100',
1973             257 => 'DSLR-A900',
1974             258 => 'DSLR-A700',
1975             259 => 'DSLR-A200',
1976             260 => 'DSLR-A350',
1977             261 => 'DSLR-A300',
1978             262 => 'DSLR-A900 (APS-C mode)', #https://exiftool.org/forum/index.php/topic,3994.0.html
1979             263 => 'DSLR-A380/A390', #PH (A390)
1980             264 => 'DSLR-A330',
1981             265 => 'DSLR-A230',
1982             266 => 'DSLR-A290', #PH
1983             269 => 'DSLR-A850',
1984             270 => 'DSLR-A850 (APS-C mode)', #https://exiftool.org/forum/index.php/topic,3994.0.html
1985             273 => 'DSLR-A550',
1986             274 => 'DSLR-A500', #PH
1987             275 => 'DSLR-A450', #http://dev.exiv2.org/issues/show/0000611
1988             278 => 'NEX-5', #PH
1989             279 => 'NEX-3', #PH
1990             280 => 'SLT-A33', #PH
1991             281 => 'SLT-A55 / SLT-A55V', #PH (A55 NC)
1992             282 => 'DSLR-A560', #PH
1993             283 => 'DSLR-A580', #https://exiftool.org/forum/index.php/topic,2881.0.html
1994             284 => 'NEX-C3', #PH
1995             285 => 'SLT-A35', #JR
1996             286 => 'SLT-A65 / SLT-A65V', #PH
1997             287 => 'SLT-A77 / SLT-A77V', #PH
1998             288 => 'NEX-5N', #PH
1999             289 => 'NEX-7', #PH (also Hasselblad Lunar, ref JR)
2000             290 => 'NEX-VG20E', #JR
2001             291 => 'SLT-A37', #JR
2002             292 => 'SLT-A57', #JR
2003             293 => 'NEX-F3', #PH
2004             294 => 'SLT-A99 / SLT-A99V', #JR (also Hasselblad HV)
2005             295 => 'NEX-6', #JR
2006             296 => 'NEX-5R', #JR
2007             297 => 'DSC-RX100', #PH (also Hasselblad Stellar, ref JR)
2008             298 => 'DSC-RX1', #JR
2009             299 => 'NEX-VG900', #JR
2010             300 => 'NEX-VG30E', #JR
2011             302 => 'ILCE-3000 / ILCE-3500', #JR
2012             303 => 'SLT-A58', #JR
2013             305 => 'NEX-3N', #PH
2014             306 => 'ILCE-7', #JR
2015             307 => 'NEX-5T', #JR
2016             308 => 'DSC-RX100M2', #JR
2017             309 => 'DSC-RX10', #JR
2018             310 => 'DSC-RX1R', #JR
2019             311 => 'ILCE-7R', #JR
2020             312 => 'ILCE-6000', #JR
2021             313 => 'ILCE-5000', #JR
2022             317 => 'DSC-RX100M3', #JR
2023             318 => 'ILCE-7S', #JR
2024             319 => 'ILCA-77M2', #IB
2025             339 => 'ILCE-5100', #JR
2026             340 => 'ILCE-7M2', #JR
2027             341 => 'DSC-RX100M4', #PH
2028             342 => 'DSC-RX10M2', #JR
2029             344 => 'DSC-RX1RM2', #JR
2030             346 => 'ILCE-QX1', #IB
2031             347 => 'ILCE-7RM2', #JR
2032             350 => 'ILCE-7SM2', #JR
2033             353 => 'ILCA-68', #IB
2034             354 => 'ILCA-99M2', #JR
2035             355 => 'DSC-RX10M3', #PH
2036             356 => 'DSC-RX100M5', #IB/JR
2037             357 => 'ILCE-6300', #IB
2038             358 => 'ILCE-9', #JR
2039             360 => 'ILCE-6500', #JR
2040             362 => 'ILCE-7RM3', #IB
2041             363 => 'ILCE-7M3', #JR/IB
2042             364 => 'DSC-RX0', #PH
2043             365 => 'DSC-RX10M4', #JR
2044             366 => 'DSC-RX100M6', #IB
2045             367 => 'DSC-HX99', #IB
2046             369 => 'DSC-RX100M5A', #JR
2047             371 => 'ILCE-6400', #IB
2048             372 => 'DSC-RX0M2', #JR
2049             373 => 'DSC-HX95', #github191
2050             374 => 'DSC-RX100M7', #IB
2051             375 => 'ILCE-7RM4', #IB
2052             376 => 'ILCE-9M2', #JR
2053             378 => 'ILCE-6600', #IB/JR
2054             379 => 'ILCE-6100', #IB/JR
2055             380 => 'ZV-1', #JR
2056             381 => 'ILCE-7C', #JR
2057             382 => 'ZV-E10', #JR
2058             383 => 'ILCE-7SM3',
2059             384 => 'ILCE-1', #PH
2060             385 => 'ILME-FX3', #JR
2061             386 => 'ILCE-7RM3A', #JR
2062             387 => 'ILCE-7RM4A', #forum12542
2063             388 => 'ILCE-7M4', #IB/JR
2064             389 => 'ZV-1F', #IB
2065             390 => 'ILCE-7RM5', #IB
2066             391 => 'ILME-FX30', #JR
2067             },
2068             },
2069             0xb020 => { #2
2070             Name => 'CreativeStyle', # (called CreativeLook by the 7SM3, ref JR)
2071             Writable => 'string',
2072             # (all of these values have been observed, ref JR and PH)
2073             # - this PrintConv is included to make these strings consistent with
2074             # other CreativeStyle tags, and to facilitate the language translations
2075             # - these values are always English, regardless of the camera language settings
2076             PrintConv => {
2077             OTHER => sub { shift }, # pass other values straight through
2078             None => 'None',
2079             AdobeRGB => 'Adobe RGB',
2080             Real => 'Real',
2081             Standard => 'Standard',
2082             Vivid => 'Vivid',
2083             Portrait => 'Portrait',
2084             Landscape => 'Landscape',
2085             Sunset => 'Sunset',
2086             Nightview => 'Night View/Portrait',
2087             BW => 'B&W',
2088             Neutral => 'Neutral',
2089             Clear => 'Clear',
2090             Deep => 'Deep',
2091             Light => 'Light',
2092             Autumnleaves=> 'Autumn Leaves',
2093             Sepia => 'Sepia',
2094             # new for the ILCE-7SM3 (ref JR)
2095             VV2 => 'Vivid 2', # (NC)
2096             FL => 'FL', # "moody finish with sharp contrast and calm coloring as well as the impressive sky and colors of the greens"
2097             IN => 'IN', # "matte textures by suppressing the contrast and saturation"
2098             SH => 'SH', # "bright, transparent, soft, and vivid mood"
2099             # (...also Custom Look 1-6, but don't konw the values)
2100             },
2101             },
2102             0xb021 => { #2
2103             Name => 'ColorTemperature',
2104             Writable => 'int32u',
2105             PrintConv => '$val ? ($val==0xffffffff ? "n/a" : $val) : "Auto"',
2106             PrintConvInv => '$val=~/Auto/i ? 0 : ($val eq "n/a" ? 0xffffffff : $val)',
2107             },
2108             0xb022 => { #7
2109             Name => 'ColorCompensationFilter',
2110             Format => 'int32s',
2111             Writable => 'int32u', # (written incorrectly as unsigned by Sony)
2112             Notes => 'negative is green, positive is magenta',
2113             },
2114             0xb023 => { #PH (A100) - (set by mode dial)
2115             Name => 'SceneMode',
2116             Writable => 'int32u',
2117             PrintConvColumns => 2,
2118             PrintConv => \%Image::ExifTool::Minolta::minoltaSceneMode,
2119             },
2120             0xb024 => { #PH (A100)
2121             Name => 'ZoneMatching',
2122             Writable => 'int32u',
2123             PrintConv => {
2124             0 => 'ISO Setting Used',
2125             1 => 'High Key',
2126             2 => 'Low Key',
2127             },
2128             },
2129             0xb025 => { #PH (A100)
2130             Name => 'DynamicRangeOptimizer',
2131             Writable => 'int32u',
2132             PrintConvColumns => 2,
2133             PrintConv => {
2134             0 => 'Off',
2135             1 => 'Standard',
2136             2 => 'Advanced Auto',
2137             3 => 'Auto', # (A550)
2138             8 => 'Advanced Lv1', #JD
2139             9 => 'Advanced Lv2', #JD
2140             10 => 'Advanced Lv3', #JD
2141             11 => 'Advanced Lv4', #JD
2142             12 => 'Advanced Lv5', #JD
2143             16 => 'Lv1', # (NEX-5)
2144             17 => 'Lv2',
2145             18 => 'Lv3',
2146             19 => 'Lv4',
2147             20 => 'Lv5',
2148             },
2149             },
2150             0xb026 => { #PH (A100)
2151             Name => 'ImageStabilization',
2152             Writable => 'int32u',
2153             PrintConv => {
2154             0 => 'Off',
2155             1 => 'On',
2156             0xffffffff => 'n/a', # (HX9V sweep panorama, ref JR)
2157             },
2158             },
2159             0xb027 => { #2
2160             Name => 'LensType',
2161             Writable => 'int32u',
2162             SeparateTable => 1,
2163             # set to 65535 for E-mount lenses (values 0x80xx)
2164             ValueConvInv => '($val & 0xff00) == 0x8000 ? 65535 : int($val)',
2165             PrintConv => \%sonyLensTypes,
2166             PrintInt => 1,
2167             },
2168             0xb028 => { #2
2169             # (used by the DSLR-A100)
2170             Name => 'MinoltaMakerNote',
2171             # must check for zero since apparently a value of zero indicates the IFD doesn't exist
2172             # (dumb Sony -- they shouldn't write this tag if the IFD is missing!)
2173             Condition => '$$valPt ne "\0\0\0\0"',
2174             Flags => 'SubIFD',
2175             SubDirectory => {
2176             TagTable => 'Image::ExifTool::Minolta::Main',
2177             Start => '$val',
2178             },
2179             },
2180             0xb029 => { #2 (set by creative style menu)
2181             Name => 'ColorMode',
2182             Writable => 'int32u',
2183             PrintConvColumns => 2,
2184             PrintConv => \%Image::ExifTool::Minolta::sonyColorMode,
2185             },
2186             0xb02a => {
2187             Name => 'LensSpec',
2188             Format => 'undef',
2189             Writable => 'int8u',
2190             Count => 8,
2191             Notes => q{
2192             like LensInfo, but also specifies lens features: DT, E, ZA, G, SSM, SAM,
2193             OSS, STF, Reflex, Macro and Fisheye
2194             },
2195             ValueConv => \&ConvLensSpec,
2196             ValueConvInv => \&ConvInvLensSpec,
2197             PrintConv => \&PrintLensSpec,
2198             PrintConvInv => \&PrintInvLensSpec,
2199             },
2200             0xb02b => { #PH (A550 JPEG and A200, A230, A300, A350, A380, A700 and A900 ARW)
2201             Name => 'FullImageSize',
2202             Writable => 'int32u',
2203             Count => 2,
2204             # values stored height first, so swap to get "width height"
2205             ValueConv => 'join(" ", reverse split(" ", $val))',
2206             ValueConvInv => 'join(" ", reverse split(" ", $val))',
2207             PrintConv => '$val =~ tr/ /x/; $val',
2208             PrintConvInv => '$val =~ tr/x/ /; $val',
2209             },
2210             0xb02c => { #PH (A550 JPEG and A200, A230, A300, A350, A380, A700 and A900 ARW)
2211             Name => 'PreviewImageSize',
2212             Writable => 'int32u',
2213             Count => 2,
2214             ValueConv => 'join(" ", reverse split(" ", $val))',
2215             ValueConvInv => 'join(" ", reverse split(" ", $val))',
2216             PrintConv => '$val =~ tr/ /x/; $val',
2217             PrintConvInv => '$val =~ tr/x/ /; $val',
2218             },
2219             0xb040 => { #2
2220             Name => 'Macro',
2221             Writable => 'int16u',
2222             RawConv => '$val == 65535 ? undef : $val',
2223             PrintConv => {
2224             0 => 'Off',
2225             1 => 'On',
2226             2 => 'Close Focus', #9
2227             65535 => 'n/a', #PH (A100)
2228             },
2229             },
2230             0xb041 => { #2
2231             Name => 'ExposureMode',
2232             Writable => 'int16u',
2233             RawConv => '$val == 65535 ? undef : $val',
2234             PrintConvColumns => 2,
2235             PrintConv => {
2236             0 => 'Program AE', # (RX100 'Program','Sunset' - PH)
2237             1 => 'Portrait', #PH (HX1)
2238             2 => 'Beach', #9
2239             3 => 'Sports', #9
2240             4 => 'Snow', #9
2241             5 => 'Landscape',
2242             6 => 'Auto', # (RX100 'Intelligent Auto' - PH)
2243             7 => 'Aperture-priority AE',
2244             8 => 'Shutter speed priority AE',
2245             9 => 'Night Scene / Twilight',#2/9
2246             10 => 'Hi-Speed Shutter', #9
2247             11 => 'Twilight Portrait', #9 (RX100 'Night Portrait' - PH)
2248             12 => 'Soft Snap/Portrait', #9 (TX7 'Soft Snap'; RX100/A37 'Portrait' but manuals say "reproduces soft skin tone" - PH)
2249             13 => 'Fireworks', #9
2250             14 => 'Smile Shutter', #9 (T200)
2251             15 => 'Manual',
2252             18 => 'High Sensitivity', #9
2253             19 => 'Macro', #JR
2254             20 => 'Advanced Sports Shooting', #9
2255             29 => 'Underwater', #9
2256             # 30 seen for DSC-W110 and W390, maybe something with Face or Portrait ??
2257             33 => 'Food', #9
2258             34 => 'Sweep Panorama', #PH (HX1)
2259             35 => 'Handheld Night Shot', #PH (HX1/TX1, also called "Hand-held Twilight")
2260             36 => 'Anti Motion Blur', #PH (TX1)
2261             37 => 'Pet', #9
2262             38 => 'Backlight Correction HDR', #9
2263             39 => 'Superior Auto', #9
2264             40 => 'Background Defocus', #PH (HX20V)
2265             41 => 'Soft Skin', #JR (HX9V) (HX200V Portrait - PH)
2266             42 => '3D Image', #JR (HX9V)
2267             # 50 seen for DSC-W530
2268             65535 => 'n/a', #PH (A100)
2269             },
2270             },
2271             0xb042 => { #9
2272             Name => 'FocusMode',
2273             # Only FocusMode for older DSC models;
2274             # Newest DSC models give only 0, many models of 'HX9V generation' give only 4 -
2275             # these models give FocusMode in tag 0xb04e, and are excluded here.
2276             Condition => q{
2277             ($$self{TagB042} = Get16u($valPt, 0)) and
2278             (not $$self{MetaVersion} or $$self{MetaVersion} ne 'DC7303320222000')
2279             },
2280             Notes => 'not valid for all models',
2281             Writable => 'int16u',
2282             RawConv => '$val == 65535 ? undef : $val',
2283             PrintConv => {
2284             # 0 - seen this for panorama shot
2285             1 => 'AF-S', # (called Single-AF by Sony)
2286             2 => 'AF-C', # (called Monitor-AF by Sony)
2287             4 => 'Permanent-AF', # (TX7,HX9V?)
2288             65535 => 'n/a', #PH (A100), also for DSC-W690 panorama shots
2289             },
2290             },
2291             0xb043 => [{ #9
2292             Name => 'AFAreaMode',
2293             # AFAreaMode only for older models;
2294             # exclude newest DSC models, which give AFAreaMode in Tag9402 0x0017 (eg. RX100 - PH)
2295             Writable => 'int16u',
2296             Condition => 'not $$self{MetaVersion} or $$self{MetaVersion} ne "DC7303320222000"', #JR
2297             RawConv => '$val == 65535 ? undef : $val',
2298             Notes => 'older models',
2299             PrintConv => {
2300             # 0 - (takes this value after camera reset, but can't be set back once changed)
2301             0 => 'Default',
2302             1 => 'Multi',
2303             2 => 'Center',
2304             3 => 'Spot',
2305             4 => 'Flexible Spot', # (T200)
2306             6 => 'Touch',
2307             14 => 'Tracking', #JR (HX9V) ("Manual" for the T200?, ref 9)
2308             15 => 'Face Tracking', # (not set when in face detect mode and no faces detected)
2309             65535 => 'n/a', #PH (A100)
2310             },
2311             },{ #JR
2312             Name => 'AFAreaMode',
2313             # AFAreaMode for DSC-HX9V generation, having values that appear to be different from older models.
2314             Writable => 'int16u',
2315             Condition => '$$self{TagB042} and $$self{TagB042} != 0',
2316             Notes => 'DSC-HX9V generation cameras',
2317             PrintConv => {
2318             0 => 'Multi',
2319             1 => 'Center',
2320             2 => 'Spot', #(NC) seen for DSC-WX9
2321             3 => 'Flexible Spot',
2322             10 => 'Selective (for Miniature effect)', # seen for Miniature effect of DSC-WX30
2323             14 => 'Tracking',
2324             15 => 'Face Tracking',
2325             255 => 'Manual',
2326             },
2327             }],
2328             0xb044 => { #9
2329             Name => 'AFIlluminator',
2330             Writable => 'int16u',
2331             RawConv => '$val == 65535 ? undef : $val',
2332             PrintConv => {
2333             0 => 'Off',
2334             1 => 'Auto',
2335             65535 => 'n/a', #PH (A100)
2336             },
2337             },
2338             # 0xb045 - int16u: 0
2339             # 0xb046 - int16u: 0
2340             0xb047 => { #2
2341             Name => 'JPEGQuality',
2342             Writable => 'int16u',
2343             RawConv => '$val == 65535 ? undef : $val',
2344             PrintConv => {
2345             0 => 'Standard',
2346             1 => 'Fine',
2347             2 => 'Extra Fine', #JR
2348             65535 => 'n/a', #PH (A100)
2349             },
2350             },
2351             0xb048 => { #9
2352             Name => 'FlashLevel', #JR other name, but values -9 to 9 match FlashExposureCompensation
2353             Writable => 'int16s',
2354             RawConv => '($val == -1 and $$self{Model} =~ /DSLR-A100\b/) ? undef : $val',
2355             PrintConv => {
2356             -32768 => 'Low',
2357             -9 => '-9/3', #JR
2358             -6 => '-6/3', #JR
2359             -5 => '-5/3', #JR
2360             -4 => '-4/3', #JR
2361             -3 => '-3/3',
2362             -2 => '-2/3',
2363             -1 => '-1/3', # (for the A100, -1 is effectively 'n/a' - PH)
2364             0 => 'Normal',
2365             1 => '+1/3',
2366             2 => '+2/3',
2367             3 => '+3/3',
2368             4 => '+4/3', #JR (NC)
2369             5 => '+5/3', #JR (NC)
2370             6 => '+6/3', #JR
2371             9 => '+9/3', #JR
2372             128 => 'n/a', #JR (HX9V)
2373             32767 => 'High',
2374             },
2375             },
2376             0xb049 => { #9
2377             Name => 'ReleaseMode',
2378             Writable => 'int16u',
2379             RawConv => '$val == 65535 ? undef : $val',
2380             PrintConv => {
2381             0 => 'Normal', # (ie. shutter button)
2382             2 => 'Continuous',
2383             5 => 'Exposure Bracketing',
2384             6 => 'White Balance Bracketing', # (HX5)
2385             8 => 'DRO Bracketing', #JR (ILCE-7RM2)
2386             65535 => 'n/a', #PH (A100)
2387             },
2388             },
2389             0xb04a => { #9
2390             Name => 'SequenceNumber',
2391             Notes => 'shot number in continuous burst',
2392             Writable => 'int16u',
2393             RawConv => '$val == 65535 ? undef : $val',
2394             PrintConv => {
2395             0 => 'Single',
2396             65535 => 'n/a', #PH (A100)
2397             OTHER => sub { shift }, # pass all other numbers straight through
2398             },
2399             },
2400             0xb04b => { #2/PH
2401             Name => 'Anti-Blur',
2402             Writable => 'int16u',
2403             RawConv => '$val == 65535 ? undef : $val',
2404             PrintConv => {
2405             0 => 'Off',
2406             1 => 'On (Continuous)', #PH (NC)
2407             2 => 'On (Shooting)', #PH (NC)
2408             65535 => 'n/a',
2409             },
2410             },
2411             # 0xb04c - rational64u: 10/10 (seen 5 for HX9V Manual-exposure images, ref JR)
2412             # 0xb04d - int16u: 0
2413             # (the Kamisaka decoding of 0xb04e seems wrong - ref JR)
2414             # 0xb04e => { #2
2415             # Name => 'LongExposureNoiseReduction',
2416             # Notes => 'LongExposureNoiseReduction for other models',
2417             # Writable => 'int16u',
2418             # RawConv => '$val == 65535 ? undef : $val',
2419             # PrintConv => {
2420             # 0 => 'Off',
2421             # 1 => 'On',
2422             # 2 => 'On 2', #PH (TX10, TX100, WX9, WX10, etc)
2423             # # 4 - seen this (CX360E, CX700E)
2424             # 65535 => 'n/a', #PH (A100)
2425             # },
2426             # },
2427             0xb04e => { #PH (RX100) - but not in RX100M3 anymore (ref JR)
2428             Name => 'FocusMode',
2429             Condition => '$$self{MetaVersion} and $$self{MetaVersion} eq "DC7303320222000"', #JR
2430             Notes => 'valid for DSC-HX9V generation and newer',
2431             Writable => 'int16u',
2432             PrintConv => {
2433             0 => 'Manual',
2434             # 1 - seen for DSC-WX7 burst, HDR-CX130E/CX560E
2435             2 => 'AF-S',
2436             3 => 'AF-C',
2437             # 4 - seen for HDR-CX360E/CX700E
2438             5 => 'Semi-manual', #JR (HX9V)
2439             6 => 'DMF', # "Direct Manual Focus"
2440             },
2441             },
2442             0xb04f => { #PH (TX1)
2443             Name => 'DynamicRangeOptimizer',
2444             Writable => 'int16u',
2445             Priority => 0, # (unreliable for the A77)
2446             PrintConv => {
2447             0 => 'Off',
2448             1 => 'Standard',
2449             2 => 'Plus',
2450             # 8 for HDR models - what does this mean?
2451             },
2452             },
2453             0xb050 => { #PH (RX100)
2454             Name => 'HighISONoiseReduction2',
2455             Condition => '$$self{Model} =~ /^(DSC-|Stellar)/',
2456             Notes => 'DSC models only',
2457             Writable => 'int16u',
2458             PrintConv => {
2459             0 => 'Normal',
2460             1 => 'High',
2461             2 => 'Low',
2462             3 => 'Off', #JR
2463             # it seems that all SLT and NEX models give n/a here (ref JR)
2464             65535 => 'n/a',
2465             },
2466             },
2467             # 0xb051 - int16u: 0
2468             0xb052 => { #PH (TX1)
2469             Name => 'IntelligentAuto',
2470             Writable => 'int16u',
2471             PrintConv => {
2472             0 => 'Off',
2473             1 => 'On',
2474             2 => 'Advanced', #9
2475             },
2476             },
2477             # 0xb053 - int16u: normally 0, but got 1 for a superior auto backlight picture (RX100)
2478             0xb054 => { #PH/9/JR (TX1,TX7,RX100,HX9V)
2479             Name => 'WhiteBalance',
2480             Writable => 'int16u',
2481             Notes => q{
2482             decoding of the Fluorescent settings matches the EXIF standard, which is
2483             different than the names used by Sony for some models
2484             },
2485             PrintConv => {
2486             0 => 'Auto',
2487             4 => 'Custom', # (manual)
2488             5 => 'Daylight',
2489             6 => 'Cloudy',
2490             # PrintConv names matching Exif Fluorescent LightSource names (ref JR)
2491             # (Sony uses conflicting names for some models)
2492             7 => 'Cool White Fluorescent', # (RX100) (TX7/HX9V "Fluorescent 1 (White)", ref 9/JR)
2493             8 => 'Day White Fluorescent', # (RX100) (TX7/HX9V "Fluorescent 2 (Natural White)", ref 9/JR)
2494             9 => 'Daylight Fluorescent', # (RX100) (TX7/HX9V "Fluorescent 3 (Day White)", ref 9/JR)
2495             10 => 'Incandescent2', #JR (HX9V)
2496             11 => 'Warm White Fluorescent',
2497             14 => 'Incandescent',
2498             15 => 'Flash',
2499             17 => 'Underwater 1 (Blue Water)', #9
2500             18 => 'Underwater 2 (Green Water)', #9
2501             19 => 'Underwater Auto', #JR
2502             },
2503             },
2504             );
2505              
2506             # "SEMC MS" maker notes
2507             %Image::ExifTool::Sony::Ericsson = (
2508             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
2509             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
2510             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
2511             NOTES => 'Maker notes found in images from some Sony Ericsson phones.',
2512             0x2000 => {
2513             Name => 'MakerNoteVersion',
2514             Writable => 'undef',
2515             Count => 4,
2516             },
2517             0x201 => {
2518             Name => 'PreviewImageStart',
2519             IsOffset => 1,
2520             MakerPreview => 1, # force preview inside maker notes
2521             OffsetPair => 0x202,
2522             DataTag => 'PreviewImage',
2523             Writable => 'int32u',
2524             WriteGroup => 'MakerNotes',
2525             Protected => 2,
2526             Notes => 'a small 320x200 preview image',
2527             },
2528             0x202 => {
2529             Name => 'PreviewImageLength',
2530             OffsetPair => 0x201,
2531             DataTag => 'PreviewImage',
2532             Writable => 'int32u',
2533             WriteGroup => 'MakerNotes',
2534             Protected => 2,
2535             },
2536             );
2537              
2538             # camera information for the A700/A850/A900 (ref JR)
2539             %Image::ExifTool::Sony::CameraInfo = (
2540             %binaryDataAttrs,
2541             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
2542             NOTES => 'Camera information for the A700, A850 and A900.',
2543             0x00 => {
2544             Name => 'LensSpec',
2545             # the A700/A850/A900 use a different int16 byte ordering! - PH
2546             Format => 'undef[8]',
2547             ValueConv => sub {
2548             my $val = shift;;
2549             return ConvLensSpec(pack('v*', unpack('n*', $val)));
2550             },
2551             ValueConvInv => sub {
2552             my $val = shift;
2553             return pack('v*', unpack('n*', ConvInvLensSpec($val)));
2554             },
2555             PrintConv => \&PrintLensSpec,
2556             PrintConvInv => \&PrintInvLensSpec,
2557             },
2558             0x0014 => {
2559             Name => 'FocusModeSetting',
2560             Notes => 'FocusModeSetting for the A700, A850 and A900',
2561             PrintConv => {
2562             0 => 'Manual',
2563             1 => 'AF-S',
2564             2 => 'AF-C',
2565             3 => 'AF-A',
2566             4 => 'DMF',
2567             },
2568             },
2569             0x0015 => { # the AF Point selected in AFAreaMode=Local or Spot; always '0' for AFAreaMode=Wide
2570             Name => 'AFPointSelected',
2571             PrintConvColumns => 2,
2572             PrintConv => {
2573             0 => 'Auto',
2574             1 => 'Center',
2575             2 => 'Top',
2576             3 => 'Upper-right',
2577             4 => 'Right',
2578             5 => 'Lower-right',
2579             6 => 'Bottom',
2580             7 => 'Lower-left',
2581             8 => 'Left',
2582             9 => 'Upper-left',
2583             10 => 'Far Right', # only given by A700
2584             11 => 'Far Left', # only given by A700
2585             },
2586             },
2587             # 0x0019 - AF sensor used for focusing for A700/A850/A900:
2588             #
2589             # A700 AF sensor layout: A850/A900 AF sensor layout:
2590             #
2591             # - *-* - = AF sensor
2592             # | | | | * = assist sensor
2593             # - *-* o = F2.8 sensor
2594             # | | |o| | | | * |o| * | A700 center: double-cross + F2.8
2595             # - *-* A850 center: double-cross + F2.8 + 4 assist
2596             # | | | |
2597             # - *-*
2598             #
2599             # Following values seen for A700/A850 in AFAreaMode=Local or Spot: (other values only seen in "Wide")
2600             #
2601             # 16
2602             # 0 19
2603             # 13
2604             # 3 1 22 20 18
2605             # 8
2606             # 2 21
2607             # 5
2608             #
2609             # Note 1: A850/A900 AFPoint Selected 'Left'/'Right' (in 0x0015) corresponds in position (see diagram)
2610             # to A700 Local AFPoint 'Far Left'/'Far Right', and gives 'Far Left'/'Far Right' in 0x0019.
2611             # Note 2: A700 in "Wide" also gives all 23 values in 0x0019, although it doesn't have assist-points ...
2612             0x0019 => { # the AF sensor used for focusing
2613             Name => 'AFPoint',
2614             PrintConv => {
2615             0 => 'Upper-left',
2616             1 => 'Left',
2617             2 => 'Lower-left',
2618             3 => 'Far Left',
2619             4 => 'Bottom Assist-left', #(NC)
2620             5 => 'Bottom',
2621             6 => 'Bottom Assist-right', #(NC)
2622             # values 7-14: 8 center points: 4 from double-cross + 4 assist; 7-10 appear horizontal, 11-14 vertical
2623             7 => 'Center (7)', #(NC)
2624             8 => 'Center (horizontal)',
2625             9 => 'Center (9)', #(NC)
2626             10 => 'Center (10)', #(NC)
2627             11 => 'Center (11)', #(NC)
2628             12 => 'Center (12)', #(NC)
2629             13 => 'Center (vertical)',
2630             14 => 'Center (14)', #(NC)
2631             15 => 'Top Assist-left', #(NC)
2632             16 => 'Top',
2633             17 => 'Top Assist-right', #(NC)
2634             18 => 'Far Right',
2635             19 => 'Upper-right',
2636             20 => 'Right',
2637             21 => 'Lower-right',
2638             22 => 'Center F2.8',
2639             },
2640             },
2641             # AF Status for A700/A850/A900, which have different sensor layout
2642             # and different int16 byte ordering
2643             0x001e => { Name => 'AFStatusActiveSensor', %Image::ExifTool::Minolta::afStatusInfo },
2644             0x0020 => { Name => 'AFStatusUpper-left', %Image::ExifTool::Minolta::afStatusInfo },
2645             0x0022 => { Name => 'AFStatusLeft', %Image::ExifTool::Minolta::afStatusInfo },
2646             0x0024 => { Name => 'AFStatusLower-left', %Image::ExifTool::Minolta::afStatusInfo },
2647             0x0026 => { Name => 'AFStatusFarLeft', %Image::ExifTool::Minolta::afStatusInfo },
2648             0x0028 => { Name => 'AFStatusBottomAssist-left', %Image::ExifTool::Minolta::afStatusInfo },
2649             0x002a => { Name => 'AFStatusBottom', %Image::ExifTool::Minolta::afStatusInfo },
2650             0x002c => { Name => 'AFStatusBottomAssist-right', %Image::ExifTool::Minolta::afStatusInfo },
2651             0x002e => { Name => 'AFStatusCenter-7', %Image::ExifTool::Minolta::afStatusInfo },
2652             0x0030 => { Name => 'AFStatusCenter-horizontal', %Image::ExifTool::Minolta::afStatusInfo },
2653             0x0032 => { Name => 'AFStatusCenter-9', %Image::ExifTool::Minolta::afStatusInfo },
2654             0x0034 => { Name => 'AFStatusCenter-10', %Image::ExifTool::Minolta::afStatusInfo },
2655             0x0036 => { Name => 'AFStatusCenter-11', %Image::ExifTool::Minolta::afStatusInfo },
2656             0x0038 => { Name => 'AFStatusCenter-12', %Image::ExifTool::Minolta::afStatusInfo },
2657             0x003a => { Name => 'AFStatusCenter-vertical', %Image::ExifTool::Minolta::afStatusInfo },
2658             0x003c => { Name => 'AFStatusCenter-14', %Image::ExifTool::Minolta::afStatusInfo },
2659             0x003e => { Name => 'AFStatusTopAssist-left', %Image::ExifTool::Minolta::afStatusInfo },
2660             0x0040 => { Name => 'AFStatusTop', %Image::ExifTool::Minolta::afStatusInfo },
2661             0x0042 => { Name => 'AFStatusTopAssist-right', %Image::ExifTool::Minolta::afStatusInfo },
2662             0x0044 => { Name => 'AFStatusFarRight', %Image::ExifTool::Minolta::afStatusInfo },
2663             0x0046 => { Name => 'AFStatusUpper-right', %Image::ExifTool::Minolta::afStatusInfo },
2664             0x0048 => { Name => 'AFStatusRight', %Image::ExifTool::Minolta::afStatusInfo },
2665             0x004a => { Name => 'AFStatusLower-right', %Image::ExifTool::Minolta::afStatusInfo },
2666             0x004c => { Name => 'AFStatusCenterF2-8', %Image::ExifTool::Minolta::afStatusInfo },
2667             0x0130 => {
2668             Name => 'AFMicroAdjValue',
2669             Condition => '$$self{Model} =~ /^DSLR-A(850|900)\b/',
2670             ValueConv => '$val - 20',
2671             ValueConvInv => '$val + 20',
2672             },
2673             0x0131 => {
2674             Name => 'AFMicroAdjMode',
2675             Condition => '$$self{Model} =~ /^DSLR-A(850|900)\b/',
2676             Mask => 0x80,
2677             PrintConv => {
2678             0 => 'Off',
2679             1 => 'On',
2680             },
2681             },
2682             305.1 => { # (0x131)
2683             Name => 'AFMicroAdjRegisteredLenses',
2684             Notes => 'number of registered lenses with a non-zero AFMicroAdjValue',
2685             Condition => '$$self{Model} =~ /^DSLR-A(850|900)\b/',
2686             Mask => 0x7f,
2687             },
2688             # 0x0166 - 40 x 128 int8u values: AF Info Blocks for A850 and A900, not for A700
2689             );
2690              
2691             # camera information for other DSLR models (ref JR)
2692             %Image::ExifTool::Sony::CameraInfo2 = (
2693             %binaryDataAttrs,
2694             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
2695             NOTES => q{
2696             Camera information for the DSLR-A200, A230, A290, A300, A330, A350, A380 and
2697             A390.
2698             },
2699             0x00 => {
2700             Name => 'LensSpec',
2701             Format => 'undef[8]',
2702             ValueConv => \&ConvLensSpec,
2703             ValueConvInv => \&ConvInvLensSpec,
2704             PrintConv => \&PrintLensSpec,
2705             PrintConvInv => \&PrintInvLensSpec,
2706             },
2707             # 0x0010 - maybe to do with AFStatus: 0 na./Manual, 4 Failed, 16 Tracking, 64 Focused
2708             0x0014 => {
2709             Name => 'AFPointSelected',
2710             PrintConvColumns => 2,
2711             PrintConv => { #JR (NC) same list as A100, A700/A900, as all have 9 point AF
2712             0 => 'Auto',
2713             1 => 'Center',
2714             2 => 'Top',
2715             3 => 'Upper-right',
2716             4 => 'Right',
2717             5 => 'Lower-right',
2718             6 => 'Bottom',
2719             7 => 'Lower-left',
2720             8 => 'Left',
2721             9 => 'Upper-left',
2722             },
2723             },
2724             0x0015 => {
2725             Name => 'FocusModeSetting',
2726             Notes => 'FocusModeSetting for other models',
2727             PrintConv => {
2728             0 => 'Manual',
2729             1 => 'AF-S',
2730             2 => 'AF-C',
2731             3 => 'AF-A',
2732             4 => 'DMF',
2733             },
2734             },
2735             # 0x0018 - AF sensor used for focusing for A200/A230/A290/A300/A330/A350/A380/A390; AF sensor layout:
2736             #
2737             # - - = AF sensor
2738             # | | + = cross sensor
2739             #
2740             # - + -
2741             #
2742             # | |
2743             # -
2744             #
2745             0x0018 => { # used A100 list which appears to match
2746             Name => 'AFPoint',
2747             PrintConv => {
2748             0 => 'Top-right',
2749             1 => 'Bottom-right',
2750             2 => 'Bottom',
2751             3 => 'Middle Horizontal',
2752             4 => 'Center Vertical',
2753             5 => 'Top',
2754             6 => 'Top-left',
2755             7 => 'Bottom-left',
2756             },
2757             },
2758             # AF Status for A200/A230/A290/A300/A330/A350/A380/A390: analogous to A100 in Minolta.pm
2759             0x001b => { Name => 'AFStatusActiveSensor', %Image::ExifTool::Minolta::afStatusInfo },
2760             0x001d => { Name => 'AFStatusTop-right', %Image::ExifTool::Minolta::afStatusInfo },
2761             0x001f => { Name => 'AFStatusBottom-right', %Image::ExifTool::Minolta::afStatusInfo },
2762             0x0021 => { Name => 'AFStatusBottom', %Image::ExifTool::Minolta::afStatusInfo },
2763             # MiddleHorizontal is any of the 3 central horizontal sensors
2764             0x0023 => { Name => 'AFStatusMiddleHorizontal', %Image::ExifTool::Minolta::afStatusInfo },
2765             0x0025 => { Name => 'AFStatusCenterVertical', %Image::ExifTool::Minolta::afStatusInfo },
2766             0x0027 => { Name => 'AFStatusTop', %Image::ExifTool::Minolta::afStatusInfo },
2767             0x0029 => { Name => 'AFStatusTop-left', %Image::ExifTool::Minolta::afStatusInfo },
2768             0x002b => { Name => 'AFStatusBottom-left', %Image::ExifTool::Minolta::afStatusInfo },
2769             # the 3 MiddleHorizontal sensors
2770             0x002d => { Name => 'AFStatusLeft', %Image::ExifTool::Minolta::afStatusInfo },
2771             0x002f => { Name => 'AFStatusCenterHorizontal', %Image::ExifTool::Minolta::afStatusInfo },
2772             0x0031 => { Name => 'AFStatusRight', %Image::ExifTool::Minolta::afStatusInfo },
2773             # 0x0166 - 59 x 96 int8u values: AF Info Blocks for A230/A290/A330/A380/A390
2774             # 0x0182 - 58 x 88 int8u values: AF Info Blocks for A200/A300/A350
2775             );
2776              
2777             # Camera information for the A55 (ref PH)
2778             # (also valid for A33, A35, A560, A580 - ref JR)
2779             %Image::ExifTool::Sony::CameraInfo3 = (
2780             %binaryDataAttrs,
2781             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
2782             IS_SUBDIR => [ 0x23 ],
2783             NOTES => q{
2784             Camera information stored by the A33, A35, A55, A450, A500, A550, A560,
2785             A580, NEX-3/5/5C/C3 and VG10E. Some tags are valid only for some of these
2786             models.
2787             },
2788             0x00 => { #JR
2789             Name => 'LensSpec',
2790             Condition => '$$self{Model} !~ /^NEX-5C/',
2791             Format => 'undef[8]',
2792             ValueConv => \&ConvLensSpec,
2793             ValueConvInv => \&ConvInvLensSpec,
2794             PrintConv => \&PrintLensSpec,
2795             PrintConvInv => \&PrintInvLensSpec,
2796             },
2797             0x0e => { #JR
2798             Name => 'FocalLength',
2799             Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)$/',
2800             Format => 'int16u',
2801             Priority => 0,
2802             ValueConv => '$val / 10',
2803             ValueConvInv => '$val * 10',
2804             PrintConv => 'sprintf("%.1f mm",$val)',
2805             PrintConvInv => '$val =~ s/ mm//; $val',
2806             },
2807             0x10 => { #JR
2808             Name => 'FocalLengthTeleZoom',
2809             Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)$/',
2810             Format => 'int16u',
2811             ValueConv => '$val * 2 / 3',
2812             ValueConvInv => 'int($val * 3 / 2 + 0.5)',
2813             PrintConv => 'sprintf("%.1f mm",$val)',
2814             PrintConvInv => '$val =~ s/ mm//; $val',
2815             },
2816             #
2817             # Note:
2818             # The below AF decoding covers cameras with 2 different AF systems, with overlapping offsets !
2819             # 1) DSLR-A450/A500/A550 with 9 point AF system: decoding/offsets identical to A200 - A390 in CameraInfo
2820             # 2) SLT-A33/A35/A55 and DSLR-A560/A580 with 15 point AF system: similar/more info but at different offsets
2821             #
2822             0x14 => { #JR
2823             Name => 'AFPointSelected',
2824             Condition => '$$self{Model} =~ /^(DSLR-A(450|500|550))\b/',
2825             # (these cameras have a 9-point AF system, ref JR)
2826             PrintConvColumns => 2,
2827             PrintConv => {
2828             0 => 'Auto', # (seen in Wide mode and for Manual Focus)
2829             1 => 'Center', # seen for AFArea=Spot
2830             2 => 'Top',
2831             3 => 'Upper-right',
2832             4 => 'Right',
2833             5 => 'Lower-right',
2834             6 => 'Bottom',
2835             7 => 'Lower-left',
2836             8 => 'Left',
2837             9 => 'Upper-left',
2838             },
2839             },
2840             0x15 => { #JR
2841             Name => 'FocusMode',
2842             Condition => '$$self{Model} =~ /^(DSLR-A(450|500|550))\b/',
2843             PrintConv => {
2844             0 => 'Manual',
2845             1 => 'AF-S',
2846             2 => 'AF-C',
2847             3 => 'AF-A',
2848             },
2849             },
2850             0x18 => { #JR
2851             Name => 'AFPoint',
2852             Condition => '$$self{Model} =~ /^DSLR-A(450|500|550)\b/',
2853             PrintConv => {
2854             0 => 'Top-right',
2855             1 => 'Bottom-right',
2856             2 => 'Bottom',
2857             3 => 'Middle Horizontal',
2858             4 => 'Center Vertical',
2859             5 => 'Top',
2860             6 => 'Top-left',
2861             7 => 'Bottom-left',
2862             },
2863             },
2864             0x19 => { #JR
2865             Name => 'FocusStatus',
2866             Condition => '$$self{Model} =~ /^(SLT-|DSLR-A(560|580))\b/',
2867             Notes => 'not valid with Contrast AF or for NEX models',
2868             # seen the following values:
2869             # 0 with MF (A35, A55V-HDR, A560, A580), non-AF lens (A35), and A580 Contrast-AF
2870             # 4 with MF (A33, A55V), and A580 Contrast-AF
2871             # 16 with AF-C (or AF-A) and focus OK
2872             # 24 with AF-C (or AF-A) and unsharp or fast moving subject e.g. bird in flight
2873             # 64 with AF-S (or AF-A) and focus OK
2874             PrintConv => {
2875             0 => 'Manual - Not confirmed (0)',
2876             4 => 'Manual - Not confirmed (4)',
2877             16 => 'AF-C - Confirmed',
2878             24 => 'AF-C - Not Confirmed',
2879             64 => 'AF-S - Confirmed',
2880             },
2881             },
2882             0x1b => { #JR
2883             Name => 'AFStatusActiveSensor',
2884             Condition => '$$self{Model} =~ /^DSLR-A(450|500|550)\b/',
2885             %Image::ExifTool::Minolta::afStatusInfo,
2886             },
2887             0x1c => {
2888             Name => 'AFPointSelected', # (v8.88: renamed from LocalAFAreaPointSelected)
2889             Condition => '$$self{Model} =~ /^(SLT-|DSLR-A(560|580))\b/',
2890             Notes => 'not valid for Contrast AF', #JR
2891             # (all of these cameras have an 15-point three-cross AF system, ref JR)
2892             PrintConvColumns => 2,
2893             PrintConv => {
2894             0 => 'Auto', # (seen in Wide mode)
2895             1 => 'Center',
2896             2 => 'Top',
2897             3 => 'Upper-right',
2898             4 => 'Right',
2899             5 => 'Lower-right',
2900             6 => 'Bottom',
2901             7 => 'Lower-left',
2902             8 => 'Left',
2903             9 => 'Upper-left',
2904             10 => 'Far Right',
2905             11 => 'Far Left',
2906             12 => 'Upper-middle',
2907             13 => 'Near Right',
2908             14 => 'Lower-middle',
2909             15 => 'Near Left',
2910             },
2911             },
2912             0x1d => [
2913             {
2914             Name => 'FocusMode',
2915             Condition => '$$self{Model} =~ /^(SLT-|DSLR-A(560|580))\b/',
2916             PrintConv => {
2917             0 => 'Manual',
2918             1 => 'AF-S',
2919             2 => 'AF-C',
2920             3 => 'AF-A',
2921             },
2922             },{ #JR
2923             Name => 'AFStatusTop-right',
2924             Condition => '$$self{Model} =~ /^DSLR-A(450|500|550)\b/',
2925             %Image::ExifTool::Minolta::afStatusInfo,
2926             },
2927             ],
2928             0x1f => { #JR
2929             Name => 'AFStatusBottom-right',
2930             Condition => '$$self{Model} =~ /^DSLR-A(450|500|550)\b/',
2931             %Image::ExifTool::Minolta::afStatusInfo,
2932             },
2933             0x20 => { #JR
2934             Name => 'AFPoint', # (v8.88: renamed from LocalAFAreaPointUsed)
2935             Condition => '$$self{Model} =~ /^(SLT-|DSLR-A(560|580))\b/',
2936             Notes => 'the AF sensor used for focusing. Not valid for Contrast AF',
2937             PrintConvColumns => 2,
2938             PrintConv => {
2939             %afPoint15,
2940             255 => '(none)', #PH (A55, guess; also A35 with non-AF lens, ref JR)
2941             },
2942             },
2943             0x21 => [ #JR
2944             {
2945             Name => 'AFStatusActiveSensor',
2946             Condition => '$$self{Model} =~ /^(SLT-|DSLR-A(560|580))\b/',
2947             %Image::ExifTool::Minolta::afStatusInfo,
2948             },{
2949             Name => 'AFStatusBottom',
2950             Condition => '$$self{Model} =~ /^DSLR-A(450|500|550)\b/',
2951             %Image::ExifTool::Minolta::afStatusInfo,
2952             },
2953             ],
2954             0x23 => [ #JR
2955             {
2956             Name => 'AFStatus15',
2957             Condition => '$$self{Model} =~ /^(SLT-|DSLR-A(560|580))\b/',
2958             Format => 'int16s[18]',
2959             SubDirectory => { TagTable => 'Image::ExifTool::Sony::AFStatus15' },
2960             },{
2961             Name => 'AFStatusMiddleHorizontal', # MiddleHorizontal is any of the 3 central horizontal sensors
2962             Condition => '$$self{Model} =~ /^DSLR-A(450|500|550)\b/',
2963             %Image::ExifTool::Minolta::afStatusInfo,
2964             },
2965             ],
2966             0x25 => { Name => 'AFStatusCenterVertical', Condition => '$$self{Model} =~ /^DSLR-A(450|500|550)\b/', %Image::ExifTool::Minolta::afStatusInfo },
2967             0x27 => { Name => 'AFStatusTop', Condition => '$$self{Model} =~ /^DSLR-A(450|500|550)\b/', %Image::ExifTool::Minolta::afStatusInfo },
2968             0x29 => { Name => 'AFStatusTop-left', Condition => '$$self{Model} =~ /^DSLR-A(450|500|550)\b/', %Image::ExifTool::Minolta::afStatusInfo },
2969             0x2b => { Name => 'AFStatusBottom-left', Condition => '$$self{Model} =~ /^DSLR-A(450|500|550)\b/', %Image::ExifTool::Minolta::afStatusInfo },
2970             # the 3 MiddleHorizontal sensors:
2971             0x2d => { Name => 'AFStatusLeft', Condition => '$$self{Model} =~ /^DSLR-A(450|500|550)\b/', %Image::ExifTool::Minolta::afStatusInfo },
2972             0x2f => { Name => 'AFStatusCenterHorizontal', Condition => '$$self{Model} =~ /^DSLR-A(450|500|550)\b/', %Image::ExifTool::Minolta::afStatusInfo },
2973             0x31 => { Name => 'AFStatusRight', Condition => '$$self{Model} =~ /^DSLR-A(450|500|550)\b/', %Image::ExifTool::Minolta::afStatusInfo },
2974             # 0x0166 - starting here there are 96 AF Info blocks of 155 bytes each for the SLT-A33/A35/A55 and DSLR-A560/A580,
2975             # starting here there are 86 AF Info blocks of 174 bytes each for the DSLR-A450/A500/A550,
2976             # but NOT for NEX, and not for the A580 in Contrast-AF mode (ref JR)
2977             # The 43rd byte of each block for A580 appears to be the AFPoint as in offset 0x20,
2978             # possibly also 73rd and 74th byte
2979             );
2980              
2981             # Camera information for other models (ref PH)
2982             %Image::ExifTool::Sony::CameraInfoUnknown = (
2983             %binaryDataAttrs,
2984             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
2985             );
2986              
2987             # white balance and other camera information (ref PH)
2988             %Image::ExifTool::Sony::FocusInfo = (
2989             %binaryDataAttrs,
2990             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
2991             PRIORITY => 0,
2992             NOTES => q{
2993             More camera settings and focus information decoded for models such as the
2994             A200, A230, A290, A300, A330, A350, A380, A390, A700, A850 and A900.
2995             },
2996             0x0e => [{ #7/JR
2997             Name => 'DriveMode2',
2998             Condition => '$$self{Model} =~ /^DSLR-A(230|290|330|380|390)$/',
2999             Notes => 'A230, A290, A330, A380 and A390',
3000             ValueConvInv => '$val',
3001             PrintHex => 1,
3002             PrintConv => { # (values confirmed for specified models - PH)
3003             0x01 => 'Single Frame', # (A230,A330,A380)
3004             0x02 => 'Continuous High', #PH (A230,A330)
3005             0x04 => 'Self-timer 10 sec', # (A230)
3006             0x05 => 'Self-timer 2 sec, Mirror Lock-up', # (A230,A290,A330,A380,390)
3007             0x07 => 'Continuous Bracketing', # (A230,A330)
3008             0x0a => 'Remote Commander', # (A230)
3009             0x0b => 'Continuous Self-timer', # (A230,A330)
3010             },
3011             },{
3012             Name => 'DriveMode2',
3013             Notes => 'A200, A300, A350, A700, A850 and A900',
3014             ValueConvInv => '$val',
3015             PrintHex => 1,
3016             PrintConv => {
3017             0x01 => 'Single Frame',
3018             0x02 => 'Continuous High', # A700/A900; not on A850
3019             0x12 => 'Continuous Low', #JR
3020             0x04 => 'Self-timer 10 sec',
3021             0x05 => 'Self-timer 2 sec, Mirror Lock-up',
3022             0x06 => 'Single-frame Bracketing',
3023             0x07 => 'Continuous Bracketing',
3024             0x18 => 'White Balance Bracketing Low', #JR
3025             0x28 => 'White Balance Bracketing High', #JR
3026             0x19 => 'D-Range Optimizer Bracketing Low', #JR
3027             0x29 => 'D-Range Optimizer Bracketing High', #JR
3028             0x0a => 'Remote Commander', #JR
3029             0x0b => 'Mirror Lock-up', #JR (A850/A900; not on A700)
3030             },
3031             }],
3032             0x10 => { #JR (1 and 2 inverted!)
3033             Name => 'Rotation',
3034             PrintConv => {
3035             0 => 'Horizontal (normal)',
3036             1 => 'Rotate 270 CW',
3037             2 => 'Rotate 90 CW',
3038             },
3039             },
3040             0x14 => {
3041             Name => 'ImageStabilizationSetting',
3042             PrintConv => { 0 => 'Off', 1 => 'On' },
3043             },
3044             0x15 => { #7
3045             Name => 'DynamicRangeOptimizerMode',
3046             PrintConv => {
3047             0 => 'Off',
3048             1 => 'Standard',
3049             2 => 'Advanced Auto',
3050             3 => 'Advanced Level',
3051             },
3052             },
3053             0x2b => { #JR seen 2,1,3 for both WB and DRO bracketing
3054             Name => 'BracketShotNumber',
3055             Notes => 'WB and DRO bracketing',
3056             },
3057             0x2c => { #JR
3058             Name => 'WhiteBalanceBracketing',
3059             PrintConv => {
3060             0 => 'Off',
3061             1 => 'Low',
3062             2 => 'High',
3063             },
3064             },
3065             0x2d => { #JR seen 2,1,3 for both WB and DRO bracketing
3066             Name => 'BracketShotNumber2',
3067             },
3068             0x2e => { #JR
3069             Name => 'DynamicRangeOptimizerBracket',
3070             PrintConv => {
3071             0 => 'Off',
3072             1 => 'Low',
3073             2 => 'High',
3074             },
3075             },
3076             0x2f => { #JR seen 0,1,2 and 0,1,2,3,4 for 3 and 5 image bracketing sequences
3077             Name => 'ExposureBracketShotNumber',
3078             },
3079             0x3f => { #JR
3080             Name => 'ExposureProgram',
3081             SeparateTable => 'ExposureProgram',
3082             PrintConv => \%sonyExposureProgram,
3083             },
3084             0x41 => { #JR style actually used (combination of mode dial + creative style menu)
3085             Name => 'CreativeStyle',
3086             PrintConvColumns => 2,
3087             PrintConv => {
3088             1 => 'Standard',
3089             2 => 'Vivid',
3090             3 => 'Portrait',
3091             4 => 'Landscape',
3092             5 => 'Sunset',
3093             6 => 'Night View/Portrait',
3094             8 => 'B&W',
3095             9 => 'Adobe RGB', # A700
3096             11 => 'Neutral',
3097             12 => 'Clear', #7
3098             13 => 'Deep', #7
3099             14 => 'Light', #7
3100             15 => 'Autumn Leaves', #7
3101             16 => 'Sepia', #7
3102             },
3103             },
3104             0x6d => {
3105             Name => 'ISOSetting',
3106             ValueConv => '$val ? exp(($val/8-6)*log(2))*100 : $val',
3107             ValueConvInv => '$val ? 8*(log($val/100)/log(2)+6) : $val',
3108             PrintConv => '$val ? sprintf("%.0f",$val) : "Auto"',
3109             PrintConvInv => '$val =~ /auto/i ? 0 : $val',
3110             },
3111             0x6f => {
3112             Name => 'ISO',
3113             ValueConv => '$val ? exp(($val/8-6)*log(2))*100 : $val',
3114             ValueConvInv => '$val ? 8*(log($val/100)/log(2)+6) : $val',
3115             PrintConv => '$val ? sprintf("%.0f",$val) : "Auto"',
3116             PrintConvInv => '$val =~ /auto/i ? 0 : $val',
3117             },
3118             0x77 => { #JR
3119             Name => 'DynamicRangeOptimizerMode',
3120             PrintConv => {
3121             0 => 'Off',
3122             1 => 'Standard',
3123             2 => 'Advanced Auto',
3124             3 => 'Advanced Level',
3125             },
3126             },
3127             0x79 => 'DynamicRangeOptimizerLevel',
3128             # 0x06f1 - int16u LensType, Condition => '$$self{Model} =~ /^DSLR-A(700|850|900)$/',
3129             # 0x4a81 - int16u LensType, Condition => '$$self{Model} !~ /^DSLR-A(700|850|900)$/',
3130             # 0x4a84 - int16uRev LensType, Condition => '$$self{Model} =~ /^DSLR-A(700|850|900)$/',
3131             0x0846 => { #13
3132             Name => 'ShutterCount', # (=ImageCount for these models)
3133             Condition => '$$self{Model} =~ /^DSLR-A(230|290|330|380|390|850|900)$/',
3134             Format => 'int32u',
3135             Notes => 'only valid for some DSLR models',
3136             RawConv => '$val & 0x00ffffff', #PH
3137             },
3138             0x09bb => { #PH (validated only for DSLR-A850)
3139             Name => 'FocusPosition',
3140             Condition => '$$self{Model} =~ /^DSLR-A(200|230|290|300|330|350|380|390|700|850|900)$/',
3141             Notes => 'only valid for some DSLR models',
3142             # 128 = infinity -- see Composite:FocusDistance below
3143             },
3144             0x1110 => { # (9600 bytes: 4 sets of 40x30 int16u values in the range 0-8191)
3145             Name => 'TiffMeteringImage',
3146             Format => 'undef[9600]',
3147             Notes => q{
3148             13-bit RBGG (?) 40x30 pixels, presumably metering info, extracted as a
3149             16-bit TIFF image;
3150             },
3151             ValueConv => sub {
3152             my ($val, $et) = @_;
3153             return undef unless length $val >= 9600;
3154             return \ "Binary data 7404 bytes" unless $et->Options('Binary');
3155             my @dat = unpack('n*', $val);
3156             # TIFF header for a 16-bit RGB 10dpi 40x30 image
3157             $val = Image::ExifTool::MakeTiffHeader(40,30,3,16,10);
3158             # re-order data to RGB pixels
3159             my ($i, @val);
3160             for ($i=0; $i<40*30; ++$i) {
3161             # data is 13-bit (max 8191), shift left to fill 16 bits
3162             # (typically, this gives a very dark image since the data should
3163             # really be anti-logged to convert from EV to perceived brightness)
3164             # push @val, $dat[$i]<<3, $dat[$i+2400]<<3, $dat[$i+1200]<<3;
3165             push @val, int(5041.1*log($dat[$i]+1)/log(2)), int(5041.1*log($dat[$i+2400]+1)/log(2)), int(5041.1*log($dat[$i+1200]+1)/log(2));
3166             }
3167             $val .= pack('v*', @val); # add TIFF strip data
3168             return \$val;
3169             },
3170             },
3171             );
3172              
3173             # more camera setting information (ref JR)
3174             # - many of these tags are the same as in CameraSettings3
3175             %Image::ExifTool::Sony::MoreInfo = (
3176             PROCESS_PROC => \&ProcessMoreInfo,
3177             WRITE_PROC => \&ProcessMoreInfo,
3178             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3179             NOTES => q{
3180             More camera settings information decoded for the A450, A500, A550, A560,
3181             A580, A33, A35, A55, NEX-3/5/C3 and VG10E.
3182             },
3183             0x0001 => { # (256 bytes)
3184             Name => 'MoreSettings',
3185             SubDirectory => { TagTable => 'Image::ExifTool::Sony::MoreSettings' },
3186             },
3187             # (byte sizes for a single A580 image -- not checked for other images)
3188             0x0002 => [ # (256 bytes)
3189             {
3190             Name => 'FaceInfo',
3191             Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)$/',
3192             SubDirectory => { TagTable => 'Image::ExifTool::Sony::FaceInfo' },
3193             },{
3194             Name => 'FaceInfoA',
3195             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)$/',
3196             SubDirectory => { TagTable => 'Image::ExifTool::Sony::FaceInfoA' },
3197             },
3198             ],
3199             # 0x0101: 512 bytes
3200             # 0x0102: 1804 bytes
3201             # 0x0103: 176 bytes
3202             # 0x0104: 1088 bytes
3203             # 0x0105: 160 bytes (all zero unless flash is used, ref JR)
3204             # 0x0106: 256 bytes (faces detected if first byte is non-zero? ref JR)
3205             0x0107 => { # (7200 bytes: 3 sets of 40x30 int16u values in the range 0-1023)
3206             Name => 'TiffMeteringImage',
3207             Notes => q{
3208             10-bit RGB data from the 1200 AE metering segments, extracted as a 16-bit
3209             TIFF image
3210             },
3211             ValueConv => sub {
3212             my ($val, $et) = @_;
3213             return undef unless length $val >= 7200;
3214             return \ "Binary data 7404 bytes" unless $et->Options('Binary');
3215             my @dat = unpack('v*', $val);
3216             # TIFF header for a 16-bit RGB 10dpi 40x30 image
3217             $val = Image::ExifTool::MakeTiffHeader(40,30,3,16,10);
3218             # re-order data to RGB pixels
3219             my ($i, @val);
3220             for ($i=0; $i<40*30; ++$i) {
3221             # data is 10-bit (max 1023), shift left to fill 16 bits
3222             # (typically, this gives a very dark image since the data should
3223             # really be anti-logged to convert from EV to perceived brightness)
3224             push @val, $dat[$i]<<6, $dat[$i+1200]<<6, $dat[$i+2400]<<6;
3225             }
3226             $val .= pack('v*', @val); # add TIFF strip data
3227             return \$val;
3228             },
3229             },
3230             # 0x0108: 140 bytes
3231             # 0x0109: 256 bytes
3232             # 0x010a: 256 bytes
3233             # 0x0306: 276 bytes
3234             # 0x0307: 256 bytes
3235             # 0x0308: 96 bytes
3236             # 0x0309: 112 bytes
3237             # 0xffff: 788 bytes
3238             0x0201 => { # (368 bytes)
3239             Name => 'MoreInfo0201',
3240             SubDirectory => { TagTable => 'Image::ExifTool::Sony::MoreInfo0201' },
3241             },
3242             # 0x0202: 144 bytes
3243             # 0x0401: 4608 bytes
3244             0x0401 => {
3245             Name => 'MoreInfo0401',
3246             SubDirectory => { TagTable => 'Image::ExifTool::Sony::MoreInfo0401' },
3247             },
3248             );
3249              
3250             %Image::ExifTool::Sony::MoreInfo0201 = (
3251             %binaryDataAttrs,
3252             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3253             PRIORITY => 0,
3254             # 0x005d - also from 0 - 255, in sync with but lower than 0x005e, depending on FocalLength
3255             # 0x005e => {
3256             # # FocusPosition for A560/A580/A33/A35/A55V
3257             # # seen values from 80 - 255 (= infinity) -- see Composite:FocusDistance2 below
3258             # Name => 'FocusPosition2_0201',
3259             # Condition => '$$self{Model} !~ /^(NEX-|DSLR-(A450|A500|A550)$)/',
3260             # },
3261             # 0x0093 - also from 0 - 255, in sync with but lower than 0x0094, depending on FocalLength
3262             # 0x0094 => {
3263             # # FocusPosition for A450/A500/A550
3264             # # seen values from 80 - 255 (= infinity) -- see Composite:FocusDistance2 below
3265             # Name => 'FocusPosition2_0201',
3266             # Condition => '$$self{Model} =~ /^(DSLR-(A450|A500|A550)$)/',
3267             # },
3268             0x011b => { #13
3269             Name => 'ImageCount',
3270             Condition => '$$self{Model} !~ /^DSLR-A(450|500|550)$/', #JR
3271             Format => 'int32u',
3272             Notes => 'not valid for the A450, A500 or A550',
3273             RawConv => '$val & 0x00ffffff',
3274             },
3275             0x0125 => { #13
3276             Name => 'ShutterCount',
3277             Condition => '$$self{Model} !~ /^DSLR-A(450|500|550)$/', #JR
3278             Format => 'int32u',
3279             Notes => 'not valid for the A450, A500 or A550',
3280             RawConv => '$val & 0x00ffffff',
3281             },
3282             0x014a => { #13
3283             Name => 'ShutterCount', # (=ImageCount for these models)
3284             Condition => '$$self{Model} =~ /^DSLR-A(450|500|550)$/', #JR
3285             Format => 'int32u',
3286             Notes => 'A450, A500 and A550 only',
3287             RawConv => '$val & 0x00ffffff',
3288             },
3289             );
3290              
3291             %Image::ExifTool::Sony::MoreInfo0401 = (
3292             %binaryDataAttrs,
3293             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3294             PRIORITY => 0,
3295             0x044e => { #JR
3296             Name => 'ShotNumberSincePowerUp',
3297             Condition => '$$self{Model} !~ /^NEX-(3|5)$/',
3298             Format => 'int32u',
3299             Notes => 'Not valid for the NEX-3 or NEX-5',
3300             RawConv => '$val & 0x00ffffff',
3301             },
3302             # 0x101e - int16u LensType Condition => '$$self{Model} =~ /^SLT-A(33|55V)/',
3303             # 0x1022 - int16u LensType Condition => '$$self{Model} =~ /^DSLR-A(560|580)/',
3304             # 0x102a - int16u LensType Condition => '$$self{Model} =~ /^(SLT-A35|NEX-C3)/',
3305              
3306             # 0x10a8 - int16u LensType Condition => '$$self{Model} =~ /^SLT-A(33|55V)/',
3307             # 0x10ac - int16u LensType Condition => '$$self{Model} =~ /^DSLR-A(560|580)/',
3308             # 0x10b4 - int16u LensType Condition => '$$self{Model} =~ /^(SLT-A35|NEX-C3)/',
3309             #
3310             # 0x10f7 - int16u LensType Condition => '$$self{Model} =~ /^SLT-A(33|55V)/',
3311             # 0x10fb - int16u LensType Condition => '$$self{Model} =~ /^DSLR-A(560|580)/',
3312             # 0x1103 - int16u LensType Condition => '$$self{Model} =~ /^(SLT-A35|NEX-C3)/',
3313             #
3314             # 0x1181 - int16u LensType Condition => '$$self{Model} =~ /^SLT-A(33|55V)/',
3315             # 0x1185 - int16u LensType Condition => '$$self{Model} =~ /^DSLR-A(560|580)/',
3316             # 0x118d - int16u LensType Condition => '$$self{Model} =~ /^(SLT-A35|NEX-C3)/',
3317             );
3318              
3319             # more camera setting information (ref JR)
3320             # - many of these tags are the same as in CameraSettings3
3321             %Image::ExifTool::Sony::MoreSettings = (
3322             %binaryDataAttrs,
3323             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3324             PRIORITY => 0,
3325             0x01 => { # interesting: somewhere between CameraSettings3 0x04 and 0x34
3326             Name => 'DriveMode2',
3327             PrintHex => 1,
3328             PrintConv => {
3329             0x10 => 'Single Frame',
3330             0x21 => 'Continuous High', # also automatically selected for Scene mode Sports-action (0x05=52)
3331             0x22 => 'Continuous Low',
3332             0x30 => 'Speed Priority Continuous',
3333             0x51 => 'Self-timer 10 sec',
3334             0x52 => 'Self-timer 2 sec, Mirror Lock-up',
3335             0x71 => 'Continuous Bracketing 0.3 EV',
3336             0x75 => 'Continuous Bracketing 0.7 EV',
3337             0x91 => 'White Balance Bracketing Low',
3338             0x92 => 'White Balance Bracketing High',
3339             0xc0 => 'Remote Commander',
3340             },
3341             },
3342             0x02 => {
3343             Name => 'ExposureProgram',
3344             SeparateTable => 'ExposureProgram2',
3345             PrintConv => \%sonyExposureProgram2,
3346             },
3347             0x03 => {
3348             Name => 'MeteringMode',
3349             PrintConv => {
3350             1 => 'Multi-segment',
3351             2 => 'Center-weighted average',
3352             3 => 'Spot',
3353             },
3354             },
3355             0x04 => {
3356             Name => 'DynamicRangeOptimizerSetting',
3357             PrintConv => {
3358             1 => 'Off',
3359             16 => 'On (Auto)',
3360             17 => 'On (Manual)',
3361             },
3362             },
3363             0x05 => 'DynamicRangeOptimizerLevel',
3364             0x06 => {
3365             Name => 'ColorSpace',
3366             PrintConv => {
3367             1 => 'sRGB',
3368             2 => 'Adobe RGB',
3369             },
3370             },
3371             0x07 => {
3372             Name => 'CreativeStyleSetting',
3373             PrintConvColumns => 2,
3374             PrintConv => {
3375             16 => 'Standard',
3376             32 => 'Vivid',
3377             64 => 'Portrait',
3378             80 => 'Landscape',
3379             96 => 'B&W',
3380             160 => 'Sunset',
3381             },
3382             },
3383             0x08 => { #JR
3384             Name => 'ContrastSetting',
3385             Format => 'int8s',
3386             PrintConv => '$val > 0 ? "+$val" : $val',
3387             PrintConvInv => '$val',
3388             },
3389             0x09 => {
3390             Name => 'SaturationSetting',
3391             Format => 'int8s',
3392             PrintConv => '$val > 0 ? "+$val" : $val',
3393             PrintConvInv => '$val',
3394             },
3395             0x0a => {
3396             Name => 'SharpnessSetting',
3397             Format => 'int8s',
3398             PrintConv => '$val > 0 ? "+$val" : $val',
3399             PrintConvInv => '$val',
3400             },
3401             0x0d => {
3402             Name => 'WhiteBalanceSetting',
3403             # many guessed, based on "logical system" as observed for Daylight and Shade and steps of 16 between the modes
3404             PrintHex => 1,
3405             PrintConvColumns => 2,
3406             PrintConv => \%whiteBalanceSetting,
3407             SeparateTable => 1,
3408             },
3409             0x0e => {
3410             Name => 'ColorTemperatureSetting',
3411             # matches "0xb021 ColorTemperature" when WB set to "Custom" or "Color Temperature/Color Filter"
3412             ValueConv => '$val * 100',
3413             ValueConvInv => '$val / 100',
3414             PrintConv => '"$val K"',
3415             PrintConvInv => '$val =~ s/ ?K$//i; $val',
3416             },
3417             0x0f => {
3418             Name => 'ColorCompensationFilterSet',
3419             # seen 0, 1-9 and 245-255, corresponding to 0, M1-M9 and G9-G1 on camera display
3420             # matches "0xb022 ColorCompensationFilter" when WB set to "Custom" or "Color Temperature/Color Filter"
3421             Format => 'int8s',
3422             Notes => 'negative is green, positive is magenta',
3423             PrintConv => '$val > 0 ? "+$val" : $val',
3424             PrintConvInv => '$val',
3425             },
3426             0x10 => {
3427             Name => 'FlashMode',
3428             PrintConvColumns => 2,
3429             PrintConv => {
3430             1 => 'Flash Off',
3431             16 => 'Autoflash',
3432             17 => 'Fill-flash',
3433             18 => 'Slow Sync',
3434             19 => 'Rear Sync',
3435             20 => 'Wireless',
3436             },
3437             },
3438             0x11 => {
3439             Name => 'LongExposureNoiseReduction',
3440             PrintConv => {
3441             1 => 'Off',
3442             16 => 'On', # (unused or dark subject)
3443             },
3444             },
3445             0x12 => {
3446             Name => 'HighISONoiseReduction',
3447             PrintConv => {
3448             16 => 'Low',
3449             17 => 'High',
3450             19 => 'Auto',
3451             },
3452             },
3453             0x13 => { # why is this not valid for A450/A500/A550 ?
3454             Name => 'FocusMode',
3455             Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)$/',
3456             PrintConv => {
3457             17 => 'AF-S',
3458             18 => 'AF-C',
3459             19 => 'AF-A',
3460             32 => 'Manual',
3461             48 => 'DMF', #(NC) (seen for NEX-5)
3462             },
3463             },
3464             0x15 => {
3465             Name => 'MultiFrameNoiseReduction',
3466             Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)$/',
3467             PrintConv => {
3468             0 => 'n/a', # seen for A450/A500/A550
3469             1 => 'Off',
3470             16 => 'On',
3471             255 => 'None', # seen for NEX-3/5/C3
3472             },
3473             },
3474             0x16 => {
3475             Name => 'HDRSetting',
3476             PrintConv => {
3477             1 => 'Off',
3478             16 => 'On (Auto)',
3479             17 => 'On (Manual)',
3480             },
3481             },
3482             0x17 => {
3483             Name => 'HDRLevel',
3484             PrintConvColumns => 3,
3485             PrintConv => {
3486             33 => '1 EV',
3487             34 => '1.5 EV', #JR (NC)
3488             35 => '2 EV',
3489             36 => '2.5 EV', #JR (NC)
3490             37 => '3 EV',
3491             38 => '3.5 EV', #PH (NC)
3492             39 => '4 EV',
3493             40 => '5 EV',
3494             41 => '6 EV',
3495             },
3496             },
3497             0x18 => {
3498             Name => 'ViewingMode',
3499             PrintConv => {
3500             16 => 'ViewFinder',
3501             33 => 'Focus Check Live View',
3502             34 => 'Quick AF Live View',
3503             },
3504             },
3505             0x19 => {
3506             Name => 'FaceDetection',
3507             PrintConv => {
3508             1 => 'Off',
3509             16 => 'On',
3510             },
3511             },
3512             0x1a => {
3513             Name => 'CustomWB_RBLevels',
3514             # matches "0x7313 WB_RGGBLevels" when WB set to "Custom", except factor of 4
3515             Format => 'int16uRev[2]',
3516             },
3517             # From here different and overlapping offsets for 3 groups of cameras:
3518             # 1) DSLR-A450/A500/A550
3519             # 2) NEX-3/5/5C
3520             # 3) DSLR-A560/A580, NEX-C3/VG10/VG10E, SLT-A33/A35/A55V
3521             0x1e => [{
3522             Name => 'BrightnessValue',
3523             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)/',
3524             Notes => 'A450, A500 and A550',
3525             ValueConv => '($val-106)/8',
3526             ValueConvInv => '$val * 8 + 106',
3527             },{
3528             Name => 'ExposureCompensationSet',
3529             Notes => 'other models',
3530             ValueConv => '($val - 128) / 24', #PH
3531             ValueConvInv => 'int($val * 24 + 128.5)',
3532             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
3533             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
3534             }],
3535             0x1f => [{
3536             Name => 'ISO',
3537             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)/',
3538             Notes => 'A450, A500 and A550',
3539             ValueConv => '$val ? exp(($val/8-6)*log(2))*100 : $val',
3540             ValueConvInv => '$val ? 8*(log($val/100)/log(2)+6) : $val',
3541             PrintConv => '$val ? sprintf("%.0f",$val) : "Auto"',
3542             PrintConvInv => '$val =~ /auto/i ? 0 : $val',
3543             },{
3544             Name => 'FlashExposureCompSet',
3545             Notes => 'other models',
3546             Description => 'Flash Exposure Comp. Setting',
3547             ValueConv => '($val - 128) / 24', #PH
3548             ValueConvInv => 'int($val * 24 + 128.5)',
3549             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
3550             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
3551             }],
3552             0x20 => [{
3553             Name => 'FNumber',
3554             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)/',
3555             Notes => 'A450, A500 and A550',
3556             ValueConv => '2 ** (($val/8 - 1) / 2)',
3557             ValueConvInv => 'int((log($val) * 2 / log(2) + 1) * 8 + 0.5)',
3558             PrintConv => 'Image::ExifTool::Exif::PrintFNumber($val)',
3559             PrintConvInv => '$val',
3560             },{
3561             Name => 'LiveViewAFMethod',
3562             Condition => '$$self{Model} !~ /^NEX-(3|5|5C)/',
3563             Notes => 'other models except the NEX-3/5/5C',
3564             PrintConv => {
3565             0 => 'n/a',
3566             1 => 'Phase-detect AF',
3567             2 => 'Contrast AF',
3568             # Contrast AF is only available with SSM/SAM lenses and in Focus Check LV,
3569             # NOT in Quick AF LV, and is automatically set when mounting SSM/SAM lens
3570             # - changes into Phase-AF when switching to Quick AF LV.
3571             },
3572             }],
3573             0x21 => [{
3574             Name => 'ExposureTime',
3575             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)/',
3576             Notes => 'A450, A500 and A550',
3577             ValueConv => '$val ? 2 ** (6 - $val/8) : 0',
3578             ValueConvInv => '$val ? int((6 - log($val) / log(2)) * 8 + 0.5) : 0',
3579             PrintConv => '$val ? Image::ExifTool::Exif::PrintExposureTime($val) : "Bulb"',
3580             PrintConvInv => 'lc($val) eq "bulb" ? 0 : Image::ExifTool::Exif::ConvertFraction($val)',
3581             },{
3582             Name => 'ISO',
3583             Condition => '$$self{Model} =~ /^NEX-(3|5|5C)/',
3584             Notes => 'NEX-3/5/5C',
3585             ValueConv => '$val ? exp(($val/8-6)*log(2))*100 : $val',
3586             ValueConvInv => '$val ? 8*(log($val/100)/log(2)+6) : $val',
3587             PrintConv => '$val ? sprintf("%.0f",$val) : "Auto"',
3588             PrintConvInv => '$val =~ /auto/i ? 0 : $val',
3589             }],
3590             0x22 => {
3591             Name => 'FNumber',
3592             Condition => '$$self{Model} =~ /^NEX-(3|5|5C)/',
3593             Notes => 'NEX-3/5/5C only',
3594             ValueConv => '2 ** (($val/8 - 1) / 2)',
3595             ValueConvInv => 'int((log($val) * 2 / log(2) + 1) * 8 + 0.5)',
3596             PrintConv => 'Image::ExifTool::Exif::PrintFNumber($val)',
3597             PrintConvInv => '$val',
3598             },
3599             0x23 => [{
3600             Name => 'FocalLength2',
3601             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)/',
3602             Notes => 'A450, A500 and A550',
3603             ValueConv => '10 * 2 ** (($val-28)/16)',
3604             ValueConvInv => '$val>0 ? log($val/10)/log(2) * 16 + 28 : 0',
3605             PrintConv => 'sprintf("%.1f mm",$val)',
3606             PrintConvInv => '$val=~s/\s*mm$//; $val',
3607             },{
3608             Name => 'ExposureTime',
3609             Condition => '$$self{Model} =~ /^NEX-(3|5|5C)/',
3610             Notes => 'NEX-3/5/5C',
3611             ValueConv => '$val ? 2 ** (6 - $val/8) : 0',
3612             ValueConvInv => '$val ? int((6 - log($val) / log(2)) * 8 + 0.5) : 0',
3613             PrintConv => '$val ? Image::ExifTool::Exif::PrintExposureTime($val) : "Bulb"',
3614             PrintConvInv => 'lc($val) eq "bulb" ? 0 : Image::ExifTool::Exif::ConvertFraction($val)',
3615             }],
3616             0x24 => {
3617             Name => 'ExposureCompensation2',
3618             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)/',
3619             Notes => 'A450, A500 and A550',
3620             Format => 'int16s',
3621             ValueConv => '$val / 8',
3622             ValueConvInv => '$val * 8',
3623             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
3624             PrintConvInv => '$val',
3625             },
3626             0x25 => [{
3627             Name => 'FocalLength2',
3628             Condition => '$$self{Model} =~ /^NEX-(3|5|5C)/',
3629             Notes => 'NEX-3/5/5C',
3630             ValueConv => '10 * 2 ** (($val-28)/16)',
3631             ValueConvInv => '$val>0 ? log($val/10)/log(2) * 16 + 28 : 0',
3632             PrintConv => 'sprintf("%.1f mm",$val)',
3633             PrintConvInv => '$val=~s/\s*mm$//; $val',
3634             },{
3635             Name => 'ISO',
3636             Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)/',
3637             Notes => 'other models except the A450, A500 and A550',
3638             ValueConv => '$val ? exp(($val/8-6)*log(2))*100 : $val',
3639             ValueConvInv => '$val ? 8*(log($val/100)/log(2)+6) : $val',
3640             PrintConv => '$val ? sprintf("%.0f",$val) : "Auto"',
3641             PrintConvInv => '$val =~ /auto/i ? 0 : $val',
3642             }],
3643             0x26 => [{
3644             Name => 'FlashExposureCompSet2',
3645             Description => 'Flash Exposure Comp. Setting 2',
3646             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)/',
3647             Notes => 'A450, A500 and A550',
3648             Format => 'int16s',
3649             ValueConv => '$val / 8',
3650             ValueConvInv => '$val * 8',
3651             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
3652             PrintConvInv => '$val',
3653             },{
3654             Name => 'ExposureCompensation2',
3655             Condition => '$$self{Model} =~ /^NEX-(3|5|5C)/',
3656             Notes => 'NEX-3/5/5C',
3657             Format => 'int16s',
3658             ValueConv => '$val / 8',
3659             ValueConvInv => '$val * 8',
3660             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
3661             PrintConvInv => '$val',
3662             },{
3663             Name => 'FNumber',
3664             Notes => 'other models',
3665             ValueConv => '2 ** (($val/8 - 1) / 2)',
3666             ValueConvInv => 'int((log($val) * 2 / log(2) + 1) * 8 + 0.5)',
3667             PrintConv => 'Image::ExifTool::Exif::PrintFNumber($val)',
3668             PrintConvInv => '$val',
3669             }],
3670             0x27 => {
3671             Name => 'ExposureTime',
3672             Condition => '$$self{Model} !~ /^NEX-(3|5|5C)|DSLR-(A450|A500|A550)/',
3673             Notes => 'models other than the A450, A500, A550 and NEX-3/5/5C',
3674             ValueConv => '$val ? 2 ** (6 - $val/8) : 0',
3675             ValueConvInv => '$val ? int((6 - log($val) / log(2)) * 8 + 0.5) : 0',
3676             PrintConv => '$val ? Image::ExifTool::Exif::PrintExposureTime($val) : "Bulb"',
3677             PrintConvInv => 'lc($val) eq "bulb" ? 0 : Image::ExifTool::Exif::ConvertFraction($val)',
3678             },
3679             0x28 => {
3680             Name => 'Orientation2',
3681             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)/',
3682             Notes => 'A450, A500 and A550',
3683             PrintConv => {
3684             1 => 'Horizontal (normal)',
3685             2 => 'Rotate 180',
3686             6 => 'Rotate 90 CW',
3687             8 => 'Rotate 270 CW',
3688             },
3689             },
3690             0x29 => [{
3691             # FocusPosition for A450/A500/A550
3692             # seen values from 80 - 255 (= infinity) -- see Composite:FocusDistance2 below
3693             Name => 'FocusPosition2',
3694             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)/',
3695             Notes => 'A450, A500 and A550',
3696             },{
3697             # value increase of 16 corresponds to doubling of FocalLength
3698             Name => 'FocalLength2',
3699             Condition => '$$self{Model} !~ /^NEX-(3|5|5C)/',
3700             Notes => 'other models except the NEX-3/5/5C',
3701             ValueConv => '10 * 2 ** (($val-28)/16)',
3702             ValueConvInv => '$val>0 ? log($val/10)/log(2) * 16 + 28 : 0',
3703             PrintConv => 'sprintf("%.1f mm",$val)',
3704             PrintConvInv => '$val=~s/\s*mm$//; $val',
3705             }],
3706             0x2a => [{
3707             Name => 'FlashAction',
3708             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)/',
3709             Notes => 'A450, A500 and A550',
3710             PrintConv => {
3711             0 => 'Did not fire',
3712             1 => 'Fired',
3713             },
3714             },{
3715             Name => 'ExposureCompensation2',
3716             Condition => '$$self{Model} !~ /^NEX-(3|5|5C)/',
3717             Notes => 'other models except the NEX-3/5/5C',
3718             Format => 'int16s',
3719             ValueConv => '$val / 8',
3720             ValueConvInv => '$val * 8',
3721             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
3722             PrintConvInv => '$val',
3723             }],
3724             0x2b => {
3725             # FocusPosition for NEX-3/5/5C
3726             # seen values from 80 - 255 (= infinity) -- see Composite:FocusDistance2 below
3727             Name => 'FocusPosition2',
3728             Condition => '$$self{Model} =~ /^NEX-(3|5|5C)/',
3729             Notes => 'NEX-3/5/5C only',
3730             },
3731             0x2c => [{
3732             Name => 'FocusMode2',
3733             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)/',
3734             Notes => 'A450, A500 and A550',
3735             PrintConv => {
3736             0 => 'AF',
3737             1 => 'MF',
3738             },
3739             },{
3740             Name => 'FlashAction',
3741             Condition => '$$self{Model} =~ /^NEX-(3|5|5C)/',
3742             Notes => 'NEX-3/5/5C FlashAction2',
3743             PrintConv => {
3744             0 => 'Did not fire',
3745             1 => 'Fired',
3746             },
3747             },{
3748             Name => 'FlashExposureCompSet2',
3749             Description => 'Flash Exposure Comp. Setting 2',
3750             Notes => 'other models FlashExposureCompSet2',
3751             Format => 'int16s',
3752             ValueConv => '$val / 8',
3753             ValueConvInv => '$val * 8',
3754             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
3755             PrintConvInv => '$val',
3756             }],
3757             0x2e => [{
3758             Name => 'FocusMode2',
3759             Condition => '$$self{Model} =~ /^NEX-(3|5|5C)/',
3760             Notes => 'NEX-3/5/5C',
3761             PrintConv => {
3762             0 => 'AF',
3763             1 => 'MF',
3764             },
3765             },{
3766             Name => 'Orientation2', # seen some A55 images where this does not match the other Orientation tags
3767             Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)/',
3768             Notes => 'other models except the A450, A500 and A550',
3769             PrintConv => {
3770             1 => 'Horizontal (normal)',
3771             2 => 'Rotate 180',
3772             6 => 'Rotate 90 CW',
3773             8 => 'Rotate 270 CW',
3774             },
3775             }],
3776             0x2f => {
3777             # FocusPosition for A560/A580/A33/A35/A55V and NEX-C3/VG10/VG10E
3778             # seen values from 80 - 255 (= infinity) -- see Composite:FocusDistance2 below
3779             Name => 'FocusPosition2',
3780             Condition => '$$self{Model} !~ /^NEX-(3|5|5C)|DSLR-(A450|A500|A550)/',
3781             Notes => 'models other than the A450, A500, A550 and NEX-3/5/5C',
3782             },
3783             0x30 => {
3784             Name => 'FlashAction',
3785             Condition => '$$self{Model} !~ /^NEX-(3|5|5C)|DSLR-(A450|A500|A550)/',
3786             Notes => 'models other than the A450, A500, A550 and NEX-3/5/5C',
3787             PrintConv => {
3788             0 => 'Did not fire',
3789             1 => 'Fired',
3790             },
3791             },
3792             0x32 => {
3793             Name => 'FocusMode2',
3794             Condition => '$$self{Model} !~ /^NEX-(3|5|5C)|DSLR-(A450|A500|A550)/',
3795             Notes => 'models other than the A450, A500, A550 and NEX-3/5/5C',
3796             PrintConv => {
3797             0 => 'AF',
3798             1 => 'MF',
3799             },
3800             },
3801             0x0077 => {
3802             Name => 'FlashAction2',
3803             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)/',
3804             PrintConv => {
3805             0 => 'Did not fire',
3806             2 => 'External Flash fired (2)',
3807             3 => 'Built-in Flash fired',
3808             4 => 'External Flash fired (4)', # what is difference with 2 ?
3809             },
3810             },
3811             0x0078 => {
3812             Name => 'FlashActionExternal',
3813             Condition => '$$self{Model} =~ /^NEX-(3|5|5C)/',
3814             PrintConv => {
3815             136 => 'Did not fire',
3816             121 => 'Fired', # what is difference with 122 ?
3817             122 => 'Fired',
3818             },
3819             },
3820             0x007c => {
3821             Name => 'FlashActionExternal',
3822             Condition => '$$self{Model} !~ /^NEX-(3|5|5C)|DSLR-(A450|A500|A550)/',
3823             PrintConv => {
3824             136 => 'Did not fire',
3825             167 => 'Fired',
3826             182 => 'Fired, HSS',
3827             },
3828             },
3829             0x0082 => {
3830             Name => 'FlashStatus',
3831             Condition => '$$self{Model} =~ /^NEX-(3|5|5C)/',
3832             PrintConv => {
3833             0 => 'None',
3834             2 => 'External',
3835             },
3836             },
3837             0x0086 => {
3838             Name => 'FlashStatus',
3839             Condition => '$$self{Model} !~ /^NEX-(3|5|5C)|DSLR-(A450|A500|A550)/',
3840             PrintConv => {
3841             0 => 'None',
3842             1 => 'Built-in',
3843             2 => 'External',
3844             },
3845             },
3846             );
3847              
3848             # Face detection information (ref JR)
3849             my %faceInfo = (
3850             Format => 'int16u[4]',
3851             # re-order to top,left,height,width and scale to full-sized image like other Sony models
3852             ValueConv => 'my @v=split(" ",$val); $_*=15 foreach @v; "$v[1] $v[0] $v[3] $v[2]"',
3853             ValueConvInv => 'my @v=split(" ",$val); $_=int($_/15+0.5) foreach @v; "$v[1] $v[0] $v[3] $v[2]"',
3854             );
3855             %Image::ExifTool::Sony::FaceInfo = (
3856             %binaryDataAttrs,
3857             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3858             FORMAT => 'int16u',
3859             DATAMEMBER => [ 0x00 ],
3860             0x00 => {
3861             Name => 'FacesDetected',
3862             DataMember => 'FacesDetected',
3863             Format => 'int16s',
3864             RawConv => '$$self{FacesDetected} = ($val == -1 ? 0 : $val); $val',
3865             PrintConv => {
3866             OTHER => sub { shift }, # pass other values straight through
3867             -1 => 'n/a',
3868             },
3869             },
3870             0x01 => {
3871             Name => 'Face1Position',
3872             Condition => '$$self{FacesDetected} >= 1',
3873             %faceInfo,
3874             Notes => q{
3875             re-ordered and scaled to return the top, left, height and width of detected
3876             face, with coordinates relative to the full-sized unrotated image and
3877             increasing Y downwards
3878             },
3879             },
3880             0x06 => {
3881             Name => 'Face2Position',
3882             Condition => '$$self{FacesDetected} >= 2',
3883             %faceInfo,
3884             },
3885             0x0b => {
3886             Name => 'Face3Position',
3887             Condition => '$$self{FacesDetected} >= 3',
3888             %faceInfo,
3889             },
3890             0x10 => {
3891             Name => 'Face4Position',
3892             Condition => '$$self{FacesDetected} >= 4',
3893             %faceInfo,
3894             },
3895             0x15 => {
3896             Name => 'Face5Position',
3897             Condition => '$$self{FacesDetected} >= 5',
3898             %faceInfo,
3899             },
3900             0x1a => {
3901             Name => 'Face6Position',
3902             Condition => '$$self{FacesDetected} >= 6',
3903             %faceInfo,
3904             },
3905             0x1f => {
3906             Name => 'Face7Position',
3907             Condition => '$$self{FacesDetected} >= 7',
3908             %faceInfo,
3909             },
3910             0x24 => {
3911             Name => 'Face8Position',
3912             Condition => '$$self{FacesDetected} >= 8',
3913             %faceInfo,
3914             },
3915             );
3916              
3917             %Image::ExifTool::Sony::FaceInfoA = ( # different offsets for A450/A500/A550
3918             %binaryDataAttrs,
3919             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3920             FORMAT => 'int16u',
3921             DATAMEMBER => [ 0x02, 0x03, 0x08 ],
3922             #
3923             # The FacesDetected number at 0x03 below is often 1 lower than the one at Tag900b 0x02.
3924             # The number of Face Positions starting at 0x5b (max. 4) corresponds to the number at 0x03.
3925             # The number of Face Positions starting at 0x0b usually corresponds to the FacesDetected number of Tag900b...
3926             # Therefore created the extra condition at 0x0b (11.1) to output an available FacePosition, even when 0x03=0...
3927             #
3928             0x02 => {
3929             Name => 'FaceTest2',
3930             DataMember => 'FaceTest2',
3931             Hidden => 1,
3932             RawConv => '$$self{FaceTest2} = $val; $$self{OPTIONS}{Unknown}<2 ? undef : $val',
3933             },
3934             0x03 => {
3935             Name => 'FacesDetected',
3936             DataMember => 'FacesDetected',
3937             RawConv => '$$self{FacesDetected} = ($val > 8 ? 0 : $val); $val',
3938             ValueConv => '$val > 8 ? 0 : $val',
3939             },
3940             0x08 => {
3941             Name => 'FaceTest8',
3942             DataMember => 'FaceTest8',
3943             Hidden => 1,
3944             RawConv => '$$self{FaceTest8} = $val; $$self{OPTIONS}{Unknown}<2 ? undef : $val',
3945             },
3946             # 0x0b - start of 8 Face Positions of 10 int16u values each
3947             0x0b => {
3948             Name => 'PotentialFace1Position',
3949             Condition => q{
3950             $$self{FacesDetected} >= 1 or
3951             ($$self{FaceTest8} > 0 and ($$self{FaceTest2} == 1 or $$self{FaceTest2} == 257))
3952             },
3953             %faceInfo,
3954             },
3955             0x15 => {
3956             Name => 'PotentialFace2Position',
3957             Condition => '$$self{FacesDetected} >= 2 or ($$self{FacesDetected} == 1 and $$self{FaceTest8} > 0)',
3958             %faceInfo,
3959             },
3960             0x1f => {
3961             Name => 'PotentialFace3Position',
3962             Condition => '$$self{FacesDetected} >= 3 or ($$self{FacesDetected} == 2 and $$self{FaceTest8} > 0)',
3963             %faceInfo,
3964             },
3965             0x29 => {
3966             Name => 'PotentialFace4Position',
3967             Condition => '$$self{FacesDetected} >= 4 or ($$self{FacesDetected} == 3 and $$self{FaceTest8} > 0)',
3968             %faceInfo,
3969             },
3970             0x33 => {
3971             Name => 'PotentialFace5Position',
3972             Condition => '$$self{FacesDetected} >= 5 or ($$self{FacesDetected} == 4 and $$self{FaceTest8} > 0)',
3973             %faceInfo,
3974             },
3975             0x3d => {
3976             Name => 'PotentialFace6Position',
3977             Condition => '$$self{FacesDetected} >= 6 or ($$self{FacesDetected} == 5 and $$self{FaceTest8} > 0)',
3978             %faceInfo,
3979             },
3980             0x47 => {
3981             Name => 'PotentialFace7Position',
3982             Condition => '$$self{FacesDetected} >= 7 or ($$self{FacesDetected} == 6 and $$self{FaceTest8} > 0)',
3983             %faceInfo,
3984             },
3985             0x51 => {
3986             Name => 'PotentialFace8Position',
3987             Condition => '$$self{FacesDetected} >= 8 or ($$self{FacesDetected} == 7 and $$self{FaceTest8} > 0)',
3988             %faceInfo,
3989             },
3990             # 0x5b - start of max. 4 further Face Positions here
3991             0x5b => {
3992             Name => 'Face1Position',
3993             Condition => '$$self{FacesDetected} >= 1',
3994             %faceInfo,
3995             },
3996             0x65 => {
3997             Name => 'Face2Position',
3998             Condition => '$$self{FacesDetected} >= 2',
3999             %faceInfo,
4000             },
4001             0x6f => {
4002             Name => 'Face3Position',
4003             Condition => '$$self{FacesDetected} >= 3',
4004             %faceInfo,
4005             },
4006             0x79 => {
4007             Name => 'Face4Position',
4008             Condition => '$$self{FacesDetected} >= 4',
4009             %faceInfo,
4010             },
4011             );
4012              
4013             # Camera settings (ref PH) (decoded mainly from A200)
4014             %Image::ExifTool::Sony::CameraSettings = (
4015             %binaryDataAttrs,
4016             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4017             FORMAT => 'int16u',
4018             PRIORITY => 0,
4019             NOTES => 'Camera settings for the A200, A300, A350, A700, A850 and A900.',
4020             0x00 => { #JR
4021             Name => 'ExposureTime',
4022             ValueConv => '$val ? 2 ** (6 - $val/8) : 0',
4023             ValueConvInv => '$val ? int((6 - log($val) / log(2)) * 8 + 0.5) : 0',
4024             PrintConv => '$val ? Image::ExifTool::Exif::PrintExposureTime($val) : "Bulb"',
4025             PrintConvInv => 'lc($val) eq "bulb" ? 0 : Image::ExifTool::Exif::ConvertFraction($val)',
4026             },
4027             0x01 => { #JR
4028             Name => 'FNumber',
4029             ValueConv => '2 ** (($val/8 - 1) / 2)',
4030             ValueConvInv => 'int((log($val) * 2 / log(2) + 1) * 8 + 0.5)',
4031             PrintConv => 'Image::ExifTool::Exif::PrintFNumber($val)',
4032             PrintConvInv => '$val',
4033             },
4034             0x02 => { #JR (requires external flash)
4035             Name => 'HighSpeedSync',
4036             PrintConv => {
4037             0 => 'Off',
4038             1 => 'On',
4039             },
4040             },
4041             0x03 => { #JR
4042             Name => 'ExposureCompensationSet',
4043             ValueConv => '($val - 128) / 24',
4044             ValueConvInv => 'int($val * 24 + 128.5)',
4045             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
4046             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
4047             },
4048             0x04 => { #7/JR
4049             Name => 'DriveMode',
4050             Mask => 0xff, # (not sure what upper byte is for)
4051             PrintHex => 1,
4052             PrintConv => {
4053             0x01 => 'Single Frame',
4054             0x02 => 'Continuous High', # A700/A900; not on A850
4055             0x12 => 'Continuous Low', #JR
4056             0x04 => 'Self-timer 10 sec',
4057             0x05 => 'Self-timer 2 sec, Mirror Lock-up',
4058             0x06 => 'Single-frame Bracketing',
4059             0x07 => 'Continuous Bracketing', # (A200 val=0x1107)
4060             0x18 => 'White Balance Bracketing Low', #JR
4061             0x28 => 'White Balance Bracketing High', #JR
4062             0x19 => 'D-Range Optimizer Bracketing Low', #JR
4063             0x29 => 'D-Range Optimizer Bracketing High', #JR
4064             0x0a => 'Remote Commander', #JR
4065             0x0b => 'Mirror Lock-up', #JR (A850/A900; not on A700)
4066             },
4067             },
4068             0x05 => { #JR
4069             Name => 'WhiteBalanceSetting',
4070             PrintConv => {
4071             2 => 'Auto',
4072             4 => 'Daylight',
4073             5 => 'Fluorescent',
4074             6 => 'Tungsten',
4075             7 => 'Flash',
4076             16 => 'Cloudy',
4077             17 => 'Shade',
4078             18 => 'Color Temperature/Color Filter',
4079             32 => 'Custom 1',
4080             33 => 'Custom 2',
4081             34 => 'Custom 3',
4082             },
4083             },
4084             0x06 => { #7 (A700) (ref JR: at least also valid for A200, ValueConv as for ColorCompensationFilterSet)
4085             Name => 'WhiteBalanceFineTune',
4086             ValueConv => '$val > 128 ? $val - 256 : $val',
4087             ValueConvInv => '$val < 0 ? $val + 256 : $val',
4088             },
4089             0x07 => { #JR as set in WB "Color Temperature/Color Filter" and in White Balance Bracketing
4090             Name => 'ColorTemperatureSet',
4091             ValueConv => '$val * 100',
4092             ValueConvInv => '$val / 100',
4093             PrintConv => '"$val K"',
4094             PrintConvInv => '$val =~ s/ ?K$//i; $val',
4095             },
4096             0x08 => { #JR as set in WB "Color Temperature/Color Filter"
4097             Name => 'ColorCompensationFilterSet',
4098             Notes => 'negative is green, positive is magenta',
4099             ValueConv => '$val > 128 ? $val - 256 : $val',
4100             ValueConvInv => '$val < 0 ? $val + 256 : $val',
4101             PrintConv => '$val > 0 ? "+$val" : $val',
4102             PrintConvInv => '$val',
4103             },
4104             0x0c => { #JR as set in WB "Custom" and in White Balance Bracketing
4105             Name => 'ColorTemperatureCustom',
4106             ValueConv => '$val * 100',
4107             ValueConvInv => '$val / 100',
4108             PrintConv => '"$val K"',
4109             PrintConvInv => '$val =~ s/ ?K$//i; $val',
4110             },
4111             0x0d => { #JR as set in WB "Custom"
4112             Name => 'ColorCompensationFilterCustom',
4113             Notes => 'negative is green, positive is magenta',
4114             ValueConv => '$val > 128 ? $val - 256 : $val',
4115             ValueConvInv => '$val < 0 ? $val + 256 : $val',
4116             PrintConv => '$val > 0 ? "+$val" : $val',
4117             PrintConvInv => '$val',
4118             },
4119             0x0f => { #JR
4120             Name => 'WhiteBalance',
4121             PrintConv => {
4122             2 => 'Auto',
4123             4 => 'Daylight',
4124             5 => 'Fluorescent',
4125             6 => 'Tungsten',
4126             7 => 'Flash',
4127             12 => 'Color Temperature',
4128             13 => 'Color Filter',
4129             14 => 'Custom',
4130             16 => 'Cloudy',
4131             17 => 'Shade',
4132             },
4133             },
4134             0x10 => { #7 (A700)
4135             Name => 'FocusModeSetting',
4136             PrintConv => {
4137             0 => 'Manual',
4138             1 => 'AF-S',
4139             2 => 'AF-C',
4140             3 => 'AF-A',
4141             4 => 'DMF', #JR
4142             },
4143             },
4144             0x11 => { #JD (A700)
4145             Name => 'AFAreaMode',
4146             PrintConv => {
4147             0 => 'Wide',
4148             1 => 'Local',
4149             2 => 'Spot',
4150             },
4151             },
4152             0x12 => { #7 (A700)
4153             Name => 'AFPointSetting',
4154             Format => 'int16u',
4155             # The AF point as selected by the user in AFAreaMode=Local or Spot;
4156             # Reported value remains at the last-set position in AFAreaModes=Wide.
4157             # A200, A300, A350: 9-point centre-cross (ref JR)
4158             # A700: 11-point centre-dual-cross (ref JR)
4159             # A850, A900: 9-point centre-dual-cross with 10 assist-points (ref JR)
4160             PrintConvColumns => 2,
4161             PrintConv => {
4162             1 => 'Center',
4163             2 => 'Top',
4164             3 => 'Upper-right',
4165             4 => 'Right',
4166             5 => 'Lower-right',
4167             6 => 'Bottom',
4168             7 => 'Lower-left',
4169             8 => 'Left',
4170             9 => 'Upper-left',
4171             10 => 'Far Right', # (presumably A700 only)
4172             11 => 'Far Left', # (presumably A700 only)
4173             },
4174             },
4175             0x13 => { #JR
4176             Name => 'FlashMode',
4177             PrintConv => {
4178             0 => 'Autoflash',
4179             2 => 'Rear Sync',
4180             3 => 'Wireless',
4181             4 => 'Fill-flash',
4182             5 => 'Flash Off',
4183             6 => 'Slow Sync',
4184             },
4185             },
4186             0x14 => { #JR
4187             Name => 'FlashExposureCompSet',
4188             Description => 'Flash Exposure Comp. Setting',
4189             # (as pre-selected by the user, not zero if flash didn't fire)
4190             ValueConv => '($val - 128) / 24', #PH
4191             ValueConvInv => 'int($val * 24 + 128.5)',
4192             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
4193             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
4194             },
4195             0x15 => { #7
4196             Name => 'MeteringMode',
4197             PrintConv => {
4198             1 => 'Multi-segment',
4199             2 => 'Center-weighted average',
4200             4 => 'Spot',
4201             },
4202             },
4203             0x16 => {
4204             Name => 'ISOSetting',
4205             # 0 indicates 'Auto' (I think)
4206             ValueConv => '$val ? exp(($val/8-6)*log(2))*100 : $val',
4207             ValueConvInv => '$val ? 8*(log($val/100)/log(2)+6) : $val',
4208             PrintConv => '$val ? sprintf("%.0f",$val) : "Auto"',
4209             PrintConvInv => '$val =~ /auto/i ? 0 : $val',
4210             },
4211             0x18 => { #7
4212             Name => 'DynamicRangeOptimizerMode',
4213             PrintConv => {
4214             0 => 'Off',
4215             1 => 'Standard',
4216             2 => 'Advanced Auto',
4217             3 => 'Advanced Level',
4218             },
4219             },
4220             0x19 => { #7
4221             Name => 'DynamicRangeOptimizerLevel',
4222             },
4223             0x1a => { # style actually used (combination of mode dial + creative style menu)
4224             Name => 'CreativeStyle',
4225             PrintConvColumns => 2,
4226             PrintConv => {
4227             1 => 'Standard',
4228             2 => 'Vivid',
4229             3 => 'Portrait',
4230             4 => 'Landscape',
4231             5 => 'Sunset',
4232             6 => 'Night View/Portrait',
4233             8 => 'B&W',
4234             9 => 'Adobe RGB', # A700
4235             11 => 'Neutral',
4236             12 => 'Clear', #7
4237             13 => 'Deep', #7
4238             14 => 'Light', #7
4239             15 => 'Autumn Leaves', #7
4240             16 => 'Sepia', #7
4241             },
4242             },
4243             0x1b => { #JR
4244             Name => 'ColorSpace',
4245             PrintConv => {
4246             0 => 'sRGB',
4247             1 => 'Adobe RGB', # (A850, selected via Colorspace menu item)
4248             5 => 'Adobe RGB (A700)', # (A700, selected via CreativeStyle menu)
4249             },
4250             },
4251             0x1c => {
4252             Name => 'Sharpness',
4253             ValueConv => '$val - 10',
4254             ValueConvInv => '$val + 10',
4255             PrintConv => '$val > 0 ? "+$val" : $val',
4256             PrintConvInv => '$val',
4257             },
4258             0x1d => {
4259             Name => 'Contrast',
4260             ValueConv => '$val - 10',
4261             ValueConvInv => '$val + 10',
4262             PrintConv => '$val > 0 ? "+$val" : $val',
4263             PrintConvInv => '$val',
4264             },
4265             0x1e => {
4266             Name => 'Saturation',
4267             ValueConv => '$val - 10',
4268             ValueConvInv => '$val + 10',
4269             PrintConv => '$val > 0 ? "+$val" : $val',
4270             PrintConvInv => '$val',
4271             },
4272             0x1f => { #7
4273             Name => 'ZoneMatchingValue',
4274             ValueConv => '$val - 10',
4275             ValueConvInv => '$val + 10',
4276             PrintConv => '$val > 0 ? "+$val" : $val',
4277             PrintConvInv => '$val',
4278             },
4279             0x22 => { #7
4280             Name => 'Brightness',
4281             ValueConv => '$val - 10',
4282             ValueConvInv => '$val + 10',
4283             PrintConv => '$val > 0 ? "+$val" : $val',
4284             PrintConvInv => '$val',
4285             },
4286             0x23 => {
4287             Name => 'FlashControl',
4288             PrintConv => {
4289             0 => 'ADI',
4290             1 => 'Pre-flash TTL',
4291             2 => 'Manual',
4292             },
4293             },
4294             0x28 => { #7
4295             Name => 'PrioritySetupShutterRelease',
4296             PrintConv => {
4297             0 => 'AF',
4298             1 => 'Release',
4299             },
4300             },
4301             0x29 => { #7
4302             Name => 'AFIlluminator',
4303             PrintConv => {
4304             0 => 'Auto',
4305             1 => 'Off',
4306             },
4307             },
4308             0x2a => { #7
4309             Name => 'AFWithShutter',
4310             PrintConv => { 0 => 'On', 1 => 'Off' },
4311             },
4312             0x2b => { #7
4313             Name => 'LongExposureNoiseReduction',
4314             PrintConv => { 0 => 'Off', 1 => 'On' },
4315             },
4316             0x2c => { #7
4317             Name => 'HighISONoiseReduction',
4318             PrintConv => {
4319             0 => 'Normal',
4320             1 => 'Low',
4321             2 => 'High',
4322             3 => 'Off',
4323             },
4324             },
4325             0x2d => { #7
4326             Name => 'ImageStyle',
4327             PrintConvColumns => 2,
4328             PrintConv => {
4329             1 => 'Standard',
4330             2 => 'Vivid',
4331             3 => 'Portrait', #PH
4332             4 => 'Landscape', #PH
4333             5 => 'Sunset', #PH
4334             7 => 'Night View/Portrait', #PH (A200/A350 when CreativeStyle was 6!)
4335             8 => 'B&W', #PH (guess)
4336             9 => 'Adobe RGB',
4337             11 => 'Neutral',
4338             129 => 'StyleBox1',
4339             130 => 'StyleBox2',
4340             131 => 'StyleBox3',
4341             132 => 'StyleBox4', #JR (A850)
4342             133 => 'StyleBox5', #JR (A850)
4343             134 => 'StyleBox6', #JR (A850)
4344             },
4345             },
4346             0x2e => { #JR (may not apply to A200/A300/A350 -- they don't have the AF/MF button)
4347             Name => 'FocusModeSwitch',
4348             PrintConv => {
4349             0 => 'AF',
4350             1 => 'Manual',
4351             },
4352             },
4353             0x2f => { #JR
4354             Name => 'ShutterSpeedSetting',
4355             Notes => 'used in M, S and Program Shift S modes',
4356             ValueConv => '$val ? 2 ** (6 - $val/8) : 0',
4357             ValueConvInv => '$val ? int((6 - log($val) / log(2)) * 8 + 0.5) : 0',
4358             PrintConv => '$val ? Image::ExifTool::Exif::PrintExposureTime($val) : "Bulb"',
4359             PrintConvInv => 'lc($val) eq "bulb" ? 0 : Image::ExifTool::Exif::ConvertFraction($val)',
4360             },
4361             0x30 => { #JR
4362             Name => 'ApertureSetting',
4363             Notes => 'used in M, A and Program Shift A modes',
4364             ValueConv => '2 ** (($val/8 - 1) / 2)',
4365             ValueConvInv => 'int((log($val) * 2 / log(2) + 1) * 8 + 0.5)',
4366             PrintConv => 'Image::ExifTool::Exif::PrintFNumber($val)',
4367             PrintConvInv => '$val',
4368             },
4369             0x3c => {
4370             Name => 'ExposureProgram',
4371             SeparateTable => 'ExposureProgram',
4372             PrintConv => \%sonyExposureProgram,
4373             },
4374             0x3d => {
4375             Name => 'ImageStabilizationSetting',
4376             PrintConv => { 0 => 'Off', 1 => 'On' },
4377             },
4378             0x3e => { #JR
4379             Name => 'FlashAction',
4380             PrintConv => {
4381             0 => 'Did not fire',
4382             1 => 'Fired',
4383             2 => 'External Flash, Did not fire',
4384             3 => 'External Flash, Fired',
4385             },
4386             },
4387             0x3f => { # (verified for A330/A380)
4388             Name => 'Rotation',
4389             PrintConv => {
4390             0 => 'Horizontal (normal)',
4391             1 => 'Rotate 90 CW', #(NC)
4392             2 => 'Rotate 270 CW',
4393             },
4394             },
4395             0x40 => { #JR
4396             Name => 'AELock',
4397             PrintConv => {
4398             1 => 'Off',
4399             2 => 'On',
4400             },
4401             },
4402             0x4c => { #JR
4403             Name => 'FlashAction2',
4404             PrintConv => {
4405             1 => 'Fired, Autoflash',
4406             2 => 'Fired, Fill-flash',
4407             3 => 'Fired, Rear Sync',
4408             4 => 'Fired, Wireless',
4409             5 => 'Did not fire',
4410             6 => 'Fired, Slow Sync',
4411             17 => 'Fired, Autoflash, Red-eye reduction',
4412             18 => 'Fired, Fill-flash, Red-eye reduction',
4413             34 => 'Fired, Fill-flash, HSS',
4414             },
4415             },
4416             0x4d => { #JR
4417             Name => 'FocusMode', # (focus mode actually used)
4418             PrintConv => {
4419             0 => 'Manual',
4420             1 => 'AF-S',
4421             2 => 'AF-C',
4422             3 => 'AF-A',
4423             4 => 'DMF', #JR
4424             },
4425             },
4426             0x50 => { #JR
4427             Name => 'BatteryState',
4428             PrintConv => {
4429             2 => 'Empty', # 0%
4430             3 => 'Very Low', # 1 - 20%
4431             4 => 'Low', # 21 - 50%
4432             5 => 'Sufficient', # 51 - 80%
4433             6 => 'Full', # > 80%
4434             },
4435             },
4436             0x51 => { #JR
4437             Name => 'BatteryLevel',
4438             PrintConv => '"$val%"',
4439             PrintConvInv => '$val=~s/\s*\%//; $val',
4440             },
4441             0x53 => { #JR
4442             Name => 'FocusStatus',
4443             PrintConv => {
4444             0 => 'Not confirmed',
4445             4 => 'Not confirmed, Tracking',
4446             BITMASK => {
4447             0 => 'Confirmed',
4448             1 => 'Failed',
4449             2 => 'Tracking',
4450             },
4451             },
4452             },
4453             0x54 => {
4454             Name => 'SonyImageSize',
4455             PrintConv => {
4456             1 => 'Large',
4457             2 => 'Medium',
4458             3 => 'Small',
4459             },
4460             },
4461             0x55 => { #7
4462             Name => 'AspectRatio',
4463             PrintConv => {
4464             1 => '3:2',
4465             2 => '16:9',
4466             },
4467             },
4468             0x56 => { #PH/7
4469             Name => 'Quality',
4470             PrintConv => {
4471             0 => 'RAW',
4472             2 => 'CRAW',
4473             34 => 'RAW + JPEG',
4474             35 => 'CRAW + JPEG',
4475             16 => 'Extra Fine',
4476             32 => 'Fine',
4477             48 => 'Standard',
4478             },
4479             },
4480             0x58 => { #7
4481             Name => 'ExposureLevelIncrements',
4482             PrintConv => {
4483             33 => '1/3 EV',
4484             50 => '1/2 EV',
4485             },
4486             },
4487             0x6a => { #JR
4488             Name => 'RedEyeReduction',
4489             PrintConv => {
4490             0 => 'Off',
4491             1 => 'On',
4492             },
4493             },
4494             0x9a => { #JR
4495             Name => 'FolderNumber',
4496             Mask => 0x03ff, # (not sure what the upper 6 bits are for)
4497             PrintConv => 'sprintf("%.3d",$val)',
4498             PrintConvInv => '$val',
4499             },
4500             0x9b => { #JR
4501             Name => 'ImageNumber',
4502             Mask => 0x3fff, # (not sure what the upper 2 bits are for)
4503             PrintConv => 'sprintf("%.4d",$val)',
4504             PrintConvInv => '$val',
4505             },
4506             );
4507              
4508             # Camera settings (ref PH) (A230, A290, A330, A380 and A390)
4509             %Image::ExifTool::Sony::CameraSettings2 = (
4510             %binaryDataAttrs,
4511             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4512             FORMAT => 'int16u',
4513             PRIORITY => 0,
4514             NOTES => 'Camera settings for the A230, A290, A330, A380 and A390.',
4515             ### 0x00-0x03: same TagID as CameraSettings
4516             0x00 => { #JR
4517             Name => 'ExposureTime',
4518             ValueConv => '$val ? 2 ** (6 - $val/8) : 0',
4519             ValueConvInv => '$val ? int((6 - log($val) / log(2)) * 8 + 0.5) : 0',
4520             PrintConv => '$val ? Image::ExifTool::Exif::PrintExposureTime($val) : "Bulb"',
4521             PrintConvInv => 'lc($val) eq "bulb" ? 0 : Image::ExifTool::Exif::ConvertFraction($val)',
4522             },
4523             0x01 => { #JR
4524             Name => 'FNumber',
4525             ValueConv => '2 ** (($val/8 - 1) / 2)',
4526             ValueConvInv => 'int((log($val) * 2 / log(2) + 1) * 8 + 0.5)',
4527             PrintConv => 'Image::ExifTool::Exif::PrintFNumber($val)',
4528             PrintConvInv => '$val',
4529             },
4530             0x02 => { #JR (requires external flash)
4531             Name => 'HighSpeedSync',
4532             PrintConv => {
4533             0 => 'Off',
4534             1 => 'On',
4535             },
4536             },
4537             0x03 => { #JR
4538             Name => 'ExposureCompensationSet',
4539             ValueConv => '($val - 128) / 24',
4540             ValueConvInv => 'int($val * 24 + 128.5)',
4541             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
4542             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
4543             },
4544             ### 0x04-0x11: subtract 1 from CameraSettings TagID
4545             0x04 => { #JR
4546             Name => 'WhiteBalanceSetting',
4547             PrintConv => {
4548             2 => 'Auto',
4549             4 => 'Daylight',
4550             5 => 'Fluorescent',
4551             6 => 'Tungsten',
4552             7 => 'Flash',
4553             16 => 'Cloudy',
4554             17 => 'Shade',
4555             18 => 'Color Temperature/Color Filter',
4556             32 => 'Custom 1',
4557             33 => 'Custom 2',
4558             34 => 'Custom 3',
4559             },
4560             },
4561             0x05 => { #JR
4562             Name => 'WhiteBalanceFineTune',
4563             ValueConv => '$val > 128 ? $val - 256 : $val',
4564             ValueConvInv => '$val < 0 ? $val + 256 : $val',
4565             },
4566             0x06 => { #JR as set in WB "Color Temperature/Color Filter" and in White Balance Bracketing
4567             Name => 'ColorTemperatureSet',
4568             ValueConv => '$val * 100',
4569             ValueConvInv => '$val / 100',
4570             PrintConv => '"$val K"',
4571             PrintConvInv => '$val =~ s/ ?K$//i; $val',
4572             },
4573             0x07 => { #JR as set in WB "Color Temperature/Color Filter"
4574             Name => 'ColorCompensationFilterSet',
4575             Notes => 'negative is green, positive is magenta',
4576             ValueConv => '$val > 128 ? $val - 256 : $val',
4577             ValueConvInv => '$val < 0 ? $val + 256 : $val',
4578             PrintConv => '$val > 0 ? "+$val" : $val',
4579             PrintConvInv => '$val',
4580             },
4581             0x08 => { #JR
4582             Name => 'CustomWB_RGBLevels',
4583             Format => 'int16u[3]',
4584             },
4585             0x0b => { #JR as set in WB "Custom" and in White Balance Bracketing
4586             Name => 'ColorTemperatureCustom',
4587             ValueConv => '$val * 100',
4588             ValueConvInv => '$val / 100',
4589             PrintConv => '"$val K"',
4590             PrintConvInv => '$val =~ s/ ?K$//i; $val',
4591             },
4592             0x0c => { #JR as set in WB "Custom"
4593             Name => 'ColorCompensationFilterCustom',
4594             Notes => 'negative is green, positive is magenta',
4595             ValueConv => '$val > 128 ? $val - 256 : $val',
4596             ValueConvInv => '$val < 0 ? $val + 256 : $val',
4597             PrintConv => '$val > 0 ? "+$val" : $val',
4598             PrintConvInv => '$val',
4599             },
4600             0x0e => { #JR
4601             Name => 'WhiteBalance',
4602             PrintConv => {
4603             2 => 'Auto',
4604             4 => 'Daylight',
4605             5 => 'Fluorescent',
4606             6 => 'Tungsten',
4607             7 => 'Flash',
4608             12 => 'Color Temperature',
4609             13 => 'Color Filter',
4610             14 => 'Custom',
4611             16 => 'Cloudy',
4612             17 => 'Shade',
4613             },
4614             },
4615             0x0f => { #JR/PH (educated guess)
4616             Name => 'FocusModeSetting',
4617             PrintConv => {
4618             0 => 'Manual',
4619             1 => 'AF-S',
4620             2 => 'AF-C',
4621             3 => 'AF-A',
4622             # seen 5 for A380 (FocusMode was Manual and FocusStatus was Confirmed)
4623             },
4624             },
4625             0x10 => { #JR/PH (educated guess)
4626             Name => 'AFAreaMode',
4627             PrintConv => {
4628             0 => 'Wide',
4629             1 => 'Local',
4630             2 => 'Spot',
4631             },
4632             },
4633             0x11 => { #JR/PH (educated guess)
4634             Name => 'AFPointSetting',
4635             Format => 'int16u',
4636             # The AF point as selected by the user in AFAreaMode=Local or Spot;
4637             # Reported value remains at the last-set position in AFAreaModes=Wide.
4638             # (all of these cameras have a 9-point centre-cross AF system, ref JR)
4639             PrintConvColumns => 2,
4640             PrintConv => {
4641             1 => 'Center',
4642             2 => 'Top',
4643             3 => 'Upper-right',
4644             4 => 'Right',
4645             5 => 'Lower-right',
4646             6 => 'Bottom',
4647             7 => 'Lower-left',
4648             8 => 'Left',
4649             9 => 'Upper-left',
4650             },
4651             },
4652             ### 0x12-0x18: subtract 2 from CameraSettings TagID
4653             0x12 => { #JR
4654             Name => 'FlashExposureCompSet',
4655             Description => 'Flash Exposure Comp. Setting',
4656             # (as pre-selected by the user, not zero if flash didn't fire)
4657             ValueConv => '($val - 128) / 24', #PH
4658             ValueConvInv => 'int($val * 24 + 128.5)',
4659             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
4660             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
4661             },
4662             0x13 => {
4663             Name => 'MeteringMode',
4664             PrintConv => {
4665             1 => 'Multi-segment',
4666             2 => 'Center-weighted average',
4667             4 => 'Spot',
4668             },
4669             },
4670             0x14 => { # A330/A380
4671             Name => 'ISOSetting',
4672             # 0 indicates 'Auto' (?)
4673             ValueConv => '$val ? exp(($val/8-6)*log(2))*100 : $val',
4674             ValueConvInv => '$val ? 8*(log($val/100)/log(2)+6) : $val',
4675             PrintConv => '$val ? sprintf("%.0f",$val) : "Auto"',
4676             PrintConvInv => '$val =~ /auto/i ? 0 : $val',
4677             },
4678             0x16 => {
4679             Name => 'DynamicRangeOptimizerMode',
4680             PrintConv => {
4681             0 => 'Off',
4682             1 => 'Standard',
4683             2 => 'Advanced Auto',
4684             3 => 'Advanced Level',
4685             },
4686             },
4687             0x17 => 'DynamicRangeOptimizerLevel',
4688             0x18 => { # A380
4689             Name => 'CreativeStyle',
4690             PrintConvColumns => 2,
4691             PrintConv => {
4692             1 => 'Standard',
4693             2 => 'Vivid',
4694             3 => 'Portrait',
4695             4 => 'Landscape',
4696             5 => 'Sunset',
4697             6 => 'Night View/Portrait',
4698             8 => 'B&W',
4699             # (these models don't have Neutral - PH)
4700             },
4701             },
4702             ### 0x19-0x1b: subtract 3 from CameraSettings TagID
4703             0x19 => {
4704             Name => 'Sharpness',
4705             ValueConv => '$val - 10',
4706             ValueConvInv => '$val + 10',
4707             PrintConv => '$val > 0 ? "+$val" : $val',
4708             PrintConvInv => '$val',
4709             },
4710             0x1a => {
4711             Name => 'Contrast',
4712             ValueConv => '$val - 10',
4713             ValueConvInv => '$val + 10',
4714             PrintConv => '$val > 0 ? "+$val" : $val',
4715             PrintConvInv => '$val',
4716             },
4717             0x1b => {
4718             Name => 'Saturation',
4719             ValueConv => '$val - 10',
4720             ValueConvInv => '$val + 10',
4721             PrintConv => '$val > 0 ? "+$val" : $val',
4722             PrintConvInv => '$val',
4723             },
4724             ### 0x1c-0x24: subtract 4 from CameraSettings TagID (not sure about 0x1c)
4725             0x1f => { #PH (educated guess)
4726             Name => 'FlashControl',
4727             PrintConv => {
4728             0 => 'ADI',
4729             1 => 'Pre-flash TTL',
4730             2 => 'Manual',
4731             },
4732             },
4733             ### 0x25-0x27: subtract 6 from CameraSettings TagID
4734             0x25 => { #PH
4735             Name => 'LongExposureNoiseReduction',
4736             PrintConv => { 0 => 'Off', 1 => 'On' },
4737             },
4738             0x26 => { #PH
4739             Name => 'HighISONoiseReduction',
4740             # (Note: the order is different from that in CameraSettings)
4741             PrintConv => {
4742             0 => 'Off',
4743             1 => 'Low',
4744             2 => 'Normal',
4745             3 => 'High',
4746             },
4747             },
4748             0x27 => { #PH
4749             Name => 'ImageStyle',
4750             PrintConvColumns => 2,
4751             PrintConv => {
4752             1 => 'Standard',
4753             2 => 'Vivid',
4754             3 => 'Portrait', #PH
4755             4 => 'Landscape', #PH
4756             5 => 'Sunset', #PH
4757             7 => 'Night View/Portrait', #PH (A200 when CreativeStyle was 6!)
4758             8 => 'B&W', #PH (A380)
4759             # (these models don't have Neutral - PH)
4760             },
4761             },
4762             ### 0x28-0x3b: subtract 7 from CameraSettings TagID
4763             0x28 => { #PH
4764             Name => 'ShutterSpeedSetting',
4765             Notes => 'used in M, S and Program Shift S modes',
4766             ValueConv => '$val ? 2 ** (6 - $val/8) : 0',
4767             ValueConvInv => '$val ? int((6 - log($val) / log(2)) * 8 + 0.5) : 0',
4768             PrintConv => '$val ? Image::ExifTool::Exif::PrintExposureTime($val) : "Bulb"',
4769             PrintConvInv => 'lc($val) eq "bulb" ? 0 : Image::ExifTool::Exif::ConvertFraction($val)',
4770             },
4771             0x29 => { #PH
4772             Name => 'ApertureSetting',
4773             Notes => 'used in M, A and Program Shift A modes',
4774             ValueConv => '2 ** (($val/8 - 1) / 2)',
4775             ValueConvInv => 'int((log($val) * 2 / log(2) + 1) * 8 + 0.5)',
4776             PrintConv => 'Image::ExifTool::Exif::PrintFNumber($val)',
4777             PrintConvInv => '$val',
4778             },
4779             ### 0x3c-0x59: same TagID as CameraSettings
4780             0x3c => {
4781             Name => 'ExposureProgram',
4782             SeparateTable => 'ExposureProgram',
4783             PrintConv => \%sonyExposureProgram,
4784             },
4785             0x3d => { # (copied from CameraSettings, ref JR)
4786             Name => 'ImageStabilizationSetting',
4787             PrintConv => { 0 => 'Off', 1 => 'On' },
4788             },
4789             0x3e => { #JR
4790             Name => 'FlashAction',
4791             PrintConv => {
4792             0 => 'Did not fire',
4793             1 => 'Fired',
4794             2 => 'External Flash, Did not fire',
4795             3 => 'External Flash, Fired',
4796             },
4797             },
4798             0x3f => { # (verified for A330/A380)
4799             Name => 'Rotation',
4800             PrintConv => {
4801             0 => 'Horizontal (normal)',
4802             1 => 'Rotate 90 CW', #(NC)
4803             2 => 'Rotate 270 CW',
4804             },
4805             },
4806             0x40 => { #JR
4807             Name => 'AELock',
4808             PrintConv => {
4809             1 => 'Off',
4810             2 => 'On',
4811             },
4812             },
4813             0x4c => { #JR
4814             Name => 'FlashAction2',
4815             PrintConv => {
4816             1 => 'Fired, Autoflash',
4817             2 => 'Fired, Fill-flash',
4818             3 => 'Fired, Rear Sync',
4819             4 => 'Fired, Wireless',
4820             5 => 'Did not fire',
4821             6 => 'Fired, Slow Sync',
4822             17 => 'Fired, Autoflash, Red-eye reduction',
4823             18 => 'Fired, Fill-flash, Red-eye reduction',
4824             34 => 'Fired, Fill-flash, HSS',
4825             },
4826             },
4827             0x4d => { #JR
4828             Name => 'FocusMode', # (focus mode actually used)
4829             PrintConv => {
4830             0 => 'Manual',
4831             1 => 'AF-S',
4832             2 => 'AF-C',
4833             3 => 'AF-A',
4834             },
4835             },
4836             0x53 => { #JR (copied from CameraSettings, but all bits may not be applicable for these models)
4837             Name => 'FocusStatus',
4838             PrintConv => {
4839             0 => 'Not confirmed',
4840             4 => 'Not confirmed, Tracking',
4841             BITMASK => {
4842             0 => 'Confirmed',
4843             1 => 'Failed',
4844             2 => 'Tracking',
4845             },
4846             },
4847             },
4848             0x54 => {
4849             Name => 'SonyImageSize',
4850             PrintConv => {
4851             1 => 'Large',
4852             2 => 'Medium',
4853             3 => 'Small',
4854             },
4855             },
4856             0x55 => { # (copied from CameraSettings, ref JR)
4857             Name => 'AspectRatio',
4858             PrintConv => {
4859             1 => '3:2',
4860             2 => '16:9',
4861             },
4862             },
4863             0x56 => { # (copied from CameraSettings, ref JR)
4864             Name => 'Quality',
4865             PrintConv => {
4866             0 => 'RAW',
4867             2 => 'CRAW',
4868             34 => 'RAW + JPEG',
4869             35 => 'CRAW + JPEG',
4870             16 => 'Extra Fine',
4871             32 => 'Fine',
4872             48 => 'Standard',
4873             },
4874             },
4875             0x58 => { # (copied from CameraSettings, ref JR)
4876             Name => 'ExposureLevelIncrements',
4877             PrintConv => {
4878             33 => '1/3 EV',
4879             50 => '1/2 EV',
4880             },
4881             },
4882             ### 0x5a onwards: subtract 1 from CameraSettings TagID
4883             # (0x69 not confirmed)
4884             #0x69 => { #JR
4885             # Name => 'RedEyeReduction',
4886             # PrintConv => {
4887             # 0 => 'Off',
4888             # 1 => 'On',
4889             # },
4890             #},
4891             0x7e => { #JR
4892             Name => 'DriveMode',
4893             Mask => 0xff, # (not sure what upper byte is for)
4894             PrintConv => { # (values confirmed for specified models - PH)
4895             1 => 'Single Frame', # (A230,A330,A380)
4896             2 => 'Continuous High', #PH (A230,A330)
4897             4 => 'Self-timer 10 sec', # (A230)
4898             5 => 'Self-timer 2 sec, Mirror Lock-up', # (A230,A290,A330,A380,390)
4899             7 => 'Continuous Bracketing', # (A230 val=0x1107, A330 val=0x1307 [0.7 EV])
4900             10 => 'Remote Commander', # (A230)
4901             11 => 'Continuous Self-timer', # (A230 val=0x800b [5 shots], A330 val=0x400b [3 shots])
4902             },
4903             },
4904             0x7f => { #JR
4905             Name => 'FlashMode',
4906             PrintConv => {
4907             0 => 'Autoflash',
4908             2 => 'Rear Sync',
4909             3 => 'Wireless',
4910             4 => 'Fill-flash',
4911             5 => 'Flash Off',
4912             6 => 'Slow Sync',
4913             },
4914             },
4915             0x83 => { #PH
4916             Name => 'ColorSpace',
4917             PrintConv => {
4918             5 => 'Adobe RGB',
4919             6 => 'sRGB',
4920             },
4921             },
4922             );
4923              
4924             # more Camera settings (ref PH)
4925             # This was decoded for the A55, but it seems to apply to the following models:
4926             # A33, A35, A55, A450, A500, A550, A560, A580, NEX-3, NEX-5, NEX-C3 and NEX-VG10E
4927             %Image::ExifTool::Sony::CameraSettings3 = (
4928             %binaryDataAttrs,
4929             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4930             FORMAT => 'int8u',
4931             PRIORITY => 0,
4932             DATAMEMBER => [ 0x99 ],
4933             NOTES => q{
4934             Camera settings for models such as the A33, A35, A55, A450, A500, A550,
4935             A560, A580, NEX-3, NEX-5, NEX-C3 and NEX-VG10E.
4936             },
4937             0x00 => { #JR
4938             Name => 'ShutterSpeedSetting',
4939             Notes => 'used only in M and S exposure modes',
4940             ValueConv => '$val ? 2 ** (6 - $val/8) : 0',
4941             ValueConvInv => '$val ? int((6 - log($val) / log(2)) * 8 + 0.5) : 0',
4942             PrintConv => '$val ? Image::ExifTool::Exif::PrintExposureTime($val) : "Bulb"',
4943             PrintConvInv => 'lc($val) eq "bulb" ? 0 : Image::ExifTool::Exif::ConvertFraction($val)',
4944             },
4945             0x01 => { #JR
4946             Name => 'ApertureSetting',
4947             Notes => 'used only in M and A exposure modes',
4948             ValueConv => '2 ** (($val/8 - 1) / 2)',
4949             ValueConvInv => 'int((log($val) * 2 / log(2) + 1) * 8 + 0.5)',
4950             PrintConv => 'Image::ExifTool::Exif::PrintFNumber($val)',
4951             PrintConvInv => '$val',
4952             },
4953             0x02 => {
4954             Name => 'ISOSetting',
4955             ValueConv => '($val and $val < 254) ? exp(($val/8-6)*log(2))*100 : $val',
4956             ValueConvInv => '($val and $val != 254) ? 8*(log($val/100)/log(2)+6) : $val',
4957             PrintConv => {
4958             OTHER => sub {
4959             my ($val, $inv) = @_;
4960             return int($val + 0.5) unless $inv;
4961             return Image::ExifTool::IsFloat($val) ? $val : undef;
4962             },
4963             0 => 'Auto',
4964             254 => 'n/a', # get this for multi-shot noise reduction
4965             },
4966             },
4967             0x03 => { #JR
4968             Name => 'ExposureCompensationSet',
4969             ValueConv => '($val - 128) / 24', #PH
4970             ValueConvInv => 'int($val * 24 + 128.5)',
4971             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
4972             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
4973             },
4974             0x04 => { #JR
4975             Name => 'DriveModeSetting',
4976             # Same drivemode info is repeated in 0x0034, but with at least the following exceptions:
4977             # - 0x0034 not for A550 ? - seen "0"
4978             # - hand-held night (0x05=56): 0x0004=0x10 and 0x0034=0xd3
4979             # - 3D sweep panorama (0x05=57): 0x0004=0x10 and 0x0034=0xd6
4980             # - sweep panorama (0x05=80): 0x0004=0x10 and 0x0034=0xd5
4981             # preliminary conclusion: 0x0004 is Drivemode as pre-set, but may be overruled by Scene/Panorama mode selections
4982             # 0x0034 is Divemode as actually used
4983             PrintHex => 1,
4984             PrintConv => {
4985             0x10 => 'Single Frame',
4986             0x21 => 'Continuous High', # also automatically selected for Scene mode Sports-action (0x05=52)
4987             0x22 => 'Continuous Low',
4988             0x30 => 'Speed Priority Continuous',
4989             0x51 => 'Self-timer 10 sec',
4990             0x52 => 'Self-timer 2 sec, Mirror Lock-up',
4991             0x71 => 'Continuous Bracketing 0.3 EV',
4992             0x75 => 'Continuous Bracketing 0.7 EV',
4993             0x91 => 'White Balance Bracketing Low',
4994             0x92 => 'White Balance Bracketing High',
4995             0xc0 => 'Remote Commander',
4996             },
4997             },
4998             0x05 => { #JR
4999             Name => 'ExposureProgram',
5000             # Camera exposure program/mode as selected with the Mode dial.
5001             # For SCN a further selection is done via the menu
5002             # Matches OK with 0xb023
5003             SeparateTable => 'ExposureProgram2',
5004             PrintConv => \%sonyExposureProgram2,
5005             },
5006             0x06 => { #JR
5007             Name => 'FocusModeSetting',
5008             PrintConv => {
5009             17 => 'AF-S',
5010             18 => 'AF-C',
5011             19 => 'AF-A',
5012             32 => 'Manual',
5013             48 => 'DMF', #(NC) (seen for NEX-5)
5014             },
5015             },
5016             0x07 => { #JR
5017             Name => 'MeteringMode',
5018             PrintConv => {
5019             1 => 'Multi-segment',
5020             2 => 'Center-weighted average',
5021             3 => 'Spot',
5022             },
5023             },
5024             0x09 => { #JR
5025             Name => 'SonyImageSize',
5026             PrintConv => { # values confirmed as noted for the A580 and A33
5027             21 => 'Large (3:2)', # A580: 16M (4912x3264), A33: 14M (4592x3056)
5028             22 => 'Medium (3:2)', # A580: 8.4M (3568x2368), A33: 7.4M (3344x2224)
5029             23 => 'Small (3:2)', # A580: 4.0M (2448x1624), A33: 3.5M (2288x1520)
5030             25 => 'Large (16:9)', # A580: 14M (4912x2760)
5031             26 => 'Medium (16:9)', # A580: 7.1M (3568x2000)
5032             27 => 'Small (16:9)', # A580: 3.4M (2448x1376)
5033             },
5034             },
5035             0x0a => { #JR
5036             Name => 'AspectRatio',
5037             # normally 4 for A580 3:2 ratio images
5038             # seen 8 when selecting 16:9 via menu, and when selecting Panorama mode
5039             PrintConv => {
5040             4 => '3:2',
5041             8 => '16:9',
5042             },
5043             },
5044             0x0b => { #JR
5045             Name => 'Quality',
5046             PrintConv => {
5047             2 => 'RAW',
5048             4 => 'RAW + JPEG',
5049             6 => 'Fine',
5050             7 => 'Standard',
5051             },
5052             },
5053             0x0c => {
5054             Name => 'DynamicRangeOptimizerSetting',
5055             PrintConv => {
5056             1 => 'Off',
5057             16 => 'On (Auto)',
5058             17 => 'On (Manual)',
5059             },
5060             },
5061             0x0d => 'DynamicRangeOptimizerLevel',
5062             0x0e => { #JR
5063             Name => 'ColorSpace',
5064             PrintConv => {
5065             1 => 'sRGB',
5066             2 => 'Adobe RGB',
5067             },
5068             },
5069             0x0f => { #JR
5070             Name => 'CreativeStyleSetting',
5071             PrintConvColumns => 2,
5072             PrintConv => {
5073             16 => 'Standard',
5074             32 => 'Vivid',
5075             64 => 'Portrait',
5076             80 => 'Landscape',
5077             96 => 'B&W',
5078             160 => 'Sunset',
5079             },
5080             },
5081             0x10 => { #JR (seen values 253, 254, 255, 0, 1, 2, 3)
5082             Name => 'ContrastSetting',
5083             Format => 'int8s',
5084             PrintConv => '$val > 0 ? "+$val" : $val',
5085             PrintConvInv => '$val',
5086             },
5087             0x11 => { #JR
5088             Name => 'SaturationSetting',
5089             Format => 'int8s',
5090             PrintConv => '$val > 0 ? "+$val" : $val',
5091             PrintConvInv => '$val',
5092             },
5093             0x12 => { #JR
5094             Name => 'SharpnessSetting',
5095             Format => 'int8s',
5096             PrintConv => '$val > 0 ? "+$val" : $val',
5097             PrintConvInv => '$val',
5098             },
5099             0x16 => { #JR
5100             Name => 'WhiteBalanceSetting',
5101             # many guessed, based on "logical system" as observed for Daylight and Shade and steps of 16 between the modes
5102             PrintHex => 1,
5103             PrintConvColumns => 2,
5104             PrintConv => \%whiteBalanceSetting,
5105             SeparateTable => 1,
5106             },
5107             0x17 => { #JR
5108             Name => 'ColorTemperatureSetting',
5109             # matches "0xb021 ColorTemperature" when WB set to "Custom" or "Color Temperature/Color Filter"
5110             ValueConv => '$val * 100',
5111             ValueConvInv => '$val / 100',
5112             PrintConv => '"$val K"',
5113             PrintConvInv => '$val =~ s/ ?K$//i; $val',
5114             },
5115             0x18 => { #JR
5116             Name => 'ColorCompensationFilterSet',
5117             # seen 0, 1-9 and 245-255, corresponding to 0, M1-M9 and G9-G1 on camera display
5118             # matches "0xb022 ColorCompensationFilter" when WB set to "Custom" or "Color Temperature/Color Filter"
5119             Format => 'int8s',
5120             Notes => 'negative is green, positive is magenta',
5121             PrintConv => '$val > 0 ? "+$val" : $val',
5122             PrintConvInv => '$val',
5123             },
5124             0x19 => { #JR
5125             Name => 'CustomWB_RGBLevels',
5126             Format => 'int16uRev[3]',
5127             # 0x19 - 0x1e are related to Custom WB measurements performed by the camera.
5128             # The values change only each time when measuring and setting a new Custom WB.
5129             # (0x19,0x1a) and (0x1d,0x1e) are same as MoreSettings (0x1a,0x1b) and (0x1c,0x1d)
5130             },
5131             # 0x1f - always 2 (ref JR)
5132             0x20 => { #JR
5133             Name => 'FlashMode',
5134             PrintConvColumns => 2,
5135             PrintConv => {
5136             1 => 'Flash Off',
5137             16 => 'Autoflash',
5138             17 => 'Fill-flash',
5139             18 => 'Slow Sync',
5140             19 => 'Rear Sync',
5141             20 => 'Wireless',
5142             },
5143             },
5144             0x21 => { #JR
5145             Name => 'FlashControl',
5146             PrintConv => {
5147             1 => 'ADI Flash',
5148             2 => 'Pre-flash TTL',
5149             },
5150             },
5151             0x23 => { #JR
5152             Name => 'FlashExposureCompSet',
5153             Description => 'Flash Exposure Comp. Setting',
5154             # (as pre-selected by the user, not zero if flash didn't fire)
5155             ValueConv => '($val - 128) / 24', #PH
5156             ValueConvInv => 'int($val * 24 + 128.5)',
5157             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
5158             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
5159             },
5160             0x24 => {
5161             Name => 'AFAreaMode',
5162             PrintConv => {
5163             1 => 'Wide',
5164             2 => 'Spot',
5165             3 => 'Local',
5166             4 => 'Flexible', #JR
5167             # (Flexible Spot is a grid of 17x11 points for the NEX-5)
5168             },
5169             },
5170             0x25 => { #JR
5171             Name => 'LongExposureNoiseReduction',
5172             PrintConv => {
5173             1 => 'Off',
5174             16 => 'On', # (unused or dark subject)
5175             },
5176             },
5177             0x26 => { #JR
5178             Name => 'HighISONoiseReduction',
5179             PrintConv => {
5180             16 => 'Low',
5181             17 => 'High',
5182             19 => 'Auto',
5183             },
5184             },
5185             0x27 => { #JR
5186             Name => 'SmileShutterMode',
5187             PrintConv => {
5188             17 => 'Slight Smile',
5189             18 => 'Normal Smile',
5190             19 => 'Big Smile',
5191             },
5192             },
5193             0x28 => { #JR
5194             Name => 'RedEyeReduction',
5195             PrintConv => {
5196             1 => 'Off',
5197             16 => 'On',
5198             },
5199             },
5200             0x2d => {
5201             Name => 'HDRSetting',
5202             PrintConv => {
5203             1 => 'Off',
5204             16 => 'On (Auto)',
5205             17 => 'On (Manual)',
5206             },
5207             },
5208             0x2e => {
5209             Name => 'HDRLevel',
5210             PrintConvColumns => 3,
5211             PrintConv => {
5212             33 => '1 EV',
5213             34 => '1.5 EV', #JR (NC)
5214             35 => '2 EV',
5215             36 => '2.5 EV', #JR (NC)
5216             37 => '3 EV',
5217             38 => '3.5 EV', #PH (NC)
5218             39 => '4 EV',
5219             40 => '5 EV',
5220             41 => '6 EV',
5221             },
5222             },
5223             0x2f => { #JR (not sure what is difference with 0x85)
5224             Name => 'ViewingMode',
5225             PrintConv => {
5226             16 => 'ViewFinder',
5227             33 => 'Focus Check Live View',
5228             34 => 'Quick AF Live View',
5229             },
5230             },
5231             0x30 => { #JR
5232             Name => 'FaceDetection',
5233             PrintConv => {
5234             1 => 'Off',
5235             16 => 'On',
5236             },
5237             },
5238             0x31 => { #JR
5239             Name => 'SmileShutter',
5240             PrintConv => {
5241             1 => 'Off',
5242             16 => 'On',
5243             },
5244             },
5245             0x32 => { #JR
5246             Name => 'SweepPanoramaSize',
5247             Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)$/',
5248             PrintConv => {
5249             1 => 'Standard',
5250             2 => 'Wide',
5251             },
5252             },
5253             0x33 => { #JR
5254             Name => 'SweepPanoramaDirection',
5255             Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)$/',
5256             PrintConv => {
5257             1 => 'Right',
5258             2 => 'Left',
5259             3 => 'Up',
5260             4 => 'Down',
5261             },
5262             },
5263             0x34 => { #JR
5264             Name => 'DriveMode', # (drive mode actually used)
5265             Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)$/',
5266             PrintHex => 1,
5267             PrintConv => {
5268             0x10 => 'Single Frame',
5269             0x21 => 'Continuous High', # also automatically selected for Scene mode Sports-action (0x05=52)
5270             0x22 => 'Continuous Low',
5271             0x30 => 'Speed Priority Continuous',
5272             0x51 => 'Self-timer 10 sec',
5273             0x52 => 'Self-timer 2 sec, Mirror Lock-up',
5274             0x71 => 'Continuous Bracketing 0.3 EV',
5275             0x75 => 'Continuous Bracketing 0.7 EV',
5276             0x91 => 'White Balance Bracketing Low',
5277             0x92 => 'White Balance Bracketing High',
5278             0xc0 => 'Remote Commander',
5279             0xd1 => 'Continuous - HDR',
5280             0xd2 => 'Continuous - Multi Frame NR',
5281             0xd3 => 'Continuous - Handheld Night Shot', # (also called "Hand-held Twilight")
5282             0xd4 => 'Continuous - Anti Motion Blur', #PH (NEX-5)
5283             0xd5 => 'Continuous - Sweep Panorama',
5284             0xd6 => 'Continuous - 3D Sweep Panorama',
5285             },
5286             },
5287             0x35 => {
5288             Name => 'MultiFrameNoiseReduction',
5289             Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)$/',
5290             PrintConv => {
5291             0 => 'n/a', # seen for A450/A500/A550
5292             1 => 'Off',
5293             16 => 'On',
5294             255 => 'None', # seen for NEX-3/5/C3
5295             },
5296             },
5297             0x36 => { #JR (not 100% sure about this one)
5298             Name => 'LiveViewAFSetting',
5299             Condition => '$$self{Model} !~ /^(NEX-|DSLR-(A450|A500|A550)$)/',
5300             PrintConv => {
5301             0 => 'n/a',
5302             1 => 'Phase-detect AF',
5303             2 => 'Contrast AF',
5304             # Contrast AF is only available with SSM/SAM lenses and in Focus Check LV,
5305             # NOT in Quick AF LV, and is automatically set when mounting SSM/SAM lens
5306             # - changes into Phase-AF when switching to Quick AF LV.
5307             },
5308             },
5309             0x38 => { #JR
5310             Name => 'PanoramaSize3D',
5311             Description => '3D Panorama Size',
5312             Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)$/',
5313             PrintConv => {
5314             0 => 'n/a',
5315             1 => 'Standard',
5316             2 => 'Wide',
5317             3 => '16:9',
5318             },
5319             },
5320             0x83 => { #JR
5321             Name => 'AFButtonPressed',
5322             # only indicates pressing and holding the "AF" button (centre-controller),
5323             # not pressing the shutter release button halfway down
5324             Condition => '$$self{Model} !~ /^(NEX-|DSLR-(A450|A500|A550)$)/',
5325             PrintConv => {
5326             1 => 'No',
5327             16 => 'Yes',
5328             },
5329             },
5330             0x84 => { #JR (not 100% sure about this one)
5331             Name => 'LiveViewMetering',
5332             Condition => '$$self{Model} !~ /^(NEX-|DSLR-(A450|A500|A550)$)/',
5333             PrintConv => {
5334             0 => 'n/a',
5335             16 => '40 Segment', # DSLR with LiveView/OVF switch in OVF position
5336             32 => '1200-zone Evaluative', # SLT, or DSLR with LiveView/OVF switch in LiveView position
5337             },
5338             },
5339             0x85 => { #JR (not sure what is difference with 0x2f)
5340             Name => 'ViewingMode2',
5341             Condition => '$$self{Model} !~ /^(NEX-|DSLR-(A450|A500|A550)$)/',
5342             PrintConv => {
5343             0 => 'n/a',
5344             16 => 'Viewfinder',
5345             33 => 'Focus Check Live View',
5346             34 => 'Quick AF Live View',
5347             },
5348             },
5349             0x86 => { #JR
5350             Name => 'AELock',
5351             Condition => '$$self{Model} !~ /^(NEX-|DSLR-(A450|A500|A550)$)/',
5352             PrintConv => {
5353             1 => 'On',
5354             2 => 'Off',
5355             },
5356             },
5357             0x87 => { #JR
5358             Name => 'FlashStatusBuilt-in',
5359             Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)/',
5360             PrintConv => {
5361             1 => 'Off',
5362             2 => 'On',
5363             },
5364             },
5365             0x88 => { #JR
5366             Name => 'FlashStatusExternal',
5367             Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)/',
5368             PrintConv => {
5369             1 => 'None',
5370             2 => 'Off',
5371             3 => 'On',
5372             },
5373             },
5374             # 0x8a => { #JR
5375             # Name => 'LensAF',
5376             # Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)$/',
5377             # PrintConv => {
5378             # 1 => 'No',
5379             # 16 => 'AF Lens',
5380             # },
5381             # },
5382             0x8b => { #JR
5383             Name => 'LiveViewFocusMode',
5384             Condition => '$$self{Model} !~ /^(NEX-|DSLR-(A450|A500|A550)$)/',
5385             PrintConv => {
5386             0 => 'n/a',
5387             1 => 'AF',
5388             16 => 'Manual',
5389             },
5390             },
5391             # 0x8e => { #JR
5392             # Name => 'LensSAM',
5393             # Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)$/',
5394             # PrintConv => {
5395             # 1 => 'No',
5396             # 16 => 'SAM Lens',
5397             # },
5398             # },
5399             0x99 => { #JR
5400             Name => 'LensMount',
5401             Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)$/',
5402             DataMember => 'LensMount',
5403             RawConv => '$$self{LensMount} = $val',
5404             PrintConv => {
5405             1 => 'Unknown',
5406             16 => 'A-mount',
5407             17 => 'E-mount',
5408             },
5409             },
5410             # 0x9b => { #JR
5411             # Name => 'LensOSS',
5412             # Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)$/',
5413             # PrintConv => {
5414             # 1 => 'No',
5415             # 16 => 'OSS Lens',
5416             # 17 => 'OSS Lens (NEX-VG)', # active ?
5417             # },
5418             # },
5419             # 0x9c - 1; 2 for multi-shot modes
5420             0x10c => { #JR
5421             Name => 'SequenceNumber',
5422             Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)$/', # seen 18 for A550, so better exclude ?
5423             # normally 0; seen 1,2,3 for bracketing, 6 for Handheld Night Shot, 3 for HDR, 6 for MFNR
5424             PrintConv => {
5425             0 => 'Single',
5426             255 => 'n/a',
5427             OTHER => sub { shift }, # pass all other numbers straight through
5428             },
5429             },
5430             # when reading 0x0114 - 0x0117 as int32u:
5431             # - upper 8 bits (0x0117): always value 4, meaning unknown
5432             # - next 10 bits: FolderNumber (max. 999 according to manual)
5433             # - last 14 bits: ImageNumber (max 9999)
5434             0x0114 => { #JR
5435             Name => 'FolderNumber',
5436             Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)$/',
5437             Format => 'int32u',
5438             Mask => 0x00ffc000,
5439             PrintConv => 'sprintf("%.3d",$val)',
5440             PrintConvInv => '$val',
5441             },
5442             276.1 => { #JR (0x0114.1)
5443             Name => 'ImageNumber',
5444             Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)$/',
5445             Format => 'int32u',
5446             Mask => 0x00003fff,
5447             PrintConv => 'sprintf("%.4d",$val)',
5448             PrintConvInv => '$val',
5449             },
5450             0x200 => { #JR
5451             Name => 'ShotNumberSincePowerUp2',
5452             Notes => q{
5453             same as ShotNumberSincePowerUp for single-shot images, but includes all
5454             shots of the current image in multi-shot modes like HDR, panorama, and
5455             multi-frame noise reduction
5456             },
5457             # (includes all shutter actuations of the current shot)
5458             Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)$/',
5459             Format => 'int32u',
5460             },
5461             0x283 => { #JR
5462             Name => 'AFButtonPressed',
5463             # only indicates pressing and holding the "AF" button (centre-controller),
5464             # not pressing the shutter release button halfway down
5465             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)$/',
5466             PrintConv => {
5467             1 => 'No',
5468             16 => 'Yes',
5469             },
5470             },
5471             0x284 => { #JR (not 100% sure about this one)
5472             Name => 'LiveViewMetering',
5473             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)$/',
5474             PrintConv => {
5475             0 => 'n/a',
5476             16 => '40 Segment', # DSLR with LiveView/OVF switch in OVF position
5477             32 => '1200-zone Evaluative', # DSLR with LiveView/OVF switch in LiveView position
5478             },
5479             },
5480             0x285 => { #JR (not sure what is difference with 0x2f)
5481             Name => 'ViewingMode2',
5482             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)$/',
5483             PrintConv => {
5484             0 => 'n/a',
5485             16 => 'Viewfinder',
5486             33 => 'Focus Check Live View',
5487             34 => 'Quick AF Live View',
5488             },
5489             },
5490             0x286 => { #JR
5491             Name => 'AELock',
5492             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)$/',
5493             PrintConv => {
5494             1 => 'On',
5495             2 => 'Off',
5496             },
5497             },
5498             0x287 => { #JR
5499             Name => 'FlashStatusBuilt-in',
5500             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)$/',
5501             Notes => 'A450, A500 and A550',
5502             PrintConv => {
5503             1 => 'Off',
5504             2 => 'On',
5505             },
5506             },
5507             0x288 => { #JR
5508             Name => 'FlashStatusExternal',
5509             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)$/',
5510             Notes => 'A450, A500 and A550',
5511             PrintConv => {
5512             1 => 'None',
5513             2 => 'Off',
5514             3 => 'On',
5515             },
5516             },
5517             0x28b => { #JR
5518             Name => 'LiveViewFocusMode',
5519             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)$/',
5520             PrintConv => {
5521             0 => 'n/a',
5522             1 => 'AF',
5523             16 => 'Manual',
5524             },
5525             },
5526             0x30c => { #JR
5527             Name => 'SequenceNumber',
5528             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)$/',
5529             Notes => 'A450, A500 and A550',
5530             # normally 0; seen 2 for HDR
5531             PrintConv => {
5532             0 => 'Single',
5533             255 => 'n/a',
5534             OTHER => sub { shift }, # pass all other numbers straight through
5535             },
5536             },
5537             0x314 => { #JR
5538             Name => 'ImageNumber',
5539             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)$/',
5540             Format => 'int16u',
5541             Notes => 'A450, A500 and A550',
5542             Mask => 0x3fff, #PH (not sure what the upper 2 bits are for)
5543             PrintConv => 'sprintf("%.4d",$val)',
5544             PrintConvInv => '$val',
5545             },
5546             0x316 => { #JR
5547             Name => 'FolderNumber',
5548             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)$/',
5549             Notes => 'A450, A500 and A550',
5550             Format => 'int16u',
5551             Mask => 0x03ff, #(NC)
5552             PrintConv => 'sprintf("%.3d",$val)',
5553             PrintConvInv => '$val',
5554             },
5555             0x03f0 => {
5556             Name => 'LensE-mountVersion',
5557             Format => 'int16u',
5558             Condition => '($$self{Model} =~ /^NEX-/)',
5559             PrintConv => 'sprintf("%x.%.2x",$val>>8,$val&0xff)',
5560             PrintConvInv => 'my @a=split(/\./,$val);(hex($a[0])<<8)|hex($a[1])',
5561             },
5562             # 0x03f3 - this is probably LensFirmwareVersion and not CameraE-MountVersion (ref JR, Sept.2015)
5563             # 0x03f3 and 0x03f4 change together and behave similarly to Tag940c 0x0014 and 0x0015 - see comments there.
5564             0x03f3 => {
5565             Name => 'LensFirmwareVersion',
5566             Format => 'int16u',
5567             Condition => '($$self{Model} =~ /^NEX-/)',
5568             PrintConv => 'sprintf("Ver.%.2x.%.3d",$val>>8,$val&0xff)',
5569             },
5570             0x3f7 => { #JR
5571             Name => 'LensType2',
5572             Condition => '($$self{Model} =~ /^NEX-/) and ($$self{LensMount} != 1)',
5573             Format => 'int16u',
5574             SeparateTable => 'LensType2',
5575             PrintConv => \%sonyLensTypes2,
5576             PrintInt => 1,
5577             },
5578             0x400 => { #JR
5579             Name => 'ImageNumber',
5580             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)$/',
5581             Format => 'int16u',
5582             Notes => 'A450, A500 and A550',
5583             Mask => 0x3fff, #PH (not sure what the upper 2 bits are for)
5584             PrintConv => 'sprintf("%.4d",$val)',
5585             PrintConvInv => '$val',
5586             },
5587             0x402 => { #JR
5588             Name => 'FolderNumber',
5589             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)$/',
5590             Format => 'int16u',
5591             Mask => 0x03ff, #(NC)
5592             Notes => 'A450, A500 and A550',
5593             PrintConv => 'sprintf("%.3d",$val)',
5594             PrintConvInv => '$val',
5595             },
5596             );
5597              
5598             # Camera settings for other models
5599             %Image::ExifTool::Sony::CameraSettingsUnknown = (
5600             %binaryDataAttrs,
5601             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5602             FORMAT => 'int16u',
5603             );
5604              
5605             # extra hardware information (ref JR)
5606             %Image::ExifTool::Sony::ExtraInfo = (
5607             %binaryDataAttrs,
5608             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5609             NOTES => 'Extra hardware information for the A850 and A900.',
5610             # 0x0000: seen values 5 or 6
5611             0x0001 => {
5612             Name => 'BatteryTemperature',
5613             # seen values of appr. 55 - 115: looks like temperature Fahrenheit
5614             # changing battery in cold weather: new battery starts with value 53
5615             ValueConv => '($val - 32) / 1.8', # convert to Celsius
5616             ValueConvInv => '$val * 1.8 + 32',
5617             PrintConv => 'sprintf("%.1f C",$val)',
5618             PrintConvInv => '$val=~ s/\s*C//; $val',
5619             # (may be invalid for non-OEM batteries)
5620             },
5621             0x0002 => {
5622             Name => 'BatteryUnknown',
5623             # appears to be an int16u value together with 0x0005 (values similar to ExtraInfo3 0x0000)
5624             # seen values of appr. 800 at 23 deg C to 630 at 40 deg C for A850 with NP-FM500H battery (7.2 V nominal)
5625             # i.e. inversely proportional to BatteryTemperature: can not be BatteryVoltage, must be something else ?
5626             Unknown => 1,
5627             Format => 'undef[4]',
5628             ValueConv => sub {
5629             my $val = shift;;
5630             my @a = unpack("CvC",pack('v*', unpack('n*', $val)));
5631             return $a[1];
5632             },
5633             },
5634             # 0x0003: seen 0 or 16
5635             # 0x0004: always 255
5636             # 0x0006: int16u value together with 0x0009: same behaviour and almost same values as 0x0002
5637             # 0x0007: always 3
5638             0x0008 => {
5639             Name => 'BatteryVoltage',
5640             # 0x0008: int16u value together with 0x000b:
5641             # values follow BatteryLevel: from appr.900 when battery full, to appr. 775 when empty.
5642             # with factor 118 they range from appr. 7.6 to 6.6 - looks like battery voltage (nominal 7.2 V)
5643             Unknown => 1,
5644             Format => 'undef[4]',
5645             ValueConv => sub {
5646             my $val = shift;;
5647             my @a = unpack("CvC",pack('v*', unpack('n*', $val)));
5648             return $a[1]/118;
5649             },
5650             PrintConv => 'sprintf("%.2f V",$val)',
5651             },
5652             0x000a => {
5653             # seen mostly 213 and 246, corresponding with other ImageStabilization On/Off tags.
5654             Name => 'ImageStabilization2',
5655             Unknown => 1, # (because the decoding is funny and possibly incomplete - PH)
5656             PrintConv => {
5657             191 => 'On (191)', # seen a few times with moving subject, continuous drive, bracketing
5658             207 => 'On (207)', # seen once with RemoteCommander
5659             210 => 'On (210)', # seen a few times with continuous drive
5660             213 => 'On',
5661             246 => 'Off',
5662             },
5663             },
5664             # 0x000c: seen always decreasing values, from max. 107 to min. 0,
5665             # then jump back to high value: correlates with battery change/recharging
5666             # Seen once 255 immediately after inserting new battery, next frame OK at 106.
5667             # Validation: matches exactly with batterylevel display on camera (all 100+ values displayed as 100%)
5668             0x000c => {
5669             Name => 'BatteryLevel',
5670             PrintConv => '"$val%"',
5671             PrintConvInv => '$val=~s/\s*\%//; $val',
5672             },
5673             # 0x000d: always 2
5674             # 0x000e: always 204
5675             # 0x000f: always 0
5676             # 0x0010-0x0019: always 204
5677             0x001a => {
5678             Name => 'ExtraInfoVersion',
5679             Format => 'int8u[4]',
5680             PrintConv => '$val=~tr/ /./; $val',
5681             PrintConvInv => '$val=~tr/./ /; $val',
5682             # always 0 1 0 1 for 0x0131 Software = DSLR-A850 v1.00
5683             # always 0 2 0 4 for 0x0131 Software = DSLR-A850 v2.00
5684             # seen 0 2 0 0 for 0x0131 Software = DSLR-A900 v1.00
5685             # seen 0 4 0 0 for 0x0131 Software = DSLR-A900 v1.00
5686             # seen 0 5 0 4 for 0x0131 Software = DSLR-A900 v2.00
5687             # A850: correlates exactly with Firmware versions.
5688             # A900: have there been different FW 1.0 versions ?
5689             },
5690             );
5691              
5692             # extra hardware information (ref JR)
5693             %Image::ExifTool::Sony::ExtraInfo2 = (
5694             %binaryDataAttrs,
5695             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5696             NOTES => 'Extra hardware information for the A230/290/330/380/390.',
5697             0x0004 => {
5698             Name => 'BatteryLevel',
5699             PrintConv => '"$val%"',
5700             PrintConvInv => '$val=~s/\s*\%//; $val',
5701             },
5702             0x0012 => {
5703             Name => 'ImageStabilization',
5704             PrintConv => {
5705             0 => 'Off',
5706             64 => 'On',
5707             },
5708             },
5709             );
5710              
5711             # extra hardware information (ref JR)
5712             %Image::ExifTool::Sony::ExtraInfo3 = (
5713             %binaryDataAttrs,
5714             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5715             NOTES => q{
5716             Extra hardware information for the A33, A35, A55, A450, A500, A550, A560,
5717             A580 and NEX-3/5/C3/VG10.
5718             },
5719             0x0000 => {
5720             Name => 'BatteryUnknown',
5721             # seen values of appr. 870 at 10 deg C to 650 at 39 deg C for A580 with NP-FM500H battery (7.2 V nominal)
5722             # i.e. inversely proportional to BatteryTemperature: can not be BatteryVoltage, must be something else ?
5723             Unknown => 1,
5724             Format => 'int16u',
5725             },
5726             0x0002 => {
5727             Name => 'BatteryTemperature',
5728             ValueConv => '($val - 32) / 1.8', # convert to Celsius
5729             ValueConvInv => '$val * 1.8 + 32',
5730             PrintConv => 'sprintf("%.1f C",$val)',
5731             PrintConvInv => '$val=~ s/\s*C//; $val',
5732             },
5733             0x0004 => {
5734             Name => 'BatteryLevel',
5735             PrintConv => '"$val%"',
5736             PrintConvInv => '$val=~s/\s*\%//; $val',
5737             },
5738             # 0x0005: always 255
5739             # from here on the differences between DSLR, SLT and NEX
5740             # 0x0006 and 0x0008:
5741             # values follow BatteryLevel: start high (970, 940) when battery full,
5742             # and decrease with decreasing battery level to (850, 815)
5743             # with factor 128 they range from (7.6, 7.3) to (6.6, 6.4) - looks like battery voltage (nominal 7.2 V)
5744             0x0006 => {
5745             Name => 'BatteryVoltage1',
5746             Format => 'int16u',
5747             Condition => '$$self{Model} !~ /^(NEX-(3|5|5C|C3|VG10|VG10E))\b/',
5748             ValueConv => '$val / 128',
5749             ValueConvInv => '$val * 128',
5750             PrintConv => 'sprintf("%.2f V",$val)',
5751             PrintConvInv => '$val=~s/\s*V//; $val',
5752             },
5753             0x0008 => {
5754             Name => 'BatteryVoltage2',
5755             Format => 'int16u',
5756             Condition => '$$self{Model} !~ /^(NEX-(3|5|5C|C3|VG10|VG10E))\b/',
5757             ValueConv => '$val / 128',
5758             ValueConvInv => '$val * 128',
5759             PrintConv => 'sprintf("%.2f V",$val)',
5760             PrintConvInv => '$val=~s/\s*V//; $val',
5761             },
5762             # 0x000a - 0x000f: 3 int16u values: probably some mode or status info:
5763             # seen various 3-number-sequences for SLT and DSLR, but meaning unknown
5764             # 0x000a => {
5765             # Name => 'ExtraInfo_000a',
5766             # Format => 'int16u[3]',
5767             # Condition => '$$self{Model} !~ /^(NEX-(3|5|5C|C3|VG10|VG10E))\b/',
5768             # },
5769             # 0x0010 seen:
5770             # 176 for SLT
5771             # 204 for NEX
5772             # 240 for DSLR
5773             0x0011 => {
5774             Name => 'ImageStabilization',
5775             Condition => '$$self{Model} !~ /^(NEX-(3|5|5C|C3|VG10|VG10E))\b/',
5776             # usually matches 0xb026 ImageStabilization, except some images with SelfTimer and on tripod
5777             PrintConv => {
5778             0 => 'Off',
5779             64 => 'On',
5780             },
5781             },
5782             0x0014 => [
5783             {
5784             Name => 'BatteryState',
5785             Condition => '$$self{Model} =~ /^SLT-/',
5786             # possibly relates to "simple" batterylevel indication with battery-icon, but not completely sure
5787             Notes => 'BatteryState for SLT models',
5788             PrintConv => {
5789             1 => 'Empty',
5790             2 => 'Low',
5791             3 => 'Half full',
5792             4 => 'Almost full',
5793             5 => 'Full',
5794             },
5795             },{
5796             Name => 'ExposureProgram',
5797             Condition => '$$self{Model} =~ /^DSLR-(A450|A500|A550)\b/',
5798             Notes => 'ExposureProgram for the A450, A500 and A550',
5799             Priority => 0, # (some unknown values)
5800             PrintConv => {
5801             241 => 'Landscape',
5802             243 => 'Aperture-priority AE',
5803             245 => 'Portrait',
5804             246 => 'Auto',
5805             247 => 'Program AE',
5806             249 => 'Macro',
5807             252 => 'Sunset',
5808             253 => 'Sports', #PH (A550)
5809             255 => 'Manual',
5810             # missing: Shutter speed priority AE, No Flash, Night View
5811             },
5812             },{
5813             Name => 'ModeDialPosition',
5814             Condition => '$$self{Model} =~ /^DSLR-/',
5815             Notes => 'ModeDialPosition for other DSLR models',
5816             # (decoded from A560/A580)
5817             PrintConv => {
5818             248 => 'No Flash',
5819             249 => 'Aperture-priority AE',
5820             250 => 'SCN', # <-- the reason we don't call it ExposureProgram for these models
5821             251 => 'Shutter speed priority AE',
5822             252 => 'Auto',
5823             253 => 'Program AE',
5824             254 => 'Panorama',
5825             255 => 'Manual',
5826             },
5827             },
5828             ],
5829             # 0x0015: DSLR: appears to be a bitmask relating to "switch" positions:
5830             # bit 0 ( 1) only seen OFF for A580
5831             # bit 1 ( 2) ON = Flash down, OFF = Flash raised
5832             # bit 2 ( 4) only seen ON for A580
5833             # bit 3 ( 8) only seen ON for A580
5834             # bit 4 ( 16) ON = AF, OFF = MF
5835             # bit 5 ( 32) ON = OVF, OFF = LiveView
5836             # bit 6 ( 64) seen ON and OFF, meaning unknown
5837             # bit 7 (128) seen ON and OFF, meaning unknown
5838             # 0x0016: DSLR: seen 244,245,252,254, decoded for A580 with 32GB SD and 16GB MS cards
5839             # 0x0016: NEX: seen 61,62, 125,126, 190: bits '64' and '128' appear to relate to CameraOrientation
5840             # 0x0016: SLT: seen 64 - 78, meaning unknown
5841             0x0016 => [{
5842             Name => 'MemoryCardConfiguration',
5843             Condition => '$$self{Model} =~ /^DSLR-/',
5844             PrintConv => {
5845             244 => 'MemoryStick in use, SD card present',
5846             245 => 'MemoryStick in use, SD slot empty',
5847             252 => 'SD card in use, MemoryStick present',
5848             254 => 'SD card in use, MemoryStick slot empty',
5849             },
5850             },{
5851             Name => 'CameraOrientation',
5852             Condition => '$$self{Model} =~ /^(NEX-(3|5|5C|C3|VG10|VG10E))\b/',
5853             Mask => 0xc0, # (don't know what other bits mean)
5854             PrintConv => {
5855             0 => 'Horizontal (normal)',
5856             1 => 'Rotate 90 CW',
5857             2 => 'Rotate 270 CW',
5858             3 => 'Rotate 180', #(NC)
5859             },
5860              
5861             }],
5862             # 0x0017: seen 0 for SLT, 255 for DSLR, variable for NEX
5863             0x0018 => {
5864             Name => 'CameraOrientation',
5865             Condition => '$$self{Model} !~ /^(NEX-(3|5|5C|C3|VG10|VG10E))\b/',
5866             Mask => 0x30, # (don't know what other bits mean)
5867             PrintConv => {
5868             0 => 'Horizontal (normal)',
5869             1 => 'Rotate 90 CW',
5870             2 => 'Rotate 270 CW',
5871             3 => 'Rotate 180',
5872             },
5873             },
5874             # 0x0019:
5875             # A450/500/550: 0 - 12 and 233 - 255
5876             # A560/580: 1 or 64, seen a few 0 and 8
5877             # A33/35/55: seen 0, 1, 64
5878             # NEX: 204
5879             # 0x001a, 0x001c appear to be 2 int16u values, meaning unknown
5880             );
5881              
5882             # shot information (ref PH)
5883             %Image::ExifTool::Sony::ShotInfo = (
5884             %binaryDataAttrs,
5885             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
5886             DATAMEMBER => [ 0x02, 0x30, 0x32, 0x34 ],
5887             IS_SUBDIR => [ 0x48, 0x5e ],
5888             # 0x00 - byte order 'II'
5889             0x02 => {
5890             Name => 'FaceInfoOffset',
5891             Format => 'int16u',
5892             DataMember => 'FaceInfoOffset',
5893             Writable => 0,
5894             RawConv => '$$self{FaceInfoOffset} = $val',
5895             },
5896             0x06 => {
5897             Name => 'SonyDateTime',
5898             Format => 'string[20]',
5899             Groups => { 2 => 'Time' },
5900             Shift => 'Time',
5901             PrintConv => '$self->ConvertDateTime($val)',
5902             PrintConvInv => '$self->InverseDateTime($val,0)',
5903             },
5904             0x1a => { Name => 'SonyImageHeight', Format => 'int16u' }, #JR
5905             0x1c => { Name => 'SonyImageWidth', Format => 'int16u' }, #JR
5906             0x30 => { #Jeffrey Friedl
5907             Name => 'FacesDetected',
5908             DataMember => 'FacesDetected',
5909             Format => 'int16u',
5910             RawConv => '$$self{FacesDetected} = $val',
5911             },
5912             0x32 => {
5913             Name => 'FaceInfoLength', # length of a single FaceInfo entry
5914             DataMember => 'FaceInfoLength',
5915             Format => 'int16u',
5916             Writable => 0,
5917             RawConv => '$$self{FaceInfoLength} = $val',
5918             },
5919             0x34 => {
5920             # oldest/other DSC/other -
5921             # older DSC models "DC5303320222000" or "DC6303320222000"
5922             # DSC-W650/W690/W730 "THm101000000000" or "THm211000000000"
5923             # DSC-HX9V generation and newer "DC7303320222000"
5924             Name => 'MetaVersion', # (tentative)
5925             Format => 'string[16]',
5926             DataMember => 'MetaVersion',
5927             RawConv => '$$self{MetaVersion} = $val',
5928             },
5929             0x48 => { # (most models: DC5303320222000 and DC6303320222000)
5930             Name => 'FaceInfo1',
5931             Condition => q{
5932             $$self{FacesDetected} and
5933             $$self{FaceInfoOffset} == 0x48 and
5934             $$self{FaceInfoLength} == 0x20
5935             },
5936             SubDirectory => { TagTable => 'Image::ExifTool::Sony::FaceInfo1' },
5937             },
5938             0x5e => { # (HX7V: DC7303320222000)
5939             Name => 'FaceInfo2',
5940             Condition => q{
5941             $$self{FacesDetected} and
5942             $$self{FaceInfoOffset} == 0x5e and
5943             $$self{FaceInfoLength} == 0x25
5944             },
5945             SubDirectory => { TagTable => 'Image::ExifTool::Sony::FaceInfo2' },
5946             },
5947             );
5948              
5949             # tags used in Tag2010 and Tag9400 tables
5950             my %sequenceImageNumber = ( #PH
5951             Name => 'SequenceImageNumber',
5952             Notes => 'number of images captured in burst sequence',
5953             # (not shutter count because it increments for auto portrait framing)
5954             Format => 'int32u',
5955             ValueConv => '$val + 1',
5956             ValueConvInv => '$val - 1',
5957             );
5958             my %sequenceFileNumber = ( #PH
5959             Name => 'SequenceFileNumber',
5960             Notes => 'file number in burst sequence',
5961             Format => 'int32u',
5962             ValueConv => '$val + 1', #JR
5963             ValueConvInv => '$val - 1',
5964             );
5965             my %releaseMode2 = ( #JR
5966             Name => 'ReleaseMode2',
5967             SeparateTable => 'ReleaseMode2',
5968             PrintConv => {
5969             0 => 'Normal',
5970             1 => 'Continuous', # (RX100 "Continuous - Self-timer")
5971             2 => 'Continuous - Exposure Bracketing', # (RX100)
5972             # 3 - also DRO Bracketing (ILCE-7RM2), not "Continuous" because only single exposure from which camera makes 3 versions
5973             3 => 'DRO or White Balance Bracketing', # (HX9V) (RX100) (ILCE-7RM2)
5974             5 => 'Continuous - Burst', # (HX9V)
5975             6 => 'Single Frame - Capture During Movie', #PH (RX100)
5976             7 => 'Continuous - Sweep Panorama',
5977             8 => 'Continuous - Anti-Motion Blur, Hand-held Twilight', # (HX9V)
5978             9 => 'Continuous - HDR',
5979             10 => 'Continuous - Background defocus', # (HX9V)
5980             13 => 'Continuous - 3D Sweep Panorama', #PH/JR
5981             15 => 'Continuous - High Resolution Sweep Panorama', #JR (HX50V)
5982             16 => 'Continuous - 3D Image', # (HX9V)
5983             17 => 'Continuous - Burst 2', # (WX7 - PH) (#JR 9400-SequenceLength=10 shots)
5984             18 => 'Normal - iAuto+', # seen for several ILCE-3500/6000/6500/7S iAuto+ single-shot images ...
5985             19 => 'Continuous - Speed/Advance Priority', #PH/JR (RX100)
5986             20 => 'Continuous - Multi Frame NR',
5987             23 => 'Single-frame - Exposure Bracketing', # (seen for ILCE-7 series)
5988             26 => 'Continuous Low', #PH (A77)
5989             27 => 'Continuous - High Sensitivity', # seen for DSC-WX60 and WX300
5990             28 => 'Smile Shutter', #PH (RX100)
5991             29 => 'Continuous - Tele-zoom Advance Priority',
5992             # 30 - seen quite often for single-shot images ... SLT-A58, ILCE-5100/6000
5993             # 33 - Continuous - seen for DSC-RX100M5, RX10M4, maybe 24 fps mode ???
5994             146 => 'Single Frame - Movie Capture', #PH (seen in Tag2010 ReleaseMode2 values)
5995             },
5996             );
5997              
5998             # tag definitions for Tag2010 tables (ref JR)
5999             my %sonyDateTime2010 = (
6000             Name => 'SonyDateTime',
6001             Format => 'undef[7]',
6002             Shift => 'Time',
6003             ValueConv => q{
6004             my @v = unpack('vC*', $val);
6005             return sprintf("%.4d:%.2d:%.2d %.2d:%.2d:%.2d", @v)
6006             },
6007             ValueConvInv => q{
6008             my @v = ($val =~ /\d+/g);
6009             return undef unless @v == 6;
6010             return pack('vC*', @v);
6011             },
6012             PrintConv => '$self->ConvertDateTime($val)',
6013             PrintConvInv => '$self->InverseDateTime($val,0)',
6014             );
6015             my %releaseMode2010 = (
6016             Name => 'ReleaseMode3',
6017             PrintConv => {
6018             0 => 'Normal',
6019             1 => 'Continuous',
6020             2 => 'Bracketing', # (all types: Continuous and Single-Frame Exposure, White Balance and DRO bracketing - PH/JR)
6021             # 3 => 'Remote Commander', (NC) (seen this when other ReleaseMode and ReleaseMode2 are 'Normal' - PH, A77)
6022             4 => 'Continuous - Burst', # seen for DSC-WX500 with burst of 10 shots
6023             5 => 'Continuous - Speed/Advance Priority',
6024             6 => 'Normal - Self-timer', # seen for ILCE-6300/6500/9, ILCA-99M2
6025             9 => 'Single Burst Shooting', # first seen for DSC-RX100M7
6026             },
6027             );
6028             my %selfTimer2010 = (
6029             Name => 'SelfTimer',
6030             PrintConv => {
6031             0 => 'Off',
6032             1 => 'Self-timer 10 s',
6033             2 => 'Self-timer 2 s',
6034             },
6035             );
6036             my %selfTimerB2010 = ( # also value 1 for new 5 s mode of DSC-HX90V/RX10M2/RX100M4/WX500, ILCE-7RM2/7SM2
6037             Name => 'SelfTimer',
6038             PrintConv => {
6039             0 => 'Off',
6040             1 => 'Self-timer 5 or 10 s',
6041             2 => 'Self-timer 2 s',
6042             },
6043             );
6044             my %gain2010 = (
6045             Name => 'StopsAboveBaseISO',
6046             # BaseISO is 100 for SLT, ILCE-3000, NEX-5N/5R/5T/6/7/VG20/VG30/VG900, DSC-RX1/RX1R
6047             # BaseISO is 200 for NEX-F3/3N
6048             # BaseISO is 160 for DSC-RX100M2
6049             # BaseISO is 125 for DSC-RX100
6050             # Also several other DSC models have BaseISO different from 100.
6051             Format => 'int16u',
6052             ValueConv => '16 - $val/256',
6053             ValueConvInv => '(16 - $val) * 256',
6054             PrintConv => '$val ? sprintf("%.1f",$val) : $val',
6055             PrintConvInv => '$val',
6056             );
6057             my %brightnessValue2010 = (
6058             Name => 'BrightnessValue',
6059             Format => 'int16u',
6060             ValueConv => '$val/256 - 56.6',
6061             ValueConvInv => '($val + 56.6) * 256',
6062             );
6063             my %dynamicRangeOptimizer2010 = (
6064             Name => 'DynamicRangeOptimizer',
6065             PrintConv => {
6066             0 => 'Off',
6067             1 => 'Auto',
6068             3 => 'Lv1',
6069             4 => 'Lv2',
6070             5 => 'Lv3',
6071             6 => 'Lv4',
6072             7 => 'Lv5',
6073             8 => 'n/a',
6074             },
6075             );
6076             my %hdr2010 = (
6077             Name => 'HDRSetting', # (Off when HDR tag is On for RX100 superior auto backlight - PH)
6078             PrintConv => {
6079             0 => 'Off',
6080             1 => 'HDR Auto',
6081             3 => 'HDR 1 EV',
6082             5 => 'HDR 2 EV',
6083             7 => 'HDR 3 EV',
6084             9 => 'HDR 4 EV',
6085             11 => 'HDR 5 EV',
6086             13 => 'HDR 6 EV',
6087             },
6088             );
6089             my %exposureComp2010 = ( # only as set manually, remains 0 in exposure-bracketing modes
6090             Name => 'ExposureCompensation',
6091             Format=>'int16s',
6092             ValueConv => '-$val/256',
6093             ValueConvInv => '-$val*256',
6094             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
6095             PrintConvInv => '$val',
6096             );
6097             my %pictureEffect2010 = (
6098             Name => 'PictureEffect2',
6099             SeparateTable => 'PictureEffect2',
6100             PrintConv => {
6101             0 => 'Off',
6102             1 => 'Toy Camera',
6103             2 => 'Pop Color',
6104             3 => 'Posterization',
6105             4 => 'Retro Photo',
6106             5 => 'Soft High Key',
6107             6 => 'Partial Color',
6108             7 => 'High Contrast Monochrome',
6109             8 => 'Soft Focus',
6110             9 => 'HDR Painting',
6111             10 => 'Rich-tone Monochrome',
6112             11 => 'Miniature',
6113             12 => 'Water Color',
6114             13 => 'Illustration',
6115             },
6116             );
6117             my %quality2010 = (
6118             Name => 'Quality2',
6119             PrintConv => {
6120             0 => 'JPEG',
6121             1 => 'RAW',
6122             2 => 'RAW + JPEG',
6123             },
6124             );
6125             my %meteringMode2010 = (
6126             Name => 'MeteringMode',
6127             PrintConv => {
6128             0 => 'Multi-segment',
6129             2 => 'Center-weighted average',
6130             3 => 'Spot',
6131             4 => 'Average',
6132             5 => 'Highlight',
6133             },
6134             );
6135             my %flashMode2010 = (
6136             Name => 'FlashMode',
6137             PrintConv => {
6138             0 => 'Autoflash',
6139             1 => 'Fill-flash',
6140             2 => 'Flash Off',
6141             3 => 'Slow Sync',
6142             4 => 'Rear Sync',
6143             6 => 'Wireless',
6144             # 129 => 'unknown', # seen for ILCE-7M3 images
6145             },
6146             );
6147             my %exposureProgram2010 = (
6148             Name => 'ExposureProgram',
6149             SeparateTable => 'ExposureProgram3',
6150             PrintConv => \%sonyExposureProgram3,
6151             );
6152             my %pictureProfile2010 = (
6153             Name => 'PictureProfile',
6154             # values 0-9: Seen for all cameras writing this tag: matches CreativeStyle and/or SceneMode settings.
6155             # 10 and higher: Seen for ILCE-7S/7M2 and newer, having a PictureProfile setting, also some DSC/HDR models.
6156             # Although intended for video, when set these profiles are also applied to (JPG) still images.
6157             PrintConv => {
6158             0 => 'Gamma Still - Standard/Neutral (PP2)', # CreativeStyle = Standard or Neutral
6159             1 => 'Gamma Still - Portrait',
6160             #2 - seen for DSC-HX90
6161             3 => 'Gamma Still - Night View/Portrait',
6162             4 => 'Gamma Still - B&W/Sepia',
6163             5 => 'Gamma Still - Clear',
6164             6 => 'Gamma Still - Deep',
6165             7 => 'Gamma Still - Light',
6166             8 => 'Gamma Still - Vivid', # SceneMode or CreativeStyle = Vivid, Autumn, Sunset or Landscape
6167             9 => 'Gamma Still - Real',
6168             10 => 'Gamma Movie (PP1)',
6169             22 => 'Gamma ITU709 (PP3 or PP4)', # (also PP4 for A7M3, ref 14)
6170             24 => 'Gamma Cine1 (PP5)',
6171             25 => 'Gamma Cine2 (PP6)',
6172             26 => 'Gamma Cine3',
6173             27 => 'Gamma Cine4',
6174             28 => 'Gamma S-Log2 (PP7)',
6175             29 => 'Gamma ITU709 (800%)',
6176             31 => 'Gamma S-Log3 (PP8 or PP9)', #14
6177             33 => 'Gamma HLG2 (PP10)', #14
6178             34 => 'Gamma HLG3', #IB
6179             37 => 'FL',
6180             38 => 'VV2',
6181             39 => 'IN',
6182             40 => 'SH',
6183             },
6184             );
6185             my %isoSetting2010 = (
6186             0 => 'Auto',
6187             5 => 25,
6188             7 => 40,
6189             8 => 50,
6190             9 => 64,
6191             10 => 80,
6192             11 => 100,
6193             12 => 125,
6194             13 => 160,
6195             14 => 200,
6196             15 => 250,
6197             16 => 320,
6198             17 => 400,
6199             18 => 500,
6200             19 => 640,
6201             20 => 800,
6202             21 => 1000,
6203             22 => 1250,
6204             23 => 1600,
6205             24 => 2000,
6206             25 => 2500,
6207             26 => 3200,
6208             27 => 4000,
6209             28 => 5000,
6210             29 => 6400,
6211             30 => 8000,
6212             31 => 10000,
6213             32 => 12800,
6214             33 => 16000,
6215             34 => 20000,
6216             35 => 25600,
6217             36 => 32000,
6218             37 => 40000,
6219             38 => 51200,
6220             39 => 64000,
6221             40 => 80000,
6222             41 => 102400,
6223             42 => 128000,
6224             43 => 160000,
6225             44 => 204800,
6226             45 => 256000,
6227             46 => 320000,
6228             47 => 409600,
6229             );
6230              
6231             %Image::ExifTool::Sony::Tag2010a = ( #JR
6232             PROCESS_PROC => \&ProcessEnciphered,
6233             WRITE_PROC => \&WriteEnciphered,
6234             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6235             FORMAT => 'int8u',
6236             NOTES => 'Valid for NEX-5N.',
6237             WRITABLE => 1,
6238             FIRST_ENTRY => 0,
6239             PRIORITY => 0,
6240             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
6241             IS_SUBDIR => [ 0x04b0 ],
6242             0x04b0 => {
6243             Name => 'MeterInfo',
6244             Format => 'int32u[486]',
6245             Unknown => 1,
6246             SubDirectory => { TagTable => 'Image::ExifTool::Sony::MeterInfo' },
6247             },
6248             0x1128 => { %releaseMode2010 },
6249             0x112c => { %releaseMode2 },
6250             0x1134 => { %selfTimer2010 },
6251             0x1138 => { %flashMode2010 },
6252             0x113e => { %gain2010 },
6253             0x1140 => { %brightnessValue2010 },
6254             0x1144 => { %dynamicRangeOptimizer2010 },
6255             0x1148 => { %hdr2010 },
6256             0x114c => { %exposureComp2010 },
6257             0x115e => { %pictureProfile2010 },
6258             0x115f => { %pictureProfile2010 },
6259             0x1163 => { %pictureEffect2010 },
6260             0x1170 => { %quality2010 },
6261             0x1174 => { %meteringMode2010 },
6262             0x1175 => { %exposureProgram2010 },
6263             0x117c => { Name => 'WB_RGBLevels', Format => 'int16u[3]' },
6264             #0x1a08 => { Name => 'SonyImageWidth', Format => 'int16u' },
6265             #0x1a0c => { Name => 'SonyImageHeight', Format => 'int16u' },
6266             );
6267              
6268             %Image::ExifTool::Sony::Tag2010b = ( #JR
6269             PROCESS_PROC => \&ProcessEnciphered,
6270             WRITE_PROC => \&WriteEnciphered,
6271             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6272             FORMAT => 'int8u',
6273             NOTES => 'Valid for SLT-A65/A77, NEX-7/VG20E.',
6274             WRITABLE => 1,
6275             FIRST_ENTRY => 0,
6276             PRIORITY => 0,
6277             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
6278             IS_SUBDIR => [ 0x04b4 ],
6279             0x0000 => { %sequenceImageNumber }, #PH
6280             0x0004 => { %sequenceFileNumber }, #PH
6281             0x0008 => { %releaseMode2, Format => 'int32u' },
6282             #0x0044 => { Name => 'SonyImageWidth3', Format => 'int16u' },
6283             #0x0048 => { Name => 'SonyImageHeight3', Format => 'int16u' },
6284             #0x0054 => { Name => 'SonyImageWidth2', Format => 'int16u' },
6285             #0x0058 => { Name => 'SonyImageHeight2', Format => 'int16u' },
6286             #0x0064 => { Name => 'SonyImageWidth', Format => 'int16u' },
6287             #0x0068 => { Name => 'SonyImageHeight', Format => 'int16u' },
6288             #0x00a8 => { Name => 'SonyImageWidth2', Format => 'int16u' },
6289             #0x00ac => { Name => 'SonyImageHeight2', Format => 'int16u' },
6290             #0x00b8 => { Name => 'SonyImageWidth2', Format => 'int16u' },
6291             #0x00bc => { Name => 'SonyImageHeight2', Format => 'int16u' },
6292             #0x00c8 => { Name => 'SonyImageWidth', Format => 'int16u' },
6293             #0x00cc => { Name => 'SonyImageHeight', Format => 'int16u' },
6294             0x01b6 => { %sonyDateTime2010, Groups => { 2 => 'Time' } },
6295             #0x0204 => { Name => 'SonyImageWidth', Format => 'int16u' },
6296             #0x0206 => { Name => 'SonyImageHeight', Format => 'int16u' },
6297             0x0324 => { %dynamicRangeOptimizer2010 },
6298             0x04b4 => {
6299             Name => 'MeterInfo',
6300             Format => 'int32u[486]',
6301             Unknown => 1,
6302             SubDirectory => { TagTable => 'Image::ExifTool::Sony::MeterInfo' },
6303             },
6304             0x1128 => { %releaseMode2010 },
6305             0x112c => { %releaseMode2 },
6306             0x1134 => { %selfTimer2010 },
6307             0x1138 => { %flashMode2010 },
6308             0x113e => { %gain2010 },
6309             0x1140 => { %brightnessValue2010 },
6310             0x1144 => { %dynamicRangeOptimizer2010 },
6311             0x1148 => { %hdr2010 },
6312             0x114c => { %exposureComp2010 },
6313             0x1162 => { %pictureProfile2010 },
6314             0x1163 => { %pictureProfile2010 },
6315             0x1167 => { %pictureEffect2010 },
6316             0x1174 => { %quality2010 },
6317             0x1178 => { %meteringMode2010 },
6318             0x1179 => { %exposureProgram2010 },
6319             0x1180 => { Name => 'WB_RGBLevels', Format => 'int16u[3]' },
6320             0x1218 => {
6321             Name => 'SonyISO',
6322             Format => 'int16u',
6323             ValueConv => '100 * 2**(16 - $val/256)',
6324             ValueConvInv => '256 * (16 - log($val/100)/log(2))',
6325             PrintConv => 'sprintf("%.0f",$val)',
6326             PrintConvInv => '$val',
6327             },
6328             #0x1a08 => { Name => 'SonyImageWidth', Format => 'int16u' },
6329             #0x1a0c => { Name => 'SonyImageHeight', Format => 'int16u' },
6330             0x1a23 => { # only for NEX-7 with Firmware v1.02 and higher, but slightly different from Tag9405 ...
6331             Name => 'DistortionCorrParams',
6332             Format => 'int16s[16]',
6333             },
6334             );
6335              
6336             %Image::ExifTool::Sony::Tag2010c = ( #JR
6337             PROCESS_PROC => \&ProcessEnciphered,
6338             WRITE_PROC => \&WriteEnciphered,
6339             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6340             FORMAT => 'int8u',
6341             NOTES => 'Valid for SLT-A37/A57 and NEX-F3.',
6342             WRITABLE => 1,
6343             FIRST_ENTRY => 0,
6344             PRIORITY => 0,
6345             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
6346             IS_SUBDIR => [ 0x0490 ],
6347             0x0000 => { %sequenceImageNumber }, #PH
6348             0x0004 => { %sequenceFileNumber }, #PH
6349             0x0008 => { %releaseMode2, Format => 'int32u' },
6350             #0x0048 => { Name => 'SonyImageWidth3', Format => 'int16u' },
6351             #0x004c => { Name => 'SonyImageHeight3', Format => 'int16u' },
6352             #0x0058 => { Name => 'SonyImageWidth2', Format => 'int16u' },
6353             #0x005c => { Name => 'SonyImageHeight2', Format => 'int16u' },
6354             #0x0068 => { Name => 'SonyImageWidth', Format => 'int16u' },
6355             #0x006c => { Name => 'SonyImageHeight', Format => 'int16u' },
6356             #0x00c0 => { Name => 'SonyImageWidth2', Format => 'int16u' },
6357             #0x00c4 => { Name => 'SonyImageHeight2', Format => 'int16u' },
6358             #0x00d0 => { Name => 'SonyImageWidth2', Format => 'int16u' },
6359             #0x00d4 => { Name => 'SonyImageHeight2', Format => 'int16u' },
6360             #0x00e0 => { Name => 'SonyImageWidth', Format => 'int16u' },
6361             #0x00e4 => { Name => 'SonyImageHeight', Format => 'int16u' },
6362             #0x0134 => { Name => 'SonyImageHeight', Format => 'int16u' },
6363             #0x0144 => { Name => 'SonyImageHeight', Format => 'int16u' },
6364             #0x0154 => { Name => 'SonyImageHeight', Format => 'int16u' },
6365             0x0200 => { Name => 'DigitalZoomRatio', ValueConv => '$val/16', ValueConvInv => '$val*16', Priority => 0 },
6366             0x0210 => { %sonyDateTime2010, Groups => { 2 => 'Time' } },
6367             0x0300 => { %dynamicRangeOptimizer2010 },
6368             0x0490 => {
6369             Name => 'MeterInfo',
6370             Format => 'int32u[486]',
6371             Unknown => 1,
6372             SubDirectory => { TagTable => 'Image::ExifTool::Sony::MeterInfo' },
6373             },
6374             0x1104 => { %releaseMode2010 },
6375             0x1108 => { %releaseMode2 },
6376             0x1110 => { %selfTimer2010 },
6377             0x1114 => { %flashMode2010 },
6378             0x111a => { %gain2010 },
6379             0x111c => { %brightnessValue2010 },
6380             0x1120 => { %dynamicRangeOptimizer2010 },
6381             0x1124 => { %hdr2010 },
6382             0x1128 => { %exposureComp2010 },
6383             0x113e => { %pictureProfile2010 },
6384             0x113f => { %pictureProfile2010 },
6385             0x1143 => { %pictureEffect2010 },
6386             0x1150 => { %quality2010 },
6387             0x1154 => { %meteringMode2010 },
6388             0x1155 => { %exposureProgram2010 },
6389             0x115c => { Name => 'WB_RGBLevels', Format => 'int16u[3]' },
6390             0x11f4 => {
6391             Name => 'SonyISO',
6392             Format => 'int16u',
6393             ValueConv => '100 * 2**(16 - $val/256)',
6394             ValueConvInv => '256 * (16 - log($val/100)/log(2))',
6395             PrintConv => 'sprintf("%.0f",$val)',
6396             PrintConvInv => '$val',
6397             },
6398             #0x1a08 => { Name => 'SonyImageWidth', Format => 'int16u' },
6399             #0x1a0c => { Name => 'SonyImageHeight', Format => 'int16u' },
6400             );
6401              
6402             %Image::ExifTool::Sony::Tag2010d = ( #JR
6403             PROCESS_PROC => \&ProcessEnciphered,
6404             WRITE_PROC => \&WriteEnciphered,
6405             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6406             FORMAT => 'int8u',
6407             NOTES => q{
6408             Valid for DSC-HX10V/HX20V/HX200V/TX66/TX200V/TX300V/WX50/WX100/WX150, but
6409             not valid for panorama images.
6410             },
6411             WRITABLE => 1,
6412             FIRST_ENTRY => 0,
6413             PRIORITY => 0,
6414             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
6415             IS_SUBDIR => [ 0x050c ],
6416             0x0000 => { %sequenceImageNumber }, #PH
6417             0x0004 => { %sequenceFileNumber }, #PH
6418             0x0008 => { %releaseMode2, Format => 'int32u' },
6419             #0x0048 => { Name => 'SonyImageWidth3', Format => 'int16u' },
6420             #0x004c => { Name => 'SonyImageHeight3', Format => 'int16u' },
6421             #0x0058 => { Name => 'SonyImageWidth2', Format => 'int16u' },
6422             #0x005c => { Name => 'SonyImageHeight2', Format => 'int16u' },
6423             #0x0068 => { Name => 'SonyImageWidth', Format => 'int16u' },
6424             #0x006c => { Name => 'SonyImageHeight', Format => 'int16u' },
6425             #0x00c0 => { Name => 'SonyImageWidth2', Format => 'int16u' },
6426             #0x00c4 => { Name => 'SonyImageHeight2', Format => 'int16u' },
6427             #0x00d0 => { Name => 'SonyImageWidth2', Format => 'int16u' },
6428             #0x00d4 => { Name => 'SonyImageHeight2', Format => 'int16u' },
6429             #0x00e0 => { Name => 'SonyImageWidth', Format => 'int16u' },
6430             #0x00e4 => { Name => 'SonyImageHeight', Format => 'int16u' },
6431             0x01fe => { %sonyDateTime2010, Groups => { 2 => 'Time' } },
6432             0x037c => { %dynamicRangeOptimizer2010 },
6433             0x050c => {
6434             Name => 'MeterInfo',
6435             Format => 'int32u[486]',
6436             Unknown => 1,
6437             SubDirectory => { TagTable => 'Image::ExifTool::Sony::MeterInfo' },
6438             },
6439             0x1180 => { %releaseMode2010 },
6440             0x1184 => { %releaseMode2 },
6441             0x118c => { %selfTimer2010 },
6442             0x1190 => { %flashMode2010 },
6443             0x1196 => { %gain2010 },
6444             0x1198 => { %brightnessValue2010 },
6445             0x119c => { %dynamicRangeOptimizer2010 },
6446             0x11a0 => { %hdr2010 },
6447             0x11ba => { %pictureProfile2010 },
6448             0x11bb => { %pictureProfile2010 },
6449             0x11bf => { %pictureEffect2010 },
6450             0x11d0 => { %meteringMode2010 },
6451             # 0x11d1 - not valid for HX20V panorama images - PH
6452             0x11d1 => { %exposureProgram2010 },
6453             0x11d8 => { Name => 'WB_RGBLevels', Format => 'int16u[3]' },
6454             0x1270 => {
6455             Name => 'SonyISO',
6456             Format => 'int16u',
6457             ValueConv => '100 * 2**(16 - $val/256)',
6458             ValueConvInv => '256 * (16 - log($val/100)/log(2))',
6459             PrintConv => 'sprintf("%.0f",$val)',
6460             PrintConvInv => '$val',
6461             },
6462             );
6463              
6464             %Image::ExifTool::Sony::Tag2010e = ( #JR
6465             PROCESS_PROC => \&ProcessEnciphered,
6466             WRITE_PROC => \&WriteEnciphered,
6467             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6468             FORMAT => 'int8u',
6469             NOTES => q{
6470             Valid for SLT-A58/A99, ILCE-3000/3500, NEX-3N/5R/5T/6/VG30E/VG900,
6471             DSC-RX100, DSC-RX1/RX1R. Also valid for DSC-HX300/HX50V/TX30/WX60/WX200/
6472             WX300, but not for panorama images.
6473             },
6474             WRITABLE => 1,
6475             FIRST_ENTRY => 0,
6476             PRIORITY => 0,
6477             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
6478             DATAMEMBER => [ 0x1892 ],
6479             IS_SUBDIR => [ 0x04b8 ],
6480             0x0000 => { %sequenceImageNumber }, #PH
6481             0x0004 => { %sequenceFileNumber }, #PH
6482             0x0008 => { %releaseMode2, Format => 'int32u' },
6483             #0x0048 => { Name => 'SonyImageWidth3', Format => 'int16u' },
6484             #0x004c => { Name => 'SonyImageHeight3', Format => 'int16u' },
6485             #0x0058 => { Name => 'SonyImageWidth2', Format => 'int16u' },
6486             #0x005c => { Name => 'SonyImageHeight2', Format => 'int16u' },
6487             #0x0068 => { Name => 'SonyImageWidth', Format => 'int16u' },
6488             #0x006c => { Name => 'SonyImageHeight', Format => 'int16u' },
6489             #0x00c0 => { Name => 'SonyImageWidth2', Format => 'int16u' },
6490             #0x00c4 => { Name => 'SonyImageHeight2', Format => 'int16u' },
6491             #0x00d0 => { Name => 'SonyImageWidth2', Format => 'int16u' },
6492             #0x00d4 => { Name => 'SonyImageHeight2', Format => 'int16u' },
6493             #0x00e0 => { Name => 'SonyImageWidth', Format => 'int16u' },
6494             #0x00e4 => { Name => 'SonyImageHeight', Format => 'int16u' },
6495             #0x01fa => { Name => 'SonyImageHeight', Format => 'int16u' },
6496             #0x0200 => { Name => 'SonyImageWidth', Format => 'int16u' },
6497             0x021c => { Name => 'DigitalZoomRatio', ValueConv => '$val/16', ValueConvInv => '$val*16', Priority => 0 },
6498             0x022c => { %sonyDateTime2010, Groups => { 2 => 'Time' } },
6499             0x0328 => { %dynamicRangeOptimizer2010 },
6500             0x04b8 => {
6501             Name => 'MeterInfo',
6502             Format => 'int32u[486]',
6503             Unknown => 1,
6504             SubDirectory => { TagTable => 'Image::ExifTool::Sony::MeterInfo' },
6505             },
6506             0x115c => { %releaseMode2010 },
6507             0x1160 => { %releaseMode2 },
6508             0x1168 => { %selfTimer2010 },
6509             0x116c => { %flashMode2010 },
6510             0x1172 => { %gain2010 },
6511             0x1174 => { %brightnessValue2010 },
6512             0x1178 => { %dynamicRangeOptimizer2010 },
6513             0x117c => { %hdr2010 },
6514             0x1180 => { %exposureComp2010 },
6515             0x1196 => { %pictureProfile2010 },
6516             0x1197 => { %pictureProfile2010 },
6517             0x119b => { %pictureEffect2010 },
6518             0x11a8 => { %quality2010 },
6519             0x11ac => { %meteringMode2010 },
6520             0x11ad => { %exposureProgram2010 },
6521             0x11b4 => { Name => 'WB_RGBLevels', Format => 'int16u[3]' },
6522             0x1254 => {
6523             Condition => '$$self{Model} =~ /^(SLT-(A99|A99V)|NEX-(5R|5T|6|VG900|VG30E)|DSC-RX100|Stellar|HV)\b/',
6524             Name => 'SonyISO',
6525             Format => 'int16u',
6526             ValueConv => '100 * 2**(16 - $val/256)',
6527             ValueConvInv => '256 * (16 - log($val/100)/log(2))',
6528             PrintConv => 'sprintf("%.0f",$val)',
6529             PrintConvInv => '$val',
6530             },
6531             0x1258 => {
6532             Condition => '$$self{Model} =~ /^(DSC-(RX1|RX1R))\b/',
6533             Name => 'SonyISO',
6534             Format => 'int16u',
6535             ValueConv => '100 * 2**(16 - $val/256)',
6536             ValueConvInv => '256 * (16 - log($val/100)/log(2))',
6537             PrintConv => 'sprintf("%.0f",$val)',
6538             PrintConvInv => '$val',
6539             },
6540             0x1278 => {
6541             Condition => '$$self{Model} =~ /^(SLT-A58|ILCE-(3000|3500)|NEX-3N|DSC-(HX300|HX50V|WX60|WX80|WX200|WX300|TX30))\b/',
6542             Name => 'FocalLength',
6543             Format => 'int16u',
6544             ValueConv => '$val / 10',
6545             ValueConvInv => '$val * 10',
6546             PrintConv => 'sprintf("%.1f mm",$val)',
6547             PrintConvInv => '$val =~ s/ ?mm//; $val',
6548             },
6549             0x127a => {
6550             Condition => '$$self{Model} =~ /^(SLT-A58|ILCE-(3000|3500)|NEX-3N|DSC-(HX300|HX50V|WX60|WX80|WX200|WX300|TX30))\b/',
6551             Name => 'MinFocalLength',
6552             Format => 'int16u',
6553             ValueConv => '$val / 10',
6554             ValueConvInv => '$val * 10',
6555             PrintConv => 'sprintf("%.1f mm",$val)',
6556             PrintConvInv => '$val =~ s/ ?mm//; $val',
6557             },
6558             0x127c => { # may give 0 for fixed focal length lenses
6559             Condition => '$$self{Model} =~ /^(SLT-A58|ILCE-(3000|3500)|NEX-3N|DSC-(HX300|HX50V|WX60|WX80|WX200|WX300|TX30))\b/',
6560             Name => 'MaxFocalLength',
6561             Format => 'int16u',
6562             RawConv => '$val || undef',
6563             ValueConv => '$val / 10',
6564             ValueConvInv => '$val * 10',
6565             PrintConv => 'sprintf("%.1f mm",$val)',
6566             PrintConvInv => '$val =~ s/ ?mm//; $val',
6567             },
6568             0x1280 => {
6569             Condition => '$$self{Model} =~ /^(SLT-A58|ILCE-(3000|3500)|NEX-3N|DSC-(HX300|HX50V|WX60|WX80|WX200|WX300|TX30))\b/',
6570             Name => 'SonyISO',
6571             Format => 'int16u',
6572             ValueConv => '100 * 2**(16 - $val/256)',
6573             ValueConvInv => '256 * (16 - log($val/100)/log(2))',
6574             PrintConv => 'sprintf("%.0f",$val)',
6575             PrintConvInv => '$val',
6576             },
6577             0x1870 => {
6578             Name => 'DistortionCorrParams',
6579             Condition => '$$self{Model} !~ /^(DSC-|Stellar)/',
6580             Format => 'int16s[16]',
6581             },
6582             # 0x1890 - same as 0x1892, but has value 3 for SAL18135, SAL50F14Z, SAL55300, SAL70200G2, SAL70300G2, SAL70400G2
6583             # Presumably, these are the A-mount lenses "compatible with software updates" as referred to in the ILCA-99M2 manual.
6584             # Indeed, SAL70400G2 on ILCA-77M2 gives Version: "Lens: Ver.01"
6585             0x1891 => {
6586             Name => 'LensFormat',
6587             Condition => '$$self{Model} !~ /^(DSC-|Stellar)/',
6588             PrintConv => {
6589             0 => 'Unknown',
6590             1 => 'APS-C',
6591             2 => 'Full-frame',
6592             },
6593             },
6594             0x1892 => {
6595             Name => 'LensMount',
6596             DataMember => 'LensMount',
6597             RawConv => '$$self{LensMount} = $val; $$self{Model} =~ /^(DSC-|Stellar)/ ? undef : $val',
6598             PrintConv => {
6599             0 => 'Unknown',
6600             1 => 'A-mount',
6601             2 => 'E-mount',
6602             },
6603             },
6604             0x1893 => { #JR
6605             Name => 'LensType2',
6606             Condition => '$$self{LensMount} == 2',
6607             Format => 'int16u',
6608             SeparateTable => 'LensType2',
6609             PrintConv => \%sonyLensTypes2,
6610             PrintInt => 1,
6611             },
6612             0x1896 => {
6613             Name => 'LensType',
6614             Condition => '$$self{LensMount} == 1',
6615             Priority => 0, #PH (just to be safe)
6616             Format => 'int16u', #PH
6617             SeparateTable => 1,
6618             ValueConvInv => '($val & 0xff00) == 0x8000 ? 0 : int($val)',
6619             PrintConv => \%sonyLensTypes,
6620             PrintInt => 1,
6621             },
6622             0x1898 => {
6623             Name => 'DistortionCorrParamsPresent',
6624             Condition => '$$self{Model} !~ /^(DSC-|Stellar)/',
6625             PrintConv => { 0 => 'No', 1 => 'Yes'},
6626             },
6627             0x1899 => {
6628             Name => 'DistortionCorrParamsNumber',
6629             Condition => '$$self{Model} !~ /^DSC-/',
6630             PrintConv => { 11 => '11 (APS-C)', 16 => '16 (Full-frame)'},
6631             },
6632             #0x1914 => { Name => 'SonyImageWidth', Format => 'int16u' },
6633             #0x1918 => { Name => 'SonyImageHeight', Format => 'int16u' },
6634             #0x192e => { Name => 'SonyImageWidth', Format => 'int16u' },
6635             #0x1930 => { Name => 'SonyImageHeight', Format => 'int16u' },
6636             );
6637              
6638             %Image::ExifTool::Sony::Tag2010f = ( #JR
6639             PROCESS_PROC => \&ProcessEnciphered,
6640             WRITE_PROC => \&WriteEnciphered,
6641             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6642             FORMAT => 'int8u',
6643             NOTES => 'Valid for DSC-RX100M2, DSC-QX10/QX100.',
6644             WRITABLE => 1,
6645             FIRST_ENTRY => 0,
6646             PRIORITY => 0,
6647             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
6648             IS_SUBDIR => [ 0x01e0 ],
6649             0x0004 => { %releaseMode2, Format => 'int32u' }, # NOT at offset 0x08 !
6650             #0x002e => { Name => 'SonyImageWidth3', Format => 'int16u' },
6651             #0x0042 => { Name => 'SonyImageWidth3', Format => 'int16u' },
6652             0x0050 => { %dynamicRangeOptimizer2010 },
6653             0x01e0 => {
6654             Name => 'MeterInfo',
6655             Format => 'int32u[486]',
6656             Unknown => 1,
6657             SubDirectory => { TagTable => 'Image::ExifTool::Sony::MeterInfo' },
6658             },
6659             0x1014 => { %releaseMode2010 },
6660             0x1018 => { %releaseMode2 },
6661             0x1020 => { %selfTimer2010 },
6662             0x1024 => { %flashMode2010 },
6663             0x102a => { %gain2010 },
6664             0x102c => { %brightnessValue2010 },
6665             0x1030 => { %dynamicRangeOptimizer2010 },
6666             0x1034 => { %hdr2010 },
6667             0x1038 => { %exposureComp2010 },
6668             0x104e => { %pictureProfile2010 },
6669             0x104f => { %pictureProfile2010 },
6670             0x1053 => { %pictureEffect2010 },
6671             0x1060 => { %quality2010 },
6672             0x1064 => { %meteringMode2010 },
6673             0x1065 => { %exposureProgram2010 },
6674             0x106c => { Name => 'WB_RGBLevels', Format => 'int16u[3]' },
6675             #0x1096 => { Name => 'SonyImageWidth3', Format => 'int16u' },
6676             #0x10aa => { Name => 'SonyImageWidth3', Format => 'int16u' },
6677             0x1134 => {
6678             Name => 'FocalLength',
6679             Format => 'int16u',
6680             ValueConv => '$val / 10',
6681             ValueConvInv => '$val * 10',
6682             PrintConv => 'sprintf("%.1f mm",$val)',
6683             PrintConvInv => '$val =~ s/ ?mm//; $val',
6684             },
6685             0x1136 => {
6686             Name => 'MinFocalLength',
6687             Format => 'int16u',
6688             ValueConv => '$val / 10',
6689             ValueConvInv => '$val * 10',
6690             PrintConv => 'sprintf("%.1f mm",$val)',
6691             PrintConvInv => '$val =~ s/ ?mm//; $val',
6692             },
6693             0x1138 => {
6694             Name => 'MaxFocalLength',
6695             Format => 'int16u',
6696             ValueConv => '$val / 10',
6697             ValueConvInv => '$val * 10',
6698             PrintConv => 'sprintf("%.1f mm",$val)',
6699             PrintConvInv => '$val =~ s/ ?mm//; $val',
6700             },
6701             0x113c => {
6702             Name => 'SonyISO',
6703             Format => 'int16u',
6704             ValueConv => '100 * 2**(16 - $val/256)',
6705             ValueConvInv => '256 * (16 - log($val/100)/log(2))',
6706             PrintConv => 'sprintf("%.0f",$val)',
6707             PrintConvInv => '$val',
6708             },
6709             #0x1914 => { Name => 'SonyImageWidth', Format => 'int16u' },
6710             #0x1918 => { Name => 'SonyImageHeight', Format => 'int16u' },
6711             #0x192e => { Name => 'SonyImageWidth', Format => 'int16u' },
6712             #0x1930 => { Name => 'SonyImageHeight', Format => 'int16u' },
6713             );
6714              
6715             %Image::ExifTool::Sony::Tag2010g = ( #JR
6716             PROCESS_PROC => \&ProcessEnciphered,
6717             WRITE_PROC => \&WriteEnciphered,
6718             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6719             FORMAT => 'int8u',
6720             NOTES => q{
6721             Valid for DSC-HX60V/HX350/HX400V/QX30/RX10/RX100M3/WX220/WX350,
6722             ILCE-7/7R/7S/7M2/5000/5100/6000/QX1, ILCA-68/77M2.
6723             },
6724             WRITABLE => 1,
6725             FIRST_ENTRY => 0,
6726             PRIORITY => 0,
6727             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
6728             DATAMEMBER => [ 0x18be ],
6729             IS_SUBDIR => [ 0x0388 ],
6730             0x0004 => { %releaseMode2, Format => 'int32u' }, # NOT at offset 0x08 !
6731             0x0050 => { %dynamicRangeOptimizer2010 },
6732             0x020c => { %releaseMode2010 },
6733             0x0210 => { %releaseMode2 },
6734             0x0218 => { %selfTimer2010 },
6735             0x021c => { %flashMode2010 },
6736             0x0222 => { %gain2010 },
6737             0x0224 => { %brightnessValue2010 },
6738             0x0228 => { %dynamicRangeOptimizer2010 },
6739             0x022c => { %hdr2010 },
6740             0x0230 => { %exposureComp2010 },
6741             0x0246 => { %pictureProfile2010 },
6742             0x0247 => { %pictureProfile2010 },
6743             0x024b => { %pictureEffect2010 },
6744             0x0258 => { %quality2010 },
6745             0x025c => { %meteringMode2010 },
6746             0x025d => { %exposureProgram2010 },
6747             0x0264 => { Name => 'WB_RGBLevels', Format => 'int16u[3]' },
6748             0x032c => {
6749             Name => 'FocalLength',
6750             Format => 'int16u',
6751             ValueConv => '$val / 10',
6752             ValueConvInv => '$val * 10',
6753             PrintConv => 'sprintf("%.1f mm",$val)',
6754             PrintConvInv => '$val =~ s/ ?mm//; $val',
6755             },
6756             0x032e => {
6757             Name => 'MinFocalLength',
6758             Format => 'int16u',
6759             ValueConv => '$val / 10',
6760             ValueConvInv => '$val * 10',
6761             PrintConv => 'sprintf("%.1f mm",$val)',
6762             PrintConvInv => '$val =~ s/ ?mm//; $val',
6763             },
6764             0x0330 => { # may give 0 for fixed focal length lenses
6765             Name => 'MaxFocalLength',
6766             Format => 'int16u',
6767             RawConv => '$val || undef',
6768             ValueConv => '$val / 10',
6769             ValueConvInv => '$val * 10',
6770             PrintConv => 'sprintf("%.1f mm",$val)',
6771             PrintConvInv => '$val =~ s/ ?mm//; $val',
6772             },
6773             0x0344 => {
6774             Name => 'SonyISO',
6775             Format => 'int16u',
6776             ValueConv => '100 * 2**(16 - $val/256)',
6777             ValueConvInv => '256 * (16 - log($val/100)/log(2))',
6778             PrintConv => 'sprintf("%.0f",$val)',
6779             PrintConvInv => '$val',
6780             },
6781             0x0388 => {
6782             Name => 'MeterInfo',
6783             Format => 'int32u[486]',
6784             Unknown => 1,
6785             SubDirectory => { TagTable => 'Image::ExifTool::Sony::MeterInfo' },
6786             },
6787             0x189c => {
6788             Name => 'DistortionCorrParams',
6789             Condition => '$$self{Model} !~ /^DSC-/',
6790             Format => 'int16s[16]',
6791             },
6792             # 0x18bc - same as 0x18be, but has value 3 for SAL18135, SAL50F14Z, SAL55300, SAL70200G2, SAL70300G2, SAL70400G2
6793             0x18bd => {
6794             Name => 'LensFormat',
6795             Condition => '$$self{Model} !~ /^DSC-/',
6796             PrintConv => {
6797             0 => 'Unknown',
6798             1 => 'APS-C',
6799             2 => 'Full-frame',
6800             },
6801             },
6802             0x18be => {
6803             Name => 'LensMount',
6804             DataMember => 'LensMount',
6805             RawConv => '$$self{LensMount} = $val; $$self{Model} =~ /^DSC-/ ? undef : $val',
6806             PrintConv => {
6807             0 => 'Unknown',
6808             1 => 'A-mount',
6809             2 => 'E-mount',
6810             },
6811             },
6812             0x18bf => { #JR
6813             Name => 'LensType2',
6814             Condition => '$$self{LensMount} == 2',
6815             Format => 'int16u',
6816             SeparateTable => 'LensType2',
6817             PrintConv => \%sonyLensTypes2,
6818             PrintInt => 1,
6819             },
6820             0x18c2 => {
6821             Name => 'LensType',
6822             Condition => '$$self{LensMount} == 1',
6823             Priority => 0, #PH (just to be safe)
6824             Format => 'int16u', #PH
6825             SeparateTable => 1,
6826             ValueConvInv => '($val & 0xff00) == 0x8000 ? 0 : int($val)',
6827             PrintConv => \%sonyLensTypes,
6828             PrintInt => 1,
6829             },
6830             0x18c4 => {
6831             Name => 'DistortionCorrParamsPresent',
6832             Condition => '$$self{Model} !~ /^DSC-/',
6833             PrintConv => { 0 => 'No', 1 => 'Yes'},
6834             },
6835             0x18c5 => {
6836             Name => 'DistortionCorrParamsNumber',
6837             Condition => '$$self{Model} !~ /^DSC-/',
6838             PrintConv => { 11 => '11 (APS-C)', 16 => '16 (Full-frame)'},
6839             },
6840             # 0x1940 => { Name => 'SonyImageWidth', Format => 'int16u' },
6841             # 0x1944 => { Name => 'SonyImageHeight', Format => 'int16u' },
6842             # 0x195a => { Name => 'SonyImageWidth', Format => 'int16u' },
6843             # 0x195c => { Name => 'SonyImageHeight', Format => 'int16u' },
6844             );
6845              
6846             %Image::ExifTool::Sony::Tag2010h = ( #JR
6847             PROCESS_PROC => \&ProcessEnciphered,
6848             WRITE_PROC => \&WriteEnciphered,
6849             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6850             FORMAT => 'int8u',
6851             NOTES => q{
6852             Valid for DSC-HX80/HX90V/RX0/RX1RM2/RX10M2/RX10M3/RX100M4/RX100M5/WX500,
6853             ILCE-6300/6500/7RM2/7SM2, ILCA-99M2.
6854             },
6855             WRITABLE => 1,
6856             FIRST_ENTRY => 0,
6857             PRIORITY => 0,
6858             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
6859             DATAMEMBER => [ 0x18ee ],
6860             IS_SUBDIR => [ 0x0388, 0x0398 ],
6861             0x0004 => { %releaseMode2, Format => 'int32u' },
6862             0x0050 => { %dynamicRangeOptimizer2010 },
6863             0x020c => { %releaseMode2010 },
6864             0x0210 => { %releaseMode2 },
6865             0x0218 => { %selfTimerB2010 },
6866             0x021c => { %flashMode2010 },
6867             0x0222 => { %gain2010 },
6868             0x0224 => { %brightnessValue2010 },
6869             0x0228 => { %dynamicRangeOptimizer2010 },
6870             0x022c => { %hdr2010 },
6871             0x0230 => { %exposureComp2010 },
6872             0x0246 => { %pictureProfile2010 },
6873             0x0247 => { %pictureProfile2010 },
6874             0x024b => { %pictureEffect2010 },
6875             0x0258 => { %quality2010 },
6876             0x025c => { %meteringMode2010 },
6877             0x025d => { %exposureProgram2010 },
6878             0x0264 => { Name => 'WB_RGBLevels', Format => 'int16u[3]' },
6879             0x032c => {
6880             Name => 'FocalLength',
6881             Format => 'int16u',
6882             ValueConv => '$val / 10',
6883             ValueConvInv => '$val * 10',
6884             PrintConv => 'sprintf("%.1f mm",$val)',
6885             PrintConvInv => '$val =~ s/ ?mm//; $val',
6886             },
6887             0x032e => {
6888             Name => 'MinFocalLength',
6889             Format => 'int16u',
6890             ValueConv => '$val / 10',
6891             ValueConvInv => '$val * 10',
6892             PrintConv => 'sprintf("%.1f mm",$val)',
6893             PrintConvInv => '$val =~ s/ ?mm//; $val',
6894             },
6895             0x0330 => { # may give 0 for fixed focal length lenses
6896             Name => 'MaxFocalLength',
6897             Format => 'int16u',
6898             RawConv => '$val || undef',
6899             ValueConv => '$val / 10',
6900             ValueConvInv => '$val * 10',
6901             PrintConv => 'sprintf("%.1f mm",$val)',
6902             PrintConvInv => '$val =~ s/ ?mm//; $val',
6903             },
6904             0x0346 => {
6905             Name => 'SonyISO',
6906             Format => 'int16u',
6907             ValueConv => '100 * 2**(16 - $val/256)',
6908             ValueConvInv => '256 * (16 - log($val/100)/log(2))',
6909             PrintConv => 'sprintf("%.0f",$val)',
6910             PrintConvInv => '$val',
6911             },
6912             0x0388 => {
6913             Name => 'MeterInfo',
6914             Format => 'int32u[486]',
6915             Condition => '$$self{Model} !~ /^(ILCA-99M2|ILCE-6500|DSC-(RX0|RX100M5))/',
6916             Unknown => 1,
6917             SubDirectory => { TagTable => 'Image::ExifTool::Sony::MeterInfo' },
6918             },
6919             0x0398 => {
6920             Name => 'MeterInfo',
6921             Format => 'int32u[486]',
6922             Condition => '$$self{Model} =~ /^(ILCA-99M2|ILCE-6500|DSC-(RX0|RX100M5))/',
6923             Unknown => 1,
6924             SubDirectory => { TagTable => 'Image::ExifTool::Sony::MeterInfo' },
6925             },
6926             0x18cc => {
6927             Name => 'DistortionCorrParams',
6928             Condition => '$$self{Model} !~ /^DSC-/',
6929             Format => 'int16s[16]',
6930             },
6931             # 0x18ec - same as 0x18ee, but has value 3 for SAL18135, SAL50F14Z, SAL55300, SAL70200G2, SAL70300G2, SAL70400G2
6932             0x18ed => {
6933             Name => 'LensFormat',
6934             Condition => '$$self{Model} !~ /^DSC-/',
6935             PrintConv => {
6936             0 => 'Unknown',
6937             1 => 'APS-C',
6938             2 => 'Full-frame',
6939             },
6940             },
6941             0x18ee => {
6942             Name => 'LensMount',
6943             DataMember => 'LensMount',
6944             RawConv => '$$self{LensMount} = $val; $$self{Model} =~ /^DSC-/ ? undef : $val',
6945             PrintConv => {
6946             0 => 'Unknown',
6947             1 => 'A-mount',
6948             2 => 'E-mount',
6949             },
6950             },
6951             0x18ef => { #JR
6952             Name => 'LensType2',
6953             Condition => '$$self{LensMount} == 2',
6954             Format => 'int16u',
6955             SeparateTable => 'LensType2',
6956             PrintConv => \%sonyLensTypes2,
6957             PrintInt => 1,
6958             },
6959             0x18f2 => {
6960             Name => 'LensType',
6961             Condition => '$$self{LensMount} == 1',
6962             Priority => 0, #PH (just to be safe)
6963             Format => 'int16u', #PH
6964             SeparateTable => 1,
6965             ValueConvInv => '($val & 0xff00) == 0x8000 ? 0 : int($val)',
6966             PrintConv => \%sonyLensTypes,
6967             PrintInt => 1,
6968             },
6969             0x18f4 => {
6970             Name => 'DistortionCorrParamsPresent',
6971             Condition => '$$self{Model} !~ /^DSC-/',
6972             PrintConv => { 0 => 'No', 1 => 'Yes'},
6973             },
6974             0x18f5 => {
6975             Name => 'DistortionCorrParamsNumber',
6976             Condition => '$$self{Model} !~ /^DSC-/',
6977             PrintConv => { 11 => '11 (APS-C)', 16 => '16 (Full-frame)'},
6978             },
6979             # 0x1970 => { Name => 'SonyImageWidth', Format => 'int16u' },
6980             # 0x1974 => { Name => 'SonyImageHeight', Format => 'int16u' },
6981             # 0x198a => { Name => 'SonyImageWidth', Format => 'int16u' },
6982             # 0x198c => { Name => 'SonyImageHeight', Format => 'int16u' },
6983             );
6984              
6985             %Image::ExifTool::Sony::Tag2010i = ( #JR
6986             PROCESS_PROC => \&ProcessEnciphered,
6987             WRITE_PROC => \&WriteEnciphered,
6988             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6989             FORMAT => 'int8u',
6990             NOTES => q{
6991             Valid for ILCE-6100/6400/6600/7C/7M3/7RM3/7RM4/9/9M2, DSC-RX0M2/RX10M4/RX100M6/
6992             RX100M5A/RX100M7/HX99.
6993             },
6994             WRITABLE => 1,
6995             FIRST_ENTRY => 0,
6996             PRIORITY => 0,
6997             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
6998             DATAMEMBER => [ 0x17f2 ],
6999             IS_SUBDIR => [ 0x036d ],
7000             0x0004 => { %releaseMode2, Format => 'int32u' },
7001             0x004e => { %dynamicRangeOptimizer2010 },
7002             0x0204 => { %releaseMode2010 },
7003             0x0208 => { %releaseMode2 },
7004             0x0210 => { %selfTimerB2010 },
7005             0x0211 => { %flashMode2010 },
7006             0x0217 => { %gain2010 },
7007             0x0219 => { %brightnessValue2010 },
7008             0x021b => { %dynamicRangeOptimizer2010 },
7009             0x021f => { %hdr2010 },
7010             0x0223 => { %exposureComp2010 },
7011             0x0237 => { %pictureProfile2010 },
7012             0x0238 => { %pictureProfile2010 },
7013             0x023c => { %pictureEffect2010 },
7014             0x0247 => { %quality2010 },
7015             0x024b => { %meteringMode2010 },
7016             0x024c => { %exposureProgram2010 },
7017             0x0252 => { Name => 'WB_RGBLevels', Format => 'int16u[3]' },
7018             0x030a => {
7019             Name => 'FocalLength',
7020             Format => 'int16u',
7021             ValueConv => '$val / 10',
7022             ValueConvInv => '$val * 10',
7023             PrintConv => 'sprintf("%.1f mm",$val)',
7024             PrintConvInv => '$val =~ s/ ?mm//; $val',
7025             },
7026             0x030c => {
7027             Name => 'MinFocalLength',
7028             Format => 'int16u',
7029             ValueConv => '$val / 10',
7030             ValueConvInv => '$val * 10',
7031             PrintConv => 'sprintf("%.1f mm",$val)',
7032             PrintConvInv => '$val =~ s/ ?mm//; $val',
7033             },
7034             0x030e => { # may give 0 for fixed focal length lenses
7035             Name => 'MaxFocalLength',
7036             Format => 'int16u',
7037             RawConv => '$val || undef',
7038             ValueConv => '$val / 10',
7039             ValueConvInv => '$val * 10',
7040             PrintConv => 'sprintf("%.1f mm",$val)',
7041             PrintConvInv => '$val =~ s/ ?mm//; $val',
7042             },
7043             0x0320 => {
7044             Name => 'SonyISO',
7045             Format => 'int16u',
7046             ValueConv => '100 * 2**(16 - $val/256)',
7047             ValueConvInv => '256 * (16 - log($val/100)/log(2))',
7048             PrintConv => 'sprintf("%.0f",$val)',
7049             PrintConvInv => '$val',
7050             },
7051             0x036d => { # different format from all previous cameras: now each triple is int16u-int32u-int32u
7052             Name => 'MeterInfo',
7053             Format => 'undef[1620]',
7054             Unknown => 1,
7055             SubDirectory => { TagTable => 'Image::ExifTool::Sony::MeterInfo9' },
7056             },
7057             0x17d0 => {
7058             Name => 'DistortionCorrParams',
7059             Condition => '$$self{Model} !~ /^DSC-/',
7060             Format => 'int16s[16]',
7061             },
7062             # 0x17f0 - same as 0x17f2, but has value 3 for SAL18135, SAL50F14Z, SAL55300, SAL70200G2, SAL70300G2, SAL70400G2
7063             0x17f1 => {
7064             Name => 'LensFormat',
7065             Condition => '$$self{Model} !~ /^DSC-/',
7066             PrintConv => {
7067             0 => 'Unknown',
7068             1 => 'APS-C',
7069             2 => 'Full-frame',
7070             },
7071             },
7072             0x17f2 => {
7073             Name => 'LensMount',
7074             DataMember => 'LensMount',
7075             RawConv => '$$self{LensMount} = $val; $$self{Model} =~ /^DSC-/ ? undef : $val',
7076             PrintConv => {
7077             0 => 'Unknown',
7078             1 => 'A-mount',
7079             2 => 'E-mount',
7080             },
7081             },
7082             0x17f3 => { #JR
7083             Name => 'LensType2',
7084             Condition => '$$self{LensMount} == 2',
7085             Format => 'int16u',
7086             SeparateTable => 'LensType2',
7087             PrintConv => \%sonyLensTypes2,
7088             PrintInt => 1,
7089             },
7090             0x17f6 => {
7091             Name => 'LensType',
7092             Condition => '$$self{LensMount} == 1',
7093             Priority => 0, #PH (just to be safe)
7094             Format => 'int16u', #PH
7095             SeparateTable => 1,
7096             ValueConvInv => '($val & 0xff00) == 0x8000 ? 0 : int($val)',
7097             PrintConv => \%sonyLensTypes,
7098             PrintInt => 1,
7099             },
7100             0x17f8 => {
7101             Name => 'DistortionCorrParamsPresent',
7102             Condition => '$$self{Model} !~ /^DSC-/',
7103             PrintConv => { 0 => 'No', 1 => 'Yes'},
7104             },
7105             0x17f9 => {
7106             Name => 'DistortionCorrParamsNumber',
7107             Condition => '$$self{Model} !~ /^DSC-/',
7108             PrintConv => { 11 => '11 (APS-C)', 16 => '16 (Full-frame)'},
7109             },
7110             );
7111              
7112             %Image::ExifTool::Sony::Tag202a = (
7113             %binaryDataAttrs,
7114             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7115             FORMAT => 'int8u',
7116             DATAMEMBER => [ 0x01 ],
7117             #
7118             # first seen for ILCE-6300
7119             # Possibly the Locations of the FocalPlaneAFPointsUsed are indicated here.
7120             # 66 bytes, structure appears to be as follows:
7121             # 0x00 - 1 for ILCE-6300/6500, ILCA-99M2
7122             # 0x01 - int8u: 0 to 15 - nr of locations to follow
7123             # 0x02 and 0x03 - (128 2) or 640 - (max.) width (X) of (LCD screen) area of following locations
7124             # 0x04 and 0x05 - (172 1) or 428 - (max.) height (Y) of (LCD screen) area of following locations
7125             # origin of X-Y coordinates appears to be top-left, i.e. X to the right, Y pointing down.
7126             # 0x06 0x07 0x08 0x09 - 2x int16u : X and Y coordinates of Location 1
7127             # etc.
7128             #
7129             0x01 => {
7130             Name => 'FocalPlaneAFPointsUsed',
7131             DataMember => 'Locations',
7132             Format => 'int8u',
7133             RawConv => '$$self{Locations} = $val',
7134             },
7135             0x02 => {
7136             Name => 'FocalPlaneAFPointArea',
7137             Condition => '$$self{Locations} >= 1', # only output this if at least 1 Location follows ?
7138             Format => 'int16u[2]',
7139             },
7140             0x06 => { Name => 'FocalPlaneAFPointLocation1', Condition => '$$self{Locations} >= 1', Format => 'int16u[2]' },
7141             0x0a => { Name => 'FocalPlaneAFPointLocation2', Condition => '$$self{Locations} >= 2', Format => 'int16u[2]' },
7142             0x0e => { Name => 'FocalPlaneAFPointLocation3', Condition => '$$self{Locations} >= 3', Format => 'int16u[2]' },
7143             0x12 => { Name => 'FocalPlaneAFPointLocation4', Condition => '$$self{Locations} >= 4', Format => 'int16u[2]' },
7144             0x16 => { Name => 'FocalPlaneAFPointLocation5', Condition => '$$self{Locations} >= 5', Format => 'int16u[2]' },
7145             0x1a => { Name => 'FocalPlaneAFPointLocation6', Condition => '$$self{Locations} >= 6', Format => 'int16u[2]' },
7146             0x1e => { Name => 'FocalPlaneAFPointLocation7', Condition => '$$self{Locations} >= 7', Format => 'int16u[2]' },
7147             0x22 => { Name => 'FocalPlaneAFPointLocation8', Condition => '$$self{Locations} >= 8', Format => 'int16u[2]' },
7148             0x26 => { Name => 'FocalPlaneAFPointLocation9', Condition => '$$self{Locations} >= 9', Format => 'int16u[2]' },
7149             0x2a => { Name => 'FocalPlaneAFPointLocation10', Condition => '$$self{Locations} >= 10', Format => 'int16u[2]' },
7150             0x2e => { Name => 'FocalPlaneAFPointLocation11', Condition => '$$self{Locations} >= 11', Format => 'int16u[2]' },
7151             0x32 => { Name => 'FocalPlaneAFPointLocation12', Condition => '$$self{Locations} >= 12', Format => 'int16u[2]' },
7152             0x36 => { Name => 'FocalPlaneAFPointLocation13', Condition => '$$self{Locations} >= 13', Format => 'int16u[2]' },
7153             0x3a => { Name => 'FocalPlaneAFPointLocation14', Condition => '$$self{Locations} >= 14', Format => 'int16u[2]' },
7154             0x3e => { Name => 'FocalPlaneAFPointLocation15', Condition => '$$self{Locations} >= 15', Format => 'int16u[2]' },
7155             );
7156              
7157             # possible metering information (ref JR)
7158             %Image::ExifTool::Sony::MeterInfo = (
7159             %binaryDataAttrs,
7160             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
7161             NOTES => q{
7162             Information possibly related to metering. Extracted only if the Unknown
7163             option is used.
7164             },
7165             #
7166             # 162 'triplets' of 3 int32u numbers: (k,n1,n2)
7167             # These appear to relate to two sets of brightness distribution over the image area:
7168             # Set 1: 7 rows of 9
7169             # Set 2: 9 rows of 11
7170             #
7171             # Exact meaning presently unknown, however:
7172             # n1 ranges from 0 (black) - appr. 1300 (bright white)
7173             # n2 ranges from 0 (black) - appr. 142000 (bright white), i.e. roughly factor 100 higher
7174             # Many panorama images: all 0
7175             # Flash images: n2 = n1
7176             # k maybe some kind of 'gain' or multiplication factor ?
7177             # k distribution over the image as function of Aspect-Ratio is as follows:
7178             #
7179             # 3:2 image 16:9 image 4:3 image
7180             # set 1:
7181             #
7182             # 12 12 12 12 12 12 12 12 12 12 12 12 15 18 15 12 12 12 9 12 12 12 12 12 12 12 9
7183             # 12 12 12 12 12 12 12 12 12 12 12 12 15 18 15 12 12 12 9 12 12 12 12 12 12 12 9
7184             # 16 16 16 16 16 16 16 16 16 12 12 12 15 18 15 12 12 12 12 16 16 16 16 16 16 16 12
7185             # 16 16 16 16 16 16 16 16 16 12 12 12 15 18 15 12 12 12 12 16 16 16 16 16 16 16 12
7186             # 16 16 16 16 16 16 16 16 16 12 12 12 15 18 15 12 12 12 12 16 16 16 16 16 16 16 12
7187             # 12 12 12 12 12 12 12 12 12 12 12 12 15 18 15 12 12 12 9 12 12 12 12 12 12 12 9
7188             # 12 12 12 12 12 12 12 12 12 12 12 12 15 18 15 12 12 12 9 12 12 12 12 12 12 12 9
7189             #
7190             # set 2:
7191             #
7192             # 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 15 18 15 12 12 12 12 9 9 12 12 12 12 12 12 12 9 9
7193             # 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 15 18 15 12 12 12 12 9 9 12 12 12 12 12 12 12 9 9
7194             # 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 15 18 15 12 12 12 12 9 9 12 12 12 12 12 12 12 9 9
7195             # 16 16 16 16 16 16 16 16 16 16 16 12 12 12 12 15 18 15 12 12 12 12 12 12 16 16 16 16 16 16 16 12 12
7196             # 16 16 16 16 16 16 16 16 16 16 16 12 12 12 12 15 18 15 12 12 12 12 12 12 16 16 16 16 16 16 16 12 12
7197             # 16 16 16 16 16 16 16 16 16 16 16 12 12 12 12 15 18 15 12 12 12 12 12 12 16 16 16 16 16 16 16 12 12
7198             # 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 15 18 15 12 12 12 12 9 9 12 12 12 12 12 12 12 9 9
7199             # 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 15 18 15 12 12 12 12 9 9 12 12 12 12 12 12 12 9 9
7200             # 12 12 12 12 12 12 12 12 12 12 12 8 8 8 8 10 12 10 8 8 8 8 9 9 12 12 12 12 12 12 12 9 9
7201             #
7202             # Usually, in the center, the numbers of set 1 row 2-6 match with set 2 row 3-7, except for first and last 2 columns.
7203             #
7204             0x0000 => { Name => 'MeterInfo1Row1', %meterInfo1 },
7205             0x006c => { Name => 'MeterInfo1Row2', %meterInfo1 },
7206             0x00d8 => { Name => 'MeterInfo1Row3', %meterInfo1 },
7207             0x0144 => { Name => 'MeterInfo1Row4', %meterInfo1 },
7208             0x01b0 => { Name => 'MeterInfo1Row5', %meterInfo1 },
7209             0x021c => { Name => 'MeterInfo1Row6', %meterInfo1 },
7210             0x0288 => { Name => 'MeterInfo1Row7', %meterInfo1 },
7211              
7212             0x02f4 => { Name => 'MeterInfo2Row1', %meterInfo2 },
7213             0x0378 => { Name => 'MeterInfo2Row2', %meterInfo2 },
7214             0x03fc => { Name => 'MeterInfo2Row3', %meterInfo2 },
7215             0x0480 => { Name => 'MeterInfo2Row4', %meterInfo2 },
7216             0x0504 => { Name => 'MeterInfo2Row5', %meterInfo2 },
7217             0x0588 => { Name => 'MeterInfo2Row6', %meterInfo2 },
7218             0x060c => { Name => 'MeterInfo2Row7', %meterInfo2 },
7219             0x0690 => { Name => 'MeterInfo2Row8', %meterInfo2 },
7220             0x0714 => { Name => 'MeterInfo2Row9', %meterInfo2 },
7221             );
7222              
7223             # possible metering information (ref JR)
7224             %Image::ExifTool::Sony::MeterInfo9 = (
7225             %binaryDataAttrs,
7226             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
7227             NOTES => q{
7228             Information possibly related to metering. Extracted only if the Unknown
7229             option is used.
7230             },
7231             # new format for ILCE-9:
7232             # 162 'triplets' of (int16u int32u int32u) numbers: (k,n1,n2)
7233             # Set 1: 7 rows of 9
7234             # Set 2: 9 rows of 11
7235             0x0000 => { Name => 'MeterInfo1Row1', %meterInfo1b },
7236             0x005a => { Name => 'MeterInfo1Row2', %meterInfo1b },
7237             0x00b4 => { Name => 'MeterInfo1Row3', %meterInfo1b },
7238             0x010e => { Name => 'MeterInfo1Row4', %meterInfo1b },
7239             0x0168 => { Name => 'MeterInfo1Row5', %meterInfo1b },
7240             0x01c2 => { Name => 'MeterInfo1Row6', %meterInfo1b },
7241             0x021c => { Name => 'MeterInfo1Row7', %meterInfo1b },
7242              
7243             0x0276 => { Name => 'MeterInfo2Row1', %meterInfo2b },
7244             0x02e4 => { Name => 'MeterInfo2Row2', %meterInfo2b },
7245             0x0352 => { Name => 'MeterInfo2Row3', %meterInfo2b },
7246             0x03c0 => { Name => 'MeterInfo2Row4', %meterInfo2b },
7247             0x042e => { Name => 'MeterInfo2Row5', %meterInfo2b },
7248             0x049c => { Name => 'MeterInfo2Row6', %meterInfo2b },
7249             0x050a => { Name => 'MeterInfo2Row7', %meterInfo2b },
7250             0x0578 => { Name => 'MeterInfo2Row8', %meterInfo2b },
7251             0x05e6 => { Name => 'MeterInfo2Row9', %meterInfo2b },
7252             );
7253              
7254             %Image::ExifTool::Sony::Tag900b = ( #JR
7255             PROCESS_PROC => \&ProcessEnciphered,
7256             WRITE_PROC => \&WriteEnciphered,
7257             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7258             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7259             # 0x0000 - always 174 (e)
7260             0x0002 => {
7261             Name => 'FacesDetected',
7262             PrintConv => {
7263             0 => '0',
7264             98 => '1',
7265             57 => '2',
7266             93 => '3',
7267             77 => '4',
7268             33 => '5',
7269             168 => '6',
7270             241 => '7',
7271             115 => '8',
7272             },
7273             },
7274             # 0x00bc - always 98 (221 (e))
7275             0x00bd => {
7276             Condition => '$$self{Model} !~ /^DSLR-(A450|A500|A550)$/', # always 98 for A450/A500/A550: exclude
7277             Name => 'FaceDetection',
7278             PrintConv => {
7279             0 => 'Off',
7280             98 => 'On',
7281             },
7282             },
7283             );
7284              
7285             %Image::ExifTool::Sony::Tag9050a = ( #JR
7286             PROCESS_PROC => \&ProcessEnciphered,
7287             WRITE_PROC => \&WriteEnciphered,
7288             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7289             FORMAT => 'int8u',
7290             NOTES => q{
7291             Valid for SLT, ILCA, NEX and ILCE models, except ILCE-6300/6500/7RM2/7SM2,
7292             ILCA-99M2.
7293             },
7294             WRITABLE => 1,
7295             FIRST_ENTRY => 0,
7296             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
7297             DATAMEMBER => [ 0x0031, 0x0105 ],
7298             NOTES => q{
7299             Data for tags 0x9050, 0x94xx and 0x2010 is encrypted by a simple
7300             substitution cipher, but the deciphered values are listed below.
7301             },
7302             0x0000 => {
7303             Condition => '$$self{Model} !~ /^(NEX-|Lunar|ILCE-)/',
7304             Name => 'SonyMaxAperture', # (at current focal length)
7305             # seen values from 17 - 48
7306             ValueConv => '2 ** (($val/8 - 1.06) / 2)',
7307             ValueConvInv => 'int((log($val) * 2 / log(2) + 1) * 8 + 0.5)',
7308             PrintConv => 'sprintf("%.1f",$val)',
7309             PrintConvInv => '$val',
7310             },
7311             0x0001 => {
7312             Condition => '$$self{Model} !~ /^(NEX-|Lunar|ILCE-)/',
7313             Name => 'SonyMinAperture', # (at current focal length)
7314             # seen values from 80 - 95
7315             ValueConv => '2 ** (($val/8 - 1.06) / 2)',
7316             ValueConvInv => 'int((log($val) * 2 / log(2) + 1) * 8 + 0.5)',
7317             PrintConv => 'sprintf("%.0f",$val)',
7318             PrintConvInv => '$val',
7319             },
7320             # 0x0002 and 0x0004 (int16u) for SLT:
7321             # appears to be difference between used FNumber and MaxAperture, 256 being +1 APEX or stop
7322             # however, not always valid e.g. bracketing, Shutter-prio e.a.
7323             # difference between 0x0002 and 0x0004 mostly 0.0, 0.1 or 0.2 stops.
7324             0x0020 => {
7325             Name => 'Shutter',
7326             Format => 'int16u[3]',
7327             PrintConv => {
7328             '0 0 0' => 'Silent / Electronic (0 0 0)',
7329             OTHER => sub {
7330             my ($val, $inv) = @_;
7331             return $inv ? ($val=~/\((.*?)\)/ ? $1 : undef) : "Mechanical ($val)";
7332             },
7333             },
7334             },
7335             0x0031 => { #JR
7336             Name => 'FlashStatus',
7337             RawConv => '$$self{FlashFired} = $val',
7338             PrintConv => {
7339             0 => 'No Flash present',
7340             2 => 'Flash Inhibited', # seen for ILCE-7/7R continuous, panorama, HDR mode
7341             64 => 'Built-in Flash present',
7342             65 => 'Built-in Flash Fired',
7343             66 => 'Built-in Flash Inhibited', # seen for panorama, HDR, burst mode
7344             128 => 'External Flash present', # seen for NEX-5N/5T
7345             129 => 'External Flash Fired', # seen for SLT-A99V, ILCE-7R, NEX-5N/5R
7346             },
7347             },
7348             0x0032 => { #13
7349             Name => 'ShutterCount',
7350             # this seems to be valid for the A7R,A37,A57,A65,A77,A99,A99V and possibly the
7351             # NEX-5N/7. For the A99V it is definitely more than 16 bits, but it wraps at
7352             # 65536 for the A7R.
7353             Format => 'int32u',
7354             Notes => q{
7355             total number of image exposures made by the camera, modulo 65536 for some
7356             models
7357             },
7358             RawConv => '$val & 0x00ffffff',
7359             },
7360             0x003a => { # appr. same value as Exif ExposureTime, but longer in HDR-modes
7361             Name => 'SonyExposureTime',
7362             Format => 'int16u',
7363             ValueConv => '$val ? 2 ** (16 - $val/256) : 0',
7364             ValueConvInv => '$val ? int((16 - log($val) / log(2)) * 256 + 0.5) : 0',
7365             PrintConv => '$val ? Image::ExifTool::Exif::PrintExposureTime($val) : "Bulb"',
7366             PrintConvInv => 'lc($val) eq "bulb" ? 0 : Image::ExifTool::Exif::ConvertFraction($val)',
7367             },
7368             0x003c => {
7369             Name => 'SonyFNumber',
7370             Format => 'int16u',
7371             ValueConv => '2 ** (($val/256 - 16) / 2)',
7372             ValueConvInv => '(log($val)*2/log(2)+16)*256',
7373             PrintConv => 'sprintf("%.1f",$val)',
7374             PrintConvInv => '$val',
7375             },
7376             0x003f => {
7377             Name => 'ReleaseMode2',
7378             %releaseMode2,
7379             },
7380             # 0x004c - 0x005b: A-Mount: 16 values, only non-zero data for lenses giving "A-mount (3)" in 0x0104 below.
7381             # e.g for SAL70400G2: 9 5 5 64 69 74 79 84 89 94 98 104 255 105 89 80
7382             # where 9 means 9 focal lengths: 64 ... 104,
7383             # corresponding to 70-400mm via FocalLength = 4.375*2**($val/16)
7384             # 0x004c, 0x0051: E-Mount: ShutterCount and dateTime
7385             0x004c => { # only ILCE-7/7R/7S/7M2/5000/5100/6000/QX1 - but appears not valid when flash is used ...
7386             Name => 'ShutterCount2',
7387             Condition => '($$self{Model} =~ /^(ILCE-(7(R|S|M2)?|[56]000|5100|QX1))\b/) and (($$self{FlashFired} & 0x01) != 1)',
7388             Format => 'int32u',
7389             RawConv => '$val & 0x00ffffff',
7390             },
7391             0x0051 => { # only ILCE-7/7R/7S/7M2/5000/5100/6000/QX1, but hours usually different from SonyDateTime - UTC?
7392             # appears not valid (all '0') when flash is used, panorama, hdr modes ...
7393             Name => 'SonyDateTime2',
7394             Condition => '$$self{Model} =~ /^(ILCE-(7(R|S|M2)?|[56]000|5100|QX1))\b/',
7395             Groups => { 2 => 'Time' },
7396             Shift => 'Time',
7397             Format => 'undef[6]',
7398             ValueConv => q{
7399             my @v = unpack('C*', $val);
7400             return undef unless $v[0] > 0;
7401             return sprintf("20%.2d:%.2d:%.2d %.2d:%.2d:%.2d", @v)
7402             },
7403             ValueConvInv => q{
7404             my @v = ($val =~ /\d+/g);
7405             return undef unless @v == 6 and ($v[0]-=2000) >= 0;
7406             return pack('C*', @v);
7407             },
7408             PrintConv => '$self->ConvertDateTime($val)',
7409             PrintConvInv => '$self->InverseDateTime($val,0)',
7410             },
7411             0x0067 => {
7412             Name => 'ReleaseMode2',
7413             Condition => '$$self{Model} !~ /^(SLT-A(65|77)V?|Lunar|NEX-(5N|7|VG20E))/',
7414             %releaseMode2,
7415             },
7416             0x007c => { #JR valid for ILCE and most NEX
7417             Name => 'InternalSerialNumber', #(NC)
7418             Condition => '$$self{Model} !~ /^(Lunar|NEX-(5N|7|VG20E)|SLT-|HV|ILCA-)/',
7419             Format => 'int8u[4]',
7420             PrintConv => 'unpack "H*", pack "C*", split " ", $val',
7421             },
7422             0x00f0 => { #JR valid for SLT/ILCA models
7423             Name => 'InternalSerialNumber', #(NC)
7424             Condition => '$$self{Model} =~ /^(SLT-|HV|ILCA-)/',
7425             Format => 'int8u[5]',
7426             PrintConv => 'unpack "H*", pack "C*", split " ", $val',
7427             PrintConvInv => 'join " ", unpack "C*", pack "H*", $val',
7428             },
7429             # 0x0104 - same as 0x0105, but has value 3 for SAL18135, SAL50F14Z, SAL55300, SAL70200G2, SAL70300G2, SAL70400G2
7430             0x0105 => {
7431             Name => 'LensMount',
7432             DataMember => 'LensMount',
7433             RawConv => '$$self{LensMount} = $val',
7434             PrintConv => {
7435             0 => 'Unknown',
7436             1 => 'A-mount',
7437             2 => 'E-mount',
7438             },
7439             },
7440             0x0106 => {
7441             Name => 'LensFormat',
7442             PrintConv => {
7443             0 => 'Unknown',
7444             1 => 'APS-C',
7445             2 => 'Full-frame',
7446             },
7447             },
7448             0x0107 => {
7449             Name => 'LensType2',
7450             Condition => '$$self{LensMount} == 2',
7451             Format => 'int16u',
7452             SeparateTable => 'LensType2',
7453             PrintConv => \%sonyLensTypes2,
7454             PrintInt => 1,
7455             },
7456             0x0109 => {
7457             Name => 'LensType',
7458             Condition => '$$self{LensMount} == 1',
7459             Priority => 0, #PH (just to be safe)
7460             Format => 'int16u', #PH
7461             Notes => 'SLT models, and NEX with A-mount lenses',
7462             SeparateTable => 1,
7463             # has a value of 0 for E-mount lenses (values 0x80xx)
7464             ValueConvInv => '($val & 0xff00) == 0x8000 ? 0 : int($val)',
7465             PrintConv => \%sonyLensTypes,
7466             PrintInt => 1,
7467             },
7468             0x010b => {
7469             Name => 'DistortionCorrParamsPresent',
7470             PrintConv => { 0 => 'No', 1 => 'Yes'},
7471             },
7472             0x0114 => {
7473             Name => 'APS-CSizeCapture',
7474             Condition => '$$self{Model} =~ /^(SLT-A99|HV|ILCE-7)/',
7475             PrintConv => {
7476             0 => 'Off',
7477             1 => 'On',
7478             },
7479             },
7480             # 0x0115 and 0x0116, or 0x0116 and 0x0117:
7481             # give the same info as the first and last bytes of LensSpec,
7482             # but also for older Sony and Minolta lenses where all LensSpec bytes are 0.
7483             0x0115 => {
7484             Name => 'LensSpecFeatures',
7485             Condition => '$$self{Model} =~ /^(SLT-A(37|57|65|77)V?|Lunar|NEX-(F3|5N|7|VG20E))/',
7486             Format => 'undef[2]',
7487             ValueConv => 'join " ", unpack "H2H2", $val',
7488             ValueConvInv => sub {
7489             my @a = split(" ", shift);
7490             return @a == 2 ? pack 'CC', hex($a[0]), hex($a[1]) : undef;
7491             },
7492             PrintConv => \&PrintLensSpec,
7493             PrintConvInv => 'Image::ExifTool::Sony::PrintInvLensSpec($val, $self, 1)',
7494             },
7495             0x0116 => {
7496             Name => 'LensSpecFeatures',
7497             Condition => '$$self{Model} !~ /^(SLT-A(37|57|65|77)V?|Lunar|NEX-(F3|5N|7|VG20E))/',
7498             Format => 'undef[2]',
7499             ValueConv => 'join " ", unpack "H2H2", $val',
7500             ValueConvInv => sub {
7501             my @a = split(" ", shift);
7502             return @a == 2 ? pack 'CC', hex($a[0]), hex($a[1]) : undef;
7503             },
7504             PrintConv => \&PrintLensSpec,
7505             PrintConvInv => 'Image::ExifTool::Sony::PrintInvLensSpec($val, $self, 1)',
7506             },
7507              
7508             # 0x0122 => {Name=>'LensType',Format=>'int16u',Condition =>'$$self{Model}=~/^(SLT-A(37|57|65|77)V?|Lunar|NEX-(F3|5N|7|VG20E))/'},
7509             # 0x0123 => {Name=>'LensType',Format=>'int16u',Condition =>'$$self{Model}=~/^(SLT-A(58|99V?)|HV|ILCA-(68|77M2)|NEX-(3N|5R|5T|6|VG30E|VG900)|ILCE-(3000|3500|5000|5100|6000|7|7R|7S|7M2|QX1))/'},
7510             # 0x012d => {Name=>'LensType',Format=>'int16u',Condition =>'$$self{Model}=~/^(SLT-A(37|57|65|77)V?|Lunar|NEX-(F3|5N|7|VG20E))/'},
7511             # 0x012e => {Name=>'LensType',Format=>'int16u',Condition =>'$$self{Model}=~/^(SLT-A(58|99V?)|HV|ILCA-(68|77M2)|NEX-(3N|5R|5T|6|VG30E|VG900)|ILCE-(3000|3500|5000|5100|6000|7|7R|7S|7M2|QX1))/'},
7512              
7513             # ShutterCount3 = ShutterCount for SLT-A58, ILCE, ILCA, NEX-3N
7514             # ShutterCount-1 for SLT-A37,A57,A65,A77,A99, NEX-F3,5N,5R,5T,6,7, sometimes 0
7515             # ShutterCount-2 for NEX-VG, and often 0; "ShutterCount-2" also seen on a few A99V images
7516             # The offset for ShutterCount3 changes with firmware version for the ILCE-7/7R/7S/7M2, so don't decode it for now:
7517             # ILCE-7M2/7S: 0x01a0 (firmware 1.0x, 1.1x), 0x01b6 (firmware 1.20, 1.21, 2.00)
7518             # ILCE-7/7R: 0x01aa (firmware 1.0x, 1.1x), 0x01c0 (firmware 1.20, 1.21, 2.00)
7519             # Similarly for ILCE-6000 v2.00: 0x01aa --> 0x01c0: removed from 0x01aa
7520             0x01a0 => {
7521             Name => 'ShutterCount3',
7522             Format => 'int32u',
7523             RawConv => '$val == 0 ? undef : $val',
7524             Condition => '$$self{Model} =~ /^(ILCE-(5100|QX1)|ILCA-(68|77M2))/',
7525             },
7526             0x01aa => {
7527             Name => 'ShutterCount3',
7528             Format => 'int32u',
7529             RawConv => '$val == 0 ? undef : $val',
7530             Condition => '$$self{Model} =~ /^(SLT-A(58|99V?)|HV|NEX-(3N|5R|5T|6|VG900|VG30E)|ILCE-([35]000|3500))\b/',
7531             },
7532             0x01bd => {
7533             Name => 'ShutterCount3',
7534             Format => 'int32u',
7535             RawConv => '$val == 0 ? undef : $val',
7536             Condition => '$$self{Model} =~ /^(SLT-A(37|57|65|77)V?|Lunar|NEX-(F3|5N|7|VG20E))/',
7537             },
7538              
7539             # 0x0222 => {Name=>'LensType2',Format=>'int16u',Condition =>'$$self{Model}=~/^(ILCE-(5100|7S|7M2|QX1))/'},
7540             # 0x0224 => {Name=>'LensType', Format=>'int16u',Condition =>'$$self{Model}=~/^(ILCE-(5100|7S|7M2|QX1)|ILCA-(68|77M2))/'},
7541             # 0x0229 => {Name=>'LensType2',Format=>'int16u',Condition =>'$$self{Model}=~/^(NEX-(5R|5T|6|VG30E|VG900))/'},
7542             # 0x022b => {Name=>'LensType', Format=>'int16u',Condition =>'$$self{Model}=~/^(NEX-(5R|5T|6|VG30E|VG900))/'},
7543             # 0x022c => {Name=>'LensType2',Format=>'int16u',Condition =>'$$self{Model}=~/^(ILCE-(3000|3500|5000|6000|7|7R)|NEX-3N)\b/'},
7544             # 0x022e => {Name=>'LensType', Format=>'int16u',Condition =>'$$self{Model}=~/^(ILCE-(3000|3500|5000|6000|7|7R)|NEX-3N|SLT-A(58|99V?)|HV)\b/'},
7545              
7546             # 0x0231 => {Name=>'LensSpecFeatures',Format=>'undef[2]',Condition=>'$$self{Model}=~/^(ILCE-(7S|7M2|5100|QX1)|ILCA-(68|77M2))/'},
7547             # 0x0238 => {Name=>'LensSpecFeatures',Format=>'undef[2]',Condition=>'$$self{Model}=~/^(NEX-(5R|5T|6|VG30E|VG900))/'},
7548             # 0x023b => {Name=>'LensSpecFeatures',Format=>'undef[2]',Condition=>'$$self{Model}=~/^(SLT-A(58|99V?)|HV|ILCE-(3000|3500|5000|6000|7|7R)|NEX-3N)\b/'},
7549              
7550             # 0x023c => {Name=>'LensType2',Format=>'int16u',Condition =>'$$self{Model}=~/^(Lunar|NEX-(F3|5N|7|VG20E))/'},
7551             # 0x023e => {Name=>'LensType', Format=>'int16u',Condition =>'$$self{Model}=~/^(SLT-A(37|57|65|77)V?|Lunar|NEX-(F3|5N|7|VG20E)|ILCE-(5100|7S|7M2|QX1)|ILCA-(68|77M2))/'},
7552             # 0x0245 => {Name=>'LensType', Format=>'int16u',Condition =>'$$self{Model}=~/^(NEX-(5R|5T|6|VG30E|VG900))/'},
7553             # 0x0248 => {Name=>'LensType', Format=>'int16u',Condition =>'$$self{Model}=~/^(SLT-A(58|99V?)|HV|ILCE-(3000|3500|5000|6000|7|7R)|NEX-3N)\b/'},
7554             # 0x0249 => {Name=>'LensType', Format=>'int16u',Condition =>'$$self{Model}=~/^(ILCE-(5100|7S|7M2|QX1)|ILCA-(68|77M2))/'},
7555              
7556             # 0x024a => {Name=>'LensSpecFeatures',Format=>'undef[2]',Condition=>'$$self{Model}=~/^(SLT-A(37|57|65|77)V?|Lunar|NEX-(F3|5N|7|VG20E))/'},
7557              
7558             # 0x0250 => {Name=>'LensType', Format=>'int16u',Condition =>'$$self{Model}=~/^(NEX-(5R|5T|6|VG30E|VG900))/'},
7559             # 0x0253 => {Name=>'LensType', Format=>'int16u',Condition =>'$$self{Model}=~/^(SLT-A(58|99V?)|HV|ILCE-(3000|3500|5000|6000|7|7R|7S|7M2)|NEX-3N)\b/'},
7560             # 0x0257 => {Name=>'LensType', Format=>'int16u',Condition =>'$$self{Model}=~/^(SLT-A(37|57|65|77)V?|Lunar|NEX-(F3|5N|7|VG20E))/'},
7561             # 0x0262 => {Name=>'LensType', Format=>'int16u',Condition =>'$$self{Model}=~/^(SLT-A(37|57|65|77)V?|Lunar|NEX-(F3|5N|7|VG20E))/'},
7562              
7563             # 0x031b => {%gain2010,Condition=>'$$self{Model}=~/^(DSC-RX100M3|ILCA-(68|77M2)|ILCE-(5100|7S|7M2|QX1))/'},
7564             # 0x032c => {%gain2010,Condition=>'$$self{Model}=~/^(NEX-(5R|5T|6|VG30E|VG900))/'},
7565             # 0x032f => {%gain2010,Condition=>'$$self{Model}=~/^(DSC-RX10|SLT-A(58|99V?)|HV|ILCE-(3000|3500|5000|6000|7|7R)|NEX-3N)\b/'},
7566             # 0x0350 => {%gain2010,Condition=>'$$self{Model}=~/^(SLT-A(37|57)|NEX-F3)/'},
7567             # 0x037b => {%gain2010,Condition=>'$$self{Model}=~/^(SLT-A(65|77)V?|Lunar|NEX-(7|VG20E))/'},
7568             );
7569              
7570             %Image::ExifTool::Sony::Tag9050b = ( #JR
7571             PROCESS_PROC => \&ProcessEnciphered,
7572             WRITE_PROC => \&WriteEnciphered,
7573             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7574             FORMAT => 'int8u',
7575             NOTES => q{
7576             Valid from July 2015 for ILCE-6100/6300/6400/6500/6600/7C/7M3/7RM2/7RM3/7RM4/
7577             7SM2/9/9M2, ILCA-99M2.
7578             },
7579             WRITABLE => 1,
7580             FIRST_ENTRY => 0,
7581             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
7582             DATAMEMBER => [ 0x0039, 0x0105 ],
7583             0x0000 => {
7584             Condition => '$$self{Model} =~ /^(ILCA-)/',
7585             Name => 'SonyMaxAperture', # (at current focal length)
7586             # seen values from 17 - 48
7587             ValueConv => '2 ** (($val/8 - 1.06) / 2)',
7588             ValueConvInv => 'int((log($val) * 2 / log(2) + 1) * 8 + 0.5)',
7589             PrintConv => 'sprintf("%.1f",$val)',
7590             PrintConvInv => '$val',
7591             },
7592             0x0001 => {
7593             Condition => '$$self{Model} =~ /^(ILCA-)/',
7594             Name => 'SonyMinAperture', # (at current focal length)
7595             # seen values from 80 - 95
7596             ValueConv => '2 ** (($val/8 - 1.06) / 2)',
7597             ValueConvInv => 'int((log($val) * 2 / log(2) + 1) * 8 + 0.5)',
7598             PrintConv => 'sprintf("%.0f",$val)',
7599             PrintConvInv => '$val',
7600             },
7601             0x0026 => {
7602             Name => 'Shutter',
7603             Format => 'int16u[3]',
7604             PrintConv => {
7605             '0 0 0' => 'Silent / Electronic (0 0 0)',
7606             OTHER => sub {
7607             my ($val, $inv) = @_;
7608             return $inv ? ($val=~/\((.*?)\)/ ? $1 : undef) : "Mechanical ($val)";
7609             },
7610             },
7611             },
7612             #0x002c => {
7613             # Name => 'Shutter',
7614             # Condition => '$$self{Model} !~ /^(ILCE-6400)/ and $$self{Software} !~ /^ILCE-9 v5.0/',
7615             # PrintConv => {
7616             # 0 => 'Silent / Electronic',
7617             # 56 => 'Mechanical',
7618             # },
7619             #},
7620             0x0039 => {
7621             Name => 'FlashStatus',
7622             RawConv => '$$self{FlashFired} = $val',
7623             PrintConv => {
7624             0 => 'No Flash present',
7625             2 => 'Flash Inhibited', # seen for ILCE-7/7R continuous, panorama, HDR mode
7626             64 => 'Built-in Flash present',
7627             65 => 'Built-in Flash Fired',
7628             66 => 'Built-in Flash Inhibited', # seen for panorama, HDR, burst mode
7629             128 => 'External Flash present', # seen for NEX-5N/5T
7630             129 => 'External Flash Fired', # seen for SLT-A99V, ILCE-7R, NEX-5N/5R
7631             # 131 => 'External Flash ???', # seen for ILCE-7RM4
7632             },
7633             },
7634             0x003a => {
7635             Name => 'ShutterCount',
7636             # or "ShutterCount"? : number of shutter actuations, does not increase during Silent Shooting,
7637             # at least for ILCE-7RM2
7638             Format => 'int32u',
7639             Notes => 'total number of image exposures made by the camera',
7640             RawConv => '$val & 0x00ffffff',
7641             },
7642             0x0046 => { # appr. same value as Exif ExposureTime, but longer in HDR-modes
7643             Name => 'SonyExposureTime',
7644             Format => 'int16u',
7645             ValueConv => '$val ? 2 ** (16 - $val/256) : 0',
7646             ValueConvInv => '$val ? int((16 - log($val) / log(2)) * 256 + 0.5) : 0',
7647             PrintConv => '$val ? Image::ExifTool::Exif::PrintExposureTime($val) : "Bulb"',
7648             PrintConvInv => 'lc($val) eq "bulb" ? 0 : Image::ExifTool::Exif::ConvertFraction($val)',
7649             },
7650             0x0048 => {
7651             Name => 'SonyFNumber',
7652             Format => 'int16u',
7653             ValueConv => '2 ** (($val/256 - 16) / 2)',
7654             ValueConvInv => '(log($val)*2/log(2)+16)*256',
7655             PrintConv => 'sprintf("%.1f",$val)',
7656             PrintConvInv => '$val',
7657             },
7658             0x004b => {
7659             Name => 'ReleaseMode2',
7660             %releaseMode2,
7661             },
7662             # March 2019: ILCE-9 with v5.0x firmware follows ILCE-6400 in many tags ...
7663             0x0050 => {
7664             Name => 'ShutterCount2',
7665             Condition => '(($$self{FlashFired} & 0x01) != 1) and ($$self{Model} =~ /^(ILCE-(6100|6400|6600|7C|7RM4A?|9M2)|ZV-E10)/ or $$self{Software} =~ /^ILCE-9 (v5.0|v6.0)/)',
7666             Format => 'int32u',
7667             RawConv => '$val & 0x00ffffff',
7668             },
7669             0x0052 => {
7670             Name => 'ShutterCount2',
7671             Condition => '(($$self{FlashFired} & 0x01) != 1) and ($$self{Model} =~ /^(ILCE-(7M3|7RM3A?))/)',
7672             Format => 'int32u',
7673             RawConv => '$val & 0x00ffffff',
7674             },
7675             # 0x0058 - 0x0067: A-Mount: 16 values, only non-zero data for lenses giving "A-mount (3)" in 0x0104 below.
7676             # e.g for SAL70400G2: 9 5 5 64 69 74 79 84 89 94 98 104 255 105 89 80
7677             # where 9 means 9 focal lengths: 64 ... 104,
7678             # corresponding to 70-400mm via FocalLength = 4.375*2**($val/16)
7679             # 0x0058, 0x0061: E-Mount: ShutterCount and dateTime
7680             0x0058 => { # appears not valid when flash is used ... not for ILCA-99M2
7681             Name => 'ShutterCount2',
7682             Condition => '(($$self{FlashFired} & 0x01) != 1) and ($$self{Model} !~ /^(ILCA-99M2|ILCE-(6100|6400|6600|7C|7M3|7RM3A?|7RM4A?|9M2)|ZV-E10)/) and $$self{Software} !~ /^ILCE-9 (v5.0|v6.0)/',
7683             Format => 'int32u',
7684             RawConv => '$val & 0x00ffffff',
7685             },
7686             0x0061 => { # only minutes-seconds, not for ILCA-99M2, ILCE-9
7687             Name => 'SonyTimeMinSec',
7688             Condition => '$$self{Model} !~ /^(ILCA-99M2|ILCE-(6100|6400|6600|7C|7M3|7RM3A?|7RM4A?|9|9M2)|ZV-E10)/',
7689             Format => 'undef[2]',
7690             ValueConv => q{
7691             my @v = unpack('C*', $val);
7692             return sprintf("%.2d:%.2d", @v)
7693             },
7694             },
7695             0x006b => {
7696             Name => 'ReleaseMode2',
7697             Condition => '$$self{Model} =~ /^(ILCE-(6100|6400|6600|7C|7RM4A?|9M2)|ZV-E10)/ or $$self{Software} =~ /^ILCE-9 (v5.0|v6.0)/',
7698             %releaseMode2,
7699             },
7700             0x006d => {
7701             Name => 'ReleaseMode2',
7702             Condition => '$$self{Model} =~ /^(ILCE-(7M3|7RM3A?))/',
7703             %releaseMode2,
7704             },
7705             0x0073 => {
7706             Name => 'ReleaseMode2',
7707             Condition => '$$self{Model} !~ /^(ILCE-(6100|6400|6600|7C|7M3|7RM3A?|7RM4A?|9M2)|ZV-E10)/ and $$self{Software} !~ /^ILCE-9 (v5.0|v6.0)/',
7708             %releaseMode2,
7709             },
7710             0x0088 => {
7711             Name => 'InternalSerialNumber', #(NC)
7712             Format => 'int8u[6]',
7713             PrintConv => 'unpack "H*", pack "C*", split " ", $val',
7714             },
7715              
7716             ##### same offsets for lens info tags
7717              
7718             # 0x0104 - same as 0x0105, but has value 3 for SAL18135, SAL50F14Z, SAL55300, SAL70200G2, SAL70300G2, SAL70400G2
7719             0x0105 => {
7720             Name => 'LensMount',
7721             DataMember => 'LensMount',
7722             RawConv => '$$self{LensMount} = $val',
7723             PrintConv => {
7724             0 => 'Unknown',
7725             1 => 'A-mount',
7726             2 => 'E-mount',
7727             },
7728             },
7729             0x0106 => {
7730             Name => 'LensFormat',
7731             PrintConv => {
7732             0 => 'Unknown',
7733             1 => 'APS-C',
7734             2 => 'Full-frame',
7735             },
7736             },
7737             0x0107 => {
7738             Name => 'LensType2',
7739             Condition => '$$self{LensMount} == 2',
7740             Format => 'int16u',
7741             SeparateTable => 'LensType2',
7742             PrintConv => \%sonyLensTypes2,
7743             PrintInt => 1,
7744             },
7745             0x0109 => {
7746             Name => 'LensType',
7747             Condition => '$$self{LensMount} == 1',
7748             Priority => 0, #PH (just to be safe)
7749             Format => 'int16u', #PH
7750             Notes => 'SLT models, and NEX with A-mount lenses',
7751             SeparateTable => 1,
7752             # has a value of 0 for E-mount lenses (values 0x80xx)
7753             ValueConvInv => '($val & 0xff00) == 0x8000 ? 0 : int($val)',
7754             PrintConv => \%sonyLensTypes,
7755             PrintInt => 1,
7756             },
7757             0x010b => {
7758             Name => 'DistortionCorrParamsPresent',
7759             PrintConv => { 0 => 'No', 1 => 'Yes'},
7760             },
7761             0x0114 => {
7762             Name => 'APS-CSizeCapture',
7763             Condition => '$$self{Model} =~ /^(ILCE-7|ILCE-9|ILCA-99)/',
7764             PrintConv => {
7765             0 => 'Off',
7766             1 => 'On',
7767             },
7768             },
7769             # 0x0116 and 0x0117:
7770             # give the same info as the first and last bytes of LensSpec,
7771             # but also for older Sony and Minolta lenses where all LensSpec bytes are 0.
7772             0x0116 => {
7773             Name => 'LensSpecFeatures',
7774             Format => 'undef[2]',
7775             ValueConv => 'join " ", unpack "H2H2", $val',
7776             ValueConvInv => sub {
7777             my @a = split(" ", shift);
7778             return @a == 2 ? pack 'CC', hex($a[0]), hex($a[1]) : undef;
7779             },
7780             PrintConv => \&PrintLensSpec,
7781             PrintConvInv => 'Image::ExifTool::Sony::PrintInvLensSpec($val, $self, 1)',
7782             },
7783             #
7784             # tags becoming model- and/or firmware-dependent from here.
7785             #
7786             0x019f => {
7787             Name => 'ShutterCount3',
7788             Condition => '$$self{Model} =~ /^(ILCE-(6100|6400|6600|7C|7M3|7RM3A?|7RM4A?|9|9M2)|ZV-E10)\b/',
7789             Format => 'int32u',
7790             RawConv => '$val == 0 ? undef : $val',
7791             },
7792             0x01cb => {
7793             Name => 'ShutterCount3',
7794             Condition => '$$self{Model} =~ /^(ILCE-(7RM2|7SM2))/',
7795             Format => 'int32u',
7796             RawConv => '$val == 0 ? undef : $val',
7797             },
7798             0x01cd => {
7799             Name => 'ShutterCount3',
7800             Condition => '$$self{Model} =~ /^(ILCE-(6300|6500)|ILCA-99M2)/',
7801             Format => 'int32u',
7802             RawConv => '$val == 0 ? undef : $val',
7803             },
7804             0x01eb => {
7805             Name => 'APS-CSizeCapture',
7806             Condition => '$$self{Model} =~ /^ILCE-(7RM4A?|7C|9M2)|ZV-E10/ or $$self{Software} =~ /^ILCE-9 (v5.0|v6.0)/',
7807             PrintConv => {
7808             0 => 'Off',
7809             1 => 'On',
7810             },
7811             },
7812             0x01ed => {
7813             Name => 'LensSpecFeatures',
7814             Condition => '$$self{Model} =~ /^ILCE-(7RM4A?|7C|9M2)|ZV-E10/ or $$self{Software} =~ /^ILCE-9 (v5.0|v6.0)/',
7815             Priority => 0,
7816             Format => 'undef[2]',
7817             ValueConv => 'join " ", unpack "H2H2", $val',
7818             ValueConvInv => sub {
7819             my @a = split(" ", shift);
7820             return @a == 2 ? pack 'CC', hex($a[0]), hex($a[1]) : undef;
7821             },
7822             PrintConv => \&PrintLensSpec,
7823             PrintConvInv => 'Image::ExifTool::Sony::PrintInvLensSpec($val, $self, 1)',
7824             },
7825             0x01ee => {
7826             Name => 'APS-CSizeCapture',
7827             Condition => '$$self{Model} =~ /^(ILCE-(7M3|7RM3A?|9))\b/ and $$self{Software} !~ /^ILCE-9 (v5.0|v6.0)/',
7828             PrintConv => {
7829             0 => 'Off',
7830             1 => 'On',
7831             },
7832             },
7833             0x01f0 => {
7834             Name => 'LensSpecFeatures',
7835             Condition => '$$self{Model} =~ /^(ILCE-(6100|6400|6600|7M3|7RM3A?|9))\b/ and $$self{Software} !~ /^ILCE-9 (v5.0|v6.0)/',
7836             Priority => 0,
7837             Format => 'undef[2]',
7838             ValueConv => 'join " ", unpack "H2H2", $val',
7839             ValueConvInv => sub {
7840             my @a = split(" ", shift);
7841             return @a == 2 ? pack 'CC', hex($a[0]), hex($a[1]) : undef;
7842             },
7843             PrintConv => \&PrintLensSpec,
7844             PrintConvInv => 'Image::ExifTool::Sony::PrintInvLensSpec($val, $self, 1)',
7845             },
7846             # the following tags are commented out because they can cause problems for the
7847             # Composite LensID of non-electronic lenses (even if Priority is set to 0)
7848             # 0x020d => {
7849             # Name=>'LensType2',
7850             # Condition => '$$self{Model} =~ /^(ILCE-(7RM2|7SM2))/',
7851             # Format=>'int16u',
7852             # },
7853             # 0x020f => [{
7854             # Name=>'LensType',
7855             # Condition => '$$self{Model} =~ /^(ILCE-(7RM2|7SM2))/',
7856             # Format=>'int16u',
7857             # },{
7858             # Name=>'LensType2',
7859             # Condition => '$$self{Model} =~ /^(ILCE-(6300|6500)|ILCA-99M2)/',
7860             # Format=>'int16u',
7861             # }],
7862             # 0x0211 => {
7863             # Name=>'LensType',
7864             # Condition => '$$self{Model} =~ /^(ILCE-(6300|6500)|ILCA-99M2)/',
7865             # Format=>'int16u',
7866             # },
7867             0x021a => {
7868             Name => 'APS-CSizeCapture',
7869             Condition => '$$self{Model} =~ /^(ILCE-(7RM2|7SM2))/',
7870             PrintConv => {
7871             0 => 'Off',
7872             1 => 'On',
7873             },
7874             },
7875             0x021c => [{
7876             Name => 'LensSpecFeatures',
7877             Condition => '$$self{Model} =~ /^(ILCE-(7RM2|7SM2))/',
7878             Priority => 0,
7879             Format => 'undef[2]',
7880             ValueConv => 'join " ", unpack "H2H2", $val',
7881             ValueConvInv => sub {
7882             my @a = split(" ", shift);
7883             return @a == 2 ? pack 'CC', hex($a[0]), hex($a[1]) : undef;
7884             },
7885             PrintConv => \&PrintLensSpec,
7886             PrintConvInv => 'Image::ExifTool::Sony::PrintInvLensSpec($val, $self, 1)',
7887             },{
7888             Name => 'APS-CSizeCapture',
7889             Condition => '$$self{Model} =~ /^(ILCA-99M2)/',
7890             PrintConv => {
7891             0 => 'Off',
7892             1 => 'On',
7893             },
7894             }],
7895             0x021e => {
7896             Name => 'LensSpecFeatures',
7897             Condition => '$$self{Model} =~ /^(ILCE-(6300|6500)|ILCA-99M2)/',
7898             Priority => 0,
7899             Format => 'undef[2]',
7900             ValueConv => 'join " ", unpack "H2H2", $val',
7901             ValueConvInv => sub {
7902             my @a = split(" ", shift);
7903             return @a == 2 ? pack 'CC', hex($a[0]), hex($a[1]) : undef;
7904             },
7905             PrintConv => \&PrintLensSpec,
7906             PrintConvInv => 'Image::ExifTool::Sony::PrintInvLensSpec($val, $self, 1)',
7907             },
7908             );
7909              
7910             %Image::ExifTool::Sony::Tag9050c = ( #JR
7911             PROCESS_PROC => \&ProcessEnciphered,
7912             WRITE_PROC => \&WriteEnciphered,
7913             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7914             FORMAT => 'int8u',
7915             NOTES => q{
7916             Valid from July 2020 for ILCE-1/7SM3, ILME-FX3.
7917             },
7918             WRITABLE => 1,
7919             FIRST_ENTRY => 0,
7920             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
7921             DATAMEMBER => [ 0x0039 ],
7922             0x0026 => {
7923             Name => 'Shutter',
7924             Format => 'int16u[3]',
7925             PrintConv => {
7926             '0 0 0' => 'Silent / Electronic (0 0 0)',
7927             OTHER => sub {
7928             my ($val, $inv) = @_;
7929             return $inv ? ($val=~/\((.*?)\)/ ? $1 : undef) : "Mechanical ($val)";
7930             },
7931             },
7932             },
7933             0x0039 => {
7934             Name => 'FlashStatus',
7935             RawConv => '$$self{FlashFired} = $val',
7936             PrintConv => {
7937             0 => 'No Flash present',
7938             2 => 'Flash Inhibited', # seen for ILCE-7/7R continuous, panorama, HDR mode
7939             64 => 'Built-in Flash present',
7940             65 => 'Built-in Flash Fired',
7941             66 => 'Built-in Flash Inhibited', # seen for panorama, HDR, burst mode
7942             128 => 'External Flash present', # seen for NEX-5N/5T
7943             129 => 'External Flash Fired', # seen for SLT-A99V, ILCE-7R, NEX-5N/5R
7944             },
7945             },
7946             0x003a => {
7947             Name => 'ShutterCount',
7948             # or "ShutterCount"? : number of shutter actuations, does not increase during Silent Shooting,
7949             # at least for ILCE-7RM2
7950             Format => 'int32u',
7951             Notes => 'total number of image exposures made by the camera',
7952             RawConv => '$val & 0x00ffffff',
7953             PrintConv => 'sprintf("%6d",$val)',
7954             },
7955             0x0046 => { # appr. same value as Exif ExposureTime, but longer in HDR-modes
7956             Name => 'SonyExposureTime',
7957             Format => 'int16u',
7958             ValueConv => '$val ? 2 ** (16 - $val/256) : 0',
7959             ValueConvInv => '$val ? int((16 - log($val) / log(2)) * 256 + 0.5) : 0',
7960             PrintConv => '$val ? Image::ExifTool::Exif::PrintExposureTime($val) : "Bulb"',
7961             PrintConvInv => 'lc($val) eq "bulb" ? 0 : Image::ExifTool::Exif::ConvertFraction($val)',
7962             },
7963             0x0048 => {
7964             Name => 'SonyFNumber',
7965             Format => 'int16u',
7966             ValueConv => '2 ** (($val/256 - 16) / 2)',
7967             ValueConvInv => '(log($val)*2/log(2)+16)*256',
7968             PrintConv => 'sprintf("%.1f",$val)',
7969             PrintConvInv => '$val',
7970             },
7971             0x004b => {
7972             Name => 'ReleaseMode2',
7973             %releaseMode2,
7974             },
7975             0x0050 => {
7976             Name => 'ShutterCount2',
7977             Condition => '($$self{FlashFired} & 0x01) != 1',
7978             Format => 'int32u',
7979             RawConv => '$val & 0x00ffffff',
7980             },
7981             0x0066 => { # appr. same value as Exif ExposureTime, but not valid in HDR-modes
7982             Name => 'SonyExposureTime',
7983             Format => 'int16u',
7984             ValueConv => '$val ? 2 ** (16 - $val/256) : 0',
7985             ValueConvInv => '$val ? int((16 - log($val) / log(2)) * 256 + 0.5) : 0',
7986             PrintConv => '$val ? Image::ExifTool::Exif::PrintExposureTime($val) : "Bulb"',
7987             PrintConvInv => 'lc($val) eq "bulb" ? 0 : Image::ExifTool::Exif::ConvertFraction($val)',
7988             },
7989             0x0068 => { # appr. same value as Exif ExposureTime, but not valid in HDR-modes
7990             Name => 'SonyFNumber',
7991             Format => 'int16u',
7992             ValueConv => '2 ** (($val/256 - 16) / 2)',
7993             ValueConvInv => '(log($val)*2/log(2)+16)*256',
7994             PrintConv => 'sprintf("%.1f",$val)',
7995             PrintConvInv => '$val',
7996             },
7997             0x006b => {
7998             Name => 'ReleaseMode2',
7999             %releaseMode2,
8000             },
8001             0x0088 => {
8002             Name => 'InternalSerialNumber', #(NC)
8003             Condition => '$$self{Model} =~ /^(ILCE-(7M4|7RM5|7SM3)|ILME-FX3)/',
8004             Format => 'int8u[6]',
8005             PrintConv => 'unpack "H*", pack "C*", split " ", $val',
8006             },
8007             0x008a => {
8008             Name => 'InternalSerialNumber', #(NC)
8009             Condition => '$$self{Model} =~ /^(ILCE-1)/',
8010             Format => 'int8u[6]',
8011             PrintConv => 'unpack "H*", pack "C*", split " ", $val',
8012             },
8013             );
8014              
8015             %Image::ExifTool::Sony::Tag9400a = ( #JR
8016             PROCESS_PROC => \&ProcessEnciphered,
8017             WRITE_PROC => \&WriteEnciphered,
8018             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8019             FORMAT => 'int8u',
8020             NOTES => 'Valid for many DSC, NEX and SLT models',
8021             WRITABLE => 1,
8022             FIRST_ENTRY => 0,
8023             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
8024             0x0008 => { %sequenceImageNumber }, #PH
8025             0x000c => { %sequenceFileNumber }, #PH
8026             0x0010 => { %releaseMode2 },
8027             0x0012 => {
8028             Name => 'DigitalZoom',
8029             Condition => '$$self{Model} !~ /^(SLT-(A65|A77)V?|NEX-(5N|7|VG20E)|Lunar|DSC-(HX10V|HX20V|HX200V|TX20|TX55|TX300V|WX30|WX70))\b/',
8030             PrintConv => {
8031             0 => 'No',
8032             1 => 'Yes',
8033             },
8034             },
8035             # 0x0013 - Flash fired 0=no, 1=yes
8036             # 0x0014 - related to flash / RedEyeReduction ?
8037             # 0x0015 - CameraType: 1=HDR, 2=DSC, 3=SLT/NEX
8038             0x001a => { #PH
8039             Name => 'ShotNumberSincePowerUp',
8040             Format => 'int32u',
8041             },
8042             # 0x001e - increments by 4 or 6 or 8 each shutter release press since power up
8043             # 0x001f - 0=most pictures, 1='Self-timer/Self-portrait', 2='Self-portrait (2 people)',
8044             # 3='Continuous Self-timer', 26='Sweep Panorama' (PH, RX100)
8045             # 0x0021 - maybe related to Image Stabilization or Smile Shutter ?
8046             0x0022 => {
8047             Name => 'SequenceLength',
8048             PrintConv => {
8049             0 => 'Continuous', # (RX100 too)
8050             1 => '1 shot',
8051             2 => '2 shots', # (Background defocus, 3D Image)
8052             3 => '3 shots', # (HDR, WB Bracketing) (RX100, also continuous bracket)
8053             4 => '4 shots', # seen for DSC-WX300 in Superior-Auto Anti-Motion-Blur
8054             5 => '5 shots', # (PH, RX100)
8055             6 => '6 shots', # (Multi Frame NR, Anti Motion blur, Hand-held Twilight)
8056             10 => '10 shots', # (HX9V Burst)
8057             100 => 'Continuous - iSweep Panorama', # (HX9V)
8058             200 => 'Continuous - Sweep Panorama',
8059             },
8060             },
8061             # 0x0027 - 1=single exposure, 2=multi-exposure (eg. pano,some superior auto) (PH, RX100)
8062             0x0028 => {
8063             Name => 'CameraOrientation', # (also RX100 - PH)
8064             PrintConv => {
8065             1 => 'Horizontal (normal)',
8066             3 => 'Rotate 180',
8067             6 => 'Rotate 90 CW',
8068             8 => 'Rotate 270 CW',
8069             },
8070             },
8071             0x0029 => {
8072             Name => 'Quality2', # (also RX100 - PH)
8073             PrintConv => {
8074             0 => 'JPEG',
8075             1 => 'RAW',
8076             2 => 'RAW + JPEG',
8077             3 => 'JPEG + MPO', # 3D images
8078             },
8079             },
8080             # 0x002b - FacesDetected_OK 0=no, 1=yes appears valid for SLT, but not for NEX and DSC-HX9V
8081             # 0x0030 - long exposure noise reduction used 0=no, 1=yes (PH, RX100)
8082             # 0x0031 - smile shutter used 0=no, 1=yes (PH, RX100)
8083             # 0x0033 - 0 for DSC-HX9V, 8 for SLT, NEX
8084             # 0x0034 and 0x0038 - different offset for HX9V and SLT/NEX, but similar numbers, non-zero when flash fired
8085             0x0044 => {
8086             Condition => '$$self{Model} =~ /^(SLT-|HV|NEX-|Lunar|DSC-RX|Stellar)/', # not valid for most other DSC and HDR models
8087             Name => 'SonyImageHeight',
8088             Format => 'int16u',
8089             PrintConv => '$val > 0 ? 8*$val : "n.a."',
8090             },
8091             0x0052 => {
8092             Name => 'ModelReleaseYear',
8093             Condition => '$$self{Model} =~ /^(SLT-|HV|NEX-|Lunar|DSC-RX|Stellar)/', # not valid for most other DSC and HDR models
8094             Format => 'int8u',
8095             PrintConv => 'sprintf("20%.2d", $val)',
8096             },
8097             );
8098              
8099             %Image::ExifTool::Sony::Tag9400b = ( #JR
8100             PROCESS_PROC => \&ProcessEnciphered,
8101             WRITE_PROC => \&WriteEnciphered,
8102             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8103             FORMAT => 'int8u',
8104             NOTES => q{
8105             Valid for NEX-3N, ILCE-3000/3500, SLT-A58, DSC-WX60, DSC-WX300, DSC-RX100M2,
8106             DSC-HX50V, DSC-QX10/QX100.
8107             },
8108             WRITABLE => 1,
8109             FIRST_ENTRY => 0,
8110             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
8111             0x0008 => { %sequenceImageNumber }, #PH
8112             0x000c => { %sequenceFileNumber }, #PH
8113             0x0010 => { %releaseMode2 },
8114             0x0012 => {
8115             Name => 'DigitalZoom',
8116             PrintConv => {
8117             0 => 'No',
8118             1 => 'Yes',
8119             },
8120             },
8121             # 0x0013 - Flash fired 0=no, 1=yes
8122             # 0x0014 - related to flash / RedEyeReduction ?
8123             # 0x0015 - CameraType: 1=HDR, 2=DSC, 3=SLT/NEX
8124             0x0016 => { #PH
8125             Name => 'ShotNumberSincePowerUp',
8126             Format => 'int32u',
8127             },
8128             0x001e => {
8129             Name => 'SequenceLength',
8130             PrintConv => {
8131             0 => 'Continuous',
8132             1 => '1 shot',
8133             2 => '2 shots',
8134             3 => '3 shots',
8135             4 => '4 shots',
8136             5 => '5 shots',
8137             6 => '6 shots',
8138             10 => '10 shots',
8139             100 => 'Continuous - iSweep Panorama',
8140             200 => 'Continuous - Sweep Panorama',
8141             },
8142             },
8143             0x0024 => {
8144             Name => 'CameraOrientation',
8145             PrintConv => {
8146             1 => 'Horizontal (normal)',
8147             3 => 'Rotate 180',
8148             6 => 'Rotate 90 CW',
8149             8 => 'Rotate 270 CW',
8150             },
8151             },
8152             0x0025 => {
8153             Name => 'Quality2',
8154             PrintConv => {
8155             0 => 'JPEG',
8156             1 => 'RAW',
8157             2 => 'RAW + JPEG',
8158             3 => 'JPEG + MPO', # 3D images
8159             },
8160             },
8161             # 0x0027 - FacesDetected_OK 0=no, 1=yes
8162             # 0x002c - long exposure noise reduction used 0=no, 1=yes (PH, RX100)
8163             0x003f => {
8164             Name => 'SonyImageHeight',
8165             Format => 'int16u',
8166             PrintConv => '$val > 0 ? 8*$val : "n.a."',
8167             },
8168             0x0046 => { # but Panorama images give incorrect result
8169             Name => 'ModelReleaseYear',
8170             Format => 'int8u',
8171             PrintConv => 'sprintf("20%.2d", $val)',
8172             },
8173             );
8174              
8175             %Image::ExifTool::Sony::Tag9400c = ( #JR
8176             PROCESS_PROC => \&ProcessEnciphered,
8177             WRITE_PROC => \&WriteEnciphered,
8178             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8179             FORMAT => 'int8u',
8180             WRITABLE => 1,
8181             NOTES => q{
8182             Valid for DSC-HX60V/HX80/HX90V/HX99/HX350/HX400V/QX30/RX0/RX1RM2/RX10/
8183             RX10M2/RX10M3/RX10M4/RX100M3/RX100M4/RX100M5/RX100M5A/RX100M6/RX100M7/WX220/
8184             WX350/WX500, ILCE-1/7/7C/7R/7S/7M2/7M3/7RM2/7RM3/7RM4/7SM2/7SM3/9/9M2/5000/
8185             5100/6000/6100/6300/6400/6500/6600/QX1, ILCA-68/77M2/99M2.
8186             },
8187             FIRST_ENTRY => 0,
8188             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
8189             0x0009 => { %releaseMode2 },
8190             0x000a => {
8191             Name => 'ShotNumberSincePowerUp',
8192             Condition => '$$self{Model} =~ /^(ILCA-(68|77M2|99M2)|ILCE-(5000|5100|6000|6300|6500|7|7M2|7R|7RM2|7S|7SM2|QX1)|DSC-(HX350|HX400V|HX60V|HX80|HX90|HX90V|QX30|RX0|RX1RM2|RX10|RX10M2|RX10M3|RX100M3|RX100M4|RX100M5|WX220|WX350|WX500))\b/',
8193             Notes => 'valid only for some models',
8194             Format => 'int32u',
8195             },
8196             0x0012 => { %sequenceImageNumber },
8197             0x0016 => {
8198             Name => 'SequenceLength',
8199             PrintConv => {
8200             0 => 'Continuous',
8201             1 => '1 shot',
8202             2 => '2 shots',
8203             3 => '3 shots',
8204             4 => '4 shots',
8205             5 => '5 shots',
8206             6 => '6 shots',
8207             7 => '7 shots', # DSC-RX100M7 Single Burst Shooting
8208             9 => '9 shots', # ILCE-7RM2 9-shot bracketing
8209             10 => '10 shots',
8210             12 => '12 shots', # ILCA-77M2 12-shot MFNR-mode
8211             16 => '16 shots', # ILCE-7RM4 16-shot PixelShift
8212             100 => 'Continuous - iSweep Panorama',
8213             200 => 'Continuous - Sweep Panorama',
8214             },
8215             },
8216             0x001a => { %sequenceFileNumber },
8217             0x001e => {
8218             Name => 'SequenceLength',
8219             PrintConv => {
8220             0 => 'Continuous',
8221             1 => '1 file',
8222             2 => '2 files',
8223             3 => '3 files',
8224             5 => '5 files',
8225             7 => '7 files', # DSC-RX100M7 Single Burst Shooting
8226             9 => '9 files', # ILCE-7RM2 9-shot bracketing
8227             10 => '10 files', # seen for DSC-WX500 with burst of 10 shots
8228             },
8229             },
8230             0x0029 => {
8231             Name => 'CameraOrientation',
8232             PrintConv => {
8233             1 => 'Horizontal (normal)',
8234             3 => 'Rotate 180',
8235             6 => 'Rotate 90 CW',
8236             8 => 'Rotate 270 CW',
8237             },
8238             },
8239             0x002a => [{
8240             Name => 'Quality2',
8241             Condition => '$$self{Model} !~ /^(ILCE-(1|7M4|7RM5|7SM3)|ILME-FX3)\b/',
8242             PrintConv => {
8243             0 => 'JPEG',
8244             1 => 'RAW',
8245             2 => 'RAW + JPEG',
8246             3 => 'JPEG + MPO', # 3D images
8247             },
8248             },{
8249             Name => 'Quality2',
8250             Condition => '$$self{Model} =~ /^(ILCE-(1|7M4|7RM5|7SM3)|ILME-FX3)\b/',
8251             PrintConv => {
8252             1 => 'JPEG',
8253             2 => 'RAW',
8254             3 => 'RAW + JPEG',
8255             4 => 'HEIF',
8256             6 => 'RAW + HEIF',
8257             },
8258             }],
8259             0x0047 => {
8260             Name => 'SonyImageHeight',
8261             Condition => '$$self{Model} !~ /^(ILCE-(1|7M4|7RM5|7SM3)|ILME-FX3)\b/',
8262             Format => 'int16u',
8263             PrintConv => '$val > 0 ? 8*$val : "n.a."',
8264             },
8265             0x0053 => {
8266             Name => 'ModelReleaseYear',
8267             Condition => '$$self{Model} !~ /^(ILCE-(1|7M4|7RM5|7SM3)|ILME-FX3)\b/',
8268             Format => 'int8u',
8269             PrintConv => 'sprintf("20%.2d", $val)',
8270             },
8271             );
8272              
8273             %Image::ExifTool::Sony::Tag9401 = ( # JR
8274             PROCESS_PROC => \&ProcessEnciphered,
8275             WRITE_PROC => \&WriteEnciphered,
8276             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8277             FORMAT => 'int8u',
8278             WRITABLE => 1,
8279             FIRST_ENTRY => 0,
8280             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
8281             DATAMEMBER => [ 0 ],
8282             IS_SUBDIR => [ 0x044e, 0x0498, 0x049d, 0x04a1, 0x04a2, 0x059d, 0x0634, 0x0636, 0x064c, 0x0653, 0x0678, 0x06b8, 0x06de, 0x06e7 ],
8283             0x0000 => { Name => 'Ver9401', Hidden => 1, RawConv => '$$self{Ver9401} = $val; $$self{OPTIONS}{Unknown}<2 ? undef : $val' },
8284              
8285             0x044e => { Name => 'ISOInfo', Condition => '$$self{Ver9401} == 178', Format => 'int8u[5]', SubDirectory => { TagTable => 'Image::ExifTool::Sony::ISOInfo' } },
8286             0x0498 => { Name => 'ISOInfo', Condition => '$$self{Ver9401} == 148', Format => 'int8u[5]', SubDirectory => { TagTable => 'Image::ExifTool::Sony::ISOInfo' } },
8287             0x049d => { Name => 'ISOInfo', Condition => '$$self{Ver9401} == 167', Format => 'int8u[5]', SubDirectory => { TagTable => 'Image::ExifTool::Sony::ISOInfo' } },
8288             0x04a1 => { Name => 'ISOInfo', Condition => '$$self{Ver9401} =~ /^(160|164)/', Format => 'int8u[5]', SubDirectory => { TagTable => 'Image::ExifTool::Sony::ISOInfo' } },
8289             0x04a2 => { Name => 'ISOInfo', Condition => '$$self{Ver9401} =~ /^(152|154|155)/', Format => 'int8u[5]', SubDirectory => { TagTable => 'Image::ExifTool::Sony::ISOInfo' } },
8290             0x059d => { Name => 'ISOInfo', Condition => '$$self{Ver9401} =~ /^(144|146)/', Format => 'int8u[5]', SubDirectory => { TagTable => 'Image::ExifTool::Sony::ISOInfo' } },
8291             0x0634 => { Name => 'ISOInfo', Condition => '$$self{Ver9401} == 68', Format => 'int8u[5]', SubDirectory => { TagTable => 'Image::ExifTool::Sony::ISOInfo' } },
8292             0x0636 => { Name => 'ISOInfo', Condition => '$$self{Ver9401} =~ /^(73|74)/', Format => 'int8u[5]', SubDirectory => { TagTable => 'Image::ExifTool::Sony::ISOInfo' } },
8293             0x064c => { Name => 'ISOInfo', Condition => '$$self{Ver9401} == 78', Format => 'int8u[5]', SubDirectory => { TagTable => 'Image::ExifTool::Sony::ISOInfo' } },
8294             0x0653 => { Name => 'ISOInfo', Condition => '$$self{Ver9401} == 90', Format => 'int8u[5]', SubDirectory => { TagTable => 'Image::ExifTool::Sony::ISOInfo' } },
8295             0x0678 => { Name => 'ISOInfo', Condition => '$$self{Ver9401} =~ /^(93|94)/', Format => 'int8u[5]', SubDirectory => { TagTable => 'Image::ExifTool::Sony::ISOInfo' } },
8296             0x06b8 => { Name => 'ISOInfo', Condition => '$$self{Ver9401} =~ /^(100|103)/', Format => 'int8u[5]', SubDirectory => { TagTable => 'Image::ExifTool::Sony::ISOInfo' } },
8297             0x06de => { Name => 'ISOInfo', Condition => '$$self{Ver9401} =~ /^(124|125)/', Format => 'int8u[5]', SubDirectory => { TagTable => 'Image::ExifTool::Sony::ISOInfo' } },
8298             0x06e7 => { Name => 'ISOInfo', Condition => '$$self{Ver9401} =~ /^(127|128|130)/', Format => 'int8u[5]', SubDirectory => { TagTable => 'Image::ExifTool::Sony::ISOInfo' } },
8299             );
8300              
8301             %Image::ExifTool::Sony::ISOInfo = ( # JR
8302             FORMAT => 'int8u',
8303             %binaryDataAttrs,
8304             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8305             0x0000 => { Name => 'ISOSetting', ValueConv => \%isoSetting2010 },
8306             0x0002 => { Name => 'ISOAutoMin', ValueConv => \%isoSetting2010 },
8307             0x0004 => { Name => 'ISOAutoMax', ValueConv => \%isoSetting2010 },
8308             );
8309              
8310             # PH (RX100)
8311             %Image::ExifTool::Sony::Tag9402 = (
8312             PROCESS_PROC => \&ProcessEnciphered,
8313             WRITE_PROC => \&WriteEnciphered,
8314             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8315             FORMAT => 'int8u',
8316             WRITABLE => 1,
8317             FIRST_ENTRY => 0,
8318             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
8319             DATAMEMBER => [ 0x02 ],
8320             PRIORITY => 0,
8321             0x02 => {
8322             Name => 'TempTest1',
8323             DataMember => 'TempTest1',
8324             Hidden => 1,
8325             RawConv => '$$self{TempTest1}=$val; $$self{OPTIONS}{Unknown}<2 ? undef : $val',
8326             },
8327             0x04 => {
8328             Name => 'AmbientTemperature',
8329             # this (and many other values) are only valid if 0x02 is 255 (why?)
8330             Condition => '$$self{TempTest1} == 255',
8331             Format => 'int8s', # (verified for negative temperature)
8332             PrintConv => '"$val C"',
8333             PrintConvInv => '$val=~s/ ?C//; $val',
8334             },
8335             0x16 => { #JR
8336             Name => 'FocusMode',
8337             Mask => 0x7f, # (often +128, not sure what upper bit is for)
8338             PrintConv => {
8339             0 => 'Manual',
8340             2 => 'AF-S',
8341             3 => 'AF-C',
8342             4 => 'AF-A', # seen in ILCE-6000 images
8343             6 => 'DMF',
8344             # 7 => 'AF-D', # not for DSC, NEX, ILCE ...
8345             },
8346             },
8347             0x17 => {
8348             Name => 'AFAreaMode',
8349             PrintConv => {
8350             0 => 'Multi', # newer DSC/ILC use name 'Wide'
8351             1 => 'Center',
8352             2 => 'Spot', #(NC) seen for DSC-WX300
8353             3 => 'Flexible Spot',
8354             10 => 'Selective (for Miniature effect)', # seen for DSC-HX30V,TX30,WX60,WX100
8355             11 => 'Zone', #JR (ILCE-7 series)
8356             12 => 'Expanded Flexible Spot', #JR (HX90V, ILCE-7 series)
8357             14 => 'Tracking',
8358             15 => 'Face Tracking',
8359             20 => 'Animal Eye Tracking',
8360             # 21 => '???', # (ILCE-7SM3)
8361             255 => 'Manual',
8362             },
8363             },
8364             # 0x24, 0x26: factor 10 for NEX and ILCE, factor 100 for DSC
8365             # 0x24, 0x26, 0x28, 0x2a: inconsistent for A-mount lenses on NEX/ILCE: some correct, some 0, some incorrect ...
8366             # 0x28 - not valid for DSC-[HTW]X models, or DSC-RX100
8367             # 0x24 => { # same values as Exif FocalLength (but have seen FocalLength for previous shot, ref IB, RX100M5)
8368             # Name => 'FocalLength',
8369             # Format => 'int16u',
8370             # RawConv => '$val || undef',
8371             # ValueConv => '$val / ($$self{Model}=~/DSC/ ? 100 : 10)',
8372             # ValueConvInv => '$val * ($$self{Model}=~/DSC/ ? 100 : 10)',
8373             # PrintConv => 'sprintf("%.1f mm",$val)',
8374             # PrintConvInv => '$val =~ s/ ?mm//; $val',
8375             # },
8376             # 0x26 => { # usually identical to 0x24 or 0
8377             # Name => 'FocalLength',
8378             # Format => 'int16u',
8379             # ValueConv => '$val / ($$self{Model}=~/DSC/ ? 100 : 10)',
8380             # ValueConvInv => '$val * ($$self{Model}=~/DSC/ ? 100 : 10)',
8381             # PrintConv => 'sprintf("%.1f mm",$val)',
8382             # PrintConvInv => '$val =~ s/ ?mm//; $val',
8383             # },
8384             # 0x28 => { # values slightly different from Exif FocalLength
8385             # Name => 'FocalLength2',
8386             # Format => 'int16u',
8387             # RawConv => '$val || undef',
8388             # ValueConv => '$val / 10',
8389             # ValueConvInv => '$val * 10',
8390             # PrintConv => 'sprintf("%.1f mm",$val)',
8391             # PrintConvInv => '$val =~ s/ ?mm//; $val',
8392             # },
8393             # 0x2a => { # usually identical to 0x28 or 0
8394             # Name => 'FocalLength2',
8395             # Format => 'int16u',
8396             # ValueConv => '$val / 10',
8397             # ValueConvInv => '$val * 10',
8398             # PrintConv => 'sprintf("%.1f mm",$val)',
8399             # PrintConvInv => '$val =~ s/ ?mm//; $val',
8400             # },
8401             # 0x002c => {
8402             # # seen values from 80 - 255 (= infinity) -- see Composite:FocusDistance2 below
8403             # Name => 'FocusPosition2',
8404             # Condition => '$$self{Model} !~ /^(DSC-|Stellar)/',
8405             # },
8406             0x002d => { # usually same as 0x002c, but some differences
8407             # seen values from 80 - 255 (= infinity) -- see Composite:FocusDistance2 below
8408             Name => 'FocusPosition2',
8409             Condition => '$$self{Model} !~ /^(DSC-|Stellar)/',
8410             },
8411             # 0x8a - int32u: some sort of accumulated time or something since power up
8412             # (doesn't increment during continuous shooting and at some other times)
8413             );
8414              
8415             # PH (RX100)
8416             %Image::ExifTool::Sony::Tag9403 = (
8417             PROCESS_PROC => \&ProcessEnciphered,
8418             WRITE_PROC => \&WriteEnciphered,
8419             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8420             FORMAT => 'int8u',
8421             WRITABLE => 1,
8422             FIRST_ENTRY => 0,
8423             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
8424             DATAMEMBER => [ 0x04 ],
8425             0x04 => {
8426             # seen values 0,2,3,18,19,32,49,50,83,130,132,148,213,229,255
8427             # CameraTemperature is valid for all values above except ==0 and >=130
8428             Name => 'TempTest2',
8429             DataMember => 'TempTest2',
8430             Hidden => 1,
8431             RawConv => '$$self{TempTest2}=$val; $$self{OPTIONS}{Unknown}<2 ? undef : $val',
8432             },
8433             0x05 => {
8434             Name => 'CameraTemperature', # (maybe SensorTemperature? - heats up when taking movies)
8435             Condition => '$$self{TempTest2} and $$self{TempTest2} < 100',
8436             Format => 'int8s', # have seen as low as -1 for AmbientTemperature of -18
8437             PrintConv => '"$val C"',
8438             PrintConvInv => '$val=~s/ ?C//; $val',
8439             },
8440             # 0x0f - same as 0x05
8441             # 0x18 - maybe another temperature?
8442             );
8443              
8444             # Tag9404 (ref JR)
8445             %Image::ExifTool::Sony::Tag9404a = (
8446             PROCESS_PROC => \&ProcessEnciphered,
8447             WRITE_PROC => \&WriteEnciphered,
8448             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8449             FORMAT => 'int8u',
8450             WRITABLE => 1,
8451             FIRST_ENTRY => 0,
8452             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
8453             0x000b => { %exposureProgram2010 },
8454             0x000d => { Name => 'IntelligentAuto', PrintConv => { 0 => 'Off', 1 => 'On'} },
8455             0x0019 => {
8456             Name => 'LensZoomPosition',
8457             Format => 'int16u',
8458             Condition => '$$self{Model} !~ /^SLT-/',
8459             PrintConv => 'sprintf("%.0f%%",$val/10.24)',
8460             PrintConvInv => '$val=~s/ ?%$//; $val * 10.24',
8461             },
8462             );
8463              
8464             # Tag9404 (ref JR)
8465             %Image::ExifTool::Sony::Tag9404b= (
8466             PROCESS_PROC => \&ProcessEnciphered,
8467             WRITE_PROC => \&WriteEnciphered,
8468             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8469             FORMAT => 'int8u',
8470             WRITABLE => 1,
8471             FIRST_ENTRY => 0,
8472             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
8473             0x000c => { %exposureProgram2010 },
8474             0x000e => { Name => 'IntelligentAuto', PrintConv => { 0 => 'Off', 1 => 'On'} },
8475             0x001e => {
8476             Name => 'LensZoomPosition',
8477             Format => 'int16u',
8478             Condition => '$$self{Model} !~ /^(SLT-|HV|ILCA-)/',
8479             PrintConv => 'sprintf("%.0f%%",$val/10.24)',
8480             PrintConvInv => '$val=~s/ ?%$//; $val * 10.24',
8481             },
8482             0x0020 => {
8483             # seen values from 80 - 255 (= infinity) -- see Composite:FocusDistance2 below
8484             Name => 'FocusPosition2',
8485             Condition => '$$self{Model} =~ /^(SLT-|HV|ILCA-)/',
8486             },
8487             );
8488              
8489             # Tag9404 (ref JR)
8490             %Image::ExifTool::Sony::Tag9404c= (
8491             PROCESS_PROC => \&ProcessEnciphered,
8492             WRITE_PROC => \&WriteEnciphered,
8493             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8494             FORMAT => 'int8u',
8495             WRITABLE => 1,
8496             FIRST_ENTRY => 0,
8497             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
8498             0x000b => { %exposureProgram2010 },
8499             0x000d => { Name => 'IntelligentAuto', PrintConv => { 0 => 'Off', 1 => 'On'} },
8500             );
8501              
8502             # Tag9405 (ref JR)
8503             %Image::ExifTool::Sony::Tag9405a = (
8504             PROCESS_PROC => \&ProcessEnciphered,
8505             WRITE_PROC => \&WriteEnciphered,
8506             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8507             FORMAT => 'int8u',
8508             WRITABLE => 1,
8509             FIRST_ENTRY => 0,
8510             PRIORITY => 0,
8511             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
8512             DATAMEMBER => [ 0x0604 ],
8513             NOTES => 'Valid for SLT, NEX, ILCE-3000/3500 and several DSC models.',
8514             0x0600 => {
8515             Name => 'DistortionCorrParamsPresent',
8516             Condition => '$$self{Model} !~ /^(DSC-|Stellar)/',
8517             PrintConv => { 0 => 'No', 1 => 'Yes'},
8518             },
8519             0x0601 => {
8520             Name => 'DistortionCorrection',
8521             PrintConv => {
8522             0 => 'None',
8523             1 => 'Applied',
8524             },
8525             },
8526             # 0x0602 - same as 0x0604, but has value 3 for SAL18135, SAL50F14Z, SAL55300, SAL70200G2, SAL70300G2, SAL70400G2
8527             0x0603 => {
8528             Name => 'LensFormat',
8529             Condition => '$$self{Model} !~ /^(DSC-|Stellar)/',
8530             PrintConv => {
8531             0 => 'Unknown',
8532             1 => 'APS-C',
8533             2 => 'Full-frame',
8534             },
8535             },
8536             0x0604 => {
8537             Name => 'LensMount',
8538             DataMember => 'LensMount',
8539             RawConv => '$$self{LensMount} = $val; $$self{Model} =~ /^(DSC-|Stellar)/ ? undef : $val',
8540             PrintConv => {
8541             0 => 'Unknown',
8542             1 => 'A-mount',
8543             2 => 'E-mount',
8544             # 6 - seen for A58 panorama image
8545             },
8546             },
8547             0x0605 => {
8548             Name => 'LensType2',
8549             Condition => '$$self{LensMount} == 2',
8550             Format => 'int16u',
8551             Notes => 'E-mount lenses',
8552             SeparateTable => 'LensType2',
8553             PrintConv => \%sonyLensTypes2,
8554             PrintInt => 1,
8555             },
8556             0x0608 => {
8557             Name => 'LensType',
8558             Condition => '$$self{LensMount} == 1',
8559             Format => 'int16u',
8560             Notes => 'A-mount lenses on SLT and NEX',
8561             SeparateTable => 1,
8562             PrintConv => \%sonyLensTypes,
8563             PrintInt => 1,
8564             },
8565             0x064a => {
8566             Name => 'VignettingCorrParams',
8567             Condition => '$$self{Model} !~ /^(DSC-|Stellar)/',
8568             Format => 'int16s[16]',
8569             },
8570             0x066a => {
8571             Name => 'ChromaticAberrationCorrParams',
8572             Condition => '$$self{Model} !~ /^(DSC-|Stellar)/',
8573             Format => 'int16s[32]',
8574             },
8575             0x06ca => {
8576             Name => 'DistortionCorrParams',
8577             Condition => '$$self{Model} !~ /^(DSC-|Stellar)/',
8578             Format => 'int16s[16]',
8579             },
8580             );
8581              
8582             # Tag9405b (ref JR)
8583             %Image::ExifTool::Sony::Tag9405b = (
8584             PROCESS_PROC => \&ProcessEnciphered,
8585             WRITE_PROC => \&WriteEnciphered,
8586             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8587             FORMAT => 'int8u',
8588             WRITABLE => 1,
8589             FIRST_ENTRY => 0,
8590             PRIORITY => 0,
8591             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
8592             DATAMEMBER => [ 0x005e ],
8593             NOTES => q{
8594             Valid for DSC-HX60V/HX80/HX90V/HX99/HX350/HX400V/QX30/RX0/RX10/RX10M2/
8595             RX10M3/RX10M4/RX100M3/RX100M4/RX100M5/RX100M5A/RX100M6/RX100M7/WX220/WX350,
8596             ILCE-7/7M2/7M3/7R/7RM2/7RM3/7RM4/7S/7SM2/9/9M2/5000/5100/6000/6100/6300/
8597             6400/6500/6600/QX1, ILCA-68/77M2/99M2.
8598             },
8599             0x0004 => {
8600             Name => 'SonyISO',
8601             Format => 'int16u',
8602             ValueConv => '100 * 2**(16 - $val/256)',
8603             ValueConvInv => '256 * (16 - log($val/100)/log(2))',
8604             PrintConv => 'sprintf("%.0f",$val)',
8605             PrintConvInv => '$val',
8606             },
8607             0x0006 => {
8608             Name => 'BaseISO',
8609             Format => 'int16u',
8610             ValueConv => '100 * 2**(16 - $val/256)',
8611             ValueConvInv => '256 * (16 - log($val/100)/log(2))',
8612             PrintConv => 'sprintf("%.0f",$val)',
8613             PrintConvInv => '$val',
8614             },
8615             0x000a => { %gain2010 },
8616             0x000e => { # appr. same value as Exif ExposureTime, but shorter in HDR-modes
8617             Name => 'SonyExposureTime2',
8618             Format => 'int16u',
8619             ValueConv => '$val ? 2 ** (16 - $val/256) : 0',
8620             ValueConvInv => '$val ? int((16 - log($val) / log(2)) * 256 + 0.5) : 0',
8621             PrintConv => '$val ? Image::ExifTool::Exif::PrintExposureTime($val) : "Bulb"',
8622             PrintConvInv => 'lc($val) eq "bulb" ? 0 : Image::ExifTool::Exif::ConvertFraction($val)',
8623             },
8624             0x0010 => {
8625             Name => 'ExposureTime',
8626             Format => 'rational32u',
8627             PrintConv => '$val ? Image::ExifTool::Exif::PrintExposureTime($val) : "Bulb"', # (Bulb NC)
8628             PrintConvInv => 'lc($val) eq "bulb" ? 0 : $val',
8629             },
8630             0x0014 => { # but often odd results for DSC models: exclude
8631             # also often deviating results for Sony FE 90mm F2.8 Macro G OSS ...
8632             Name => 'SonyFNumber',
8633             Format => 'int16u',
8634             Condition => '$$self{Model} !~ /^(DSC-|ZV-)/',
8635             ValueConv => '2 ** (($val/256 - 16) / 2)',
8636             ValueConvInv => '(log($val)*2/log(2)+16)*256',
8637             PrintConv => 'sprintf("%.1f",$val)',
8638             PrintConvInv => '$val',
8639             },
8640             0x0016 => {
8641             Name => 'SonyMaxApertureValue', # (at current focal length)
8642             Format => 'int16u',
8643             ValueConv => '2 ** (($val/256 - 16) / 2)',
8644             ValueConvInv => '(log($val)*2/log(2)+16)*256',
8645             PrintConv => 'sprintf("%.1f",$val)',
8646             PrintConvInv => '$val',
8647             },
8648             0x0024 => { %sequenceImageNumber },
8649             0x0034 => { %releaseMode2 },
8650             # 0x003e and 0x0040: maximum image size; ShotInfo gives actual image size
8651             0x003e => { Name => 'SonyImageWidthMax', Format => 'int16u' },
8652             0x0040 => { Name => 'SonyImageHeightMax', Format => 'int16u' },
8653             0x0042 => {
8654             Name => 'HighISONoiseReduction',
8655             PrintConv => {
8656             0 => 'Off',
8657             1 => 'Low',
8658             2 => 'Normal',
8659             3 => 'High',
8660             },
8661             },
8662             0x0044 => {
8663             Name => 'LongExposureNoiseReduction',
8664             PrintConv => {
8665             0 => 'Off',
8666             1 => 'On', # (unused or dark subject)
8667             },
8668             },
8669             0x0046 => { %pictureEffect2010 },
8670             0x0048 => { %exposureProgram2010 },
8671             0x004a => {
8672             Name => 'CreativeStyle',
8673             PrintConv => {
8674             0 => 'Standard',
8675             1 => 'Vivid',
8676             2 => 'Neutral',
8677             3 => 'Portrait',
8678             4 => 'Landscape',
8679             5 => 'B&W',
8680             6 => 'Clear',
8681             7 => 'Deep',
8682             8 => 'Light',
8683             9 => 'Sunset',
8684             10 => 'Night View/Portrait',
8685             11 => 'Autumn Leaves',
8686             13 => 'Sepia',
8687             },
8688             },
8689             0x0052 => {
8690             Name => 'Sharpness',
8691             Format => 'int8s',
8692             PrintConv => '$val > 0 ? "+$val" : $val',
8693             PrintConvInv => '$val',
8694             },
8695             0x005a => {
8696             Name => 'DistortionCorrParamsPresent',
8697             Condition => '$$self{Model} !~ /^DSC-/',
8698             PrintConv => { 0 => 'No', 1 => 'Yes'},
8699             },
8700             0x005b => {
8701             Name => 'DistortionCorrection',
8702             PrintConv => {
8703             0 => 'None',
8704             1 => 'Applied',
8705             },
8706             },
8707             # 0x005c - same as 0x005e, but has value 3 for SAL18135, SAL50F14Z, SAL55300, SAL70200G2, SAL70300G2, SAL70400G2
8708             0x005d => {
8709             Name => 'LensFormat',
8710             Condition => '$$self{Model} !~ /^DSC-/',
8711             PrintConv => {
8712             0 => 'Unknown',
8713             1 => 'APS-C',
8714             2 => 'Full-frame',
8715             },
8716             },
8717             0x005e => {
8718             Name => 'LensMount',
8719             DataMember => 'LensMount',
8720             RawConv => '$$self{LensMount} = $val; $$self{Model} =~ /^DSC-/ ? undef : $val',
8721             PrintConv => {
8722             0 => 'Unknown',
8723             1 => 'A-mount',
8724             2 => 'E-mount',
8725             },
8726             },
8727             0x0060 => {
8728             Name => 'LensType2',
8729             Condition => '$$self{LensMount} == 2',
8730             Format => 'int16u',
8731             Notes => 'E-mount lenses',
8732             SeparateTable => 'LensType2',
8733             PrintConv => \%sonyLensTypes2,
8734             PrintInt => 1,
8735             },
8736             0x0062 => {
8737             Name => 'LensType',
8738             Condition => '$$self{LensMount} == 1',
8739             Format => 'int16u',
8740             Notes => 'A-mount lenses on SLT and NEX',
8741             SeparateTable => 1,
8742             PrintConv => \%sonyLensTypes,
8743             PrintInt => 1,
8744             },
8745             0x0064 => {
8746             Name => 'DistortionCorrParams',
8747             Condition => '$$self{Model} !~ /^DSC-/',
8748             Format => 'int16s[16]',
8749             },
8750             0x0342 => {
8751             Name => 'LensZoomPosition',
8752             Condition => '$$self{Model} !~ /^(ILCA-|ILCE-(7RM2|7M3|7RM3A?|7RM4A?|7SM2|6100|6300|6400|6500|6600|7C|9|9M2)|DSC-(HX80|HX90V|HX99|RX0|RX10M2|RX10M3|RX10M4|RX100M4|RX100M5|RX100M5A|RX100M6|RX100M7|WX500)|ZV-)/',
8753             Format => 'int16u',
8754             PrintConv => 'sprintf("%.0f%%",$val/10.24)',
8755             PrintConvInv => '$val=~s/ ?%$//; $val * 10.24',
8756             },
8757             0x034a => {
8758             Name => 'VignettingCorrParams',
8759             Condition => '$$self{Model} =~ /^(ILCA-(68|77M2)|ILCE-(5000|5100|6000|7|7R|7S|QX1)|Lusso)\b/',
8760             Format => 'int16s[16]',
8761             },
8762             0x034e => {
8763             Name => 'LensZoomPosition',
8764             Condition => '$$self{Model} =~ /^(DSC-(RX100M5|RX100M5A|RX100M6|RX100M7|RX10M4|HX99)|ILCE-(6100|6400|6600|7C|7M3|7RM3A?|7RM4A?|9M2)|ZV-E10)/',
8765             Format => 'int16u',
8766             PrintConv => 'sprintf("%.0f%%",$val/10.24)',
8767             PrintConvInv => '$val=~s/ ?%$//; $val * 10.24',
8768             },
8769             0x0350 => {
8770             Name => 'VignettingCorrParams',
8771             Condition => '$$self{Model} =~ /^(ILCE-7M2)/',
8772             Format => 'int16s[16]',
8773             },
8774             0x035c => {
8775             Name => 'VignettingCorrParams',
8776             Condition => '$$self{Model} =~ /^(ILCA-99M2|ILCE-(6100|6400|6500|6600|7C|7M3|7RM3A?|7RM4A?|9|9M2)|ZV-E10)/',
8777             Format => 'int16s[16]',
8778             },
8779             0x035a => {
8780             Name => 'LensZoomPosition',
8781             Condition => '$$self{Model} =~ /^(ILCE-(7RM2|7SM2)|DSC-(HX80|HX90V|RX10M2|RX10M3|RX100M4|WX500))/',
8782             Format => 'int16u',
8783             PrintConv => 'sprintf("%.0f%%",$val/10.24)',
8784             PrintConvInv => '$val=~s/ ?%$//; $val * 10.24',
8785             },
8786             0x0368 => {
8787             Name => 'VignettingCorrParams',
8788             Condition => '$$self{Model} =~ /^(ILCE-(6300|7RM2|7SM2))/',
8789             Format => 'int16s[16]',
8790             },
8791             0x037c => {
8792             Name => 'ChromaticAberrationCorrParams',
8793             Condition => '$$self{Model} =~ /^(ILCA-(68|77M2)|ILCE-(5000|5100|6000|7|7R|7S|QX1)|Lusso)\b/',
8794             Format => 'int16s[32]',
8795             },
8796             0x0384 => {
8797             Name => 'ChromaticAberrationCorrParams',
8798             Condition => '$$self{Model} =~ /^(ILCE-7M2)/',
8799             Format => 'int16s[32]',
8800             },
8801             0x039c => {
8802             Name => 'ChromaticAberrationCorrParams',
8803             Condition => '$$self{Model} =~ /^(ILCE-(6300|7RM2|7SM2))/',
8804             Format => 'int16s[32]',
8805             },
8806             0x03b0 => {
8807             Name => 'ChromaticAberrationCorrParams',
8808             Condition => '$$self{Model} =~ /^(ILCA-99M2|ILCE-6500)/',
8809             Format => 'int16s[32]',
8810             },
8811             0x03b8 => {
8812             Name => 'ChromaticAberrationCorrParams',
8813             Condition => '$$self{Model} =~ /^(ILCE-(6100|6400|6600|7C|7M3|7RM3A?|7RM4A?|9|9M2)|ZV-E10)/',
8814             Format => 'int16s[32]',
8815             },
8816             );
8817              
8818             # Tag9406 (ref JR)
8819             %Image::ExifTool::Sony::Tag9406 = (
8820             PROCESS_PROC => \&ProcessEnciphered,
8821             WRITE_PROC => \&WriteEnciphered,
8822             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8823             FORMAT => 'int8u',
8824             WRITABLE => 1,
8825             FIRST_ENTRY => 0,
8826             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
8827             # 0x0000: 1 for SLT-A37/A57/A65/A77, NEX-5N/7/F3/VG20
8828             # 2 for SLT-A58/99V, NEX-3N/5R/5T/6/VG30/VG900, ILCA-68/77M2, ILCE-3000/3500/7/7M2/7R/7S/5000/6000
8829             # 3 for ILCA-99M2, ILCE-6100/6300/6400/6500/6600/7M3/7RM2/7RM3/7RM4/7SM2/9/9M2
8830             # 0x0001+0x0002: Int16u, seen 580 - 770: similar to "BatteryUnknown" ??
8831             # 0x0005: int8u, seen 73 - 117: maybe Fahrenheit? Higher than "AmbientTemperature", but same trend.
8832             0x0005 => {
8833             Name => 'BatteryTemperature',
8834             ValueConv => '($val - 32) / 1.8', # convert to Celsius
8835             ValueConvInv => '$val * 1.8 + 32',
8836             PrintConv => 'sprintf("%.1f C",$val)',
8837             PrintConvInv => '$val=~s/\s*C//; $val',
8838             },
8839             # 0x0006: usually 0, seen non-zero values only for SLT-A99V, ILCA-77M2/99M2 and ILCE-7/7R/7RM2/9: BatteryLevel Grip ?
8840             0x0006 => {
8841             Name => 'BatteryLevelGrip1',
8842             RawConv => '$val ? $val : undef', # only valid when not 0
8843             PrintConv => '"$val%"',
8844             PrintConvInv => '$val=~s/\s*\%//; $val',
8845             },
8846             # 0x0007: seen values from 8 - 105, decreasing in sequences of images: BatteryLevel
8847             0x0007 => {
8848             Name => 'BatteryLevel',
8849             PrintConv => '"$val%"',
8850             PrintConvInv => '$val=~s/\s*\%//; $val',
8851             },
8852             # 0x0008: usually 255 or 0 (ILCE-7/7R), seen other values only for A99V and ILCE-7/7R when 0x0006 not 0.
8853             # A99V with grip can have 3 batteries: => Grip 2;
8854             # but ILCE-7/7R with grip can have max 2, and as all ILCE-7/7R samples give >100 values, exclude...
8855             0x0008 => {
8856             Name => 'BatteryLevelGrip2',
8857             Condition => '$$self{Model} !~ /^(ILCE-(7|7R)|Lusso)$/', # not valid for ILCE-7/7R
8858             RawConv => '($val and $val != 255) ? $val : undef', # not valid if 0 or 255
8859             PrintConv => '"$val%"',
8860             PrintConvInv => '$val=~s/\s*\%//; $val',
8861             },
8862             # 0x0009-0x001a: looks like 9 Int16u values
8863             # 0x0022: 0 or 1 for A99, NEX-5R, 6
8864             # 0x0025: 0 or 1 for other SLT and NEX (0x0022, 0x0023, 0x0024 = 255)
8865             );
8866              
8867             # Tag940a (ref PH, decoded mainly from A77)
8868             %Image::ExifTool::Sony::Tag940a = (
8869             PROCESS_PROC => \&ProcessEnciphered,
8870             WRITE_PROC => \&WriteEnciphered,
8871             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8872             FORMAT => 'int8u',
8873             WRITABLE => 1,
8874             FIRST_ENTRY => 0,
8875             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8876             NOTES => 'These tags are currently extracted for SLT models only.',
8877             # 0x00 - 10(A65,A77,NEX-5N,7,VG20E), 11(A37,A57,A99,NEX-5R,6,F3,RX1,RX100),
8878             # 9(HX9V), 4,68,86,110(panoramas) - ref JR
8879             0x04 => {
8880             Name => 'AFPointsSelected',
8881             Format => 'int32u',
8882             PrintConvColumns => 2,
8883             PrintConv => {
8884             # verified for A77 firmware 1.03 and 1.07 and A99 firmware 1.00,
8885             # but there were inconsistencies with my A77 firmware 1.04 samples - PH
8886             0 => '(none)', # ILCA-68/77M2/99M2 always give this
8887             0x00007801 => 'Center Zone',
8888             0x0001821c => 'Right Zone',
8889             0x000605c0 => 'Left Zone',
8890             0x0003ffff => '(all LA-EA4)', # for LA-EA4: 18 bits
8891             0x7fffffff => '(all)', # also for LA-EA2
8892             0xffffffff => 'n/a', # DSC and ILCE/NEX models always give this, except when using LA-EA2 or LA-EA4
8893             # (on Wide AFAreaMode, outer focus points are dropped
8894             # at progressively higher digital zoom ratios, ref JR)
8895             BITMASK => {
8896             0 => 'Center', # (1.04 gave this for Upper-middle and Near Left)
8897             1 => 'Top', # (1.04 didn't give this value)
8898             2 => 'Upper-right', # (1.04 OK)
8899             3 => 'Right', # (1.04 didn't give this value)
8900             4 => 'Lower-right', # (1.04 gave this for Bottom)
8901             5 => 'Bottom', # (1.04 gave this for Lower-middle)
8902             6 => 'Lower-left', # (1.04 gave this for Left and Lower Far Left)
8903             7 => 'Left', # (1.04 gave this for Far Left)
8904             8 => 'Upper-left', # (1.04 OK)
8905             9 => 'Far Right', # (1.04 gave this for Upper Far Right and Right)
8906             10 => 'Far Left', # (1.04 didn't give this value)
8907             11 => 'Upper-middle', # (1.04 gave this for Top)
8908             12 => 'Near Right', # (1.04 gave this for Center)
8909             13 => 'Lower-middle', # (1.04 gave this for Lower-left and Near Right)
8910             14 => 'Near Left', # (1.04 didn't give this value)
8911             15 => 'Upper Far Right',# (1.04 didn't give this value)
8912             16 => 'Lower Far Right',# (1.04 OK, but gave this for Far Right and Lower-right too)
8913             17 => 'Lower Far Left', # (1.04 didn't give this value)
8914             18 => 'Upper Far Left', # (1.04 OK)
8915             # higher bits may be used in panorama images - ref JR
8916             },
8917             },
8918             },
8919             # 0x0a - int16u: 0,1,2,3
8920             # 0xa6 - 8 bytes face detection info ?; starts with 1, otherwise all 0
8921             );
8922              
8923             # Tag940c (ref JR)
8924             %Image::ExifTool::Sony::Tag940c = (
8925             PROCESS_PROC => \&ProcessEnciphered,
8926             WRITE_PROC => \&WriteEnciphered,
8927             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8928             FORMAT => 'int8u',
8929             WRITABLE => 1,
8930             FIRST_ENTRY => 0,
8931             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
8932             DATAMEMBER => [ 0x0008 ],
8933             NOTES => 'E-mount cameras only.',
8934              
8935             # 0x0001 - 0 for all NEX and ILCE-3000/3500, 20 for all other ILCE (17 for ILCE samples from Sony.net)
8936             # 0x0008 - LensMount, but different values from Tag9405-0x0105 and Tag9050-0x0604.
8937             # don't know what difference is between values '1' and '5' ...
8938             0x0008 => {
8939             Name => 'LensMount2', # ? maybe some other meaning ? (A-mount adapter-only images give 0)
8940             RawConv => '$$self{LensMount} = $val',
8941             PrintConv => {
8942             0 => 'Unknown', # LA-EA3 with non-SSM/SAM lens will often give this, not 1 or 5
8943             1 => 'A-mount (1)',
8944             4 => 'E-mount',
8945             5 => 'A-mount (5)',
8946             },
8947             },
8948             # 0x0009 - LensType3:
8949             # This tag appears to also indicate adapter info, similar to CameraSettings3-0x03f7 for the original NEX-3/5.
8950             # (Tag9405-0x0605 and Tag9050-0x0107 LensType2 always give '0' for adapters/A-mount lenses.)
8951             # - seen a few instances of 0x0009 indicating an E-mount lens, but 0xb027 LensType indicating an A-mount lens:
8952             # possibly due to adapter info not being read/reset correctly ?
8953             # August 2015: renamed from LensType2 into Lenstype3 because too often info here relates to previously-mounted-lens
8954             0x0009 => {
8955             Name => 'LensType3',
8956             RawConv => '(($$self{LensMount} != 0) or ($val > 0 and $val < 32784)) ? $val : undef',
8957             Format => 'int16u',
8958             SeparateTable => 'LensType2',
8959             PrintConv => \%sonyLensTypes2,
8960             PrintInt => 1,
8961             },
8962             0x000b => {
8963             Name => 'CameraE-mountVersion',
8964             Format => 'int16u',
8965             PrintConv => 'sprintf("%x.%.2x",$val>>8,$val&0xff)',
8966             PrintConvInv => 'my @a=split(/\./,$val);(hex($a[0])<<8)|hex($a[1])',
8967             # E-mount versions seen for various cameras / camera-firmware versions:
8968             # - : info not present in CameraSettings3 for NEX-3/5/5C/C3/VG10E
8969             # 1.14: NEX-5N/5R/6/7/F3/VG20E/VG30E/VG900 v1.00, NEX-5N v1.01, NEX-3N v0.90
8970             # 1.20: NEX-3N v1.00, NEX-6 v1.01, NEX-7 v1.02, ILCE-3000 v1.00, ILCE-3500 v1.01
8971             # 1.30: NEX-5T v1.00, NEX-6 v1.02/v1.03, NEX-7 v1.03
8972             # 1.31: ILCE-7/7R v0.95/v1.00/v1.01, ILCE-5000
8973             # 1.40: ILCE-7/7R v1.02/v1.10, ILCE-7S v1.00, ILCE-6000 v1.00/v1.10, ILCE-5100/QX1
8974             # 1.50: ILCE-7/7R/7S v1.20-v3.20, ILCE-7M2, ILCE-7RM2 v1.00-v3.00, ILCE-7SM2 v1.00-v2.20,
8975             # ILCE-6000 v1.20-v3.20
8976             # 1.60: ILCE-6300/6500, ILCE-7RM2 v3.05-v4.00
8977             # 1.70: ILCE-7M3/7RM3, ILCE-9 v1.00-v4.10
8978             # 1.80: ILCE-6100/6400/6600/7RM4/9M2, ILCE-9 v5.00-v6.00
8979             },
8980             0x000d => {
8981             Name => 'LensE-mountVersion',
8982             Condition => '$$self{LensMount} != 0',
8983             Format => 'int16u',
8984             PrintConv => 'sprintf("%x.%.2x",$val>>8,$val&0xff)',
8985             PrintConvInv => 'my @a=split(/\./,$val);(hex($a[0])<<8)|hex($a[1])',
8986             # E-mount versions seen for various lens models:
8987             # 0.00: Unknown lenses/adapters
8988             # 1.00: SEL18200LE, Sigma DN, Tamron Di III, Zeiss Touit
8989             # 1.07: (Ver.01) original E-lenses (SEL16F28, SEL18200, SEL1855, SEL24F18Z, SEL30M35, SEL50F18, SEL55210) and LA-EA1
8990             # 1.08: LA-EA1 (Ver.02), Metabones Smart
8991             # 1.14: LA-EA2
8992             # 1.20: (Ver.02) firmware-updated E-lenses (SEL1855, SEL24F18Z, SEL30M35, SEL50F18, SEL55210),
8993             # newer E-lenses (SEL1018, SEL1670Z, SEL20F28, SEL35F18, SELP1650, SELP18105G, SELP18200) or LA-EA3 Ver.01
8994             # 1.30: LA-EA4
8995             # 1.31: original FE-lenses (SEL2470Z, SEL2870, SEL35F28Z, SEL55F18Z), SEL1850
8996             # 1.35: SEL70200G, SEL55210 (Black?, seen with ILCE-3500)
8997             # 1.40: SEL1635Z, SEL24240, SEL35F14Z, SELP28135G, Zeiss Loxia 35mm/50mm Ver.01, Zeiss Touit Ver.02
8998             # 1.41: SELP18105G Ver.02
8999             # 1.50: SEL28F20, SEL90M28G, Zeiss Batis 18mm/25mm/85mm/135mm, Zeiss Loxia 21mm, Zeiss Loxia 35mm/50mm Ver.02,
9000             # Tokina FiRIN 20mm
9001             # 1.60: SEL1224G, SEL1635GM, SEL1655G, SELP18110G, SEL18135, SEL2470GM, SEL24105G, SEL35F18F, SEL50F14Z, SEL50F18F,
9002             # SEL50M28, SEL70200GM, SEL70300G, SEL70350G, SEL85F14GM, SEL85F18, SEL100F28GM, SEL100400GM, SEL135F18GM,
9003             # SEL200600G, SEL600F40GM, Sigma 16F14DCDN/30F14DCDN/35F12DGDN/45F28DGDN, Sigma MC-11, Samyang AF 14mm/50mm,
9004             # Voigtlander 15mm, Viltrox 85mm MF
9005             # 1.70: LA-EA3 Ver.02, Samyang AF 24mm/35mm/85mm, Tamron 17-28mm, 28-75mm, Tokina FiRIN 20mm AF Ver.01, Tokina FiRIN 100mm Macro,
9006             # Voigtlander 10mm/12mm/40mm/65mm, Zeiss Loxia 25mm/85mm, Sigma 14-24mm
9007             # 1.80: Voigtlander 21mm
9008             },
9009             # 0x0014 and 0x0015: change together: LensFirmwareVersion
9010             # 0x0015 as 2-digit hex matches known firmware versions of Sony lenses and Metabones adapters,
9011             # 0x0014 as 3-digit decimal: not confirmed sub-versions
9012             # Some versions as seen with this decoding:
9013             # 00.nnn for several pre-production Sony E-mount lenses
9014             # 01.000 - 01.009 for various Sony E-mount lenses
9015             # 02.nnn, 03.nnn for various Sony E-mount lenses for which a Ver.02 or Ver.03 update is available
9016             # 16.001 for Metabones Speed Booster
9017             # 19/22/24/30/32/41.001 etc. for Metabones Canon EF Smart adapters
9018             0x0014 => {
9019             Name => 'LensFirmwareVersion',
9020             Condition => '$$self{LensMount} != 0',
9021             Format => 'int16u',
9022             PrintConv => 'sprintf("Ver.%.2x.%.3d",$val>>8,$val&0xff)',
9023             },
9024             # 0x0016 - 0x003f: non-0 data present when: 0x0001>0 AND 0x0008=4(E-mount) AND 0x000f<255
9025             );
9026              
9027              
9028             # AFInfo 0x940e (SLT models only) (ref PH, decoded mainly from A77)
9029             %Image::ExifTool::Sony::AFInfo = (
9030             PROCESS_PROC => \&ProcessEnciphered,
9031             WRITE_PROC => \&WriteEnciphered,
9032             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
9033             FORMAT => 'int8u',
9034             WRITABLE => 1,
9035             FIRST_ENTRY => 0,
9036             PRIORITY => 0,
9037             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9038             DATAMEMBER => [ 0x02 ],
9039             IS_SUBDIR => [ 0x11, 0x7d ],
9040             NOTES => 'These tags are currently extracted for SLT models only.',
9041             # first 4 bytes (deciphered) (ref JR):
9042             # 0 1 1 0 for A37, A57, A58
9043             # 2 1 1 0 for A65V
9044             # 2 1 2 0 for A77V
9045             # 0 1 2 0 for A99V
9046             # 1 1 3 0 for ILCA-68/77M2/99M2
9047             # 0 0 0 0 for NEX and ILCE-3000/3500, also seen for SLT/ILCA with non-AF lens
9048             # 1 0 0 0 for ILCE-5000/5100/6000/7/7M2/7R/7S/QX1
9049             # 6 0 0 0 for ILCE-6100/6300/6400/6500/6600/7C/7M3/7RM2/7RM3/7RM4/7SM2/9/9M2
9050             # 9 . . . for ILCE-7SM3
9051             # 11 . . . for ILCE-1
9052             # 0 2 0 0 for NEX/ILCE with LA-EA2/EA4 Phase-AF adapter
9053             # 2 0 0 0 seen for a few NEX-5N images
9054             # 2 2 0 0 seen for a few NEX-5N/7 images with LA-EA2 adapter
9055             0x02 => {
9056             Name => 'AFType',
9057             RawConv => '$$self{AFType} = $val',
9058             PrintConv => {
9059             # 0 => '?? n.a.', # seen on some A99V images with non-AF (Samyang) lens
9060             1 => '15-point',
9061             2 => '19-point',
9062             3 => '79-point', # ILCA-68/77M2/99M2
9063             },
9064             },
9065              
9066             ### decoding for SLT; ILCA-68/77M2/99M2 (AFType == 3) uses different offsets: see below
9067              
9068             0x04 => {
9069             Name => 'AFStatusActiveSensor',
9070             Condition => '$$self{Model} !~ /^ILCA-/',
9071             %Image::ExifTool::Minolta::afStatusInfo,
9072             },
9073             0x07 => [ # the active AF sensor
9074             {
9075             Name => 'AFPoint',
9076             Condition => '$$self{AFType} == 1',
9077             Notes => 'models with 15-point AF',
9078             PrintConvColumns => 2,
9079             PrintConv => \%afPoint15,
9080             },{
9081             Name => 'AFPoint',
9082             Condition => '$$self{AFType} == 2',
9083             Notes => 'models with 19-point AF',
9084             PrintConvColumns => 2,
9085             PrintConv => \%afPoint19,
9086             },
9087             ],
9088             0x08 => [ # the AF sensor in focus at focus time (shutter release half press)
9089             {
9090             Name => 'AFPointInFocus',
9091             Condition => '$$self{AFType} == 1',
9092             Notes => 'models with 15-point AF',
9093             PrintConvColumns => 2,
9094             PrintConv => {
9095             %afPoint15,
9096             255 => '(none)',
9097             },
9098             },{
9099             Name => 'AFPointInFocus',
9100             Condition => '$$self{AFType} == 2',
9101             Notes => 'models with 19-point AF',
9102             PrintConvColumns => 2,
9103             PrintConv => {
9104             %afPoint19,
9105             255 => '(none)',
9106             },
9107             },
9108             ],
9109             0x09 => [ # the AF sensor in focus at shutter release (shutter release full press)
9110             {
9111             Name => 'AFPointAtShutterRelease',
9112             Condition => '$$self{AFType} == 1',
9113             Notes => 'models with 15-point AF',
9114             PrintConvColumns => 2,
9115             PrintConv => {
9116             %afPoint15,
9117             30 => '(out of focus)',
9118             },
9119             },{
9120             Name => 'AFPointAtShutterRelease',
9121             Condition => '$$self{AFType} == 2',
9122             Notes => 'models with 19-point AF',
9123             PrintConvColumns => 2,
9124             PrintConv => {
9125             %afPoint19,
9126             30 => '(out of focus)',
9127             },
9128             },
9129             ],
9130             0x0a => {
9131             Name => 'AFAreaMode',
9132             Condition => '$$self{Model} !~ /^ILCA-/',
9133             PrintConv => {
9134             0 => 'Wide',
9135             1 => 'Spot',
9136             2 => 'Local',
9137             3 => 'Zone',
9138             },
9139             },
9140             0x0b => {
9141             Name => 'FocusMode',
9142             Condition => '$$self{Model} !~ /^ILCA-/',
9143             PrintConvColumns => 2,
9144             # validated for A77 firmware 1.03, 1.04 and 1.07 and A99
9145             # - not confirmed for A37,A57 and A65 which also write this tag
9146             PrintConv => {
9147             0 => 'Manual',
9148             2 => 'AF-S',
9149             3 => 'AF-C',
9150             4 => 'AF-A',
9151             6 => 'DMF',
9152             7 => 'AF-D', # (unique to A99)
9153             },
9154             },
9155             0x11 => [ #JR
9156             {
9157             Name => 'AFStatus15',
9158             Condition => '$$self{AFType} == 1',
9159             Format => 'int16s[18]',
9160             SubDirectory => { TagTable => 'Image::ExifTool::Sony::AFStatus15' },
9161             },{
9162             Name => 'AFStatus19',
9163             Condition => '$$self{AFType} == 2',
9164             Format => 'int16s[30]',
9165             SubDirectory => { TagTable => 'Image::ExifTool::Sony::AFStatus19' },
9166             },
9167             ],
9168             # 0x004d - 18 or 30 int16 values
9169             # 0x0089 - 18 or 30 int16 values
9170             # 0x00b1 - 18 or 30 int16 values
9171             # 0x0121 - 18 or 30 int16s values, similar to 0x11 AFStatus
9172             # 0x016e - SLT: 4 bytes indicating 'AFPointsUsed', identical to first 4 bytes of 0x2020 for A58/A99V
9173             0x016e => {
9174             Name => 'AFPointsUsed',
9175             Condition => '$$self{Model} !~ /^ILCA-/',
9176             Notes => 'SLT models only',
9177             Format => 'int32u',
9178             PrintConvColumns => 2,
9179             PrintConv => {
9180             0 => '(none)',
9181             BITMASK => {
9182             0 => 'Center',
9183             1 => 'Top',
9184             2 => 'Upper-right',
9185             3 => 'Right',
9186             4 => 'Lower-right',
9187             5 => 'Bottom',
9188             6 => 'Lower-left',
9189             7 => 'Left',
9190             8 => 'Upper-left',
9191             9 => 'Far Right',
9192             10 => 'Far Left',
9193             11 => 'Upper-middle',
9194             12 => 'Near Right',
9195             13 => 'Lower-middle',
9196             14 => 'Near Left',
9197             15 => 'Upper Far Right',
9198             16 => 'Lower Far Right',
9199             17 => 'Lower Far Left',
9200             18 => 'Upper Far Left',
9201             },
9202             },
9203             },
9204             # 0x017b: int16s: also has to do with AFMicroAdj: value equals -AFMA * 4 * MaxApertureValue (ref JR)
9205             0x017d => { #PH (verified for the SLT-A77/A99; other SLT models don't have this setting - ref JR)
9206             # (different from AFMicroAdjValue because it is 0 when the adjustment is off)
9207             Name => 'AFMicroAdj',
9208             Condition => '$$self{Model} !~ /^ILCA-/',
9209             Format => 'int8s',
9210             },
9211             0x017e => { #JR
9212             Name => 'ExposureProgram',
9213             Condition => '$$self{Model} !~ /^ILCA-/',
9214             Priority => 0,
9215             SeparateTable => 'ExposureProgram3',
9216             PrintConv => \%sonyExposureProgram3,
9217             },
9218             # 0x01b8 - 65 AF Info blocks of 180 bytes each for SLT (ref JR)
9219             # In each block, the 9th, 10th and 11th byte appear to relate to AFPoint as at offsets 0x07, 0x08, 0x09 above..
9220             # Possibly, these blocks relate to sequential focusing attempts and/or object tracking,
9221             # the first byte being an Index or Counter.
9222             # The last block before the block with index 0, appears to relate to the AF data at ShutterRelease.
9223              
9224             # 0xf38,0x1208,0x14d8,0x158c,0x1640,(and more) - 0 if AFMicroAdj is On, 1 if Off
9225             # 0x1ab6 - 0x80 if AFMicroAdj is On, 0 if Off
9226             # tags also related to AFPoint (PH, A77):
9227             # 0x11ec, 0x122a, 0x1408, 0x1446, 0x14bc, 0x1f86,
9228             # 0x14fa, 0x1570, 0x1572, 0x15ae, 0x1f48
9229              
9230             ### decoding for ILCA-68/77M2/99M2, AFType == 3
9231              
9232             0x0005 => { #JR
9233             Name => 'FocusMode',
9234             Condition => '$$self{Model} =~ /^ILCA-/',
9235             Notes => 'ILCA models only',
9236             Writable => 'int8u',
9237             Priority => 0,
9238             PrintConv => {
9239             0 => 'Manual',
9240             2 => 'AF-S',
9241             3 => 'AF-C',
9242             4 => 'AF-A',
9243             6 => 'DMF',
9244             # 7 => 'AF-D', # not yet seen
9245             },
9246             },
9247             # 0x0010 - for ILCA-68/77M2/99M2: 10 bytes identical to 0x2020, and probably indicating 'AFPointsUsed' (ref JR)
9248             0x0010 => {
9249             Name => 'AFPointsUsed',
9250             Condition => '$$self{Model} =~ /^ILCA-/',
9251             Format => 'int8u[10]',
9252             BitsPerWord => 8,
9253             BitsTotal => 80,
9254             PrintConv => {
9255             0 => '(none)',
9256             BITMASK => { %afPoints79 },
9257             },
9258             },
9259             # 0x0037, 0x0038, 0x0039 similar to 0x07, 0x08, 0x09, but using numbers from 0-94 for ILCA-68/77M2/99M2
9260             0x0037 => { # the active AF sensor
9261             Name => 'AFPoint',
9262             Condition => '$$self{AFType} == 3',
9263             PrintConv => {
9264             %afPoints79_940e,
9265             255 => '(none)',
9266             },
9267             },
9268             0x0038 => { # the AF sensor in focus at focus time (shutter release half press)
9269             Name => 'AFPointInFocus',
9270             Condition => '$$self{AFType} == 3',
9271             PrintConv => {
9272             %afPoints79_940e,
9273             255 => '(none)',
9274             },
9275             },
9276             0x0039 => { # the AF sensor in focus at shutter release (shutter release full press)
9277             Name => 'AFPointAtShutterRelease',
9278             Condition => '$$self{AFType} == 3',
9279             PrintConv => {
9280             %afPoints79_940e,
9281             95 => '(none)',
9282             },
9283             },
9284             0x003a => { #JR
9285             Name => 'AFAreaMode',
9286             Condition => '$$self{Model} =~ /^ILCA-/',
9287             PrintConv => {
9288             0 => 'Wide',
9289             1 => 'Center',
9290             2 => 'Flexible Spot',
9291             3 => 'Zone',
9292             4 => 'Expanded Flexible Spot', #(NC)
9293             },
9294             },
9295             0x003b => {
9296             Name => 'AFStatusActiveSensor',
9297             Condition => '$$self{Model} =~ /^ILCA-/',
9298             %Image::ExifTool::Minolta::afStatusInfo,
9299             },
9300             0x0043 => {
9301             Name => 'ExposureProgram',
9302             Condition => '$$self{Model} =~ /^ILCA-/',
9303             Priority => 0,
9304             SeparateTable => 'ExposureProgram3',
9305             PrintConv => \%sonyExposureProgram3,
9306             },
9307             # 0x004e: int16s: also has to do with AFMicroAdj: value equals -AFMA * 4 * MaxApertureValue (ref JR)
9308             0x0050 => { #PH (ILCA-A77M2, to be confirmed for other ILCA models)
9309             Name => 'AFMicroAdj',
9310             Condition => '$$self{Model} =~ /^ILCA-/',
9311             Format => 'int8s',
9312             },
9313             # 0x007d - AFStatus79 - 95 int16s values for the ILCA-68/77M2/99M2: 79 AF points + 15 cross + 1 F2.8
9314             0x007d => {
9315             Name => 'AFStatus79',
9316             Condition => '$$self{AFType} == 3',
9317             Format => 'int16s[95]',
9318             SubDirectory => { TagTable => 'Image::ExifTool::Sony::AFStatus79' },
9319             },
9320             # 0x013b - 95 int8u values
9321             # 0x01ab - 95 int8u values
9322             # 0x021b - 95 int16s values, similar to 0x007d AFStatus79, but not sure if this is valid for ILCA-99M2
9323             # 0x04c0 - 45 AF Info blocks of 244 bytes each for ILCA-68/77M2
9324             # 0x12a0 - 30 AF Info blocks of 244 bytes each for ILCA-99M2
9325             );
9326              
9327             %Image::ExifTool::Sony::Tag940e = ( #JR
9328             PROCESS_PROC => \&ProcessEnciphered,
9329             WRITE_PROC => \&WriteEnciphered,
9330             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
9331             FORMAT => 'int8u',
9332             FIRST_ENTRY => 0,
9333             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
9334             NOTES => 'E-mount models.',
9335              
9336             # (see comment in AFInfo for deciphered values of first 4 bytes for various models)
9337              
9338             # 0x0004 - if 0x0001 == 2: LA-EA2/EA4 15-point SLT Phase-detect AF adapter used:
9339             # start of 164-byte AF Info Blocks, possibly the 11th byte might be the AFPoint.
9340             # ILCE-7M2/7RM2/7SM2: 40 Blocks of 164 bytes
9341             # other NEX/ILCE: 74 blocks of 164 bytes
9342              
9343             # 0x1a06 onwards - first seen for ILCE-7RM2: appears to be some kind of metering image
9344             # but not valid anymore for ILCE-6400, ILCE-9 v5.0x
9345             0x1a06 => { Name => 'TiffMeteringImageWidth', Condition => '$$self{Model} =~ /^(ILCE-(6300|6500|7M3|7RM2|7RM3A?|7SM2|9))\b/ and $$self{Software} !~ /^ILCE-9 (v5.0|v6.0)/' },
9346             0x1a07 => { Name => 'TiffMeteringImageHeight', Condition => '$$self{Model} =~ /^(ILCE-(6300|6500|7M3|7RM2|7RM3A?|7SM2|9))\b/ and $$self{Software} !~ /^ILCE-9 (v5.0|v6.0)/' },
9347             0x1a08 => { # (2640 bytes: 1 set of 44x30 int16u values)
9348             Name => 'TiffMeteringImage',
9349             Condition => '$$self{Model} =~ /^(ILCE-(6300|6500|7M3|7RM2|7RM3A?|7SM2|9))\b/ and $$self{Software} !~ /^ILCE-9 (v5.0|v6.0)/',
9350             Format => 'undef[2640]',
9351             Notes => q{
9352             13(?)-bit intensity data from 1320 (1200) metering segments, extracted as a
9353             16-bit TIFF image
9354             },
9355             ValueConv => sub {
9356             my ($val, $et) = @_;
9357             return undef unless length $val >= 2640;
9358             return \ "Binary data 2640 bytes" unless $et->Options('Binary');
9359             my @dat = unpack('v*', $val);
9360             # TIFF header for a 16-bit RGB 10dpi 44x30 image
9361             $val = Image::ExifTool::MakeTiffHeader(44,30,3,16,10);
9362             # re-order data to RGB pixels - use same value for R, G and B
9363             my ($i, @val);
9364             for ($i=0; $i<44*30; ++$i) {
9365             # data is 13-bit (max 8191), shift left to fill 16 bits
9366             push @val, int(5041.1*log($dat[$i]+1)/log(2)), int(5041.1*log($dat[$i]+1)/log(2)), int(5041.1*log($dat[$i]+1)/log(2));
9367             }
9368             $val .= pack('v*', @val); # add TIFF strip data
9369             return \$val;
9370             },
9371             },
9372             );
9373              
9374             # AF Point Status (ref JR)
9375             %Image::ExifTool::Sony::AFStatus15 = (
9376             %binaryDataAttrs,
9377             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9378             NOTES => 'AF Status information for models with 15-point AF.',
9379             0x00 => { Name => 'AFStatusUpper-left', %Image::ExifTool::Minolta::afStatusInfo },
9380             0x02 => { Name => 'AFStatusLeft', %Image::ExifTool::Minolta::afStatusInfo },
9381             0x04 => { Name => 'AFStatusLower-left', %Image::ExifTool::Minolta::afStatusInfo },
9382             0x06 => { Name => 'AFStatusFarLeft', %Image::ExifTool::Minolta::afStatusInfo },
9383             0x08 => { Name => 'AFStatusTopHorizontal', %Image::ExifTool::Minolta::afStatusInfo },
9384             0x0a => { Name => 'AFStatusNearRight', %Image::ExifTool::Minolta::afStatusInfo },
9385             0x0c => { Name => 'AFStatusCenterHorizontal', %Image::ExifTool::Minolta::afStatusInfo },
9386             0x0e => { Name => 'AFStatusNearLeft', %Image::ExifTool::Minolta::afStatusInfo },
9387             0x10 => { Name => 'AFStatusBottomHorizontal', %Image::ExifTool::Minolta::afStatusInfo },
9388             0x12 => { Name => 'AFStatusTopVertical', %Image::ExifTool::Minolta::afStatusInfo },
9389             0x14 => { Name => 'AFStatusCenterVertical', %Image::ExifTool::Minolta::afStatusInfo },
9390             0x16 => { Name => 'AFStatusBottomVertical', %Image::ExifTool::Minolta::afStatusInfo },
9391             0x18 => { Name => 'AFStatusFarRight', %Image::ExifTool::Minolta::afStatusInfo },
9392             0x1a => { Name => 'AFStatusUpper-right', %Image::ExifTool::Minolta::afStatusInfo },
9393             0x1c => { Name => 'AFStatusRight', %Image::ExifTool::Minolta::afStatusInfo },
9394             0x1e => { Name => 'AFStatusLower-right', %Image::ExifTool::Minolta::afStatusInfo },
9395             0x20 => { Name => 'AFStatusUpper-middle', %Image::ExifTool::Minolta::afStatusInfo },
9396             0x22 => { Name => 'AFStatusLower-middle', %Image::ExifTool::Minolta::afStatusInfo },
9397             );
9398              
9399             # AF Point Status (ref JR)
9400             %Image::ExifTool::Sony::AFStatus19 = (
9401             %binaryDataAttrs,
9402             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9403             NOTES => 'AF Status information for models with 19-point AF.',
9404             0x00 => { Name => 'AFStatusUpperFarLeft', %Image::ExifTool::Minolta::afStatusInfo },
9405             0x02 => { Name => 'AFStatusUpper-leftHorizontal', %Image::ExifTool::Minolta::afStatusInfo },
9406             0x04 => { Name => 'AFStatusFarLeftHorizontal', %Image::ExifTool::Minolta::afStatusInfo },
9407             0x06 => { Name => 'AFStatusLeftHorizontal', %Image::ExifTool::Minolta::afStatusInfo },
9408             0x08 => { Name => 'AFStatusLowerFarLeft', %Image::ExifTool::Minolta::afStatusInfo },
9409             0x0a => { Name => 'AFStatusLower-leftHorizontal', %Image::ExifTool::Minolta::afStatusInfo },
9410             0x0c => { Name => 'AFStatusUpper-leftVertical', %Image::ExifTool::Minolta::afStatusInfo },
9411             0x0e => { Name => 'AFStatusLeftVertical', %Image::ExifTool::Minolta::afStatusInfo },
9412             0x10 => { Name => 'AFStatusLower-leftVertical', %Image::ExifTool::Minolta::afStatusInfo },
9413             0x12 => { Name => 'AFStatusFarLeftVertical', %Image::ExifTool::Minolta::afStatusInfo },
9414             0x14 => { Name => 'AFStatusTopHorizontal', %Image::ExifTool::Minolta::afStatusInfo },
9415             0x16 => { Name => 'AFStatusNearRight', %Image::ExifTool::Minolta::afStatusInfo },
9416             0x18 => { Name => 'AFStatusCenterHorizontal', %Image::ExifTool::Minolta::afStatusInfo },
9417             0x1a => { Name => 'AFStatusNearLeft', %Image::ExifTool::Minolta::afStatusInfo },
9418             0x1c => { Name => 'AFStatusBottomHorizontal', %Image::ExifTool::Minolta::afStatusInfo },
9419             0x1e => { Name => 'AFStatusTopVertical', %Image::ExifTool::Minolta::afStatusInfo },
9420             0x20 => { Name => 'AFStatusUpper-middle', %Image::ExifTool::Minolta::afStatusInfo },
9421             0x22 => { Name => 'AFStatusCenterVertical', %Image::ExifTool::Minolta::afStatusInfo },
9422             0x24 => { Name => 'AFStatusLower-middle', %Image::ExifTool::Minolta::afStatusInfo },
9423             0x26 => { Name => 'AFStatusBottomVertical', %Image::ExifTool::Minolta::afStatusInfo },
9424             0x28 => { Name => 'AFStatusUpperFarRight', %Image::ExifTool::Minolta::afStatusInfo },
9425             0x2a => { Name => 'AFStatusUpper-rightHorizontal',%Image::ExifTool::Minolta::afStatusInfo },
9426             0x2c => { Name => 'AFStatusFarRightHorizontal', %Image::ExifTool::Minolta::afStatusInfo },
9427             0x2e => { Name => 'AFStatusRightHorizontal', %Image::ExifTool::Minolta::afStatusInfo },
9428             0x30 => { Name => 'AFStatusLowerFarRight', %Image::ExifTool::Minolta::afStatusInfo },
9429             0x32 => { Name => 'AFStatusLower-rightHorizontal',%Image::ExifTool::Minolta::afStatusInfo },
9430             0x34 => { Name => 'AFStatusFarRightVertical', %Image::ExifTool::Minolta::afStatusInfo },
9431             0x36 => { Name => 'AFStatusUpper-rightVertical', %Image::ExifTool::Minolta::afStatusInfo },
9432             0x38 => { Name => 'AFStatusRightVertical', %Image::ExifTool::Minolta::afStatusInfo },
9433             0x3a => { Name => 'AFStatusLower-rightVertical', %Image::ExifTool::Minolta::afStatusInfo },
9434             );
9435              
9436             # AF Point Status (ref JR)
9437             %Image::ExifTool::Sony::AFStatus79 = (
9438             %binaryDataAttrs,
9439             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9440             NOTES => 'AF Status information for models with 79-point AF.',
9441             #
9442             # ILCA-68/77M2 AF sensor layout:
9443             # A5* A6* A7*
9444             # B2 B3 B4 B5 B6 B7 B8 B9 B10
9445             # C1 C2 C3 C4 C5* C6* C7* C8 C9 C10 C11
9446             # D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11
9447             # E1 E2 E3 E4 E5* E6* E7* E8 E9 E10 E11
9448             # F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11
9449             # G1 G2 G3 G4 G5* G6* G7* G8 G9 G10 G11
9450             # H2 H3 H4 H5 H6 H7 H8 H9 H10
9451             # I5* I6* I7*
9452             # left section, from top to bottom, from right to left
9453             0x00 => { Name => 'AFStatus_00_B4', %Image::ExifTool::Minolta::afStatusInfo },
9454             0x02 => { Name => 'AFStatus_01_C4', %Image::ExifTool::Minolta::afStatusInfo },
9455             0x04 => { Name => 'AFStatus_02_D4', %Image::ExifTool::Minolta::afStatusInfo },
9456             0x06 => { Name => 'AFStatus_03_E4', %Image::ExifTool::Minolta::afStatusInfo },
9457             0x08 => { Name => 'AFStatus_04_F4', %Image::ExifTool::Minolta::afStatusInfo },
9458             0x0a => { Name => 'AFStatus_05_G4', %Image::ExifTool::Minolta::afStatusInfo },
9459             0x0c => { Name => 'AFStatus_06_H4', %Image::ExifTool::Minolta::afStatusInfo },
9460             0x0e => { Name => 'AFStatus_07_B3', %Image::ExifTool::Minolta::afStatusInfo },
9461             0x10 => { Name => 'AFStatus_08_C3', %Image::ExifTool::Minolta::afStatusInfo },
9462             0x12 => { Name => 'AFStatus_09_D3', %Image::ExifTool::Minolta::afStatusInfo },
9463             0x14 => { Name => 'AFStatus_10_E3', %Image::ExifTool::Minolta::afStatusInfo },
9464             0x16 => { Name => 'AFStatus_11_F3', %Image::ExifTool::Minolta::afStatusInfo },
9465             0x18 => { Name => 'AFStatus_12_G3', %Image::ExifTool::Minolta::afStatusInfo },
9466             0x1a => { Name => 'AFStatus_13_H3', %Image::ExifTool::Minolta::afStatusInfo },
9467             0x1c => { Name => 'AFStatus_14_B2', %Image::ExifTool::Minolta::afStatusInfo },
9468             0x1e => { Name => 'AFStatus_15_C2', %Image::ExifTool::Minolta::afStatusInfo },
9469             0x20 => { Name => 'AFStatus_16_D2', %Image::ExifTool::Minolta::afStatusInfo },
9470             0x22 => { Name => 'AFStatus_17_E2', %Image::ExifTool::Minolta::afStatusInfo },
9471             0x24 => { Name => 'AFStatus_18_F2', %Image::ExifTool::Minolta::afStatusInfo },
9472             0x26 => { Name => 'AFStatus_19_G2', %Image::ExifTool::Minolta::afStatusInfo },
9473             0x28 => { Name => 'AFStatus_20_H2', %Image::ExifTool::Minolta::afStatusInfo },
9474             0x2a => { Name => 'AFStatus_21_C1', %Image::ExifTool::Minolta::afStatusInfo },
9475             0x2c => { Name => 'AFStatus_22_D1', %Image::ExifTool::Minolta::afStatusInfo },
9476             0x2e => { Name => 'AFStatus_23_E1', %Image::ExifTool::Minolta::afStatusInfo },
9477             0x30 => { Name => 'AFStatus_24_F1', %Image::ExifTool::Minolta::afStatusInfo },
9478             0x32 => { Name => 'AFStatus_25_G1', %Image::ExifTool::Minolta::afStatusInfo },
9479             # center section, cross-sensors *, from right to left, from top to bottom
9480             # These are presumably Vertical, as all others are default Horizontal (ref Sony ILCA-77M2 brochure).
9481             0x34 => { Name => 'AFStatus_26_A7_Vertical', %Image::ExifTool::Minolta::afStatusInfo },
9482             0x36 => { Name => 'AFStatus_27_A6_Vertical', %Image::ExifTool::Minolta::afStatusInfo },
9483             0x38 => { Name => 'AFStatus_28_A5_Vertical', %Image::ExifTool::Minolta::afStatusInfo },
9484             0x3a => { Name => 'AFStatus_29_C7_Vertical', %Image::ExifTool::Minolta::afStatusInfo },
9485             0x3c => { Name => 'AFStatus_30_C6_Vertical', %Image::ExifTool::Minolta::afStatusInfo },
9486             0x3e => { Name => 'AFStatus_31_C5_Vertical', %Image::ExifTool::Minolta::afStatusInfo },
9487             0x40 => { Name => 'AFStatus_32_E7_Vertical', %Image::ExifTool::Minolta::afStatusInfo },
9488             0x42 => { Name => 'AFStatus_33_E6_Center_Vertical', %Image::ExifTool::Minolta::afStatusInfo },
9489             0x44 => { Name => 'AFStatus_34_E5_Vertical', %Image::ExifTool::Minolta::afStatusInfo },
9490             0x46 => { Name => 'AFStatus_35_G7_Vertical', %Image::ExifTool::Minolta::afStatusInfo },
9491             0x48 => { Name => 'AFStatus_36_G6_Vertical', %Image::ExifTool::Minolta::afStatusInfo },
9492             0x4a => { Name => 'AFStatus_37_G5_Vertical', %Image::ExifTool::Minolta::afStatusInfo },
9493             0x4c => { Name => 'AFStatus_38_I7_Vertical', %Image::ExifTool::Minolta::afStatusInfo },
9494             0x4e => { Name => 'AFStatus_39_I6_Vertical', %Image::ExifTool::Minolta::afStatusInfo },
9495             0x50 => { Name => 'AFStatus_40_I5_Vertical', %Image::ExifTool::Minolta::afStatusInfo },
9496             # center section, all sensors, from top to bottom, from right to left
9497             0x52 => { Name => 'AFStatus_41_A7', %Image::ExifTool::Minolta::afStatusInfo },
9498             0x54 => { Name => 'AFStatus_42_B7', %Image::ExifTool::Minolta::afStatusInfo },
9499             0x56 => { Name => 'AFStatus_43_C7', %Image::ExifTool::Minolta::afStatusInfo },
9500             0x58 => { Name => 'AFStatus_44_D7', %Image::ExifTool::Minolta::afStatusInfo },
9501             0x5a => { Name => 'AFStatus_45_E7', %Image::ExifTool::Minolta::afStatusInfo },
9502             0x5c => { Name => 'AFStatus_46_F7', %Image::ExifTool::Minolta::afStatusInfo },
9503             0x5e => { Name => 'AFStatus_47_G7', %Image::ExifTool::Minolta::afStatusInfo },
9504             0x60 => { Name => 'AFStatus_48_H7', %Image::ExifTool::Minolta::afStatusInfo },
9505             0x62 => { Name => 'AFStatus_49_I7', %Image::ExifTool::Minolta::afStatusInfo },
9506             0x64 => { Name => 'AFStatus_50_A6', %Image::ExifTool::Minolta::afStatusInfo },
9507             0x66 => { Name => 'AFStatus_51_B6', %Image::ExifTool::Minolta::afStatusInfo },
9508             0x68 => { Name => 'AFStatus_52_C6', %Image::ExifTool::Minolta::afStatusInfo },
9509             0x6a => { Name => 'AFStatus_53_D6', %Image::ExifTool::Minolta::afStatusInfo },
9510             0x6c => { Name => 'AFStatus_54_E6_Center', %Image::ExifTool::Minolta::afStatusInfo },
9511             0x6e => { Name => 'AFStatus_55_F6', %Image::ExifTool::Minolta::afStatusInfo },
9512             0x70 => { Name => 'AFStatus_56_G6', %Image::ExifTool::Minolta::afStatusInfo },
9513             0x72 => { Name => 'AFStatus_57_H6', %Image::ExifTool::Minolta::afStatusInfo },
9514             0x74 => { Name => 'AFStatus_58_I6', %Image::ExifTool::Minolta::afStatusInfo },
9515             0x76 => { Name => 'AFStatus_59_A5', %Image::ExifTool::Minolta::afStatusInfo },
9516             0x78 => { Name => 'AFStatus_60_B5', %Image::ExifTool::Minolta::afStatusInfo },
9517             0x7a => { Name => 'AFStatus_61_C5', %Image::ExifTool::Minolta::afStatusInfo },
9518             0x7c => { Name => 'AFStatus_62_D5', %Image::ExifTool::Minolta::afStatusInfo },
9519             0x7e => { Name => 'AFStatus_63_E5', %Image::ExifTool::Minolta::afStatusInfo },
9520             0x80 => { Name => 'AFStatus_64_F5', %Image::ExifTool::Minolta::afStatusInfo },
9521             0x82 => { Name => 'AFStatus_65_G5', %Image::ExifTool::Minolta::afStatusInfo },
9522             0x84 => { Name => 'AFStatus_66_H5', %Image::ExifTool::Minolta::afStatusInfo },
9523             0x86 => { Name => 'AFStatus_67_I5', %Image::ExifTool::Minolta::afStatusInfo },
9524             # right section, from top to bottom, from right to left
9525             0x88 => { Name => 'AFStatus_68_C11', %Image::ExifTool::Minolta::afStatusInfo },
9526             0x8a => { Name => 'AFStatus_69_D11', %Image::ExifTool::Minolta::afStatusInfo },
9527             0x8c => { Name => 'AFStatus_70_E11', %Image::ExifTool::Minolta::afStatusInfo },
9528             0x8e => { Name => 'AFStatus_71_F11', %Image::ExifTool::Minolta::afStatusInfo },
9529             0x90 => { Name => 'AFStatus_72_G11', %Image::ExifTool::Minolta::afStatusInfo },
9530             0x92 => { Name => 'AFStatus_73_B10', %Image::ExifTool::Minolta::afStatusInfo },
9531             0x94 => { Name => 'AFStatus_74_C10', %Image::ExifTool::Minolta::afStatusInfo },
9532             0x96 => { Name => 'AFStatus_75_D10', %Image::ExifTool::Minolta::afStatusInfo },
9533             0x98 => { Name => 'AFStatus_76_E10', %Image::ExifTool::Minolta::afStatusInfo },
9534             0x9a => { Name => 'AFStatus_77_F10', %Image::ExifTool::Minolta::afStatusInfo },
9535             0x9c => { Name => 'AFStatus_78_G10', %Image::ExifTool::Minolta::afStatusInfo },
9536             0x9e => { Name => 'AFStatus_79_H10', %Image::ExifTool::Minolta::afStatusInfo },
9537             0xa0 => { Name => 'AFStatus_80_B9', %Image::ExifTool::Minolta::afStatusInfo },
9538             0xa2 => { Name => 'AFStatus_81_C9', %Image::ExifTool::Minolta::afStatusInfo },
9539             0xa4 => { Name => 'AFStatus_82_D9', %Image::ExifTool::Minolta::afStatusInfo },
9540             0xa6 => { Name => 'AFStatus_83_E9', %Image::ExifTool::Minolta::afStatusInfo },
9541             0xa8 => { Name => 'AFStatus_84_F9', %Image::ExifTool::Minolta::afStatusInfo },
9542             0xaa => { Name => 'AFStatus_85_G9', %Image::ExifTool::Minolta::afStatusInfo },
9543             0xac => { Name => 'AFStatus_86_H9', %Image::ExifTool::Minolta::afStatusInfo },
9544             0xae => { Name => 'AFStatus_87_B8', %Image::ExifTool::Minolta::afStatusInfo },
9545             0xb0 => { Name => 'AFStatus_88_C8', %Image::ExifTool::Minolta::afStatusInfo },
9546             0xb2 => { Name => 'AFStatus_89_D8', %Image::ExifTool::Minolta::afStatusInfo },
9547             0xb4 => { Name => 'AFStatus_90_E8', %Image::ExifTool::Minolta::afStatusInfo },
9548             0xb6 => { Name => 'AFStatus_91_F8', %Image::ExifTool::Minolta::afStatusInfo },
9549             0xb8 => { Name => 'AFStatus_92_G8', %Image::ExifTool::Minolta::afStatusInfo },
9550             0xba => { Name => 'AFStatus_93_H8', %Image::ExifTool::Minolta::afStatusInfo },
9551             # central F2.8 sensor
9552             0xbc => { Name => 'AFStatus_94_E6_Center_F2-8', %Image::ExifTool::Minolta::afStatusInfo },
9553             );
9554              
9555             # tag 0x9416 decoding (ref JR)
9556             %Image::ExifTool::Sony::Tag9416 = (
9557             PROCESS_PROC => \&ProcessEnciphered,
9558             WRITE_PROC => \&WriteEnciphered,
9559             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
9560             FORMAT => 'int8u',
9561             NOTES => 'Valid for the ILCE-1/7M4/7RM5/7SM3, ILME-FX3.',
9562             FIRST_ENTRY => 0,
9563             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
9564             0x0000 => { Name => 'Tag9416_0000', PrintConv => 'sprintf("%3d",$val)', RawConv => '$$self{TagVersion} = $val' },
9565             0x0004 => {
9566             Name => 'SonyISO',
9567             Format => 'int16u',
9568             ValueConv => '100 * 2**(16 - $val/256)',
9569             ValueConvInv => '256 * (16 - log($val/100)/log(2))',
9570             PrintConv => 'sprintf("%.0f",$val)',
9571             PrintConvInv => '$val',
9572             },
9573             0x0006 => { %gain2010 },
9574             0x000a => { # appr. same value as Exif ExposureTime, but shorter in HDR-modes
9575             Name => 'SonyExposureTime2',
9576             Format => 'int16u',
9577             ValueConv => '$val ? 2 ** (16 - $val/256) : 0',
9578             ValueConvInv => '$val ? int((16 - log($val) / log(2)) * 256 + 0.5) : 0',
9579             PrintConv => '$val ? Image::ExifTool::Exif::PrintExposureTime($val) : "Bulb"',
9580             PrintConvInv => 'lc($val) eq "bulb" ? 0 : Image::ExifTool::Exif::ConvertFraction($val)',
9581             },
9582             0x000c => {
9583             Name => 'ExposureTime',
9584             Format => 'rational32u',
9585             PrintConv => '$val ? Image::ExifTool::Exif::PrintExposureTime($val) : "Bulb"', # (Bulb NC)
9586             PrintConvInv => 'lc($val) eq "bulb" ? 0 : $val',
9587             },
9588             0x0010 => { # but sometimes deviating results
9589             Name => 'SonyFNumber2',
9590             Format => 'int16u',
9591             ValueConv => '2 ** (($val/256 - 16) / 2)',
9592             ValueConvInv => '(log($val)*2/log(2)+16)*256',
9593             PrintConv => 'sprintf("%.1f",$val)',
9594             PrintConvInv => '$val',
9595             },
9596             0x0012 => {
9597             Name => 'SonyMaxApertureValue', # (at current focal length)
9598             Format => 'int16u',
9599             ValueConv => '2 ** (($val/256 - 16) / 2)',
9600             ValueConvInv => '(log($val)*2/log(2)+16)*256',
9601             PrintConv => 'sprintf("%.1f",$val)',
9602             PrintConvInv => '$val',
9603             },
9604             0x001d => { %sequenceImageNumber },
9605             0x0035 => {
9606             Name => 'ExposureProgram',
9607             Priority => 0,
9608             SeparateTable => 'ExposureProgram3',
9609             PrintConv => \%sonyExposureProgram3,
9610             },
9611             0x0048 => {
9612             Name => 'LensMount',
9613             Condition => '$$self{Model} !~ /^(DSC-)/',
9614             PrintConv => {
9615             0 => 'Unknown',
9616             1 => 'A-mount',
9617             2 => 'E-mount',
9618             3 => 'A-mount (3)',
9619             },
9620             },
9621             0x0049 => {
9622             Name => 'LensFormat',
9623             Condition => '$$self{Model} !~ /^(DSC-)/',
9624             PrintConv => {
9625             0 => 'Unknown',
9626             1 => 'APS-C',
9627             2 => 'Full-frame',
9628             },
9629             },
9630             0x004a => {
9631             Name => 'LensMount',
9632             DataMember => 'LensMount',
9633             RawConv => '$$self{LensMount} = $val; $$self{Model} =~ /^(DSC-)/ ? undef : $val',
9634             PrintConv => {
9635             0 => 'Unknown',
9636             1 => 'A-mount',
9637             2 => 'E-mount',
9638             },
9639             },
9640             0x004b => {
9641             Name => 'LensType2',
9642             Condition => '$$self{LensMount} == 2',
9643             Format => 'int16u',
9644             SeparateTable => 'LensType2',
9645             PrintConv => \%sonyLensTypes2,
9646             PrintInt => 1,
9647             },
9648             0x004d => {
9649             Name => 'LensType',
9650             Condition => '$$self{LensMount} == 1',
9651             Priority => 0, #PH (just to be safe)
9652             Format => 'int16u', #PH
9653             SeparateTable => 1,
9654             ValueConvInv => '($val & 0xff00) == 0x8000 ? 0 : int($val)',
9655             PrintConv => \%sonyLensTypes,
9656             PrintInt => 1,
9657             },
9658             0x004f => {
9659             Name => 'DistortionCorrParams',
9660             Format => 'int16s[16]',
9661             },
9662             0x0070 => { %pictureProfile2010 }, #IB
9663             0x0071 => {
9664             Name => 'FocalLength',
9665             Format => 'int16u',
9666             ValueConv => '$val / 10',
9667             ValueConvInv => '$val * 10',
9668             PrintConv => 'sprintf("%.1f mm",$val)',
9669             PrintConvInv => '$val =~ s/ ?mm//; $val',
9670             },
9671             0x0073 => {
9672             Name => 'MinFocalLength',
9673             Format => 'int16u',
9674             ValueConv => '$val / 10',
9675             ValueConvInv => '$val * 10',
9676             PrintConv => 'sprintf("%.1f mm",$val)',
9677             PrintConvInv => '$val =~ s/ ?mm//; $val',
9678             },
9679             0x0075 => { # may give 0 for fixed focal length lenses
9680             Name => 'MaxFocalLength',
9681             Format => 'int16u',
9682             RawConv => '$val || undef',
9683             ValueConv => '$val / 10',
9684             ValueConvInv => '$val * 10',
9685             PrintConv => 'sprintf("%.1f mm",$val)',
9686             PrintConvInv => '$val =~ s/ ?mm//; $val',
9687             },
9688             0x088f => {
9689             Name => 'VignettingCorrParams',
9690             Condition => '$$self{Model} =~ /^(ILCE-(1|7SM3)|ILME-FX3)\b/',
9691             Format => 'int16s[16]',
9692             },
9693             0x0891 => {
9694             Name => 'VignettingCorrParams',
9695             Condition => '$$self{Model} =~ /^(ILCE-7M4)/',
9696             Format => 'int16s[16]',
9697             },
9698             0x089b => {
9699             Name => 'VignettingCorrParams',
9700             Condition => '$$self{Model} =~ /^(ILCE-7RM5|ILME-FX30)\b/',
9701             Format => 'int16s[16]',
9702             },
9703             0x0914 => {
9704             Name => 'ChromaticAberrationCorrParams',
9705             Condition => '$$self{Model} =~ /^(ILCE-(1|7SM3)|ILME-FX3)\b/',
9706             Format => 'int16s[32]',
9707             },
9708             0x0916 => {
9709             Name => 'ChromaticAberrationCorrParams',
9710             Condition => '$$self{Model} =~ /^(ILCE-7M4)/',
9711             Format => 'int16s[32]',
9712             },
9713             0x0945 => {
9714             Name => 'ChromaticAberrationCorrParams',
9715             Condition => '$$self{Model} =~ /^(ILCE-7RM5|ILME-FX30)\b/',
9716             Format => 'int16s[32]',
9717             },
9718             );
9719              
9720             %Image::ExifTool::Sony::FaceInfo1 = (
9721             %binaryDataAttrs,
9722             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
9723             0x00 => {
9724             Name => 'Face1Position',
9725             Format => 'int16u[4]',
9726             Notes => q{
9727             top, left, height and width of detected face. Coordinates are relative to
9728             the full-sized unrotated image, with increasing Y downwards
9729             },
9730             RawConv => '$$self{FacesDetected} < 1 ? undef : $val',
9731             },
9732             0x20 => {
9733             Name => 'Face2Position',
9734             Format => 'int16u[4]',
9735             RawConv => '$$self{FacesDetected} < 2 ? undef : $val',
9736             },
9737             0x40 => {
9738             Name => 'Face3Position',
9739             Format => 'int16u[4]',
9740             RawConv => '$$self{FacesDetected} < 3 ? undef : $val',
9741             },
9742             0x60 => {
9743             Name => 'Face4Position',
9744             Format => 'int16u[4]',
9745             RawConv => '$$self{FacesDetected} < 4 ? undef : $val',
9746             },
9747             0x80 => {
9748             Name => 'Face5Position',
9749             Format => 'int16u[4]',
9750             RawConv => '$$self{FacesDetected} < 5 ? undef : $val',
9751             },
9752             0xa0 => {
9753             Name => 'Face6Position',
9754             Format => 'int16u[4]',
9755             RawConv => '$$self{FacesDetected} < 6 ? undef : $val',
9756             },
9757             0xc0 => {
9758             Name => 'Face7Position',
9759             Format => 'int16u[4]',
9760             RawConv => '$$self{FacesDetected} < 7 ? undef : $val',
9761             },
9762             0xe0 => {
9763             Name => 'Face8Position',
9764             Format => 'int16u[4]',
9765             RawConv => '$$self{FacesDetected} < 8 ? undef : $val',
9766             },
9767             );
9768              
9769             %Image::ExifTool::Sony::FaceInfo2 = (
9770             %binaryDataAttrs,
9771             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
9772             0x00 => {
9773             Name => 'Face1Position',
9774             Format => 'int16u[4]',
9775             Notes => q{
9776             top, left, height and width of detected face. Coordinates are relative to
9777             the full-sized unrotated image, with increasing Y downwards
9778             },
9779             RawConv => '$$self{FacesDetected} < 1 ? undef : $val',
9780             },
9781             0x25 => {
9782             Name => 'Face2Position',
9783             Format => 'int16u[4]',
9784             RawConv => '$$self{FacesDetected} < 2 ? undef : $val',
9785             },
9786             0x4a => {
9787             Name => 'Face3Position',
9788             Format => 'int16u[4]',
9789             RawConv => '$$self{FacesDetected} < 3 ? undef : $val',
9790             },
9791             0x6f => {
9792             Name => 'Face4Position',
9793             Format => 'int16u[4]',
9794             RawConv => '$$self{FacesDetected} < 4 ? undef : $val',
9795             },
9796             0x94 => {
9797             Name => 'Face5Position',
9798             Format => 'int16u[4]',
9799             RawConv => '$$self{FacesDetected} < 5 ? undef : $val',
9800             },
9801             0xb9 => {
9802             Name => 'Face6Position',
9803             Format => 'int16u[4]',
9804             RawConv => '$$self{FacesDetected} < 6 ? undef : $val',
9805             },
9806             0xde => {
9807             Name => 'Face7Position',
9808             Format => 'int16u[4]',
9809             RawConv => '$$self{FacesDetected} < 7 ? undef : $val',
9810             },
9811             0x103 => {
9812             Name => 'Face8Position',
9813             Format => 'int16u[4]',
9814             RawConv => '$$self{FacesDetected} < 8 ? undef : $val',
9815             },
9816             );
9817              
9818             # panorama info for cameras such as the HX1, HX5, TX7 (ref 9/PH)
9819             %Image::ExifTool::Sony::Panorama = (
9820             %binaryDataAttrs,
9821             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
9822             FORMAT => 'int32u',
9823             NOTES => q{
9824             Tags found in panorama images from various Sony DSC, NEX, SLT and DSLR
9825             cameras. The width/height values of these tags are not affected by camera
9826             rotation -- the width is always the longer dimension.
9827             },
9828             # 0: 257 for panorama images, 0 for all other images (ref JR)
9829             1 => 'PanoramaFullWidth', # (including black/gray borders)
9830             2 => 'PanoramaFullHeight',
9831             3 => {
9832             Name => 'PanoramaDirection',
9833             PrintConv => {
9834             0 => 'Left or Up',
9835             1 => 'Right or Down',
9836             },
9837             },
9838             # crop area to remove black/gray borders from full image
9839             4 => 'PanoramaCropLeft',
9840             5 => 'PanoramaCropTop', #PH guess (NC)
9841             6 => 'PanoramaCropRight',
9842             7 => 'PanoramaCropBottom',
9843             # 8: 1728 (HX1), 1824 (HX5/TX7) (value8/value9 = 16/9)
9844             8 => 'PanoramaFrameWidth', #PH guess (NC)
9845             # 9: 972 (HX1), 1026 (HX5/TX7)
9846             9 => 'PanoramaFrameHeight', #PH guess (NC)
9847             # 10: 3200-3800 (HX1), 4000-4900 (HX5/TX7)
9848             10 => 'PanoramaSourceWidth', #PH guess (NC)
9849             # 11: 800-1800 (larger for taller panoramas)
9850             11 => 'PanoramaSourceHeight', #PH guess (NC)
9851             # 12-15: 0
9852             );
9853              
9854             # tag table for SRF0 IFD (ref 1)
9855             %Image::ExifTool::Sony::SRF = (
9856             PROCESS_PROC => \&ProcessSRF,
9857             GROUPS => { 0 => 'MakerNotes', 1 => 'SRF#', 2 => 'Camera' },
9858             NOTES => q{
9859             The maker notes in SRF (Sony Raw Format) images contain 7 IFD's with family
9860             1 group names SRF0 through SRF6. SRF0 and SRF1 use the tags in this table,
9861             while SRF2 through SRF5 use the tags in the next table, and SRF6 uses
9862             standard EXIF tags. All information other than SRF0 is encrypted, but
9863             thanks to Dave Coffin the decryption algorithm is known. SRF images are
9864             written by the Sony DSC-F828 and DSC-V3.
9865             },
9866             # tags 0-1 are used in SRF1
9867             0 => {
9868             Name => 'SRF2Key',
9869             Notes => 'key to decrypt maker notes from the start of SRF2',
9870             RawConv => '$$self{SRF2Key} = $val',
9871             },
9872             1 => {
9873             Name => 'DataKey',
9874             Notes => 'key to decrypt the rest of the file from the end of the maker notes',
9875             RawConv => '$$self{SRFDataKey} = $val',
9876             },
9877             # SRF0 contains a single unknown tag with TagID 0x0003
9878             );
9879              
9880             # tag table for Sony RAW Format (ref 1)
9881             %Image::ExifTool::Sony::SRF2 = (
9882             PROCESS_PROC => \&ProcessSRF,
9883             GROUPS => { 0 => 'MakerNotes', 1 => 'SRF#', 2 => 'Camera' },
9884             NOTES => "These tags are found in the SRF2 through SRF5 IFD's.",
9885             # the following tags are used in SRF2-5
9886             2 => 'SRF6Offset', #PH
9887             # SRFDataOffset references 2220 bytes of unknown data for the DSC-F828 - PH
9888             3 => { Name => 'SRFDataOffset', Unknown => 1 }, #PH
9889             4 => { Name => 'RawDataOffset' }, #PH
9890             5 => { Name => 'RawDataLength' }, #PH
9891             0x0043 => 'MaxApertureAtMaxFocal', #IB
9892             0x0044 => 'MaxApertureAtMinFocal', #IB
9893             0x0045 => { #IB
9894             Name => 'MinFocalLength',
9895             PrintConv => '"$val mm"',
9896             },
9897             0x0046 => { #IB
9898             Name => 'MaxFocalLength',
9899             PrintConv => '"$val mm"',
9900             },
9901             0x00c0 => 'WBRedDaylight', #IB
9902             0x00c1 => 'WBGreenDaylight', #IB
9903             0x00c2 => 'WBBlueDaylight', #IB
9904             0x00c3 => 'WBRedCloudy', #IB
9905             0x00c4 => 'WBGreenCloudy', #IB
9906             0x00c5 => 'WBBlueCloudy', #IB
9907             0x00c6 => 'WBRedFluorescent', #IB
9908             0x00c7 => 'WBGreenFluorescent', #IB
9909             0x00c8 => 'WBBlueFluorescent', #IB
9910             0x00c9 => 'WBRedTungsten', #IB
9911             0x00ca => 'WBGreenTungsten', #IB
9912             0x00cb => 'WBBlueTungsten', #IB
9913             0x00cc => 'WBRedFlash', #IB
9914             0x00cd => 'WBGreenFlash', #IB
9915             0x00ce => 'WBBlueFlash', #IB
9916             0x00d0 => 'WBRedAsShot', #IB
9917             0x00d1 => 'WBGreenAsShot', #IB
9918             0x00d2 => 'WBBlueAsShot', #IB
9919             );
9920              
9921             # tag table for Sony RAW 2 Format Private IFD (ref 1)
9922             %Image::ExifTool::Sony::SR2Private = (
9923             PROCESS_PROC => \&ProcessSR2,
9924             WRITE_PROC => \&WriteSR2,
9925             GROUPS => { 0 => 'MakerNotes', 1 => 'SR2', 2 => 'Camera' },
9926             NOTES => q{
9927             The SR2 format uses the DNGPrivateData tag to reference a private IFD
9928             containing these tags. SR2 images are written by the Sony DSC-R1, but
9929             this information is also written to ARW images by other models.
9930             },
9931             0x7200 => {
9932             Name => 'SR2SubIFDOffset',
9933             # (adjusting offset messes up calculations for AdobeSR2 in DNG images)
9934             # Flags => 'IsOffset',
9935             # (can't set OffsetPair or else DataMember won't be set when writing)
9936             # OffsetPair => 0x7201,
9937             DataMember => 'SR2SubIFDOffset',
9938             RawConv => '$$self{SR2SubIFDOffset} = $val',
9939             },
9940             0x7201 => {
9941             Name => 'SR2SubIFDLength',
9942             # (can't set OffsetPair or else DataMember won't be set when writing)
9943             # OffsetPair => 0x7200,
9944             DataMember => 'SR2SubIFDLength',
9945             RawConv => '$$self{SR2SubIFDLength} = $val',
9946             },
9947             0x7221 => {
9948             Name => 'SR2SubIFDKey',
9949             Format => 'int32u',
9950             Notes => 'key to decrypt SR2SubIFD',
9951             DataMember => 'SR2SubIFDKey',
9952             RawConv => '$$self{SR2SubIFDKey} = $val',
9953             PrintConv => 'sprintf("0x%.8x", $val)',
9954             },
9955             0x7240 => { #PH
9956             Name => 'IDC_IFD',
9957             Groups => { 1 => 'SonyIDC' },
9958             Condition => '$$valPt !~ /^\0\0\0\0/', # (just in case this could be zero)
9959             Flags => 'SubIFD',
9960             SubDirectory => {
9961             DirName => 'SonyIDC',
9962             TagTable => 'Image::ExifTool::SonyIDC::Main',
9963             Start => '$val',
9964             },
9965             },
9966             0x7241 => { #PH
9967             Name => 'IDC2_IFD',
9968             Groups => { 1 => 'SonyIDC' },
9969             Condition => '$$valPt !~ /^\0\0\0\0/', # may be zero if dir doesn't exist
9970             Flags => 'SubIFD',
9971             SubDirectory => {
9972             DirName => 'SonyIDC2',
9973             TagTable => 'Image::ExifTool::SonyIDC::Main',
9974             Start => '$val',
9975             Base => '$start',
9976             MaxSubdirs => 20, # (A900 has 10 null entries, but IDC writes only 1)
9977             RelativeBase => 1, # needed to write SubIFD with relative offsets
9978             },
9979             },
9980             0x7250 => { #1
9981             Name => 'MRWInfo',
9982             Condition => '$$valPt !~ /^\0\0\0\0/', # (just in case this could be zero)
9983             SubDirectory => {
9984             TagTable => 'Image::ExifTool::MinoltaRaw::Main',
9985             },
9986             },
9987             );
9988              
9989             %Image::ExifTool::Sony::SR2SubIFD = (
9990             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
9991             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
9992             GROUPS => { 0 => 'MakerNotes', 1 => 'SR2SubIFD', 2 => 'Camera' },
9993             WRITE_GROUP => 'SR2SubIFD',
9994             PERMANENT => 1,
9995             SET_GROUP1 => 1, # set group1 name to directory name for all tags in table
9996             NOTES => 'Tags in the encrypted SR2SubIFD',
9997             0x7300 => { Name => 'BlackLevel', Writable => 'int16u', Count => 4, Protected => 1 },
9998             0x7302 => { Name => 'WB_GRBGLevelsAuto', Writable => 'int16s', Count => 4, Protected => 1 }, #IB (R1)
9999             0x7303 => { Name => 'WB_GRBGLevels', Writable => 'int16s', Count => 4, Protected => 1 }, #1 (R1 "as shot", ref IB)
10000             0x7310 => { Name => 'BlackLevel', Writable => 'int16u', Count => 4, Protected => 1 }, #IB (divide by 4)
10001             0x7312 => { Name => 'WB_RGGBLevelsAuto', Writable => 'int16s', Count => 4, Protected => 1 }, #IB
10002             0x7313 => { Name => 'WB_RGGBLevels', Writable => 'int16s', Count => 4, Protected => 1 }, #6
10003             0x7480 => { Name => 'WB_RGBLevelsDaylight', Writable => 'int16s', Count => 4, Protected => 1 }, #IB (R1)
10004             0x7481 => { Name => 'WB_RGBLevelsCloudy', Writable => 'int16s', Count => 4, Protected => 1 }, #IB (R1)
10005             0x7482 => { Name => 'WB_RGBLevelsTungsten', Writable => 'int16s', Count => 4, Protected => 1 }, #IB (R1)
10006             0x7483 => { Name => 'WB_RGBLevelsFlash', Writable => 'int16s', Count => 4, Protected => 1 }, #IB (R1)
10007             0x7484 => { Name => 'WB_RGBLevels4500K', Writable => 'int16s', Count => 4, Protected => 1 }, #IB (R1)
10008             0x7486 => { Name => 'WB_RGBLevelsFluorescent', Writable => 'int16s', Count => 4, Protected => 1 }, #IB (R1)
10009             0x74a0 => 'MaxApertureAtMaxFocal', #PH
10010             0x74a1 => 'MaxApertureAtMinFocal', #PH
10011             0x74a2 => { #IB (R1)
10012             Name => 'MaxFocalLength',
10013             PrintConv => '"$val mm"',
10014             },
10015             0x74a3 => { #IB (R1)
10016             Name => 'MinFocalLength',
10017             PrintConv => '"$val mm"',
10018             },
10019             0x74c0 => { #PH
10020             Name => 'SR2DataIFD',
10021             Groups => { 1 => 'SR2DataIFD' }, # (needed to set SubIFD DirName)
10022             Flags => 'SubIFD',
10023             SubDirectory => {
10024             TagTable => 'Image::ExifTool::Sony::SR2DataIFD',
10025             Start => '$val',
10026             MaxSubdirs => 20, # an A700 ARW has 14 of these! - PH
10027             },
10028             },
10029             0x7800 => 'ColorMatrix', #IB (divide by 1024)
10030             0x7820 => { Name => 'WB_RGBLevelsDaylight', Writable => 'int16s', Count => 3, Protected => 1 }, #6 (or 5300K, ref IB)
10031             0x7821 => { Name => 'WB_RGBLevelsCloudy', Writable => 'int16s', Count => 3, Protected => 1 }, #6 (or 6100K, ref IB)
10032             0x7822 => { Name => 'WB_RGBLevelsTungsten', Writable => 'int16s', Count => 3, Protected => 1 }, #6
10033             0x7823 => { Name => 'WB_RGBLevelsFlash', Writable => 'int16s', Count => 3, Protected => 1 }, #IB
10034             0x7824 => { Name => 'WB_RGBLevels4500K', Writable => 'int16s', Count => 3, Protected => 1 }, #IB
10035             0x7825 => { Name => 'WB_RGBLevelsShade', Writable => 'int16s', Count => 3, Protected => 1 }, #6 (or 7500K, ref IB)
10036             0x7826 => { Name => 'WB_RGBLevelsFluorescent', Writable => 'int16s', Count => 3, Protected => 1 }, #6 (~4000K)
10037             0x7827 => { Name => 'WB_RGBLevelsFluorescentP1', Writable => 'int16s', Count => 3, Protected => 1 }, #IB (~5000K)
10038             0x7828 => { Name => 'WB_RGBLevelsFluorescentP2', Writable => 'int16s', Count => 3, Protected => 1 }, #IB (~6500K) (was Flash, ref 6)
10039             0x7829 => { Name => 'WB_RGBLevelsFluorescentM1', Writable => 'int16s', Count => 3, Protected => 1 }, #IB (~3500K)
10040             0x782a => { Name => 'WB_RGBLevels8500K', Writable => 'int16s', Count => 3, Protected => 1 }, #IB
10041             0x782b => { Name => 'WB_RGBLevels6000K', Writable => 'int16s', Count => 3, Protected => 1 }, #IB
10042             0x782c => { Name => 'WB_RGBLevels3200K', Writable => 'int16s', Count => 3, Protected => 1 }, #IB
10043             0x782d => { Name => 'WB_RGBLevels2500K', Writable => 'int16s', Count => 3, Protected => 1 }, #IB
10044             0x787f => { Name => 'WhiteLevel', Writable => 'int16u', Count => 3, Protected => 1 }, #IB (divide by 4)
10045             0x797d => 'VignettingCorrParams', #forum7640
10046             0x7980 => 'ChromaticAberrationCorrParams', #forum6509 (Sony A7 ARW)
10047             0x7982 => 'DistortionCorrParams', #forum6509 (Sony A7 ARW)
10048             );
10049              
10050             %Image::ExifTool::Sony::SR2DataIFD = (
10051             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
10052             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
10053             GROUPS => { 0 => 'MakerNotes', 1 => 'SR2DataIFD', 2 => 'Camera' },
10054             SET_GROUP1 => 1, # set group1 name to directory name for all tags in table
10055             # 0x7313 => 'WB_RGGBLevels', (duplicated in all SR2DataIFD's)
10056             0x7770 => { #PH
10057             Name => 'ColorMode',
10058             Priority => 0,
10059             },
10060             );
10061              
10062             # extract information from "SONY PIC\0" maker notes (ref PH)
10063             %Image::ExifTool::Sony::PIC = (
10064             PROCESS_PROC => \&ProcessSonyPIC,
10065             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10066             NOTES => q{
10067             The TextInfo data is extracted as a block to preserve the formatting, and
10068             some of the more interesting information is extracted as separate tags.
10069             },
10070             TextInfo1 => { Binary => 1 },
10071             TextInfo2 => { Binary => 1 },
10072             # tags extracted from TextInfo blocks (ID's must end with ':')
10073             'Temp:' => {
10074             Name => 'CameraTemperature',
10075             RawConv => '$val =~ /^-?\d+/ ? $val : undef',
10076             PrintConv => '"$val C"',
10077             },
10078             'Temp:Clbt:' => { Name => 'BoardTemperature', PrintConv => '"$val C"' }, #(NC)
10079             'Capt:' => { Name => 'SensorTemperature', PrintConv => '"$val C"' }, #(NC)
10080             'VR Enable C:' => {
10081             Name => 'VibrationReduction',
10082             PrintConv => { 0 => 'Off', 1 => 'On' }, #(NC)
10083             },
10084             'FWVer:' => 'FirmwareVersion',
10085             'BC:' => {
10086             Name => 'Barcode',
10087             Condition => 'not $$self{VALUE}{Barcode}',
10088             ValueConv => '$val=~s/IP1.*//; $val',
10089             },
10090             'barcode:' => 'Barcode',
10091             'BarCode:' => {
10092             Name => 'Barcode',
10093             ValueConv => 'length($val) > 12 ? substr($val,0,12) : $val',
10094             },
10095             # 'EvA:' - exposure compensation * 10 (ref JR)
10096             # IFD: for documentation only -- this IFD is handled manually
10097             IFD => {
10098             Name => 'PIC_IFD',
10099             SubDirectory => { TagTable => 'Image::ExifTool::Sony::Main' },
10100             },
10101             );
10102              
10103             # tags found in DSC-F1 PMP header (ref 10)
10104             %Image::ExifTool::Sony::PMP = (
10105             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
10106             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
10107             FIRST_ENTRY => 0,
10108             NOTES => q{
10109             These tags are written in the proprietary-format header of PMP images from
10110             the DSC-F1.
10111             },
10112             8 => { #PH
10113             Name => 'JpgFromRawStart',
10114             Format => 'int32u',
10115             Notes => q{
10116             OK, not really a RAW file, but this mechanism is used to allow extraction of
10117             the JPEG image from a PMP file
10118             },
10119             },
10120             12 => { Name => 'JpgFromRawLength', Format => 'int32u' },
10121             22 => { Name => 'SonyImageWidth', Format => 'int16u' },
10122             24 => { Name => 'SonyImageHeight', Format => 'int16u' },
10123             27 => {
10124             Name => 'Orientation',
10125             PrintConv => {
10126             0 => 'Horizontal (normal)',
10127             1 => 'Rotate 270 CW',#11
10128             2 => 'Rotate 180',
10129             3 => 'Rotate 90 CW',#11
10130             },
10131             },
10132             29 => {
10133             Name => 'ImageQuality',
10134             PrintConv => {
10135             8 => 'Snap Shot',
10136             23 => 'Standard',
10137             51 => 'Fine',
10138             },
10139             },
10140             # 40 => ImageWidth again (int16u)
10141             # 42 => ImageHeight again (int16u)
10142             52 => { Name => 'Comment', Format => 'string[19]' },
10143             76 => {
10144             Name => 'DateTimeOriginal',
10145             Description => 'Date/Time Original',
10146             Format => 'int8u[6]',
10147             Groups => { 2 => 'Time' },
10148             ValueConv => q{
10149             my @a = split ' ', $val;
10150             $a[0] += $a[0] < 70 ? 2000 : 1900;
10151             sprintf('%.4d:%.2d:%.2d %.2d:%.2d:%.2d', @a);
10152             },
10153             PrintConv => '$self->ConvertDateTime($val)',
10154             },
10155             84 => {
10156             Name => 'ModifyDate',
10157             Format => 'int8u[6]',
10158             Groups => { 2 => 'Time' },
10159             ValueConv => q{
10160             my @a = split ' ', $val;
10161             $a[0] += $a[0] < 70 ? 2000 : 1900;
10162             sprintf('%.4d:%.2d:%.2d %.2d:%.2d:%.2d', @a);
10163             },
10164             PrintConv => '$self->ConvertDateTime($val)',
10165             },
10166             102 => {
10167             Name => 'ExposureTime',
10168             Format => 'int16s',
10169             RawConv => '$val <= 0 ? undef : $val',
10170             ValueConv => '2 ** (-$val / 100)',
10171             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
10172             },
10173             106 => { # (NC -- not written by DSC-F1)
10174             Name => 'FNumber',
10175             Format => 'int16s',
10176             RawConv => '$val <= 0 ? undef : $val',
10177             ValueConv => '$val / 100', # (likely wrong)
10178             },
10179             108 => { # (NC -- not written by DSC-F1)
10180             Name => 'ExposureCompensation',
10181             Format => 'int16s',
10182             RawConv => '($val == -1 or $val == -32768) ? undef : $val',
10183             ValueConv => '$val / 100', # (probably wrong too)
10184             },
10185             112 => { # (NC -- not written by DSC-F1)
10186             Name => 'FocalLength',
10187             Format => 'int16s',
10188             Groups => { 2 => 'Camera' },
10189             RawConv => '$val <= 0 ? undef : $val',
10190             ValueConv => '$val / 100',
10191             PrintConv => 'sprintf("%.1f mm",$val)',
10192             },
10193             118 => {
10194             Name => 'Flash',
10195             Groups => { 2 => 'Camera' },
10196             PrintConv => { 0 => 'No Flash', 1 => 'Fired' },
10197             },
10198             );
10199              
10200             # tags found in 'rtmd' timed metadata in ILCE-7S/DSC-RX100M6 MP4 videos (ref PH)
10201             %Image::ExifTool::Sony::rtmd = (
10202             PROCESS_PROC => \&Process_rtmd,
10203             GROUPS => { 2 => 'Video' },
10204             NOTES => q{
10205             These tags are extracted from the 'rtmd' timed metadata of MP4 videos from
10206             some models when the L option is used.
10207             },
10208             # 0x060e - 16 bytes starting with 0x060e2b340253 (fake tag ID - comes before 0x8300 container)
10209             0x060e => { Name => 'Sony_rtmd_0x060e', Format => 'int8u', %hidUnk },
10210             # 0x32xx - 16 bytes starting with 0x060e2b340401
10211             0x3210 => { Name => 'Sony_rtmd_0x3210', Format => 'int8u', %hidUnk },
10212             0x3219 => { Name => 'Sony_rtmd_0x3219', Format => 'int8u', %hidUnk },
10213             0x321a => { Name => 'Sony_rtmd_0x321a', Format => 'int8u', %hidUnk },
10214             0x8000 => { #forum12218
10215             Name => 'FNumber',
10216             Format => 'int16u',
10217             ValueConv => '2 ** (8-$val/8192)',
10218             PrintConv => 'Image::ExifTool::Exif::PrintFNumber($val)',
10219             },
10220             0x8001 => { Name => 'Sony_rtmd_0x8001', Format => 'int16u', %hidUnk },
10221             0x8004 => { Name => 'Sony_rtmd_0x8004', Format => 'int16u', %hidUnk }, # (FocalLength35efl?, forum14315)
10222             0x8005 => { Name => 'Sony_rtmd_0x8005', Format => 'int16u', %hidUnk }, # (FocalLength?, forum14315)
10223             0x800a => { Name => 'Sony_rtmd_0x800a', Format => 'int16u', %hidUnk }, # (FocusRingPosition?, forum14315)
10224             0x800b => { Name => 'Sony_rtmd_0x800b', Format => 'int16u', %hidUnk }, # (ZoomRingPosition?, forum14315)
10225             # 0x8100 - 16 bytes starting with 0x060e2b340401
10226             0x8100 => { Name => 'Sony_rtmd_0x8100', Format => 'int8u', %hidUnk },
10227             0x8101 => { Name => 'Sony_rtmd_0x8101', Format => 'int8u', %hidUnk }, # seen: 0,1
10228             0x8104 => { Name => 'Sony_rtmd_0x8104', Format => 'int16u', %hidUnk }, # seen: 35616
10229             0x8105 => { Name => 'Sony_rtmd_0x8105', Format => 'int16u', %hidUnk }, # seen: 20092
10230             0x8106 => { Name => 'Sony_rtmd_0x8106', Format => 'int32u', %hidUnk }, # seen: "25 1","24000 1001" frame rate?
10231             0x8109 => { #forum12218
10232             Name => 'ExposureTime',
10233             Format => 'rational64u',
10234             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
10235             },
10236             0x810a => { #PH (NC, based on samples from forum12218)
10237             Name => 'MasterGainAdjustment',
10238             Format => 'int16u',
10239             ValueConv => '$val / 100',
10240             PrintConv => 'sprintf("%.2f dB", $val)',
10241             },
10242             0x810b => { Name => 'ISO', Format => 'int16u' }, #forum12218
10243             0x810c => { #PH (NC, based on samples from forum12218)
10244             Name => 'ElectricalExtenderMagnification',
10245             Format => 'int16u',
10246             },
10247             0x810d => { Name => 'Sony_rtmd_0x810d', Format => 'int8u', %hidUnk }, # seen: 0,1
10248             0x8115 => { Name => 'Sony_rtmd_0x8115', Format => 'int16u', %hidUnk }, # seen: 100
10249             # 0x8300 - container for other tags in this format
10250             0x8500 => {
10251             Name => 'GPSVersionID',
10252             Groups => { 2 => 'Location' },
10253             Format => 'int8u',
10254             PrintConv => '$val =~ tr/ /./; $val',
10255             },
10256             0x8501 => {
10257             Name => 'GPSLatitudeRef',
10258             Groups => { 2 => 'Location' },
10259             Format => 'string',
10260             PrintConv => {
10261             N => 'North',
10262             S => 'South',
10263             },
10264             },
10265             0x8502 => {
10266             Name => 'GPSLatitude',
10267             Groups => { 2 => 'Location' },
10268             Format => 'rational64u',
10269             ValueConv => 'require Image::ExifTool::GPS;Image::ExifTool::GPS::ToDegrees($val)',
10270             PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1)',
10271             },
10272             0x8503 => {
10273             Name => 'GPSLongitudeRef',
10274             Groups => { 2 => 'Location' },
10275             Format => 'string',
10276             PrintConv => {
10277             E => 'East',
10278             W => 'West',
10279             },
10280             },
10281             0x8504 => {
10282             Name => 'GPSLongitude',
10283             Groups => { 2 => 'Location' },
10284             Format => 'rational64u',
10285             ValueConv => 'require Image::ExifTool::GPS;Image::ExifTool::GPS::ToDegrees($val)',
10286             PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1)',
10287             },
10288             0x8507 => {
10289             Name => 'GPSTimeStamp',
10290             Groups => { 2 => 'Time' },
10291             Format => 'rational64u',
10292             ValueConv => 'require Image::ExifTool::GPS;Image::ExifTool::GPS::ConvertTimeStamp($val)',
10293             PrintConv => 'Image::ExifTool::GPS::PrintTimeStamp($val)',
10294             },
10295             0x8509 => {
10296             Name => 'GPSStatus',
10297             Groups => { 2 => 'Location' },
10298             Format => 'string',
10299             PrintConv => {
10300             A => 'Measurement Active',
10301             V => 'Measurement Void',
10302             },
10303             },
10304             0x850a => {
10305             Name => 'GPSMeasureMode',
10306             Groups => { 2 => 'Location' },
10307             Format => 'string',
10308             PrintConv => {
10309             2 => '2-Dimensional Measurement',
10310             3 => '3-Dimensional Measurement',
10311             },
10312             },
10313             0x8512 => {
10314             Name => 'GPSMapDatum',
10315             Groups => { 2 => 'Location' },
10316             Format => 'string',
10317             },
10318             0x851d => {
10319             Name => 'GPSDateStamp',
10320             Groups => { 2 => 'Time' },
10321             Format => 'string',
10322             ValueConv => 'Image::ExifTool::Exif::ExifDate($val)',
10323             },
10324             0xe000 => { Name => 'Sony_rtmd_0xe000', Format => 'int8u', %hidUnk }, # (16 bytes)
10325             0xe300 => { Name => 'Sony_rtmd_0xe300', Format => 'int8u', %hidUnk }, # seen: 0,1
10326             0xe301 => { Name => 'Sony_rtmd_0xe301', Format => 'int32u', %hidUnk }, # seen: 100,1600,12800
10327             0xe302 => { Name => 'Sony_rtmd_0xe302', Format => 'int8u', %hidUnk }, # seen: 1
10328             0xe303 => { #forum12218
10329             Name => 'WhiteBalance',
10330             Format => 'int8u',
10331             PrintConv => {
10332             1 => 'Incandescent',
10333             2 => 'Fluorescent',
10334             4 => 'Daylight',
10335             5 => 'Cloudy',
10336             6 => 'Custom', # ("Shade" uses this value too)
10337             255 => 'Preset',
10338             },
10339             },
10340             0xe304 => {
10341             Name => 'DateTime',
10342             Groups => { 2 => 'Time' },
10343             Format => 'undef',
10344             ValueConv => 'my @a=unpack("x1H4H2H2H2H2H2",$val); "$a[0]:$a[1]:$a[2] $a[3]:$a[4]:$a[5]"',
10345             PrintConv => '$self->ConvertDateTime($val)',
10346             },
10347             0xe435 => { Name => 'Sony_rtmd_0xe435', Format => 'int32u', %hidUnk }, # seen: 2000
10348             0xe437 => { Name => 'Sony_rtmd_0xe437', Format => 'int32s', %hidUnk }, # seen: -3800 to -3400
10349             0xe43b => {
10350             Name => 'PitchRollYaw',
10351             Format => 'int16s',
10352             RawConv => 'substr($val, 8)',
10353             },
10354             0xe445 => { Name => 'Sony_rtmd_0xe445', Format => 'int32u', %hidUnk }, # seen: 2000
10355             0xe44b => {
10356             Name => 'Accelerometer', # (NC)
10357             Format => 'int16s',
10358             RawConv => 'substr($val, 8)',
10359             },
10360             # f010 - 2048 bytes
10361             # f020 - 543 bytes
10362             );
10363              
10364             # Composite Sony tags
10365             %Image::ExifTool::Sony::Composite = (
10366             GROUPS => { 2 => 'Camera' },
10367             FocusDistance => {
10368             Require => {
10369             0 => 'Sony:FocusPosition',
10370             1 => 'FocalLength',
10371             },
10372             Notes => 'distance in metres = FocusPosition * FocalLength / 1000',
10373             ValueConv => '$val >= 128 ? "inf" : $val * $val[1] / 1000',
10374             PrintConv => '$val eq "inf" ? $val : "$val m"',
10375             },
10376             FocusDistance2 => {
10377             # For DSLR-A550 and newer, NEX/ILCE/SLT/ILCA (only A65V/A77V are missing ...):
10378             # seen FocusPosition2 with values from 80 - 255 (and 21 for Touit 12mm...)
10379             # Formula from minolta.pm (WBInfoA100 - 0x49bb) gives mostly correct/acceptable distance indications.
10380             # (https://exiftool.org/forum/index.php/topic,3688.0.html)
10381             # if this value is the 35mm equivalent magnification, then the formula could
10382             # be (1.5 * 2**($val/16-5)+1) * FocalLength, but this tends to underestimate
10383             # distance by about 18% (ref 20) (255=inf)
10384             # modified 16-10-2014 based on A99V measurements: use FocalLengthIn35mmFormat and leave out the "1.5*" factor.
10385             Require => {
10386             0 => 'Sony:FocusPosition2',
10387             1 => 'FocalLengthIn35mmFormat',
10388             },
10389             ValueConv => q{
10390             return undef unless $val;
10391             return 'inf' if $val >= 255;
10392             return (2**($val/16-5) + 1) * $val[1] / 1000;
10393             },
10394             PrintConv => '$val eq "inf" ? $val : sprintf("%.4g m", $val)',
10395             },
10396             GPSDateTime => {
10397             Description => 'GPS Date/Time',
10398             Groups => { 2 => 'Time' },
10399             SubDoc => 1, # generate for all sub-documents
10400             Require => {
10401             0 => 'Sony:GPSDateStamp',
10402             1 => 'Sony:GPSTimeStamp',
10403             },
10404             ValueConv => '"$val[0] $val[1]Z"',
10405             PrintConv => '$self->ConvertDateTime($val)',
10406             },
10407             GPSLatitude => {
10408             SubDoc => 1, # generate for all sub-documents
10409             Groups => { 2 => 'Location' },
10410             Require => {
10411             0 => 'Sony:GPSLatitude',
10412             1 => 'Sony:GPSLatitudeRef',
10413             },
10414             ValueConv => '$val[1] =~ /^S/i ? -$val[0] : $val[0]',
10415             PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "N")',
10416             },
10417             GPSLongitude => {
10418             SubDoc => 1, # generate for all sub-documents
10419             Groups => { 2 => 'Location' },
10420             Require => {
10421             0 => 'Sony:GPSLongitude',
10422             1 => 'Sony:GPSLongitudeRef',
10423             },
10424             ValueConv => '$val[1] =~ /^W/i ? -$val[0] : $val[0]',
10425             PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "E")',
10426             },
10427             );
10428              
10429             # add our composite tags
10430             Image::ExifTool::AddCompositeTags('Image::ExifTool::Sony');
10431              
10432             sub SortLensTypes
10433             {
10434 53594 100 100 53594 0 131418 return $a <=> $b unless $a =~ /\./ and $b =~ /\./;
10435 12968         24594 my @a = split /\./, $a;
10436 12968         22116 my @b = split /\./, $b;
10437             # must compare the decimal part separately to sort in proper order
10438 12968   66     36765 return $a[0] <=> $b[0] || $a[1] <=> $b[1];
10439             }
10440              
10441             # fill in Sony LensType lookup based on Minolta values
10442             {
10443             my $minoltaTypes = \%Image::ExifTool::Minolta::minoltaLensTypes;
10444             %sonyLensTypes = %$minoltaTypes;
10445             my $other = $$minoltaTypes{OTHER};
10446             delete $$minoltaTypes{Notes}; # (temporarily)
10447             delete $$minoltaTypes{OTHER}; # (temporarily)
10448             my $id;
10449             # 5-digit lens ID's are missing the last digit (usually "1") in the metadata for
10450             # some Sony models, so generate corresponding 4-digit entries for these cameras
10451             foreach $id (sort SortLensTypes keys %$minoltaTypes) {
10452             next if $id < 10000;
10453             my $sid = int($id/10);
10454             my $i;
10455             my $lens = $$minoltaTypes{$id};
10456             if ($sonyLensTypes{$sid}) {
10457             # put lens name with "or" first in list
10458             if ($lens =~ / or /) {
10459             my $tmp = $sonyLensTypes{$sid};
10460             $sonyLensTypes{$sid} = $lens;
10461             $lens = $tmp;
10462             }
10463             for (;;) {
10464             $i = ($i || 0) + 1;
10465             $sid = int($id/10) . ".$i";
10466             last unless $sonyLensTypes{$sid};
10467             }
10468             }
10469             $sonyLensTypes{$sid} = $lens;
10470             }
10471             $$minoltaTypes{Notes} = $sonyLensTypes{Notes}; # (restore original Notes)
10472             $$minoltaTypes{OTHER} = $other;
10473             }
10474              
10475             #------------------------------------------------------------------------------
10476             # Process "SONY PIC\0" maker notes (DSC-H200/J10/W370/W510, MHS-TS20, ref PH)
10477             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
10478             # Returns: 1
10479             sub ProcessSonyPIC($$$)
10480             {
10481 0     0 0 0 my ($et, $dirInfo, $tagTablePtr) = @_;
10482 0         0 my $dataPt = $$dirInfo{DataPt};
10483 0   0     0 my $start = $$dirInfo{DirStart} || 0;
10484 0   0     0 my $len = $$dirInfo{DirLen} || (length($$dataPt) - $start);
10485 0         0 my $data = substr($$dataPt, $start, $len);
10486              
10487             # H200 panorama images have an IFD at offset 12 (non-panoramas have 0's here)
10488             # - assume other images could too, but do a bit of validation to check
10489             # - MHS-TS20 images have some other data here
10490 0 0       0 if ($len >= 26) {
10491 0         0 my $count = Get16u($dataPt, $start + 12);
10492 0 0       0 if ($count > 256) {
10493 0         0 ToggleByteOrder();
10494 0         0 $count = Get16u($dataPt, $start + 12);
10495             }
10496 0 0 0     0 if ($count and $count < 256) {
10497 0         0 my $format = Get16u($dataPt, $start + 16);
10498 0 0 0     0 if ($format >= 1 and $format <= 10) {
10499 0         0 $$dirInfo{DirStart} = $start + 12;
10500 0         0 $$dirInfo{DirLen} = $len - 12;
10501 0         0 my $sonyTable = GetTagTable('Image::ExifTool::Sony::Main');
10502 0         0 Image::ExifTool::Exif::ProcessExif($et, $dirInfo, $sonyTable);
10503             }
10504             }
10505             }
10506             # Do a brute force search for text data:
10507             # For the DSC-J10/W370/W510 the first text block is at offset 0x1ec and
10508             # starts with "BarCode:". For the H200 it is at 0x1f0 and starts with "BC:".
10509             # For the TS20 it is at 0x5b and starts with "V400 AELOG\nbarcode:".
10510             # The second text block starts with "AFLOG" (Auto-Focus log) and is at
10511             # 0x600 for all models, except for the TS20 it is at 0x45b.
10512 0         0 my $i = 0;
10513 0         0 while ($data =~ /(\w[\x09\x0a\x0d\x20-\x7e]+)/sg) {
10514 0 0       0 next unless length $1 > 32;
10515 0         0 my ($tag, $val) = ('TextInfo' . (++$i), $1);
10516 0 0       0 $$tagTablePtr{$tag} or AddTagToTable($tagTablePtr, $tag, { Name => $tag, Binary => 1 });
10517 0         0 $et->HandleTag($tagTablePtr, $tag, $val);
10518             # extract interesting tags separately (might want to speed this up)
10519 0         0 foreach $tag (sort { lc $a cmp lc $b } keys %$tagTablePtr) {
  0         0  
10520 0 0 0     0 next unless $tag =~ /:$/ and $val =~ /\b$tag\s*([^\s;,:]+)/;
10521 0         0 $et->HandleTag($tagTablePtr, $tag, $1);
10522             }
10523             }
10524 0         0 return 1;
10525             }
10526              
10527             #------------------------------------------------------------------------------
10528             # MeterInfo value conversions
10529             # Inputs: 0) value
10530             # Returns: converted value
10531             sub ConvMeter1($)
10532             {
10533 0     0 0 0 my $val = shift;
10534 0 0       0 return \$val unless length($val) == 90;
10535 0         0 my @a = unpack("SLLSLLSLLSLLSLLSLLSLLSLLSLL",$val);
10536 0         0 return join ' ', @a;
10537             }
10538             sub ConvMeter2($)
10539             {
10540 0     0 0 0 my $val = shift;
10541 0 0       0 return \$val unless length($val) == 110;
10542 0         0 my @a = unpack("SLLSLLSLLSLLSLLSLLSLLSLLSLLSLLSLL",$val);
10543 0         0 return join ' ', @a;
10544             }
10545              
10546             #------------------------------------------------------------------------------
10547             # LensSpec value conversions
10548             # Inputs: 0) value
10549             # Returns: converted value
10550             # Notes: unpacks in format compatible with LensInfo, with extra flags bytes at start and end
10551             sub ConvLensSpec($)
10552             {
10553 0     0 0 0 my $val = shift;
10554 0 0       0 return \$val unless length($val) == 8;
10555 0         0 my @a = unpack("H2H4H4H2H2H2",$val);
10556 0         0 $a[1] += 0; $a[2] += 0; # remove leading zeros from focal lengths
  0         0  
10557 0         0 s/([a-f])/hex($1)/e foreach @a[3,4]; # convert hex digits (ie. "b0" = f11)
  0         0  
10558 0         0 $a[3] /= 10; $a[4] /= 10; # divide f-numbers by 10
  0         0  
10559 0         0 return join ' ', @a;
10560             }
10561             sub ConvInvLensSpec($)
10562             {
10563 4     4 0 8 my $val = shift;
10564 4         16 my @a=split(" ", $val);
10565 4 50       13 return $val unless @a == 6;
10566 4         15 $a[3] *= 10; $a[4] *= 10; # f-numbers are multiplied by 10
  4         9  
10567 4         38 s/^(\d{2})0$/sprintf('%x0',$1)/e foreach @a[3,4];
  0         0  
10568 4         25 $_ = hex foreach @a; # convert from hex
10569 4         31 return pack 'CnnCCC', @a;
10570             }
10571              
10572             #------------------------------------------------------------------------------
10573             # Print Sony LensSpec value
10574             # Inputs: 0) LensSpec numerical value
10575             # Returns: converted LensSpec string (eg. "DT 18-55mm F3.5-5.6 SAM")
10576             # Refs: http://equational.org/importphotos/alphalensinfo.html
10577             # http://www.dyxum.com/dforum/the-lens-information-different-from-lensid_topic37682.html
10578             my @lensFeatures = (
10579             # lens features in the order they are added to the LensSpec string
10580             # (high byte of Mask/Bits represents byte 0 of LensSpec, low byte is byte 7)
10581             # Mask { Bits Name Bits Name } Prefix flag
10582             # ------ ------ ----- ------ ----- -----------
10583             [ 0x4000, { 0x4000 => 'PZ' }, 1 ],
10584             [ 0x0300, { 0x0100 => 'DT', 0x0200 => 'FE', 0x0300 => 'E' }, 1 ], # (will come before preceding prefix), FE added (ref JR)
10585             [ 0x00e0, { 0x0020 => 'STF', 0x0040 => 'Reflex', 0x0060 => 'Macro', 0x0080 => 'Fisheye' } ],
10586             [ 0x000c, { 0x0004 => 'ZA', 0x0008 => 'G' } ],
10587             [ 0x0003, { 0x0001 => 'SSM', 0x0002 => 'SAM' } ],
10588             [ 0x8000, { 0x8000 => 'OSS' } ],
10589             [ 0x2000, { 0x2000 => 'LE' } ], #JR
10590             [ 0x0800, { 0x0800 => 'II' } ], #JR
10591             );
10592             sub PrintLensSpec($)
10593             {
10594 0     0 0 0 my $val = shift;
10595 0         0 my ($rtnVal, $feature, $f1, $sf, $lf, $sa, $la, $f2);
10596             # 0=flags1, 1=short focal, 2=long focal, 3=max aperture at short focal,
10597             # 4=max aperture at long focal, 5=flags2
10598 0         0 my @a = split ' ', $val;
10599 0 0       0 if (@a == 2) { # LensSpecFeatures patch
    0          
10600 0         0 ($f1, $f2) = @a;
10601 0         0 $rtnVal = '';
10602             } elsif (@a >= 6) {
10603 0         0 ($f1, $sf, $lf, $sa, $la, $f2) = @a;
10604             # crude validation of focal length and aperture values
10605 0 0 0     0 if ($sf != 0 and $sa != 0 and ($lf == 0 or $lf >= $sf) and ($la == 0 or $la >= $sa)) {
      0        
      0        
      0        
      0        
10606             # use focal and aperture range if this is a zoom lens
10607 0 0 0     0 $sf .= '-' . $lf if $lf != $sf and $lf != 0;
10608 0 0 0     0 $sa .= '-' . $la if $sa != $la and $la != 0;
10609 0         0 $rtnVal = "${sf}mm F$sa"; # heart of LensSpec is a LensInfo string
10610             }
10611             }
10612 0 0       0 if (defined $rtnVal) {
10613             # loop through available lens features
10614 0         0 my $flags = hex($f1 . $f2);
10615 0         0 foreach $feature (@lensFeatures) {
10616 0         0 my $bits = $$feature[0] & $flags;
10617 0 0 0     0 next unless $bits or $$feature[1]{$bits};
10618             # add feature name as a prefix or suffix to the LensSpec
10619 0   0     0 my $str = $$feature[1]{$bits} || sprintf('Unknown(%.4x)',$bits);
10620 0 0       0 $rtnVal = $rtnVal ? ($$feature[2] ? "$str $rtnVal" : "$rtnVal $str") : $str;
    0          
10621             }
10622             } else {
10623 0         0 $rtnVal = "Unknown ($val)";
10624             }
10625 0         0 return $rtnVal;
10626             }
10627             # inverse conversion
10628             sub PrintInvLensSpec($;$$)
10629             {
10630 14     14 0 42 my ($val, $self, $features) = @_;
10631 14 50       41 return $1 if $val =~ /Unknown \((.*)\)/i;
10632 14         59 my ($sf, $lf, $sa, $la) = Image::ExifTool::Exif::GetLensInfo($val);
10633 14         32 my $str;
10634 14 100       46 if ($features) {
    100          
10635 6         14 $str = '';
10636             } elsif ($sf) {
10637             # fixed focal length and aperture have zero for 2nd number
10638 4 50       16 $lf = 0 if $lf == $sf;
10639 4 50       20 $la = 0 if $la == $sa;
10640 4         13 $str = " $sf $lf $sa $la";
10641             } else {
10642 4         13 return undef;
10643             }
10644 10         15 my $flags = 0;
10645 10         21 my ($feature, $bits);
10646 10         24 foreach $feature (@lensFeatures) {
10647 80         149 foreach $bits (keys %{$$feature[1]}) {
  80         216  
10648             # set corresponding flag bits for each feature name found
10649 150         268 my $name = $$feature[1]{$bits};
10650 150 100       1071 $val =~ /\b$name\b/i and $flags |= $bits;
10651             }
10652             }
10653 10         109 return sprintf "%.2x$str %.2x", $flags>>8, $flags&0xff;
10654             }
10655              
10656             #------------------------------------------------------------------------------
10657             # Read/Write MoreInfo information (tag 0x0020, count 20480)
10658             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
10659             # Returns: 1 on success when reading, or new directory when writing (IsWriting set)
10660             sub ProcessMoreInfo($$$)
10661             {
10662 0     0 0 0 my ($et, $dirInfo, $tagTablePtr) = @_;
10663 0 0       0 $et or return 1; # allow dummy access to write routine
10664 0         0 my $dataPt = $$dirInfo{DataPt};
10665 0   0     0 my $start = $$dirInfo{DirStart} || 0;
10666 0   0     0 my $dirLen = $$dirInfo{DirLen} || length($$dataPt);
10667 0         0 my $isWriting = $$dirInfo{IsWriting};
10668 0 0       0 my $rtnVal = $isWriting ? undef : 0;
10669 0 0       0 return $rtnVal if $dirLen < 4;
10670              
10671 0         0 my $num = Get16u($dataPt, $start); # number of entries
10672 0         0 my $len = Get16u($dataPt, $start + 2); # total data length
10673              
10674 0 0       0 if ($dirLen < 4 + $num * 4) {
10675 0         0 $et->Warn('Truncated MoreInfo data', 1);
10676 0         0 return $rtnVal;
10677             }
10678 0 0       0 if ($num > 50) {
10679 0         0 $et->Warn('Possibly corrupted MoreInfo data', 1);
10680 0         0 return $rtnVal;
10681             }
10682              
10683 0 0       0 $et->VerboseDir('MoreInfo', $num, $len) unless $isWriting;
10684              
10685 0 0       0 if ($len > $dirLen) {
10686 0         0 $et->Warn('MoreInfo data length too large', 1);
10687 0         0 $len = $dirLen;
10688             }
10689             # loop through the MoreInfo index section to get the block offsets and tag ID's
10690             # (in case they are out of order, even though this may never happen)
10691 0         0 my ($i, @offset, @tagID, %blockSize);
10692 0         0 for ($i=0; $i<$num; ++$i) {
10693 0         0 my $entry = $start + 4 + $i * 4;
10694 0         0 push @tagID, Get16u($dataPt, $entry);
10695 0         0 push @offset, Get16u($dataPt, $entry + 2);
10696 0 0 0     0 if ($offset[-1] > $len and $offset[-1] <= $dirLen) {
10697 0         0 $et->Warn('MoreInfo data length too small', 1);
10698 0         0 $len = $dirLen;
10699             }
10700             }
10701             # generate a lookup table of block sizes
10702 0         0 my @sorted = sort { $a <=> $b } @offset;
  0         0  
10703 0         0 push @sorted, 0xffff; # (simplifies logic in loop below)
10704 0         0 for ($i=0; $i<$num; ++$i) {
10705 0         0 my $offset = $sorted[$i];
10706 0         0 my $size = $sorted[$i+1] - $offset;
10707             # note that block size will be negative for blocks with starting
10708             # offsets greater than $dirLen, but we will ignore these below
10709 0 0       0 $size = $len - $offset if $size > $len - $offset;
10710             # (if blockSize is already defined for this offset, then there
10711             # are 2 blocks with the same starting offset and the existing
10712             # size must be zero. Since we can't know which block is
10713             # actually non-zero size, the reasonable thing to do is
10714             # assume that both have a size of zero)
10715 0 0       0 $blockSize{$offset} = $size unless defined $blockSize{$offset};
10716             }
10717             # initialize successful return value
10718 0 0       0 $rtnVal = $isWriting ? substr($$dataPt, $start, $dirLen) : 1;
10719             # now process each block
10720 0         0 my $unknown = $$et{OPTIONS}{Unknown};
10721 0         0 for ($i=0; $i<$num; ++$i) {
10722 0 0       0 next if $offset[$i] > $dirLen; # ignore bad offsets
10723 0         0 my $tag = $tagID[$i];
10724 0 0       0 if ($isWriting) {
10725             # write new tags
10726 0         0 my $tagInfo = $$tagTablePtr{$tag};
10727 0 0 0     0 next unless ref $tagInfo eq 'HASH' and $$tagInfo{SubDirectory};
10728 0         0 my $offset = $offset[$i];
10729 0         0 my $size = $blockSize{$offset};
10730 0 0       0 next unless $size; # ignore zero-length blocks
10731             my %dirInfo = (
10732             DirName => $$tagInfo{Name},
10733             Parent => $$dirInfo{DirName},
10734 0         0 DataPt => \$rtnVal,
10735             DirStart => $offset,
10736             DirLen => $size,
10737             );
10738 0         0 my $subTable = GetTagTable($$tagInfo{SubDirectory}{TagTable});
10739 0         0 my $val = $et->WriteDirectory(\%dirInfo, $subTable);
10740             # update this block in the returned MoreInfo data
10741 0 0       0 substr($rtnVal, $offset, $size) = $val if defined $val;
10742 0         0 next;
10743             }
10744             # generate binary tables for unknown tags if -U option used
10745 0 0 0     0 if (not defined $$tagTablePtr{$tag} and $unknown > 1) {
10746 0         0 my $name = sprintf('MoreInfo%.4x', $tag);
10747 0         0 my $table = "Image::ExifTool::Sony::$name";
10748 26     26   374 no strict 'refs';
  26         81  
  26         2000  
10749 0         0 %$table = (
10750             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
10751             FIRST_ENTRY => 0,
10752             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
10753             );
10754 26     26   232 use strict 'refs';
  26         102  
  26         140137  
10755 0         0 my %tagInfo = (
10756             Name => $name,
10757             SubDirectory => { TagTable => $table },
10758             );
10759 0         0 AddTagToTable($tagTablePtr, $tag, \%tagInfo);
10760             }
10761             $et->HandleTag($tagTablePtr, $tag, undef,
10762             Index => $i,
10763             DataPt => $dataPt,
10764             DataPos => $$dirInfo{DataPos},
10765             Start => $start + $offset[$i],
10766 0         0 Size => $blockSize{$offset[$i]},
10767             );
10768             }
10769 0         0 return $rtnVal;
10770             }
10771              
10772             #------------------------------------------------------------------------------
10773             # Read Sony DSC-F1 PMP file
10774             # Inputs: 0) ExifTool object ref, 1) dirInfo ref
10775             # Returns: 1 on success when reading, 0 if this isn't a valid PMP file
10776             sub ProcessPMP($$)
10777             {
10778 1     1 0 5 my ($et, $dirInfo) = @_;
10779 1         4 my $raf = $$dirInfo{RAF};
10780 1         2 my $buff;
10781 1 50       5 $raf->Read($buff, 128) == 128 or return 0;
10782             # validate header length (124 bytes)
10783 1 50       7 $buff =~ /^.{8}\0{3}\x7c.{112}\xff\xd8\xff\xdb$/s or return 0;
10784 1         8 $et->SetFileType();
10785 1         6 SetByteOrder('MM');
10786 1         5 $et->FoundTag(Make => 'Sony');
10787 1         4 $et->FoundTag(Model => 'DSC-F1');
10788             # extract information from 124-byte header
10789 1         5 my $tagTablePtr = GetTagTable('Image::ExifTool::Sony::PMP');
10790 1         8 my %dirInfo = ( DataPt => \$buff, DirName => 'PMP' );
10791 1         6 $et->ProcessDirectory(\%dirInfo, $tagTablePtr);
10792             # process JPEG image
10793 1         6 $raf->Seek(124, 0);
10794 1         4 $$dirInfo{Base} = 124;
10795 1         10 $et->ProcessJPEG($dirInfo);
10796 1         5 return 1;
10797             }
10798              
10799             #------------------------------------------------------------------------------
10800             # Set the ARW file type and decide between SubIFD and A100DataOffset
10801             # Inputs: 0) ExifTool object ref, 1) reference to tag 0x14a raw data
10802             # Returns: true if tag 0x14a is a SubIFD, false otherwise
10803             sub SetARW($$)
10804             {
10805 0     0 0 0 my ($et, $valPt) = @_;
10806              
10807             # assume ARW for now -- SR2's get identified when FileFormat is parsed
10808 0         0 $et->OverrideFileType($$et{TIFF_TYPE} = 'ARW');
10809              
10810             # this should always be a SubIFD for models other than the A100
10811 0 0 0     0 return 1 unless $$et{Model} eq 'DSLR-A100' and length $$valPt == 4;
10812              
10813             # for the A100, IFD0 tag 0x14a is either a pointer to the raw data if this is
10814             # an original image, or a SubIFD offset if the image was edited by Sony IDC,
10815             # so assume it points to the raw data if it isn't a valid IFD (this assumption
10816             # will be checked later when we try to parse the SR2Private directory)
10817             my %subdir = (
10818             DirStart => Get32u($valPt, 0),
10819             Base => 0,
10820             RAF => $$et{RAF},
10821 0         0 AllowOutOfOrderTags => 1, # doh!
10822             );
10823 0         0 return Image::ExifTool::Exif::ValidateIFD(\%subdir);
10824             }
10825              
10826             #------------------------------------------------------------------------------
10827             # Finish writing ARW image, patching necessary Sony quirks, etc
10828             # Inputs: 0) ExifTool ref, 1) dirInfo ref, 2) EXIF data ref, 3) image data reference
10829             # Returns: undef on success, error string otherwise
10830             # Notes: (it turns that all of this is for the A100 only)
10831             sub FinishARW($$$$)
10832             {
10833 0     0 0 0 my ($et, $dirInfo, $dataPt, $imageData) = @_;
10834              
10835             # pre-scan IFD0 to get IFD entry offsets for each tag
10836 0         0 my $dataLen = length $$dataPt;
10837 0 0       0 return 'Truncated IFD0' if $dataLen < 2;
10838 0         0 my $n = Get16u($dataPt, 0);
10839 0 0       0 return 'Truncated IFD0' if $dataLen < 2 + 12 * $n;
10840 0         0 my ($i, %entry, $dataBlock, $pad, $dataOffset);
10841 0         0 for ($i=0; $i<$n; ++$i) {
10842 0         0 my $entry = 2 + $i * 12;
10843 0         0 $entry{Get16u($dataPt, $entry)} = $entry;
10844             }
10845             # fix up SR2Private offset and A100DataOffset (A100 only)
10846 0 0 0     0 if ($entry{0xc634} and $$et{MRWDirData}) {
10847 0 0       0 return 'Unexpected MRW block' unless $$et{Model} eq 'DSLR-A100';
10848 0 0 0     0 return 'Missing A100DataOffset' unless $entry{0x14a} and $$et{A100DataOffset};
10849             # account for total length of image data
10850 0         0 my $totalLen = 8 + $dataLen;
10851 0 0       0 if (ref $imageData) {
10852 0         0 foreach $dataBlock (@$imageData) {
10853 0         0 my ($pos, $size, $pad) = @$dataBlock;
10854 0         0 $totalLen += $size + $pad;
10855             }
10856             }
10857             # align MRW block on an even 4-byte boundary
10858 0         0 my $remain = $totalLen & 0x03;
10859 0 0 0     0 $pad = 4 - $remain and $totalLen += $pad if $remain;
10860             # set offset for the MRW directory data
10861 0         0 Set32u($totalLen, $dataPt, $entry{0xc634} + 8);
10862             # also pad MRWDirData data to an even 4 bytes (just to be safe)
10863 0         0 $remain = length($$et{MRWDirData}) & 0x03;
10864 0 0       0 $$et{MRWDirData} .= "\0" x (4 - $remain) if $remain;
10865 0         0 $totalLen += length $$et{MRWDirData};
10866             # fix up A100DataOffset
10867 0         0 $dataOffset = $$et{A100DataOffset};
10868 0         0 Set32u($totalLen, $dataPt, $entry{0x14a} + 8);
10869             }
10870             # patch double-referenced and incorrectly-sized A100 PreviewImage
10871 0 0 0     0 if ($entry{0x201} and $$et{A100PreviewStart} and
      0        
      0        
10872             $entry{0x202} and $$et{A100PreviewLength})
10873             {
10874 0         0 Set32u($$et{A100PreviewStart}, $dataPt, $entry{0x201} + 8);
10875 0         0 Set32u($$et{A100PreviewLength}, $dataPt, $entry{0x202} + 8);
10876             }
10877             # write TIFF IFD structure
10878 0         0 my $outfile = $$dirInfo{OutFile};
10879 0         0 my $header = GetByteOrder() . Set16u(0x2a) . Set32u(8);
10880 0 0       0 Write($outfile, $header, $$dataPt) or return 'Error writing';
10881             # copy over image data
10882 0 0       0 if (ref $imageData) {
10883 0 0       0 $et->CopyImageData($imageData, $outfile) or return 'Error copying image data';
10884             }
10885             # write MRW data if necessary
10886 0 0       0 if ($$et{MRWDirData}) {
10887 0 0       0 Write($outfile, "\0" x $pad) if $pad; # write padding if necessary
10888 0         0 Write($outfile, $$et{MRWDirData});
10889 0         0 delete $$et{MRWDirData};
10890             # set TIFF_END to copy over the MRW image data
10891 0 0       0 $$et{TIFF_END} = $dataOffset if $dataOffset;
10892             }
10893 0         0 return undef;
10894             }
10895              
10896             #------------------------------------------------------------------------------
10897             # Decrypt/Encrypt Sony data (ref 1) (reversible encryption)
10898             # Inputs: 0) data reference, 1) start offset, 2) data length, 3) decryption key
10899             # Returns: nothing (original data buffer is updated with decrypted data)
10900             # Notes: data length should be a multiple of 4
10901             sub Decrypt($$$$)
10902             {
10903 1     1 0 78 my ($dataPt, $start, $len, $key) = @_;
10904 1         3 my ($i, $j, @pad);
10905 1         9 my $words = int ($len / 4);
10906              
10907 1         8 for ($i=0; $i<4; ++$i) {
10908 4         10 my $lo = ($key & 0xffff) * 0x0edd + 1;
10909 4         9 my $hi = ($key >> 16) * 0x0edd + ($key & 0xffff) * 0x02e9 + ($lo >> 16);
10910 4         12 $pad[$i] = $key = (($hi & 0xffff) << 16) + ($lo & 0xffff);
10911             }
10912 1         6 $pad[3] = ($pad[3] << 1 | ($pad[0]^$pad[2]) >> 31) & 0xffffffff;
10913 1         5 for ($i=4; $i<0x7f; ++$i) {
10914 123         298 $pad[$i] = (($pad[$i-4]^$pad[$i-2]) << 1 |
10915             ($pad[$i-3]^$pad[$i-1]) >> 31) & 0xffffffff;
10916             }
10917 1         11 my @data = unpack("x$start N$words", $$dataPt);
10918 1         6 for ($i=0x7f,$j=0; $j<$words; ++$i,++$j) {
10919 1         7 $data[$j] ^= $pad[$i & 0x7f] = $pad[($i+1) & 0x7f] ^ $pad[($i+65) & 0x7f];
10920             }
10921 1         13 substr($$dataPt, $start, $words*4) = pack('N*', @data);
10922             }
10923              
10924             #------------------------------------------------------------------------------
10925             # Decipher/encipher Sony tag 0x2010, 0x900b, 0x9050 and 0x940x data (ref PH)
10926             # Inputs: 0) data reference, 1) true to encipher the data
10927             sub Decipher($;$)
10928             {
10929 0     0 0 0 my ($dataPt, $encipher) = @_;
10930             # This is a simple substitution cipher, so use a hardcoded translation table for speed.
10931             # The formula is: $c = ($b*$b*$b) % 249, where $c is the enciphered data byte
10932             # (note that bytes with values 249-255 are not translated, and 0-1, 82-84,
10933             # 165-167 and 248 have the same enciphered value)
10934 0 0       0 if ($encipher) { # encipher
10935 0         0 $$dataPt =~ tr/\x02-\xf7/\x08\x1b\x40\x7d\xd8\x5e\x0e\xe7\x04V\xea\xcd\x05\x8ap\xb6i\x88\x200\xbe\xd7\x81\xbb\x92\x0c\x28\xecl\xa0\x95Q\xd3\x2f\x5dj\x5c9\x07\xc5\x87L\x1a\xf0\xe2\xef\x24y\x02\xb7\xac\xe0\x60\x2bG\xba\x91\xcbu\x8e\x233\xc4\xe3\x96\xdc\xc2N\x7fb\xf6OeE\xeet\xcf\x138KRST\x5bn\x93\xd02\xb1aAW\xa9D\x27X\xdd\xc3\x10\xbc\xdbs\x83\x181\xd4\x15\xe5_\x7bF\xbf\xf3\xe8\xa4\x2d\x82\xb0\xbd\xaf\x8cZ\x1f\xda\x9fmJ\x3cIw\xccU\x11\x06\x3a\xb3\x7e\x9a\x14\xe4\x25\xc8\xe1v\x86\x1e\x3d\xe96\x1c\xa1\xd2\xb5P\xa2\xb8\x98H\xc7\x29f\x8b\x9e\xa5\xa6\xa7\xae\xc1\xe6\x2a\x85\x0b\xb4\x94\xaa\x03\x97z\xab7\x1dc\x165\xc6\xd6k\x84\x2eh\x3f\xb2\xce\x99\x19MB\xf7\x80\xd5\x0a\x17\x09\xdf\xadr4\xf2\xc0\x9d\x8f\x9c\xca\x26\xa8dY\x8d\x0d\xd1\xedg\x3ex\x22\x3b\xc9\xd9q\x90C\x89o\xf4\x2c\x0f\xa3\xf5\x12\xeb\x9b\x21\x7c\xb9\xde\xf1/;
10936             } else { # decipher
10937 0         0 $$dataPt =~ tr/\x08\x1b\x40\x7d\xd8\x5e\x0e\xe7\x04V\xea\xcd\x05\x8ap\xb6i\x88\x200\xbe\xd7\x81\xbb\x92\x0c\x28\xecl\xa0\x95Q\xd3\x2f\x5dj\x5c9\x07\xc5\x87L\x1a\xf0\xe2\xef\x24y\x02\xb7\xac\xe0\x60\x2bG\xba\x91\xcbu\x8e\x233\xc4\xe3\x96\xdc\xc2N\x7fb\xf6OeE\xeet\xcf\x138KRST\x5bn\x93\xd02\xb1aAW\xa9D\x27X\xdd\xc3\x10\xbc\xdbs\x83\x181\xd4\x15\xe5_\x7bF\xbf\xf3\xe8\xa4\x2d\x82\xb0\xbd\xaf\x8cZ\x1f\xda\x9fmJ\x3cIw\xccU\x11\x06\x3a\xb3\x7e\x9a\x14\xe4\x25\xc8\xe1v\x86\x1e\x3d\xe96\x1c\xa1\xd2\xb5P\xa2\xb8\x98H\xc7\x29f\x8b\x9e\xa5\xa6\xa7\xae\xc1\xe6\x2a\x85\x0b\xb4\x94\xaa\x03\x97z\xab7\x1dc\x165\xc6\xd6k\x84\x2eh\x3f\xb2\xce\x99\x19MB\xf7\x80\xd5\x0a\x17\x09\xdf\xadr4\xf2\xc0\x9d\x8f\x9c\xca\x26\xa8dY\x8d\x0d\xd1\xedg\x3ex\x22\x3b\xc9\xd9q\x90C\x89o\xf4\x2c\x0f\xa3\xf5\x12\xeb\x9b\x21\x7c\xb9\xde\xf1/\x02-\xf7/;
10938             }
10939             }
10940              
10941             #------------------------------------------------------------------------------
10942             # Process Sony 0x94xx cipherdata directory
10943             # Inputs: 0) ExifTool object ref, 1) directory information ref, 2) tag table ref
10944             # Returns: 1 on success
10945             # Notes:
10946             # 1) dirInfo may contain VarFormatData (reference to empty list) to return
10947             # details about any variable-length-format tags in the table (used when writing)
10948             # 2) A bug in ExifTool 9.04-9.10 could have double-enciphered these blocks
10949             sub ProcessEnciphered($$$)
10950             {
10951 0     0 0 0 my ($et, $dirInfo, $tagTablePtr) = @_;
10952 0         0 my $dataPt = $$dirInfo{DataPt};
10953 0   0     0 my $dirStart = $$dirInfo{DirStart} || 0;
10954 0   0     0 my $dirLen = $$dirInfo{DirLen} || (length($$dataPt) - $dirStart);
10955 0         0 my $data = substr($$dataPt, $dirStart, $dirLen);
10956             my %dirInfo = (
10957             %$dirInfo,
10958             DataPt => \$data,
10959 0         0 DataPos => $$dirInfo{DataPos} + $dirStart,
10960             DirStart => 0,
10961             );
10962 0         0 Decipher(\$data);
10963 0 0       0 if ($$et{DoubleCipher}) {
10964 0         0 Decipher(\$data);
10965 0         0 $et->WarnOnce('Some Sony metadata is double-enciphered. Write any tag to fix',1);
10966             }
10967 0 0       0 if ($et->Options('Verbose') > 2) {
10968 0   0     0 my $tagInfo = $$dirInfo{TagInfo} || { Name => 'data' };
10969 0 0       0 my $str = $$et{DoubleCipher} ? 'ouble-d' : '';
10970 0         0 $et->VerboseDir("D${str}eciphered $$tagInfo{Name}");
10971             $et->VerboseDump(\$data,
10972             Prefix => $$et{INDENT} . ' ',
10973 0   0     0 DataPos => $$dirInfo{DirStart} + $$dirInfo{DataPos} + ($$dirInfo{Base} || 0),
10974             );
10975             }
10976 0         0 return $et->ProcessBinaryData(\%dirInfo, $tagTablePtr);
10977             }
10978              
10979             #------------------------------------------------------------------------------
10980             # Write Sony 0x94xx cipherdata directory
10981             # Inputs: 0) ExifTool object ref, 1) source dirInfo ref, 2) tag table ref
10982             # Returns: cipherdata block or undefined on error
10983             sub WriteEnciphered($$$)
10984             {
10985 1346     1346 0 2722 my ($et, $dirInfo, $tagTablePtr) = @_;
10986 1346 50       5167 $et or return 1;
10987 0           my $dataPt = $$dirInfo{DataPt};
10988 0   0       my $dirStart = $$dirInfo{DirStart} || 0;
10989 0   0       my $dirLen = $$dirInfo{DirLen} || (length($$dataPt) - $dirStart);
10990 0           my $data = substr($$dataPt, $dirStart, $dirLen);
10991 0           my $changed = $$et{CHANGED};
10992 0           Decipher(\$data);
10993             # fix double-enciphered data (due to bug in ExifTool 9.04-9.10)
10994 0 0         if ($$et{DoubleCipher}) {
10995 0           Decipher(\$data);
10996 0           ++$$et{CHANGED};
10997 0           $et->WarnOnce('Fixed double-enciphered Sony metadata',1);
10998             }
10999             my %dirInfo = (
11000             %$dirInfo,
11001             DataPt => \$data,
11002 0           DataPos => $$dirInfo{DataPos} + $dirStart,
11003             DirStart => 0,
11004             );
11005 0           $data = $et->WriteBinaryData(\%dirInfo, $tagTablePtr);
11006 0 0         if ($changed == $$et{CHANGED}) {
    0          
11007             # nothing changed, so recover original data
11008 0           $data = substr($$dataPt, $dirStart, $dirLen);
11009             } elsif (defined $data) {
11010 0           Decipher(\$data,1); # re-encipher
11011             }
11012 0           return $data;
11013             }
11014              
11015             #------------------------------------------------------------------------------
11016             # Process "rtmd" timed metadata embedded in Sony MP4 videos (ref PH)
11017             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
11018             # Returns: 1 on success
11019             sub Process_rtmd($$$)
11020             {
11021 0     0 0   my ($et, $dirInfo, $tagTablePtr) = @_;
11022 0           my $dataPt = $$dirInfo{DataPt};
11023 0   0       my $dataPos = ($$dirInfo{DataPos} || 0) + ($$dirInfo{Base} || 0);
      0        
11024 0           my $end = length $$dataPt;
11025 0 0         return 0 if $end < 2;
11026 0           $et->VerboseDir('Sony rtmd', undef, $end);
11027             # Note: The 0x1c-byte header contains some as-yet unextracted information:
11028             # offset 0x0e: int8u some minutes
11029             # 0x0f: int8u some seconds
11030             # 0x11: int8u frame number? (0-24 or 0-25)
11031 0           my $pos = Get16u($dataPt, 0); # get header length (= 0x1c)
11032 0           while ($pos + 4 < $end) {
11033 0           my $tag = Get16u($dataPt, $pos);
11034 0 0         last if $tag == 0;
11035 0           my $len = Get16u($dataPt, $pos+2);
11036 0 0         if ($tag == 0x060e) {
11037 0           $len = 0x10; # (unknown 16 bytes starting with 0x060e2b340253)
11038             } else {
11039 0           $pos += 4; # skip tag id/size
11040 0 0         next if $tag == 0x8300; # descend into contents of 0x8300 (container)
11041             }
11042 0 0         last if $pos + $len > $end;
11043 0           $et->HandleTag($tagTablePtr, $tag, undef,
11044             DataPt => $dataPt,
11045             DataPos => $dataPos,
11046             Start => $pos,
11047             Size => $len,
11048             );
11049 0           $pos += $len; # step to next tag
11050             }
11051 0           return 1;
11052             };
11053              
11054             #------------------------------------------------------------------------------
11055             # Process SRF maker notes
11056             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
11057             # Returns: 1 on success
11058             sub ProcessSRF($$$)
11059             {
11060 0     0 0   my ($et, $dirInfo, $tagTablePtr) = @_;
11061 0           my $dataPt = $$dirInfo{DataPt};
11062 0           my $start = $$dirInfo{DirStart};
11063 0           my $verbose = $et->Options('Verbose');
11064              
11065             # process IFD chain
11066 0           my ($ifd, $success);
11067 0           for ($ifd=0; ; ) {
11068             # switch tag table for SRF2-5 and SRF6
11069 0 0         if ($ifd == 2) {
    0          
11070 0           $tagTablePtr = GetTagTable('Image::ExifTool::Sony::SRF2');
11071             } elsif ($ifd == 6) {
11072             # SRF6 uses standard EXIF tags
11073 0           $tagTablePtr = GetTagTable('Image::ExifTool::Exif::Main');
11074             }
11075 0           my $srf = $$dirInfo{DirName} = "SRF$ifd";
11076 0           $$et{SET_GROUP1} = $srf;
11077 0           $success = Image::ExifTool::Exif::ProcessExif($et, $dirInfo, $tagTablePtr);
11078 0           delete $$et{SET_GROUP1};
11079 0 0         last unless $success;
11080             #
11081             # get pointer to next IFD
11082             #
11083 0           my $count = Get16u($dataPt, $$dirInfo{DirStart});
11084 0           my $dirEnd = $$dirInfo{DirStart} + 2 + $count * 12;
11085 0 0         last if $dirEnd + 4 > length($$dataPt);
11086 0           my $nextIFD = Get32u($dataPt, $dirEnd);
11087 0 0         last unless $nextIFD;
11088 0           $nextIFD -= $$dirInfo{DataPos}; # adjust for position of makernotes data
11089 0           $$dirInfo{DirStart} = $nextIFD;
11090             #
11091             # decrypt next IFD data if necessary
11092             #
11093 0           ++$ifd;
11094 0           my ($key, $len);
11095 0 0         if ($ifd == 1) {
    0          
11096             # get the key to decrypt IFD1
11097 0           my $cp = $start + 0x8ddc; # why?
11098 0 0         last if $cp + 1 > length($$dataPt);
11099 0           my $ip = $cp + 4 * unpack("x$cp C", $$dataPt);
11100 0 0         last if $ip + 4 > length($$dataPt);
11101 0           $key = unpack("x$ip N", $$dataPt);
11102 0           $len = $cp + $nextIFD; # decrypt up to $cp
11103             } elsif ($ifd == 2) {
11104             # get the key to decrypt IFD2
11105 0           $key = $$et{SRF2Key};
11106 0           $len = length($$dataPt) - $nextIFD; # decrypt rest of maker notes
11107             } else {
11108 0           next; # no decryption needed
11109             }
11110             # decrypt data
11111 0 0         Decrypt($dataPt, $nextIFD, $len, $key) if defined $key;
11112 0 0         next unless $verbose > 2;
11113             # display decrypted data in verbose mode
11114 0           $et->VerboseDir("Decrypted SRF$ifd", 0, $nextIFD + $len);
11115             $et->VerboseDump($dataPt,
11116             Prefix => "$$et{INDENT} ",
11117             Start => $nextIFD,
11118             DataPos => $$dirInfo{DataPos},
11119 0           );
11120             }
11121             }
11122              
11123             #------------------------------------------------------------------------------
11124             # Write SR2 data
11125             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
11126             # Returns: 1 on success when reading, or SR2 directory or undef when writing
11127             sub WriteSR2($$$)
11128             {
11129 0     0 0   my ($et, $dirInfo, $tagTablePtr) = @_;
11130 0 0         $et or return 1; # allow dummy access
11131 0           my $buff = '';
11132 0           $$dirInfo{OutFile} = \$buff;
11133 0           return ProcessSR2($et, $dirInfo, $tagTablePtr);
11134             }
11135              
11136             #------------------------------------------------------------------------------
11137             # Read/Write SR2 IFD and its encrypted subdirectories
11138             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
11139             # Returns: 1 on success when reading, or SR2 directory or undef when writing
11140             sub ProcessSR2($$$)
11141             {
11142 0     0 0   my ($et, $dirInfo, $tagTablePtr) = @_;
11143 0           my $raf = $$dirInfo{RAF};
11144 0           my $dataPt = $$dirInfo{DataPt};
11145 0           my $dataPos = $$dirInfo{DataPos};
11146 0   0       my $dataLen = $$dirInfo{DataLen} || length $$dataPt;
11147 0   0       my $base = $$dirInfo{Base} || 0;
11148 0           my $outfile = $$dirInfo{OutFile};
11149              
11150             # clear SR2 member variables to be safe
11151 0           delete $$et{SR2SubIFDOffset};
11152 0           delete $$et{SR2SubIFDLength};
11153 0           delete $$et{SR2SubIFDKey};
11154              
11155             # make sure we have the first 4 bytes available to test directory type
11156 0           my $buff;
11157 0 0 0       if ($dataLen < 4 and $raf) {
11158 0   0       my $pos = $dataPos + ($$dirInfo{DirStart}||0) + $base;
11159 0 0 0       if ($raf->Seek($pos, 0) and $raf->Read($buff, 4) == 4) {
11160 0           $dataPt = \$buff;
11161 0           undef $$dirInfo{DataPt}; # must load data from file
11162 0           $raf->Seek($pos, 0);
11163             }
11164             }
11165             # this may either be a normal IFD, or a MRW data block
11166             # (only original ARW images from the A100 use the MRW block)
11167 0           my $dataOffset;
11168 0 0 0       if ($dataPt and $$dataPt =~ /^\0MR[IM]/) {
    0          
11169 0           my ($err, $srfPos, $srfLen, $dataOffset);
11170 0           $dataOffset = $$et{A100DataOffset};
11171 0 0         if ($dataOffset) {
11172             # save information about the RAW data trailer so it will be preserved
11173 0           $$et{KnownTrailer} = { Name => 'A100 RAW Data', Start => $dataOffset };
11174             } else {
11175 0           $err = 'A100DataOffset tag is missing from A100 ARW image';
11176             }
11177 0 0         $raf or $err = 'Unrecognized SR2 structure';
11178 0 0         unless ($err) {
11179 0           $srfPos = $raf->Tell();
11180 0           $srfLen = $dataOffset - $srfPos;
11181 0 0 0       unless ($srfLen > 0 and $raf->Read($buff, $srfLen) == $srfLen) {
11182 0           $err = 'Error reading MRW directory';
11183             }
11184             }
11185 0 0         if ($err) {
11186 0 0         $outfile and $et->Error($err), return undef;
11187 0           $et->Warn($err);
11188 0           return 0;
11189             }
11190 0           my %dirInfo = ( DataPt => \$buff );
11191 0           require Image::ExifTool::MinoltaRaw;
11192 0 0         if ($outfile) {
11193             # save MRW data to be written last
11194 0           $$et{MRWDirData} = Image::ExifTool::MinoltaRaw::WriteMRW($et, \%dirInfo);
11195 0 0         return $$et{MRWDirData} ? "\0\0\0\0\0\0" : undef;
11196             } else {
11197 0 0 0       if (not $outfile and $$et{HTML_DUMP}) {
11198 0           $et->HDump($srfPos, $srfLen, '[A100 SRF Data]');
11199             }
11200 0           return Image::ExifTool::MinoltaRaw::ProcessMRW($et, \%dirInfo);
11201             }
11202             } elsif ($$et{A100DataOffset}) {
11203 0           my $err = 'Unexpected A100DataOffset tag';
11204 0 0         $outfile and $et->Error($err), return undef;
11205 0           $et->Warn($err);
11206 0           return 0;
11207             }
11208 0           my $verbose = $et->Options('Verbose');
11209 0           my $result;
11210 0 0         if ($outfile) {
11211 0           $result = Image::ExifTool::Exif::WriteExif($et, $dirInfo, $tagTablePtr);
11212 0 0         return undef unless $result;
11213 0           $$outfile .= $result;
11214              
11215             } else {
11216 0           $result = Image::ExifTool::Exif::ProcessExif($et, $dirInfo, $tagTablePtr);
11217             }
11218 0 0 0       return $result unless $result and $$et{SR2SubIFDOffset};
11219             # only take first offset value if more than one!
11220 0           my @offsets = split ' ', $$et{SR2SubIFDOffset};
11221 0           my $offset = shift @offsets;
11222 0           my $length = $$et{SR2SubIFDLength};
11223 0           my $key = $$et{SR2SubIFDKey};
11224 0           my @subifdPos;
11225 0 0 0       if ($offset and $length and defined $key) {
      0        
11226 0           my $buff;
11227             # read encrypted SR2SubIFD from file
11228 0 0 0       if (($raf and $raf->Seek($offset+$base, 0) and
      0        
      0        
      0        
      0        
11229             $raf->Read($buff, $length) == $length) or
11230             # or read from data (when processing Adobe DNGPrivateData)
11231             ($offset - $dataPos >= 0 and $offset - $dataPos + $length < $dataLen and
11232             ($buff = substr($$dataPt, $offset - $dataPos, $length))))
11233             {
11234 0           Decrypt(\$buff, 0, $length, $key);
11235             # display decrypted data in verbose mode
11236 0 0 0       if ($verbose > 2 and not $outfile) {
11237 0           $et->VerboseDir("Decrypted SR2SubIFD", 0, $length);
11238 0           $et->VerboseDump(\$buff, Addr => $offset + $base);
11239             }
11240 0           my $num = '';
11241 0           my $dPos = $offset;
11242 0           for (;;) {
11243 0           my %dirInfo = (
11244             Base => $base,
11245             DataPt => \$buff,
11246             DataLen => length $buff,
11247             DirStart => $offset - $dPos,
11248             DirName => "SR2SubIFD$num",
11249             DataPos => $dPos,
11250             );
11251 0           my $subTable = GetTagTable('Image::ExifTool::Sony::SR2SubIFD');
11252 0 0         if ($outfile) {
11253 0           my $fixup = new Image::ExifTool::Fixup;
11254 0           $dirInfo{Fixup} = $fixup;
11255 0           $result = $et->WriteDirectory(\%dirInfo, $subTable);
11256 0 0         return undef unless $result;
11257             # save position of this SubIFD
11258 0           push @subifdPos, length($$outfile);
11259             # add this directory to the returned data
11260 0           $$fixup{Start} += length($$outfile);
11261 0           $$outfile .= $result;
11262 0           $$dirInfo{Fixup}->AddFixup($fixup);
11263             } else {
11264 0           $result = $et->ProcessDirectory(\%dirInfo, $subTable);
11265             }
11266 0 0         last unless @offsets;
11267 0           $offset = shift @offsets;
11268 0   0       $num = ($num || 1) + 1;
11269             }
11270              
11271             } else {
11272 0           $et->Warn('Error reading SR2 data');
11273             }
11274             }
11275 0 0 0       if ($outfile and @subifdPos) {
11276             # the SR2SubIFD must be padded to a multiple of 4 bytes for the encryption
11277 0           my $sr2Len = length($$outfile) - $subifdPos[0];
11278 0 0         if ($sr2Len & 0x03) {
11279 0           my $pad = 4 - ($sr2Len & 0x03);
11280 0           $sr2Len += $pad;
11281 0           $$outfile .= ' ' x $pad;
11282             }
11283             # save the new SR2SubIFD Length and Key to be used later for encryption
11284 0           $$et{SR2SubIFDLength} = $sr2Len;
11285 0           my $newKey = $$et{VALUE}{SR2SubIFDKey};
11286 0 0         $$et{SR2SubIFDKey} = $newKey if defined $newKey;
11287             # update SubIFD pointers manually and add to fixup, and set SR2SubIFDLength
11288 0           my $n = Get16u($outfile, 0);
11289 0           my ($i, %found);
11290 0           for ($i=0; $i<$n; ++$i) {
11291 0           my $entry = 2 + 12 * $i;
11292 0           my $tagID = Get16u($outfile, $entry);
11293             # only interested in SR2SubIFDOffset (0x7200) and SR2SubIFDLength (0x7201)
11294 0 0 0       next unless $tagID == 0x7200 or $tagID == 0x7201;
11295 0           $found{$tagID} = 1;
11296 0           my $fmt = Get16u($outfile, $entry + 2);
11297 0 0         if ($fmt != 0x04) { # must be int32u
11298 0           $et->Error("Unexpected format ($fmt) for SR2SubIFD tag");
11299 0           return undef;
11300             }
11301 0 0         if ($tagID == 0x7201) { # SR2SubIFDLength
11302 0           Set32u($sr2Len, $outfile, $entry + 8);
11303 0           next;
11304             }
11305 0           my $tag = 'SR2SubIFDOffset';
11306 0 0         my $valuePtr = @subifdPos < 2 ? $entry+8 : Get32u($outfile, $entry+8);
11307 0           my $pos;
11308 0           foreach $pos (@subifdPos) {
11309 0           Set32u($pos, $outfile, $valuePtr);
11310 0           $$dirInfo{Fixup}->AddFixup($valuePtr, $tag);
11311 0           undef $tag;
11312 0           $valuePtr += 4;
11313             }
11314             }
11315 0 0 0       unless ($found{0x7200} and $found{0x7201}) {
11316 0           $et->Error('Missing SR2SubIFD tag');
11317 0           return undef;
11318             }
11319             }
11320 0 0         return $outfile ? $$outfile : $result;
11321             }
11322              
11323             1; # end
11324              
11325             __END__