Coverage Report

Created: 2026-03-12 07:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/LibRaw/src/metadata/epson.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
17
void LibRaw::parseEpsonMakernote(INT64 base, int uptag, unsigned dng_writer)
18
0
{
19
20
0
#define isRIC imgdata.sizes.raw_inset_crops[0]
21
22
0
  unsigned entries, tag, type, len;
23
0
  INT64 save;
24
0
  short morder, sorder = order;
25
0
  ushort c;
26
0
  INT64 fsize = ifp->size();
27
28
0
  fseek(ifp, -2, SEEK_CUR);
29
30
0
  entries = get2();
31
0
  if (entries > 1000)
32
0
    return;
33
0
  morder = order;
34
35
0
  while (entries--)
36
0
  {
37
0
    order = morder;
38
0
    tiff_get(base, &tag, &type, &len, &save);
39
0
    INT64 pos = ifp->tell();
40
0
    if (len > 8 && pos + len > 2 * fsize)
41
0
    {
42
0
      fseek(ifp, save, SEEK_SET); // Recover tiff-read position!!
43
0
      continue;
44
0
    }
45
46
0
    tag |= uptag << 16;
47
0
    if (len > 100 * 1024 * 1024)
48
0
      goto next; // 100Mb tag? No!
49
50
0
  if (callbacks.makernotes_cb)
51
0
    {
52
0
      INT64 _savepos = ifp->tell();
53
0
      callbacks.makernotes_cb(callbacks.makernotesparser_data, tag, type, len, order, ifp, base);
54
0
      fseek(ifp, _savepos, SEEK_SET);
55
0
    }
56
57
0
    if (tag == 0x020b)
58
0
    {
59
0
      if (tagtypeIs(LIBRAW_EXIFTAG_TYPE_LONG))
60
0
        isRIC.cwidth = get4();
61
0
      else if (tagtypeIs(LIBRAW_EXIFTAG_TYPE_SHORT))
62
0
        isRIC.cwidth = get2();
63
0
    }
64
0
    else if (tag == 0x020c)
65
0
    {
66
0
      if (tagtypeIs(LIBRAW_EXIFTAG_TYPE_LONG))
67
0
        isRIC.cheight = get4();
68
0
      else if (tagtypeIs(LIBRAW_EXIFTAG_TYPE_SHORT))
69
0
        isRIC.cheight = get2();
70
0
    }
71
0
    else if (tag == 0x0400)
72
0
    {                                 // sensor area
73
0
      ushort sdims[4] = {0, 0, 0, 0}; // left margin, top margin, width, height
74
0
      FORC4 sdims[c] = get2();
75
0
      isRIC.cleft = (sdims[2] - sdims[0] - isRIC.cwidth) / 2;
76
0
      isRIC.ctop = (sdims[3] - sdims[1] - isRIC.cheight) / 2;
77
0
    }
78
79
0
    if (dng_writer == nonDNG)
80
0
    {
81
82
0
      if (tag == 0x0280)
83
0
      {
84
0
        thumb_offset = ftell(ifp);
85
0
        thumb_length = len;
86
0
      }
87
0
      else if (tag == 0x0401)
88
0
      {
89
0
        FORC4 cblack[RGGB_2_RGBG(c)] = get4();
90
0
      }
91
0
      else if (tag == 0x0e80)
92
0
      {
93
0
        fseek(ifp, 48, SEEK_CUR);
94
0
        cam_mul[0] = get2() * 567.0f / 0x10000;
95
0
        cam_mul[2] = get2() * 431.0f / 0x10000;
96
0
      }
97
0
    }
98
99
0
  next:
100
0
    fseek(ifp, save, SEEK_SET);
101
0
  }
102
0
  order = sorder;
103
0
#undef isRIC
104
0
}