Coverage Report

Created: 2026-06-30 07:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libraw/src/metadata/olympus.cpp
Line
Count
Source
1
/* -*- C++ -*-
2
 * Copyright 2019-2025 LibRaw LLC (info@libraw.org)
3
 *
4
 LibRaw is free software; you can redistribute it and/or modify
5
 it under the terms of the one of two licenses as you choose:
6
7
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
8
   (See file LICENSE.LGPL provided in LibRaw distribution archive for details).
9
10
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
11
   (See file LICENSE.CDDL provided in LibRaw distribution archive for details).
12
13
 */
14
15
#include "../../internal/dcraw_defs.h"
16
#include "../../internal/libraw_cameraids.h"
17
18
void LibRaw::setOlympusBodyFeatures(unsigned long long id)
19
25.3k
{
20
25.3k
  ilm.CamID = id;
21
22
25.3k
  if ((id == OlyID_E_1)      ||
23
25.2k
      (id == OlyID_E_300)    ||
24
25.2k
      (id == OlyID_AIR_A01)  ||
25
25.2k
      ((id & 0xffff000000ULL) == 0x5330000000ULL))
26
57
  {
27
57
    ilm.CameraFormat = LIBRAW_FORMAT_FT;
28
29
57
    if ((id == OlyID_E_1)   ||
30
53
        (id == OlyID_E_300) ||
31
50
        ((id >= OlyID_E_330) && (id <= OlyID_E_520)) ||
32
35
        (id == OlyID_E_620) ||
33
32
        (id == OlyID_E_450) ||
34
30
        (id == OlyID_E_600) ||
35
26
        (id == OlyID_E_5))
36
35
    {
37
35
      ilm.CameraMount = LIBRAW_MOUNT_FT;
38
35
    }
39
22
    else
40
22
    {
41
22
      ilm.CameraMount = LIBRAW_MOUNT_mFT;
42
22
    }
43
57
  }
44
45
25.2k
  else
46
25.2k
  {
47
25.2k
    if (
48
25.2k
        (id == OlyID_SH_2)  ||
49
25.2k
        (id == OlyID_TG_4)  ||
50
25.2k
        (id == OlyID_TG_5)  ||
51
25.1k
        (id == OlyID_TG_6)  ||
52
25.1k
        (id == OlyID_TG_7)  ||
53
25.0k
        (id == OlyID_XZ_10)
54
25.2k
       ) {
55
165
      ilm.CameraFormat = LIBRAW_FORMAT_1div2p3INCH;
56
165
    }
57
25.0k
    else
58
25.0k
    {
59
25.0k
      if (
60
25.0k
           (id == OlyID_STYLUS_1) ||
61
25.0k
           (id == OlyID_XZ_2)
62
25.0k
         ) {
63
14
        ilm.CameraFormat = LIBRAW_FORMAT_1div1p7INCH;
64
14
      }
65
25.0k
    }
66
25.2k
    ilm.LensMount = ilm.CameraMount = LIBRAW_MOUNT_FixedLens;
67
25.2k
  }
68
25.3k
  return;
69
25.3k
}
70
71
void LibRaw::getOlympus_CameraType2()
72
131k
{
73
74
131k
  if (OlyID != 0x0ULL)
75
106k
    return;
76
77
25.3k
  int i = 0;
78
25.3k
  fread(imOly.CameraType2, 6, 1, ifp);
79
25.3k
  imOly.CameraType2[5] = 0;
80
34.6k
  while ((i < 6) && imOly.CameraType2[i])
81
9.51k
  {
82
9.51k
    OlyID = OlyID << 8 | imOly.CameraType2[i];
83
9.51k
    if (i < 5 && isspace(imOly.CameraType2[i + 1])) {
84
123
      imOly.CameraType2[i + 1] = '\0';
85
123
      break;
86
123
    }
87
9.39k
    i++;
88
9.39k
  }
89
25.3k
  if (OlyID == OlyID_NORMA) {
90
2
    if (strcmp(model, "SP510UZ")) OlyID = OlyID_SP_510UZ;
91
0
    else OlyID = 0x0ULL;
92
2
  }
93
25.3k
  unique_id = OlyID;
94
25.3k
  setOlympusBodyFeatures(OlyID);
95
25.3k
  return;
96
131k
}
97
98
void LibRaw::getOlympus_SensorTemperature(unsigned len)
99
28.2k
{
100
28.2k
  if (OlyID != 0x0ULL)
101
20.6k
  {
102
20.6k
    short temp = get2();
103
20.6k
    if ((OlyID == OlyID_E_1)  ||
104
20.6k
        (OlyID == OlyID_E_M5) ||
105
20.5k
        (len != 1))
106
2.83k
      imCommon.SensorTemperature = (float)temp;
107
17.8k
    else if ((temp != -32768) && (temp != 0))
108
15.1k
    {
109
15.1k
      if (temp > 199)
110
1.74k
        imCommon.SensorTemperature = 86.474958f - 0.120228f * (float)temp;
111
13.3k
      else
112
13.3k
        imCommon.SensorTemperature = (float)temp;
113
15.1k
    }
114
20.6k
  }
115
28.2k
  return;
116
28.2k
}
117
118
void LibRaw::parseOlympus_Equipment(unsigned tag, unsigned /*type */, unsigned len,
119
                                    unsigned dng_writer)
120
3.41M
{
121
  // uptag 2010
122
123
3.41M
  switch (tag)
124
3.41M
  {
125
79.5k
  case 0x0100:
126
79.5k
    getOlympus_CameraType2();
127
79.5k
    break;
128
13.2k
  case 0x0101:
129
13.2k
    if ((!imgdata.shootinginfo.BodySerial[0]) && (dng_writer == nonDNG))
130
10.2k
      stmread(imgdata.shootinginfo.BodySerial, len, ifp);
131
13.2k
    break;
132
14.7k
  case 0x0102:
133
14.7k
    stmread(imgdata.shootinginfo.InternalBodySerial, len, ifp);
134
14.7k
    break;
135
22.3k
  case 0x0201:
136
22.3k
  {
137
22.3k
  unsigned char bits[4] = { 0,0,0,0 };
138
22.3k
    fread(bits, 1, 4, ifp);
139
22.3k
    ilm.LensID = (unsigned long long)bits[0] << 16 |
140
22.3k
                 (unsigned long long)bits[2] << 8 | (unsigned long long)bits[3];
141
22.3k
    ilm.LensMount = LIBRAW_MOUNT_FT;
142
22.3k
    ilm.LensFormat = LIBRAW_FORMAT_FT;
143
22.3k
    if (((ilm.LensID < 0x20000) || (ilm.LensID > 0x4ffff)) &&
144
21.6k
        (ilm.LensID & 0x10))
145
4.10k
      ilm.LensMount = LIBRAW_MOUNT_mFT;
146
22.3k
  }
147
22.3k
    break;
148
9.36k
  case 0x0202:
149
9.36k
    if ((!imgdata.lens.LensSerial[0]))
150
7.22k
      stmread(imgdata.lens.LensSerial, len, ifp);
151
9.36k
    break;
152
11.6k
  case 0x0203:
153
11.6k
    stmread(ilm.Lens, len, ifp);
154
11.6k
    break;
155
8.92k
  case 0x0205:
156
8.92k
    ilm.MaxAp4MinFocal = libraw_powf64l(sqrt(2.0f), get2() / 256.0f);
157
8.92k
    break;
158
8.33k
  case 0x0206:
159
8.33k
    ilm.MaxAp4MaxFocal = libraw_powf64l(sqrt(2.0f), get2() / 256.0f);
160
8.33k
    break;
161
7.93k
  case 0x0207:
162
7.93k
    ilm.MinFocal = (float)get2();
163
7.93k
    break;
164
5.16k
  case 0x0208:
165
5.16k
    ilm.MaxFocal = (float)get2();
166
5.16k
    if (ilm.MaxFocal > 1000.0f)
167
3.15k
      ilm.MaxFocal = ilm.MinFocal;
168
5.16k
    break;
169
7.89k
  case 0x020a:
170
7.89k
    ilm.MaxAp4CurFocal = libraw_powf64l(sqrt(2.0f), get2() / 256.0f);
171
7.89k
    break;
172
24.6k
  case 0x0301:
173
24.6k
    ilm.TeleconverterID = fgetc(ifp) << 8;
174
24.6k
    fgetc(ifp);
175
24.6k
    ilm.TeleconverterID = ilm.TeleconverterID | fgetc(ifp);
176
24.6k
    break;
177
32.8k
  case 0x0303:
178
32.8k
    stmread(ilm.Teleconverter, len, ifp);
179
32.8k
    if (!strlen(ilm.Teleconverter) && strchr(ilm.Lens, '+')) {
180
3.49k
      if (strstr(ilm.Lens, "MC-20"))
181
803
        strcpy(ilm.Teleconverter, "MC-20");
182
2.69k
      else if (strstr(ilm.Lens, "MC-14"))
183
337
        strcpy(ilm.Teleconverter, "MC-14");
184
2.35k
      else if (strstr(ilm.Lens, "EC-20"))
185
351
        strcpy(ilm.Teleconverter, "EC-20");
186
2.00k
      else if (strstr(ilm.Lens, "EC-14"))
187
807
        strcpy(ilm.Teleconverter, "EC-14");    }
188
32.8k
    break;
189
2.46k
  case 0x0403:
190
2.46k
    stmread(ilm.Attachment, len, ifp);
191
2.46k
    break;
192
3.41M
  }
193
194
3.41M
  return;
195
3.41M
}
196
void LibRaw::parseOlympus_CameraSettings(INT64 base, unsigned tag, unsigned type,
197
                                         unsigned len, unsigned dng_writer)
198
1.23M
{
199
  // uptag 0x2020
200
201
1.23M
  int c;
202
1.23M
  switch (tag)
203
1.23M
  {
204
7.93k
  case 0x0101:
205
7.93k
    if (dng_writer == nonDNG)
206
3.37k
    {
207
3.37k
      thumb_offset = get4() + base;
208
3.37k
    }
209
7.93k
    break;
210
8.04k
  case 0x0102:
211
8.04k
    if (dng_writer == nonDNG)
212
3.51k
    {
213
3.51k
      thumb_length = get4();
214
3.51k
    }
215
8.04k
    break;
216
7.41k
  case 0x0200:
217
7.41k
    imgdata.shootinginfo.ExposureMode = get2();
218
7.41k
    break;
219
1.88k
  case 0x0202:
220
1.88k
    imgdata.shootinginfo.MeteringMode = get2();
221
1.88k
    break;
222
12.1k
  case 0x0301:
223
12.1k
    imgdata.shootinginfo.FocusMode = imOly.FocusMode[0] = get2();
224
12.1k
    if (len == 2)
225
1.59k
    {
226
1.59k
      imOly.FocusMode[1] = get2();
227
1.59k
    }
228
12.1k
    break;
229
2.72k
  case 0x0304:
230
177k
    for (c = 0; c < 64; c++)
231
174k
    {
232
174k
      imOly.AFAreas[c] = get4();
233
174k
    }
234
2.72k
    break;
235
1.23k
  case 0x0305:
236
7.42k
    for (c = 0; c < 5; c++)
237
6.19k
    {
238
6.19k
      imOly.AFPointSelected[c] = getreal(type);
239
6.19k
    }
240
1.23k
    break;
241
3.21k
  case 0x0306:
242
3.21k
    imOly.AFFineTune = fgetc(ifp);
243
3.21k
    break;
244
1.93k
  case 0x0307:
245
5.79k
    FORC3 imOly.AFFineTuneAdj[c] = get2();
246
1.93k
    break;
247
4.59k
  case 0x0401:
248
4.59k
    imCommon.FlashEC = getrealf(type);
249
4.59k
    break;
250
6.24k
  case 0x0507:
251
6.24k
    imOly.ColorSpace = get2();
252
6.24k
    switch (imOly.ColorSpace) {
253
1.93k
    case 0:
254
1.93k
      imCommon.ColorSpace = LIBRAW_COLORSPACE_sRGB;
255
1.93k
      break;
256
1.51k
    case 1:
257
1.51k
      imCommon.ColorSpace = LIBRAW_COLORSPACE_AdobeRGB;
258
1.51k
      break;
259
864
    case 2:
260
864
      imCommon.ColorSpace = LIBRAW_COLORSPACE_ProPhotoRGB;
261
864
      break;
262
1.92k
    default:
263
1.92k
      imCommon.ColorSpace = LIBRAW_COLORSPACE_Unknown;
264
1.92k
      break;
265
6.24k
    }
266
6.24k
    break;
267
6.24k
  case 0x0600:
268
5.89k
    imgdata.shootinginfo.DriveMode = imOly.DriveMode[0] = get2();
269
20.3k
    for (c = 1; c < (int)len && c < 5; c++)
270
14.4k
    {
271
14.4k
      imOly.DriveMode[c] = get2();
272
14.4k
    }
273
5.89k
    break;
274
1.91k
  case 0x0601:
275
1.91k
    imOly.Panorama_mode = get2();
276
1.91k
    imOly.Panorama_frameNum = get2();
277
1.91k
    break;
278
1.19k
  case 0x0604:
279
1.19k
    imgdata.shootinginfo.ImageStabilization = get4();
280
1.19k
    break;
281
4.05k
  case 0x0804:
282
4.05k
    imOly.StackedImage[0] = get4();
283
4.05k
    imOly.StackedImage[1] = get4();
284
4.05k
    if (imOly.StackedImage[0] == 3) {
285
1.24k
      imOly.isLiveND = 1;
286
1.24k
      imOly.LiveNDfactor = imOly.StackedImage[1];
287
2.80k
    } else {
288
2.80k
      imOly.isLiveND = 0;
289
2.80k
    }
290
4.05k
    break;
291
1.23M
  }
292
293
1.23M
  return;
294
1.23M
}
295
296
void LibRaw::parseOlympus_ImageProcessing(unsigned tag, unsigned type,
297
                                          unsigned len, unsigned dng_writer)
298
2.55M
{
299
  // uptag 0x2040
300
301
2.55M
  int i, c, wb[4], nWB, tWB, wbG;
302
2.55M
  ushort CT;
303
2.55M
  short sorder;
304
305
2.55M
  if ((tag == 0x0100) && (dng_writer == nonDNG))
306
39.0k
  {
307
39.0k
    cam_mul[0] = float(get2()) / 256.f;
308
39.0k
    cam_mul[2] = float(get2()) / 256.f;
309
39.0k
  }
310
2.51M
  else if ((tag == 0x0101) && (len == 2) &&
311
2.14k
           ((OlyID == OlyID_E_410) || (OlyID == OlyID_E_510)))
312
0
  {
313
0
    for (i = 0; i < 64; i++)
314
0
    {
315
0
    icWBCCTC[i][2] = icWBCCTC[i][4] = 256.f;
316
0
    icWBC[i][1] = icWBC[i][3] = 0x100;
317
0
    }
318
0
    for (i = 64; i < 256; i++)
319
0
    {
320
0
      icWBC[i][1] = icWBC[i][3] = 0x100;
321
0
    }
322
0
  }
323
2.51M
  else if ((tag > 0x0101) && (tag <= 0x0111))
324
73.8k
  {
325
73.8k
    nWB = tag - 0x0101;
326
73.8k
    tWB = Oly_wb_list2[nWB << 1];
327
73.8k
    CT = Oly_wb_list2[(nWB << 1) | 1];
328
73.8k
    wb[0] = get2();
329
73.8k
    wb[2] = get2();
330
73.8k
    if (tWB != 0x100)
331
55.6k
    {
332
55.6k
      icWBC[tWB][0] = wb[0];
333
55.6k
      icWBC[tWB][2] = wb[2];
334
55.6k
    }
335
73.8k
    if (CT)
336
29.7k
    {
337
29.7k
      icWBCCTC[nWB - 1][0] = CT;
338
29.7k
      icWBCCTC[nWB - 1][1] = float(wb[0]);
339
29.7k
      icWBCCTC[nWB - 1][3] = float(wb[2]);
340
29.7k
    }
341
73.8k
    if (len == 4)
342
7.44k
    {
343
7.44k
      wb[1] = get2();
344
7.44k
      wb[3] = get2();
345
7.44k
      if (tWB != 0x100)
346
3.78k
      {
347
3.78k
        icWBC[tWB][1] = wb[1];
348
3.78k
        icWBC[tWB][3] = wb[3];
349
3.78k
      }
350
7.44k
      if (CT)
351
3.86k
      {
352
3.86k
        icWBCCTC[nWB - 1][2] = float(wb[1]);
353
3.86k
        icWBCCTC[nWB - 1][4] = float(wb[3]);
354
3.86k
      }
355
7.44k
    }
356
73.8k
  }
357
2.44M
  else if ((tag >= 0x0112) && (tag <= 0x011e))
358
21.2k
  {
359
21.2k
    nWB = tag - 0x0112;
360
21.2k
    wbG = get2();
361
21.2k
    tWB = Oly_wb_list2[nWB << 1];
362
21.2k
    if (nWB)
363
18.4k
      icWBCCTC[nWB - 1][2] = icWBCCTC[nWB - 1][4] = float(wbG);
364
21.2k
    if (tWB != 0x100)
365
12.4k
      icWBC[tWB][1] = icWBC[tWB][3] = wbG;
366
21.2k
  }
367
2.42M
  else if (tag == 0x011f)
368
6.13k
  {
369
6.13k
    wbG = get2();
370
6.13k
    if (icWBC[LIBRAW_WBI_Flash][0])
371
1.13k
      icWBC[LIBRAW_WBI_Flash][1] =
372
1.13k
          icWBC[LIBRAW_WBI_Flash][3] = wbG;
373
24.5k
    FORC4 if (icWBC[LIBRAW_WBI_Custom1 + c][0])
374
4.94k
        icWBC[LIBRAW_WBI_Custom1 + c][1] =
375
4.94k
        icWBC[LIBRAW_WBI_Custom1 + c][3] = wbG;
376
6.13k
  }
377
2.41M
  else if (tag == 0x0121)
378
2.99k
  {
379
2.99k
    icWBC[LIBRAW_WBI_Flash][0] = get2();
380
2.99k
    icWBC[LIBRAW_WBI_Flash][2] = get2();
381
2.99k
    if (len == 4)
382
1.09k
    {
383
1.09k
      icWBC[LIBRAW_WBI_Flash][1] = get2();
384
1.09k
      icWBC[LIBRAW_WBI_Flash][3] = get2();
385
1.09k
    }
386
2.99k
  }
387
2.41M
  else if ((tag == 0x0200) && (dng_writer == nonDNG) &&
388
35.8k
           strcmp(software, "v757-71"))
389
34.5k
  {
390
138k
    for (i = 0; i < 3; i++)
391
103k
    {
392
103k
      if (!imOly.ColorSpace)
393
97.6k
      {
394
293k
        FORC3 cmatrix[i][c] = float((short)get2()) / 256.f;
395
97.6k
      }
396
6.07k
      else
397
6.07k
      {
398
18.2k
        FORC3 imgdata.color.ccm[i][c] = float((short)get2()) / 256.f;
399
6.07k
      }
400
103k
    }
401
34.5k
  }
402
2.37M
  else if ((tag == 0x0600) && (dng_writer == nonDNG))
403
18.7k
  {
404
75.1k
    FORC4 cblack[RGGB_2_RGBG(c)] = get2();
405
18.7k
  }
406
2.35M
  else if ((tag == 0x0611) && (dng_writer == nonDNG))
407
1.40k
  {
408
1.40k
     imOly.ValidBits = get2();
409
1.40k
  }
410
2.35M
  else if ((tag == 0x0612) && (dng_writer == nonDNG))
411
2.72k
  {
412
2.72k
    imgdata.sizes.raw_inset_crops[0].cleft = get2();
413
2.72k
  }
414
2.35M
  else if ((tag == 0x0613) && (dng_writer == nonDNG))
415
3.98k
  {
416
3.98k
    imgdata.sizes.raw_inset_crops[0].ctop = get2();
417
3.98k
  }
418
2.35M
  else if ((tag == 0x0614) && (dng_writer == nonDNG))
419
2.14k
  {
420
2.14k
    imgdata.sizes.raw_inset_crops[0].cwidth = get2();
421
2.14k
  }
422
2.34M
  else if ((tag == 0x0615) && (dng_writer == nonDNG))
423
1.95k
  {
424
1.95k
    imgdata.sizes.raw_inset_crops[0].cheight = get2();
425
1.95k
  }
426
2.34M
  else if ((tag == 0x0640) && (dng_writer == nonDNG))
427
1.19k
  {
428
1.19k
    imOly.tagX640 = get2();
429
1.19k
  }
430
2.34M
  else if ((tag == 0x0641) && (dng_writer == nonDNG))
431
910
  {
432
910
    imOly.tagX641 = get2();
433
910
  }
434
2.34M
  else if ((tag == 0x0642) && (dng_writer == nonDNG))
435
732
  {
436
732
    imOly.tagX642 = get2();
437
732
  }
438
2.34M
  else if ((tag == 0x0643) && (dng_writer == nonDNG))
439
1.20k
  {
440
1.20k
    imOly.tagX643 = get2();
441
1.20k
  }
442
2.34M
  else if ((tag == 0x0644) && (dng_writer == nonDNG))
443
1.67k
  {
444
1.67k
    imOly.tagX644 = get2();
445
1.67k
  }
446
2.34M
  else if ((tag == 0x0645) && (dng_writer == nonDNG))
447
862
  {
448
862
    imOly.tagX645 = get2();
449
862
  }
450
2.33M
  else if ((tag == 0x0646) && (dng_writer == nonDNG))
451
1.34k
  {
452
1.34k
    imOly.tagX646 = get2();
453
1.34k
  }
454
2.33M
  else if ((tag == 0x0647) && (dng_writer == nonDNG))
455
626
  {
456
626
    imOly.tagX647 = get2();
457
626
  }
458
2.33M
  else if ((tag == 0x0648) && (dng_writer == nonDNG))
459
1.04k
  {
460
1.04k
    imOly.tagX648 = get2();
461
1.04k
  }
462
2.33M
  else if ((tag == 0x0649) && (dng_writer == nonDNG))
463
2.02k
  {
464
2.02k
    imOly.tagX649 = get2();
465
2.02k
  }
466
2.33M
  else if ((tag == 0x0650) && (dng_writer == nonDNG))
467
1.26k
  {
468
1.26k
    imOly.tagX650 = get2();
469
1.26k
  }
470
2.33M
  else if ((tag == 0x0651) && (dng_writer == nonDNG))
471
809
  {
472
809
    imOly.tagX651 = get2();
473
809
  }
474
2.33M
  else if ((tag == 0x0652) && (dng_writer == nonDNG))
475
869
  {
476
869
    imOly.tagX652 = get2();
477
869
  }
478
2.33M
  else if ((tag == 0x0653) && (dng_writer == nonDNG))
479
1.97k
  {
480
1.97k
    imOly.tagX653 = get2();
481
1.97k
  }
482
2.32M
  else if ((tag == 0x0805) && (len == 2))
483
4.76k
  {
484
4.76k
    imOly.SensorCalibration[0] = int(getreal(type));
485
4.76k
    imOly.SensorCalibration[1] = int(getreal(type));
486
4.76k
    if ((dng_writer == nonDNG) && (OlyID != OlyID_XZ_1))
487
16.6k
      FORC4 imgdata.color.linear_max[c] = imOly.SensorCalibration[0];
488
4.76k
  }
489
2.32M
  else if (tag == 0x1112)
490
20.1k
  {
491
20.1k
    sorder = order;
492
20.1k
    order = 0x4d4d;
493
20.1k
    c = get2();
494
20.1k
    order = sorder;
495
20.1k
    switch (c) {
496
1.28k
    case 0x0101:
497
2.84k
    case 0x0901:
498
4.22k
    case 0x0909:
499
4.22k
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_4to3;
500
4.22k
      break;
501
2.08k
    case 0x0104:
502
3.41k
    case 0x0401:
503
3.41k
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_1to1;
504
3.41k
      break;
505
802
    case 0x0201:
506
1.87k
    case 0x0202:
507
1.87k
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_3to2;
508
1.87k
      break;
509
869
    case 0x0301:
510
1.60k
    case 0x0303:
511
1.60k
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_16to9;
512
1.60k
      break;
513
1.59k
    case 0x0404:
514
//      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_6to6;
515
1.59k
        imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_1to1;
516
1.59k
      break;
517
728
    case 0x0505:
518
728
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_5to4;
519
728
      break;
520
638
    case 0x0606:
521
638
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_7to6;
522
638
      break;
523
441
    case 0x0707:
524
441
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_6to5;
525
441
      break;
526
625
    case 0x0808:
527
625
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_7to5;
528
625
      break;
529
5.05k
    default:
530
5.05k
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_OTHER;
531
5.05k
      break;
532
20.1k
    }
533
20.1k
  }
534
2.30M
  else if (tag == 0x1113)
535
1.45k
  {
536
1.45k
    imOly.AspectFrame[0] = get2();
537
1.45k
    imOly.AspectFrame[1] = get2();
538
1.45k
    imOly.AspectFrame[2] = get2();
539
1.45k
    imOly.AspectFrame[3] = get2();
540
1.45k
  }
541
2.30M
  else if (tag == 0x1306)
542
10.9k
  {
543
10.9k
    c = get2();
544
10.9k
    if ((c != 0) && (c != 100))
545
7.45k
    {
546
7.45k
      if (c < 61)
547
1.63k
        imCommon.CameraTemperature = (float)c;
548
5.81k
      else
549
5.81k
        imCommon.CameraTemperature = (float)(c - 32) / 1.8f;
550
7.45k
      if ((imCommon.exifAmbientTemperature > -273.15f) &&
551
4.33k
          ((OlyID == OlyID_TG_5) ||
552
3.41k
           (OlyID == OlyID_TG_6) ||
553
2.74k
           (OlyID == OlyID_TG_7))
554
7.45k
      )
555
2.17k
        imCommon.CameraTemperature += imCommon.exifAmbientTemperature;
556
7.45k
    }
557
10.9k
  }
558
559
2.55M
  return;
560
2.55M
}
561
562
void LibRaw::parseOlympus_RawInfo(unsigned tag, unsigned /*type */, unsigned len,
563
                                  unsigned dng_writer)
564
1.49M
{
565
  // uptag 0x3000
566
567
1.49M
  int wb_ind, c, i;
568
569
1.49M
  if ((tag == 0x0110) && strcmp(software, "v757-71"))
570
12.9k
  {
571
12.9k
    icWBC[LIBRAW_WBI_Auto][0] = get2();
572
12.9k
    icWBC[LIBRAW_WBI_Auto][2] = get2();
573
12.9k
    if (len == 2)
574
6.37k
    {
575
1.63M
      for (i = 0; i < 256; i++)
576
1.63M
        icWBC[i][1] = icWBC[i][3] = 0x100;
577
6.37k
    }
578
12.9k
  }
579
1.47M
  else if ((((tag >= 0x0120) && (tag <= 0x0124)) ||
580
1.47M
            ((tag >= 0x0130) && (tag <= 0x0133))) &&
581
13.6k
           strcmp(software, "v757-71"))
582
11.9k
  {
583
11.9k
    if (tag <= 0x0124)
584
7.38k
      wb_ind = tag - 0x0120;
585
4.54k
    else
586
4.54k
      wb_ind = tag - 0x0130 + 5;
587
588
11.9k
    icWBC[Oly_wb_list1[wb_ind]][0] = get2();
589
11.9k
    icWBC[Oly_wb_list1[wb_ind]][2] = get2();
590
11.9k
  }
591
1.46M
  else if ((tag == 0x0200) && (dng_writer == nonDNG))
592
18.8k
  {
593
75.5k
    for (i = 0; i < 3; i++)
594
56.6k
    {
595
56.6k
      if (!imOly.ColorSpace)
596
53.4k
      {
597
160k
        FORC3 cmatrix[i][c] = float((short)get2()) / 256.f;
598
53.4k
      }
599
3.26k
      else
600
3.26k
      {
601
9.80k
        FORC3 imgdata.color.ccm[i][c] = float((short)get2()) / 256.f;
602
3.26k
      }
603
56.6k
    }
604
18.8k
  }
605
1.44M
  else if ((tag == 0x0600) && (dng_writer == nonDNG))
606
14.3k
  {
607
57.5k
    FORC4 cblack[RGGB_2_RGBG(c)] = get2();
608
14.3k
  }
609
1.43M
  else if ((tag == 0x0612) && (dng_writer == nonDNG))
610
998
  {
611
998
    imgdata.sizes.raw_inset_crops[0].cleft = get2();
612
998
  }
613
1.43M
  else if ((tag == 0x0613) && (dng_writer == nonDNG))
614
1.12k
  {
615
1.12k
    imgdata.sizes.raw_inset_crops[0].ctop = get2();
616
1.12k
  }
617
1.43M
  else if ((tag == 0x0614) && (dng_writer == nonDNG))
618
3.69k
  {
619
3.69k
    imgdata.sizes.raw_inset_crops[0].cwidth = get2();
620
3.69k
  }
621
1.42M
  else if ((tag == 0x0615) && (dng_writer == nonDNG))
622
2.53k
  {
623
2.53k
    imgdata.sizes.raw_inset_crops[0].cheight = get2();
624
2.53k
  }
625
1.49M
  return;
626
1.49M
}
627
628
629
26.4M
void LibRaw::parseOlympusMakernotes (INT64 base, unsigned tag, unsigned type, unsigned len, unsigned dng_writer) {
630
631
26.4M
  int c;
632
26.4M
  unsigned a;
633
26.4M
  if ((tag >= 0x20100000) && (tag <= 0x2010ffff)) {
634
3.41M
        parseOlympus_Equipment((tag & 0x0000ffff), type, len, dng_writer);
635
636
23.0M
  } else if ((tag >= 0x20200000) && (tag <= 0x2020ffff)) {
637
1.23M
    parseOlympus_CameraSettings(base, (tag & 0x0000ffff), type, len, dng_writer);
638
639
21.8M
  } else if ((tag >= 0x20400000) && (tag <= 0x2040ffff)) {
640
2.55M
     parseOlympus_ImageProcessing((tag & 0x0000ffff), type, len, dng_writer);
641
642
19.2M
  } else if ((tag >= 0x30000000) && (tag <= 0x3000ffff)) {
643
1.49M
        parseOlympus_RawInfo((tag & 0x0000ffff), type, len, dng_writer);
644
645
17.7M
  } else {
646
17.7M
    switch (tag) {
647
126k
      case 0x0200:
648
380k
        FORC3 if ((imOly.SpecialMode[c] = get4()) >= 0xff) imOly.SpecialMode[c] = 0xffffffff;
649
126k
        break;
650
51.8k
      case 0x0207:
651
51.8k
        getOlympus_CameraType2();
652
51.8k
        break;
653
20.4k
      case 0x0404:
654
22.8k
      case 0x101a:
655
22.8k
        if (!imgdata.shootinginfo.BodySerial[0] && (dng_writer == nonDNG))
656
12.4k
          stmread(imgdata.shootinginfo.BodySerial, len, ifp);
657
22.8k
        break;
658
4.21k
      case 0x1002:
659
4.21k
        ilm.CurAp = float(libraw_powf64l(2.0f, getrealf(type) / 2.f));
660
4.21k
        break;
661
2.40k
      case 0x1007:
662
2.40k
        imCommon.SensorTemperature = (float)get2();
663
2.40k
        break;
664
1.17k
      case 0x1008:
665
1.17k
        imCommon.LensTemperature = (float)get2();
666
1.17k
        break;
667
2.89k
      case 0x100b:
668
2.89k
        if (imOly.FocusMode[0] == 0xffff) {
669
1.27k
          imgdata.shootinginfo.FocusMode = imOly.FocusMode[0] = get2();
670
1.27k
          if (imgdata.shootinginfo.FocusMode == 1)
671
44
            imgdata.shootinginfo.FocusMode = imOly.FocusMode[0] = 10;
672
1.27k
        }
673
2.89k
        break;
674
4.31k
      case 0x100d:
675
4.31k
        if (imOly.ZoomStepCount == 0xffff) imOly.ZoomStepCount = get2();
676
4.31k
        break;
677
3.07k
      case 0x100e:
678
3.07k
        if (imOly.FocusStepCount == 0xffff) imOly.FocusStepCount = get2();
679
3.07k
        break;
680
6.05k
      case 0x1011:
681
6.05k
        if (strcmp(software, "v757-71") && (dng_writer == nonDNG)) {
682
20.0k
          for (int i = 0; i < 3; i++) {
683
15.0k
            if (!imOly.ColorSpace) {
684
23.7k
              FORC3 cmatrix[i][c] = float((short)get2()) / 256.f;
685
7.91k
            } else {
686
21.4k
              FORC3 imgdata.color.ccm[i][c] = float((short)get2()) / 256.f;
687
7.13k
            }
688
15.0k
          }
689
5.01k
        }
690
6.05k
        break;
691
2.62k
      case 0x1012:
692
2.62k
        if (dng_writer == nonDNG)
693
7.29k
          FORC4 cblack[RGGB_2_RGBG(c)] = get2();
694
2.62k
        break;
695
3.27k
      case 0x1017:
696
3.27k
        if (dng_writer == nonDNG)
697
2.84k
          cam_mul[0] = float(get2()) / 256.f;
698
3.27k
        break;
699
2.66k
      case 0x1018:
700
2.66k
        if (dng_writer == nonDNG)
701
1.92k
          cam_mul[2] = float(get2()) / 256.f;
702
2.66k
        break;
703
1.42k
      case 0x102c:
704
1.42k
        if (dng_writer == nonDNG)
705
992
          imOly.ValidBits = get2();
706
1.42k
        break;
707
1.55k
      case 0x1038:
708
1.55k
        imOly.AFResult = get2();
709
1.55k
        break;
710
3.41k
      case 0x103b:
711
3.41k
        if (imOly.FocusStepInfinity == 0xffff) imOly.FocusStepInfinity = get2();
712
3.41k
        break;
713
4.05k
      case 0x103c:
714
4.05k
        if (imOly.FocusStepNear == 0xffff) imOly.FocusStepNear = get2();
715
4.05k
        break;
716
1.66k
      case 0x20300108:
717
7.54k
      case 0x20310109:
718
7.54k
        if (dng_writer == nonDNG) {
719
6.97k
          imOly.ColorSpace = get2();
720
6.97k
          switch (imOly.ColorSpace) {
721
1.57k
          case 0:
722
1.57k
            imCommon.ColorSpace = LIBRAW_COLORSPACE_sRGB;
723
1.57k
            break;
724
982
          case 1:
725
982
            imCommon.ColorSpace = LIBRAW_COLORSPACE_AdobeRGB;
726
982
            break;
727
1.88k
          case 2:
728
1.88k
            imCommon.ColorSpace = LIBRAW_COLORSPACE_ProPhotoRGB;
729
1.88k
            break;
730
2.53k
          default:
731
2.53k
            imCommon.ColorSpace = LIBRAW_COLORSPACE_Unknown;
732
2.53k
            break;
733
6.97k
          }
734
6.97k
        }
735
9.16k
      case 0x20500209:
736
9.16k
        imOly.AutoFocus = get2();
737
9.16k
        break;
738
17.0k
      case 0x20500300:
739
17.0k
        imOly.ZoomStepCount = get2();
740
17.0k
        break;
741
1.36k
      case 0x20500301:
742
1.36k
        imOly.FocusStepCount = get2();
743
1.36k
        break;
744
24.3k
      case 0x20500303:
745
24.3k
        imOly.FocusStepInfinity = get2();
746
24.3k
        break;
747
2.58k
      case 0x20500304:
748
2.58k
        imOly.FocusStepNear = get2();
749
2.58k
        break;
750
4.18k
      case 0x20500305:
751
4.18k
        a = get4();
752
4.18k
        /*b = */ get4(); // b is not used, so removed
753
4.18k
        if (a >= 0x7f000000) imOly.FocusDistance = -1.0; // infinity
754
2.16k
        else imOly.FocusDistance = (double) a / 1000.0;  // convert to meters
755
4.18k
        break;
756
2.90k
      case 0x20500308:
757
2.90k
        imOly.AFPoint = get2();
758
2.90k
        break;
759
28.2k
      case 0x20501500:
760
28.2k
        getOlympus_SensorTemperature(len);
761
28.2k
        break;
762
17.7M
    }
763
17.7M
  }
764
26.4M
}