Coverage Report

Created: 2026-03-12 07:14

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
0
{
20
0
  ilm.CamID = id;
21
22
0
  if ((id == OlyID_E_1)      ||
23
0
      (id == OlyID_E_300)    ||
24
0
      (id == OlyID_AIR_A01)  ||
25
0
      ((id & 0xffff000000ULL) == 0x5330000000ULL))
26
0
  {
27
0
    ilm.CameraFormat = LIBRAW_FORMAT_FT;
28
29
0
    if ((id == OlyID_E_1)   ||
30
0
        (id == OlyID_E_300) ||
31
0
        ((id >= OlyID_E_330) && (id <= OlyID_E_520)) ||
32
0
        (id == OlyID_E_620) ||
33
0
        (id == OlyID_E_450) ||
34
0
        (id == OlyID_E_600) ||
35
0
        (id == OlyID_E_5))
36
0
    {
37
0
      ilm.CameraMount = LIBRAW_MOUNT_FT;
38
0
    }
39
0
    else
40
0
    {
41
0
      ilm.CameraMount = LIBRAW_MOUNT_mFT;
42
0
    }
43
0
  }
44
45
0
  else
46
0
  {
47
0
    if (
48
0
        (id == OlyID_SH_2)  ||
49
0
        (id == OlyID_TG_4)  ||
50
0
        (id == OlyID_TG_5)  ||
51
0
        (id == OlyID_TG_6)  ||
52
0
        (id == OlyID_TG_7)  ||
53
0
        (id == OlyID_XZ_10)
54
0
       ) {
55
0
      ilm.CameraFormat = LIBRAW_FORMAT_1div2p3INCH;
56
0
    }
57
0
    else
58
0
    {
59
0
      if (
60
0
           (id == OlyID_STYLUS_1) ||
61
0
           (id == OlyID_XZ_2)
62
0
         ) {
63
0
        ilm.CameraFormat = LIBRAW_FORMAT_1div1p7INCH;
64
0
      }
65
0
    }
66
0
    ilm.LensMount = ilm.CameraMount = LIBRAW_MOUNT_FixedLens;
67
0
  }
68
0
  return;
69
0
}
70
71
void LibRaw::getOlympus_CameraType2()
72
0
{
73
74
0
  if (OlyID != 0x0ULL)
75
0
    return;
76
77
0
  int i = 0;
78
0
  fread(imOly.CameraType2, 6, 1, ifp);
79
0
  imOly.CameraType2[5] = 0;
80
0
  while ((i < 6) && imOly.CameraType2[i])
81
0
  {
82
0
    OlyID = OlyID << 8 | imOly.CameraType2[i];
83
0
    if (i < 5 && isspace(imOly.CameraType2[i + 1])) {
84
0
      imOly.CameraType2[i + 1] = '\0';
85
0
      break;
86
0
    }
87
0
    i++;
88
0
  }
89
0
  if (OlyID == OlyID_NORMA) {
90
0
    if (strcmp(model, "SP510UZ")) OlyID = OlyID_SP_510UZ;
91
0
    else OlyID = 0x0ULL;
92
0
  }
93
0
  unique_id = OlyID;
94
0
  setOlympusBodyFeatures(OlyID);
95
0
  return;
96
0
}
97
98
void LibRaw::getOlympus_SensorTemperature(unsigned len)
99
0
{
100
0
  if (OlyID != 0x0ULL)
101
0
  {
102
0
    short temp = get2();
103
0
    if ((OlyID == OlyID_E_1)  ||
104
0
        (OlyID == OlyID_E_M5) ||
105
0
        (len != 1))
106
0
      imCommon.SensorTemperature = (float)temp;
107
0
    else if ((temp != -32768) && (temp != 0))
108
0
    {
109
0
      if (temp > 199)
110
0
        imCommon.SensorTemperature = 86.474958f - 0.120228f * (float)temp;
111
0
      else
112
0
        imCommon.SensorTemperature = (float)temp;
113
0
    }
114
0
  }
115
0
  return;
116
0
}
117
118
void LibRaw::parseOlympus_Equipment(unsigned tag, unsigned /*type */, unsigned len,
119
                                    unsigned dng_writer)
120
0
{
121
  // uptag 2010
122
123
0
  switch (tag)
124
0
  {
125
0
  case 0x0100:
126
0
    getOlympus_CameraType2();
127
0
    break;
128
0
  case 0x0101:
129
0
    if ((!imgdata.shootinginfo.BodySerial[0]) && (dng_writer == nonDNG))
130
0
      stmread(imgdata.shootinginfo.BodySerial, len, ifp);
131
0
    break;
132
0
  case 0x0102:
133
0
    stmread(imgdata.shootinginfo.InternalBodySerial, len, ifp);
134
0
    break;
135
0
  case 0x0201:
136
0
  {
137
0
  unsigned char bits[4] = { 0,0,0,0 };
138
0
    fread(bits, 1, 4, ifp);
139
0
    ilm.LensID = (unsigned long long)bits[0] << 16 |
140
0
                 (unsigned long long)bits[2] << 8 | (unsigned long long)bits[3];
141
0
    ilm.LensMount = LIBRAW_MOUNT_FT;
142
0
    ilm.LensFormat = LIBRAW_FORMAT_FT;
143
0
    if (((ilm.LensID < 0x20000) || (ilm.LensID > 0x4ffff)) &&
144
0
        (ilm.LensID & 0x10))
145
0
      ilm.LensMount = LIBRAW_MOUNT_mFT;
146
0
  }
147
0
    break;
148
0
  case 0x0202:
149
0
    if ((!imgdata.lens.LensSerial[0]))
150
0
      stmread(imgdata.lens.LensSerial, len, ifp);
151
0
    break;
152
0
  case 0x0203:
153
0
    stmread(ilm.Lens, len, ifp);
154
0
    break;
155
0
  case 0x0205:
156
0
    ilm.MaxAp4MinFocal = libraw_powf64l(sqrt(2.0f), get2() / 256.0f);
157
0
    break;
158
0
  case 0x0206:
159
0
    ilm.MaxAp4MaxFocal = libraw_powf64l(sqrt(2.0f), get2() / 256.0f);
160
0
    break;
161
0
  case 0x0207:
162
0
    ilm.MinFocal = (float)get2();
163
0
    break;
164
0
  case 0x0208:
165
0
    ilm.MaxFocal = (float)get2();
166
0
    if (ilm.MaxFocal > 1000.0f)
167
0
      ilm.MaxFocal = ilm.MinFocal;
168
0
    break;
169
0
  case 0x020a:
170
0
    ilm.MaxAp4CurFocal = libraw_powf64l(sqrt(2.0f), get2() / 256.0f);
171
0
    break;
172
0
  case 0x0301:
173
0
    ilm.TeleconverterID = fgetc(ifp) << 8;
174
0
    fgetc(ifp);
175
0
    ilm.TeleconverterID = ilm.TeleconverterID | fgetc(ifp);
176
0
    break;
177
0
  case 0x0303:
178
0
    stmread(ilm.Teleconverter, len, ifp);
179
0
    if (!strlen(ilm.Teleconverter) && strchr(ilm.Lens, '+')) {
180
0
      if (strstr(ilm.Lens, "MC-20"))
181
0
        strcpy(ilm.Teleconverter, "MC-20");
182
0
      else if (strstr(ilm.Lens, "MC-14"))
183
0
        strcpy(ilm.Teleconverter, "MC-14");
184
0
      else if (strstr(ilm.Lens, "EC-20"))
185
0
        strcpy(ilm.Teleconverter, "EC-20");
186
0
      else if (strstr(ilm.Lens, "EC-14"))
187
0
        strcpy(ilm.Teleconverter, "EC-14");    }
188
0
    break;
189
0
  case 0x0403:
190
0
    stmread(ilm.Attachment, len, ifp);
191
0
    break;
192
0
  }
193
194
0
  return;
195
0
}
196
void LibRaw::parseOlympus_CameraSettings(INT64 base, unsigned tag, unsigned type,
197
                                         unsigned len, unsigned dng_writer)
198
0
{
199
  // uptag 0x2020
200
201
0
  int c;
202
0
  switch (tag)
203
0
  {
204
0
  case 0x0101:
205
0
    if (dng_writer == nonDNG)
206
0
    {
207
0
      thumb_offset = get4() + base;
208
0
    }
209
0
    break;
210
0
  case 0x0102:
211
0
    if (dng_writer == nonDNG)
212
0
    {
213
0
      thumb_length = get4();
214
0
    }
215
0
    break;
216
0
  case 0x0200:
217
0
    imgdata.shootinginfo.ExposureMode = get2();
218
0
    break;
219
0
  case 0x0202:
220
0
    imgdata.shootinginfo.MeteringMode = get2();
221
0
    break;
222
0
  case 0x0301:
223
0
    imgdata.shootinginfo.FocusMode = imOly.FocusMode[0] = get2();
224
0
    if (len == 2)
225
0
    {
226
0
      imOly.FocusMode[1] = get2();
227
0
    }
228
0
    break;
229
0
  case 0x0304:
230
0
    for (c = 0; c < 64; c++)
231
0
    {
232
0
      imOly.AFAreas[c] = get4();
233
0
    }
234
0
    break;
235
0
  case 0x0305:
236
0
    for (c = 0; c < 5; c++)
237
0
    {
238
0
      imOly.AFPointSelected[c] = getreal(type);
239
0
    }
240
0
    break;
241
0
  case 0x0306:
242
0
    imOly.AFFineTune = fgetc(ifp);
243
0
    break;
244
0
  case 0x0307:
245
0
    FORC3 imOly.AFFineTuneAdj[c] = get2();
246
0
    break;
247
0
  case 0x0401:
248
0
    imCommon.FlashEC = getrealf(type);
249
0
    break;
250
0
  case 0x0507:
251
0
    imOly.ColorSpace = get2();
252
0
    switch (imOly.ColorSpace) {
253
0
    case 0:
254
0
      imCommon.ColorSpace = LIBRAW_COLORSPACE_sRGB;
255
0
      break;
256
0
    case 1:
257
0
      imCommon.ColorSpace = LIBRAW_COLORSPACE_AdobeRGB;
258
0
      break;
259
0
    case 2:
260
0
      imCommon.ColorSpace = LIBRAW_COLORSPACE_ProPhotoRGB;
261
0
      break;
262
0
    default:
263
0
      imCommon.ColorSpace = LIBRAW_COLORSPACE_Unknown;
264
0
      break;
265
0
    }
266
0
    break;
267
0
  case 0x0600:
268
0
    imgdata.shootinginfo.DriveMode = imOly.DriveMode[0] = get2();
269
0
    for (c = 1; c < (int)len && c < 5; c++)
270
0
    {
271
0
      imOly.DriveMode[c] = get2();
272
0
    }
273
0
    break;
274
0
  case 0x0601:
275
0
    imOly.Panorama_mode = get2();
276
0
    imOly.Panorama_frameNum = get2();
277
0
    break;
278
0
  case 0x0604:
279
0
    imgdata.shootinginfo.ImageStabilization = get4();
280
0
    break;
281
0
  case 0x0804:
282
0
    imOly.StackedImage[0] = get4();
283
0
    imOly.StackedImage[1] = get4();
284
0
    if (imOly.StackedImage[0] == 3) {
285
0
      imOly.isLiveND = 1;
286
0
      imOly.LiveNDfactor = imOly.StackedImage[1];
287
0
    } else {
288
0
      imOly.isLiveND = 0;
289
0
    }
290
0
    break;
291
0
  }
292
293
0
  return;
294
0
}
295
296
void LibRaw::parseOlympus_ImageProcessing(unsigned tag, unsigned type,
297
                                          unsigned len, unsigned dng_writer)
298
0
{
299
  // uptag 0x2040
300
301
0
  int i, c, wb[4], nWB, tWB, wbG;
302
0
  ushort CT;
303
0
  short sorder;
304
305
0
  if ((tag == 0x0100) && (dng_writer == nonDNG))
306
0
  {
307
0
    cam_mul[0] = float(get2()) / 256.f;
308
0
    cam_mul[2] = float(get2()) / 256.f;
309
0
  }
310
0
  else if ((tag == 0x0101) && (len == 2) &&
311
0
           ((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
0
  else if ((tag > 0x0101) && (tag <= 0x0111))
324
0
  {
325
0
    nWB = tag - 0x0101;
326
0
    tWB = Oly_wb_list2[nWB << 1];
327
0
    CT = Oly_wb_list2[(nWB << 1) | 1];
328
0
    wb[0] = get2();
329
0
    wb[2] = get2();
330
0
    if (tWB != 0x100)
331
0
    {
332
0
      icWBC[tWB][0] = wb[0];
333
0
      icWBC[tWB][2] = wb[2];
334
0
    }
335
0
    if (CT)
336
0
    {
337
0
      icWBCCTC[nWB - 1][0] = CT;
338
0
      icWBCCTC[nWB - 1][1] = float(wb[0]);
339
0
      icWBCCTC[nWB - 1][3] = float(wb[2]);
340
0
    }
341
0
    if (len == 4)
342
0
    {
343
0
      wb[1] = get2();
344
0
      wb[3] = get2();
345
0
      if (tWB != 0x100)
346
0
      {
347
0
        icWBC[tWB][1] = wb[1];
348
0
        icWBC[tWB][3] = wb[3];
349
0
      }
350
0
      if (CT)
351
0
      {
352
0
        icWBCCTC[nWB - 1][2] = float(wb[1]);
353
0
        icWBCCTC[nWB - 1][4] = float(wb[3]);
354
0
      }
355
0
    }
356
0
  }
357
0
  else if ((tag >= 0x0112) && (tag <= 0x011e))
358
0
  {
359
0
    nWB = tag - 0x0112;
360
0
    wbG = get2();
361
0
    tWB = Oly_wb_list2[nWB << 1];
362
0
    if (nWB)
363
0
      icWBCCTC[nWB - 1][2] = icWBCCTC[nWB - 1][4] = float(wbG);
364
0
    if (tWB != 0x100)
365
0
      icWBC[tWB][1] = icWBC[tWB][3] = wbG;
366
0
  }
367
0
  else if (tag == 0x011f)
368
0
  {
369
0
    wbG = get2();
370
0
    if (icWBC[LIBRAW_WBI_Flash][0])
371
0
      icWBC[LIBRAW_WBI_Flash][1] =
372
0
          icWBC[LIBRAW_WBI_Flash][3] = wbG;
373
0
    FORC4 if (icWBC[LIBRAW_WBI_Custom1 + c][0])
374
0
        icWBC[LIBRAW_WBI_Custom1 + c][1] =
375
0
        icWBC[LIBRAW_WBI_Custom1 + c][3] = wbG;
376
0
  }
377
0
  else if (tag == 0x0121)
378
0
  {
379
0
    icWBC[LIBRAW_WBI_Flash][0] = get2();
380
0
    icWBC[LIBRAW_WBI_Flash][2] = get2();
381
0
    if (len == 4)
382
0
    {
383
0
      icWBC[LIBRAW_WBI_Flash][1] = get2();
384
0
      icWBC[LIBRAW_WBI_Flash][3] = get2();
385
0
    }
386
0
  }
387
0
  else if ((tag == 0x0200) && (dng_writer == nonDNG) &&
388
0
           strcmp(software, "v757-71"))
389
0
  {
390
0
    for (i = 0; i < 3; i++)
391
0
    {
392
0
      if (!imOly.ColorSpace)
393
0
      {
394
0
        FORC3 cmatrix[i][c] = float((short)get2()) / 256.f;
395
0
      }
396
0
      else
397
0
      {
398
0
        FORC3 imgdata.color.ccm[i][c] = float((short)get2()) / 256.f;
399
0
      }
400
0
    }
401
0
  }
402
0
  else if ((tag == 0x0600) && (dng_writer == nonDNG))
403
0
  {
404
0
    FORC4 cblack[RGGB_2_RGBG(c)] = get2();
405
0
  }
406
0
  else if ((tag == 0x0611) && (dng_writer == nonDNG))
407
0
  {
408
0
     imOly.ValidBits = get2();
409
0
  }
410
0
  else if ((tag == 0x0612) && (dng_writer == nonDNG))
411
0
  {
412
0
    imgdata.sizes.raw_inset_crops[0].cleft = get2();
413
0
  }
414
0
  else if ((tag == 0x0613) && (dng_writer == nonDNG))
415
0
  {
416
0
    imgdata.sizes.raw_inset_crops[0].ctop = get2();
417
0
  }
418
0
  else if ((tag == 0x0614) && (dng_writer == nonDNG))
419
0
  {
420
0
    imgdata.sizes.raw_inset_crops[0].cwidth = get2();
421
0
  }
422
0
  else if ((tag == 0x0615) && (dng_writer == nonDNG))
423
0
  {
424
0
    imgdata.sizes.raw_inset_crops[0].cheight = get2();
425
0
  }
426
0
  else if ((tag == 0x0640) && (dng_writer == nonDNG))
427
0
  {
428
0
    imOly.tagX640 = get2();
429
0
  }
430
0
  else if ((tag == 0x0641) && (dng_writer == nonDNG))
431
0
  {
432
0
    imOly.tagX641 = get2();
433
0
  }
434
0
  else if ((tag == 0x0642) && (dng_writer == nonDNG))
435
0
  {
436
0
    imOly.tagX642 = get2();
437
0
  }
438
0
  else if ((tag == 0x0643) && (dng_writer == nonDNG))
439
0
  {
440
0
    imOly.tagX643 = get2();
441
0
  }
442
0
  else if ((tag == 0x0644) && (dng_writer == nonDNG))
443
0
  {
444
0
    imOly.tagX644 = get2();
445
0
  }
446
0
  else if ((tag == 0x0645) && (dng_writer == nonDNG))
447
0
  {
448
0
    imOly.tagX645 = get2();
449
0
  }
450
0
  else if ((tag == 0x0646) && (dng_writer == nonDNG))
451
0
  {
452
0
    imOly.tagX646 = get2();
453
0
  }
454
0
  else if ((tag == 0x0647) && (dng_writer == nonDNG))
455
0
  {
456
0
    imOly.tagX647 = get2();
457
0
  }
458
0
  else if ((tag == 0x0648) && (dng_writer == nonDNG))
459
0
  {
460
0
    imOly.tagX648 = get2();
461
0
  }
462
0
  else if ((tag == 0x0649) && (dng_writer == nonDNG))
463
0
  {
464
0
    imOly.tagX649 = get2();
465
0
  }
466
0
  else if ((tag == 0x0650) && (dng_writer == nonDNG))
467
0
  {
468
0
    imOly.tagX650 = get2();
469
0
  }
470
0
  else if ((tag == 0x0651) && (dng_writer == nonDNG))
471
0
  {
472
0
    imOly.tagX651 = get2();
473
0
  }
474
0
  else if ((tag == 0x0652) && (dng_writer == nonDNG))
475
0
  {
476
0
    imOly.tagX652 = get2();
477
0
  }
478
0
  else if ((tag == 0x0653) && (dng_writer == nonDNG))
479
0
  {
480
0
    imOly.tagX653 = get2();
481
0
  }
482
0
  else if ((tag == 0x0805) && (len == 2))
483
0
  {
484
0
    imOly.SensorCalibration[0] = int(getreal(type));
485
0
    imOly.SensorCalibration[1] = int(getreal(type));
486
0
    if ((dng_writer == nonDNG) && (OlyID != OlyID_XZ_1))
487
0
      FORC4 imgdata.color.linear_max[c] = imOly.SensorCalibration[0];
488
0
  }
489
0
  else if (tag == 0x1112)
490
0
  {
491
0
    sorder = order;
492
0
    order = 0x4d4d;
493
0
    c = get2();
494
0
    order = sorder;
495
0
    switch (c) {
496
0
    case 0x0101:
497
0
    case 0x0901:
498
0
    case 0x0909:
499
0
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_4to3;
500
0
      break;
501
0
    case 0x0104:
502
0
    case 0x0401:
503
0
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_1to1;
504
0
      break;
505
0
    case 0x0201:
506
0
    case 0x0202:
507
0
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_3to2;
508
0
      break;
509
0
    case 0x0301:
510
0
    case 0x0303:
511
0
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_16to9;
512
0
      break;
513
0
    case 0x0404:
514
//      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_6to6;
515
0
        imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_1to1;
516
0
      break;
517
0
    case 0x0505:
518
0
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_5to4;
519
0
      break;
520
0
    case 0x0606:
521
0
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_7to6;
522
0
      break;
523
0
    case 0x0707:
524
0
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_6to5;
525
0
      break;
526
0
    case 0x0808:
527
0
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_7to5;
528
0
      break;
529
0
    default:
530
0
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_OTHER;
531
0
      break;
532
0
    }
533
0
  }
534
0
  else if (tag == 0x1113)
535
0
  {
536
0
    imOly.AspectFrame[0] = get2();
537
0
    imOly.AspectFrame[1] = get2();
538
0
    imOly.AspectFrame[2] = get2();
539
0
    imOly.AspectFrame[3] = get2();
540
0
  }
541
0
  else if (tag == 0x1306)
542
0
  {
543
0
    c = get2();
544
0
    if ((c != 0) && (c != 100))
545
0
    {
546
0
      if (c < 61)
547
0
        imCommon.CameraTemperature = (float)c;
548
0
      else
549
0
        imCommon.CameraTemperature = (float)(c - 32) / 1.8f;
550
0
      if ((imCommon.exifAmbientTemperature > -273.15f) &&
551
0
          ((OlyID == OlyID_TG_5) ||
552
0
           (OlyID == OlyID_TG_6) ||
553
0
           (OlyID == OlyID_TG_7))
554
0
      )
555
0
        imCommon.CameraTemperature += imCommon.exifAmbientTemperature;
556
0
    }
557
0
  }
558
559
0
  return;
560
0
}
561
562
void LibRaw::parseOlympus_RawInfo(unsigned tag, unsigned /*type */, unsigned len,
563
                                  unsigned dng_writer)
564
0
{
565
  // uptag 0x3000
566
567
0
  int wb_ind, c, i;
568
569
0
  if ((tag == 0x0110) && strcmp(software, "v757-71"))
570
0
  {
571
0
    icWBC[LIBRAW_WBI_Auto][0] = get2();
572
0
    icWBC[LIBRAW_WBI_Auto][2] = get2();
573
0
    if (len == 2)
574
0
    {
575
0
      for (i = 0; i < 256; i++)
576
0
        icWBC[i][1] = icWBC[i][3] = 0x100;
577
0
    }
578
0
  }
579
0
  else if ((((tag >= 0x0120) && (tag <= 0x0124)) ||
580
0
            ((tag >= 0x0130) && (tag <= 0x0133))) &&
581
0
           strcmp(software, "v757-71"))
582
0
  {
583
0
    if (tag <= 0x0124)
584
0
      wb_ind = tag - 0x0120;
585
0
    else
586
0
      wb_ind = tag - 0x0130 + 5;
587
588
0
    icWBC[Oly_wb_list1[wb_ind]][0] = get2();
589
0
    icWBC[Oly_wb_list1[wb_ind]][2] = get2();
590
0
  }
591
0
  else if ((tag == 0x0200) && (dng_writer == nonDNG))
592
0
  {
593
0
    for (i = 0; i < 3; i++)
594
0
    {
595
0
      if (!imOly.ColorSpace)
596
0
      {
597
0
        FORC3 cmatrix[i][c] = float((short)get2()) / 256.f;
598
0
      }
599
0
      else
600
0
      {
601
0
        FORC3 imgdata.color.ccm[i][c] = float((short)get2()) / 256.f;
602
0
      }
603
0
    }
604
0
  }
605
0
  else if ((tag == 0x0600) && (dng_writer == nonDNG))
606
0
  {
607
0
    FORC4 cblack[RGGB_2_RGBG(c)] = get2();
608
0
  }
609
0
  else if ((tag == 0x0612) && (dng_writer == nonDNG))
610
0
  {
611
0
    imgdata.sizes.raw_inset_crops[0].cleft = get2();
612
0
  }
613
0
  else if ((tag == 0x0613) && (dng_writer == nonDNG))
614
0
  {
615
0
    imgdata.sizes.raw_inset_crops[0].ctop = get2();
616
0
  }
617
0
  else if ((tag == 0x0614) && (dng_writer == nonDNG))
618
0
  {
619
0
    imgdata.sizes.raw_inset_crops[0].cwidth = get2();
620
0
  }
621
0
  else if ((tag == 0x0615) && (dng_writer == nonDNG))
622
0
  {
623
0
    imgdata.sizes.raw_inset_crops[0].cheight = get2();
624
0
  }
625
0
  return;
626
0
}
627
628
629
0
void LibRaw::parseOlympusMakernotes (INT64 base, unsigned tag, unsigned type, unsigned len, unsigned dng_writer) {
630
631
0
  int c;
632
0
  unsigned a;
633
0
  if ((tag >= 0x20100000) && (tag <= 0x2010ffff)) {
634
0
        parseOlympus_Equipment((tag & 0x0000ffff), type, len, dng_writer);
635
636
0
  } else if ((tag >= 0x20200000) && (tag <= 0x2020ffff)) {
637
0
    parseOlympus_CameraSettings(base, (tag & 0x0000ffff), type, len, dng_writer);
638
639
0
  } else if ((tag >= 0x20400000) && (tag <= 0x2040ffff)) {
640
0
     parseOlympus_ImageProcessing((tag & 0x0000ffff), type, len, dng_writer);
641
642
0
  } else if ((tag >= 0x30000000) && (tag <= 0x3000ffff)) {
643
0
        parseOlympus_RawInfo((tag & 0x0000ffff), type, len, dng_writer);
644
645
0
  } else {
646
0
    switch (tag) {
647
0
      case 0x0200:
648
0
        FORC3 if ((imOly.SpecialMode[c] = get4()) >= 0xff) imOly.SpecialMode[c] = 0xffffffff;
649
0
        break;
650
0
      case 0x0207:
651
0
        getOlympus_CameraType2();
652
0
        break;
653
0
      case 0x0404:
654
0
      case 0x101a:
655
0
        if (!imgdata.shootinginfo.BodySerial[0] && (dng_writer == nonDNG))
656
0
          stmread(imgdata.shootinginfo.BodySerial, len, ifp);
657
0
        break;
658
0
      case 0x1002:
659
0
        ilm.CurAp = float(libraw_powf64l(2.0f, getrealf(type) / 2.f));
660
0
        break;
661
0
      case 0x1007:
662
0
        imCommon.SensorTemperature = (float)get2();
663
0
        break;
664
0
      case 0x1008:
665
0
        imCommon.LensTemperature = (float)get2();
666
0
        break;
667
0
      case 0x100b:
668
0
        if (imOly.FocusMode[0] == 0xffff) {
669
0
          imgdata.shootinginfo.FocusMode = imOly.FocusMode[0] = get2();
670
0
          if (imgdata.shootinginfo.FocusMode == 1)
671
0
            imgdata.shootinginfo.FocusMode = imOly.FocusMode[0] = 10;
672
0
        }
673
0
        break;
674
0
      case 0x100d:
675
0
        if (imOly.ZoomStepCount == 0xffff) imOly.ZoomStepCount = get2();
676
0
        break;
677
0
      case 0x100e:
678
0
        if (imOly.FocusStepCount == 0xffff) imOly.FocusStepCount = get2();
679
0
        break;
680
0
      case 0x1011:
681
0
        if (strcmp(software, "v757-71") && (dng_writer == nonDNG)) {
682
0
          for (int i = 0; i < 3; i++) {
683
0
            if (!imOly.ColorSpace) {
684
0
              FORC3 cmatrix[i][c] = float((short)get2()) / 256.f;
685
0
            } else {
686
0
              FORC3 imgdata.color.ccm[i][c] = float((short)get2()) / 256.f;
687
0
            }
688
0
          }
689
0
        }
690
0
        break;
691
0
      case 0x1012:
692
0
        if (dng_writer == nonDNG)
693
0
          FORC4 cblack[RGGB_2_RGBG(c)] = get2();
694
0
        break;
695
0
      case 0x1017:
696
0
        if (dng_writer == nonDNG)
697
0
          cam_mul[0] = float(get2()) / 256.f;
698
0
        break;
699
0
      case 0x1018:
700
0
        if (dng_writer == nonDNG)
701
0
          cam_mul[2] = float(get2()) / 256.f;
702
0
        break;
703
0
      case 0x102c:
704
0
        if (dng_writer == nonDNG)
705
0
          imOly.ValidBits = get2();
706
0
        break;
707
0
      case 0x1038:
708
0
        imOly.AFResult = get2();
709
0
        break;
710
0
      case 0x103b:
711
0
        if (imOly.FocusStepInfinity == 0xffff) imOly.FocusStepInfinity = get2();
712
0
        break;
713
0
      case 0x103c:
714
0
        if (imOly.FocusStepNear == 0xffff) imOly.FocusStepNear = get2();
715
0
        break;
716
0
      case 0x20300108:
717
0
      case 0x20310109:
718
0
        if (dng_writer == nonDNG) {
719
0
          imOly.ColorSpace = get2();
720
0
          switch (imOly.ColorSpace) {
721
0
          case 0:
722
0
            imCommon.ColorSpace = LIBRAW_COLORSPACE_sRGB;
723
0
            break;
724
0
          case 1:
725
0
            imCommon.ColorSpace = LIBRAW_COLORSPACE_AdobeRGB;
726
0
            break;
727
0
          case 2:
728
0
            imCommon.ColorSpace = LIBRAW_COLORSPACE_ProPhotoRGB;
729
0
            break;
730
0
          default:
731
0
            imCommon.ColorSpace = LIBRAW_COLORSPACE_Unknown;
732
0
            break;
733
0
          }
734
0
        }
735
0
      case 0x20500209:
736
0
        imOly.AutoFocus = get2();
737
0
        break;
738
0
      case 0x20500300:
739
0
        imOly.ZoomStepCount = get2();
740
0
        break;
741
0
      case 0x20500301:
742
0
        imOly.FocusStepCount = get2();
743
0
        break;
744
0
      case 0x20500303:
745
0
        imOly.FocusStepInfinity = get2();
746
0
        break;
747
0
      case 0x20500304:
748
0
        imOly.FocusStepNear = get2();
749
0
        break;
750
0
      case 0x20500305:
751
0
        a = get4();
752
0
        /*b = */ get4(); // b is not used, so removed
753
0
        if (a >= 0x7f000000) imOly.FocusDistance = -1.0; // infinity
754
0
        else imOly.FocusDistance = (double) a / 1000.0;  // convert to meters
755
0
        break;
756
0
      case 0x20500308:
757
0
        imOly.AFPoint = get2();
758
0
        break;
759
0
      case 0x20501500:
760
0
        getOlympus_SensorTemperature(len);
761
0
        break;
762
0
    }
763
0
  }
764
0
}