Coverage Report

Created: 2025-11-11 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libraw/src/metadata/minolta.cpp
Line
Count
Source
1
/* -*- C++ -*-
2
 * Copyright 2019-2025 LibRaw LLC (info@libraw.org)
3
 *
4
 LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder,
5
 dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net.
6
 LibRaw do not use RESTRICTED code from dcraw.c
7
8
 LibRaw is free software; you can redistribute it and/or modify
9
 it under the terms of the one of two licenses as you choose:
10
11
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
12
   (See file LICENSE.LGPL provided in LibRaw distribution archive for details).
13
14
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
15
   (See file LICENSE.CDDL provided in LibRaw distribution archive for details).
16
17
 */
18
19
#include "../../internal/dcraw_defs.h"
20
21
void LibRaw::parse_minolta(INT64 base)
22
998
{
23
998
  int tag, len, high = 0, wide = 0, i, c;
24
998
  short sorder = order;
25
998
  INT64 save,offset;
26
27
998
  fseek(ifp, base, SEEK_SET);
28
998
  if (fgetc(ifp) || fgetc(ifp) - 'M' || fgetc(ifp) - 'R')
29
996
    return;
30
2
  order = fgetc(ifp) * 0x101;
31
2
  offset = base + get4() + 8;
32
2
  INT64 fsize = ifp->size();
33
2
  if (offset > fsize - 8LL) // At least 8 bytes for tag/len
34
0
    offset = fsize - 8LL;
35
36
6
  while ((save = ftell(ifp)) < offset)
37
4
  {
38
20
    for (tag = i = 0; i < 4; i++)
39
16
      tag = tag << 8 | fgetc(ifp);
40
4
    len = get4();
41
4
    if (len < 0)
42
0
      return; // just ignore wrong len?? or raise bad file exception?
43
4
    if ((INT64)len + save + 8LL > fsize)
44
0
      return; // just ignore out of file metadata, stop parse
45
4
    switch (tag)
46
4
    {
47
0
    case 0x505244: /* PRD */
48
0
      fseek(ifp, 8, SEEK_CUR);
49
0
      high = get2();
50
0
      wide = get2();
51
0
      imSony.prd_ImageHeight = get2();
52
0
      imSony.prd_ImageWidth = get2();
53
0
      imSony.prd_Total_bps = (ushort)fgetc(ifp);
54
0
      imSony.prd_Active_bps = (ushort)fgetc(ifp);
55
0
      imSony.prd_StorageMethod = (ushort)fgetc(ifp);
56
0
      fseek(ifp, 4L, SEEK_CUR);
57
0
      imSony.prd_BayerPattern = (ushort)fgetc(ifp);
58
0
      break;
59
0
    case 0x524946: /* RIF */
60
0
      fseek(ifp, 8, SEEK_CUR);
61
0
      icWBC[LIBRAW_WBI_Tungsten][0] = get2();
62
0
      icWBC[LIBRAW_WBI_Tungsten][2] = get2();
63
0
      icWBC[LIBRAW_WBI_Daylight][0] = get2();
64
0
      icWBC[LIBRAW_WBI_Daylight][2] = get2();
65
0
      icWBC[LIBRAW_WBI_Cloudy][0] = get2();
66
0
      icWBC[LIBRAW_WBI_Cloudy][2] = get2();
67
0
      icWBC[LIBRAW_WBI_FL_W][0] = get2();
68
0
      icWBC[LIBRAW_WBI_FL_W][2] = get2();
69
0
      icWBC[LIBRAW_WBI_Flash][0] = get2();
70
0
      icWBC[LIBRAW_WBI_Flash][2] = get2();
71
0
      icWBC[LIBRAW_WBI_Custom][0] = get2();
72
0
      icWBC[LIBRAW_WBI_Custom][2] = get2();
73
0
      icWBC[LIBRAW_WBI_Tungsten][1] = icWBC[LIBRAW_WBI_Tungsten][3] =
74
0
        icWBC[LIBRAW_WBI_Daylight][1] = icWBC[LIBRAW_WBI_Daylight][3] =
75
0
        icWBC[LIBRAW_WBI_Cloudy][1] = icWBC[LIBRAW_WBI_Cloudy][3] =
76
0
        icWBC[LIBRAW_WBI_FL_W][1] = icWBC[LIBRAW_WBI_FL_W][3] =
77
0
        icWBC[LIBRAW_WBI_Flash][1] = icWBC[LIBRAW_WBI_Flash][3] =
78
0
        icWBC[LIBRAW_WBI_Custom][1] = icWBC[LIBRAW_WBI_Custom][3] = 0x100;
79
0
      if (!strncasecmp(model, "DSLR-A100", 9)) {
80
0
        icWBC[LIBRAW_WBI_Shade][0] = get2();
81
0
        icWBC[LIBRAW_WBI_Shade][2] = get2();
82
0
        icWBC[LIBRAW_WBI_FL_D][0] = get2();
83
0
        icWBC[LIBRAW_WBI_FL_D][2] = get2();
84
0
        icWBC[LIBRAW_WBI_FL_N][0] = get2();
85
0
        icWBC[LIBRAW_WBI_FL_N][2] = get2();
86
0
        icWBC[LIBRAW_WBI_FL_WW][0] = get2();
87
0
        icWBC[LIBRAW_WBI_FL_WW][2] = get2();
88
0
        icWBC[LIBRAW_WBI_Shade][1] = icWBC[LIBRAW_WBI_Shade][3] =
89
0
          icWBC[LIBRAW_WBI_FL_D][1] = icWBC[LIBRAW_WBI_FL_D][3] =
90
0
          icWBC[LIBRAW_WBI_FL_N][1] = icWBC[LIBRAW_WBI_FL_N][3] =
91
0
          icWBC[LIBRAW_WBI_FL_WW][1] = icWBC[LIBRAW_WBI_FL_WW][3] = 0x0100;
92
0
      }
93
0
      break;
94
2
    case 0x574247: /* WBG */
95
2
      get4();
96
2
      if (imSony.prd_BayerPattern == LIBRAW_MINOLTA_G2BRG1)
97
0
        FORC4 cam_mul[G2BRG1_2_RGBG(c)] = get2();
98
2
      else
99
8
        FORC4 cam_mul[RGGB_2_RGBG(c)] = get2();
100
2
      break;
101
0
    case 0x545457: /* TTW */
102
0
      parse_tiff(ftell(ifp));
103
0
      data_offset = offset;
104
4
    }
105
4
    fseek(ifp, save + len + 8, SEEK_SET);
106
4
  }
107
2
  raw_height = high;
108
2
  raw_width = wide;
109
2
  order = sorder;
110
2
}