Coverage Report

Created: 2026-02-11 06:15

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libraw/internal/libraw_cxx_defs.h
Line
Count
Source
1
/* -*- C++ -*-
2
 * File: internal/libraw_cxx_defs.h
3
 * Copyright 2008-2025 LibRaw LLC (info@libraw.org)
4
 * Created: Sat Aug  17, 2020
5
6
LibRaw is free software; you can redistribute it and/or modify
7
it under the terms of the one of two licenses as you choose:
8
9
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
10
   (See file LICENSE.LGPL provided in LibRaw distribution archive for details).
11
12
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
13
   (See file LICENSE.CDDL provided in LibRaw distribution archive for details).
14
15
 */
16
17
#ifndef _LIBRAW_CXX_DEFS_H
18
#define _LIBRAW_CXX_DEFS_H
19
20
#include <math.h>
21
#include <errno.h>
22
#include <float.h>
23
#include <new>
24
#include <exception>
25
#include <sys/types.h>
26
#include <sys/stat.h>
27
#define LIBRAW_LIBRARY_BUILD
28
#include "libraw/libraw.h"
29
#include "internal/defines.h"
30
#ifdef USE_ZLIB
31
#include <zlib.h>
32
#endif
33
34
#ifndef LIBRAW_WIN32_CALLS
35
#include <netinet/in.h>
36
#else
37
#ifndef LIBRAW_NO_WINSOCK2
38
#include <winsock2.h>
39
#endif
40
#include <io.h>
41
#endif
42
#ifdef USE_RAWSPEED
43
void *make_camera_metadata();
44
void clear_camera_metadata(void*);
45
void clear_rawspeed_decoder(void*);
46
#endif
47
#ifdef USE_DNGSDK
48
void clear_dng_negative(void *);
49
void clear_dng_image(void*);
50
#endif
51
52
53
18.3M
#define P1 imgdata.idata
54
5.22G
#define S  imgdata.sizes
55
#ifndef LIBRAW_DNGSDK_CONFLICT
56
430k
#define O  imgdata.params
57
176M
#define C  imgdata.color
58
36.9M
#define T  imgdata.thumbnail
59
4.08M
#define MN imgdata.makernotes
60
#ifndef LIBRAW_EXPAT_CONFLICT
61
1.29G
#define IO libraw_internal_data.internal_output_params
62
67.0k
#define ID libraw_internal_data.internal_data
63
#endif
64
#endif
65
66
692k
#define makeIs(idx) (imgdata.idata.maker_index == idx)
67
894
#define mnCamID imgdata.lens.makernotes.CamID
68
69
#define EXCEPTION_HANDLER(e)                                                   \
70
7.41k
  do                                                                           \
71
7.41k
  {                                                                            \
72
7.41k
    switch (e)                                                                 \
73
7.41k
    {                                                                          \
74
9
    case LIBRAW_EXCEPTION_MEMPOOL:                                             \
75
9
      recycle();                                                               \
76
9
      return LIBRAW_MEMPOOL_OVERFLOW;                                          \
77
2
    case LIBRAW_EXCEPTION_ALLOC:                                               \
78
2
      recycle();                                                               \
79
2
      return LIBRAW_UNSUFFICIENT_MEMORY;                                       \
80
150
    case LIBRAW_EXCEPTION_TOOBIG:                                              \
81
150
      recycle();                                                               \
82
150
      return LIBRAW_TOO_BIG;                                                   \
83
14
    case LIBRAW_EXCEPTION_DECODE_RAW:                                          \
84
14
    case LIBRAW_EXCEPTION_DECODE_JPEG:                                         \
85
14
      recycle();                                                               \
86
14
      return LIBRAW_DATA_ERROR;                                                \
87
14
    case LIBRAW_EXCEPTION_DECODE_JPEG2000:                                     \
88
0
      recycle();                                                               \
89
0
      return LIBRAW_DATA_ERROR;                                                \
90
6.73k
    case LIBRAW_EXCEPTION_IO_EOF:                                              \
91
7.23k
    case LIBRAW_EXCEPTION_IO_CORRUPT:                                          \
92
7.23k
      recycle();                                                               \
93
7.23k
      return LIBRAW_IO_ERROR;                                                  \
94
6.73k
    case LIBRAW_EXCEPTION_CANCELLED_BY_CALLBACK:                               \
95
0
      recycle();                                                               \
96
0
      return LIBRAW_CANCELLED_BY_CALLBACK;                                     \
97
6.73k
    case LIBRAW_EXCEPTION_BAD_CROP:                                            \
98
0
      recycle();                                                               \
99
0
      return LIBRAW_BAD_CROP;                                                  \
100
6.73k
    case LIBRAW_EXCEPTION_UNSUPPORTED_FORMAT:                                  \
101
0
      recycle();                                                               \
102
0
      return LIBRAW_FILE_UNSUPPORTED;                                          \
103
6.73k
    default:                                                                   \
104
4
      return LIBRAW_UNSPECIFIED_ERROR;                                         \
105
7.41k
    }                                                                          \
106
7.41k
  } while (0)
107
108
// copy-n-paste from image pipe
109
5.60k
#define MIN(a, b) ((a) < (b) ? (a) : (b))
110
4.57G
#define MAX(a, b) ((a) > (b) ? (a) : (b))
111
2.28G
#define LIM(x, min, max) MAX(min, MIN(x, max))
112
#ifndef CLIP
113
#define CLIP(x) LIM(x, 0, 65535)
114
#endif
115
1.37k
#define THUMB_READ_BEYOND 16384
116
117
484k
#define ZERO(a) memset(&a, 0, sizeof(a))
118
119
#endif