Coverage Report

Created: 2025-11-09 07:12

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
2.19M
#define P1 imgdata.idata
54
3.00G
#define S  imgdata.sizes
55
#ifndef LIBRAW_DNGSDK_CONFLICT
56
119k
#define O  imgdata.params
57
805k
#define C  imgdata.color
58
14.7k
#define T  imgdata.thumbnail
59
612k
#define MN imgdata.makernotes
60
#ifndef LIBRAW_EXPAT_CONFLICT
61
772M
#define IO libraw_internal_data.internal_output_params
62
12.4k
#define ID libraw_internal_data.internal_data
63
#endif
64
#endif
65
66
104k
#define makeIs(idx) (imgdata.idata.maker_index == idx)
67
203
#define mnCamID imgdata.lens.makernotes.CamID
68
69
#define EXCEPTION_HANDLER(e)                                                   \
70
1.18k
  do                                                                           \
71
1.18k
  {                                                                            \
72
1.18k
    switch (e)                                                                 \
73
1.18k
    {                                                                          \
74
8
    case LIBRAW_EXCEPTION_MEMPOOL:                                             \
75
8
      recycle();                                                               \
76
8
      return LIBRAW_MEMPOOL_OVERFLOW;                                          \
77
0
    case LIBRAW_EXCEPTION_ALLOC:                                               \
78
0
      recycle();                                                               \
79
0
      return LIBRAW_UNSUFFICIENT_MEMORY;                                       \
80
4
    case LIBRAW_EXCEPTION_TOOBIG:                                              \
81
4
      recycle();                                                               \
82
4
      return LIBRAW_TOO_BIG;                                                   \
83
4
    case LIBRAW_EXCEPTION_DECODE_RAW:                                          \
84
4
    case LIBRAW_EXCEPTION_DECODE_JPEG:                                         \
85
4
      recycle();                                                               \
86
4
      return LIBRAW_DATA_ERROR;                                                \
87
4
    case LIBRAW_EXCEPTION_DECODE_JPEG2000:                                     \
88
0
      recycle();                                                               \
89
0
      return LIBRAW_DATA_ERROR;                                                \
90
848
    case LIBRAW_EXCEPTION_IO_EOF:                                              \
91
1.16k
    case LIBRAW_EXCEPTION_IO_CORRUPT:                                          \
92
1.16k
      recycle();                                                               \
93
1.16k
      return LIBRAW_IO_ERROR;                                                  \
94
848
    case LIBRAW_EXCEPTION_CANCELLED_BY_CALLBACK:                               \
95
0
      recycle();                                                               \
96
0
      return LIBRAW_CANCELLED_BY_CALLBACK;                                     \
97
848
    case LIBRAW_EXCEPTION_BAD_CROP:                                            \
98
0
      recycle();                                                               \
99
0
      return LIBRAW_BAD_CROP;                                                  \
100
848
    case LIBRAW_EXCEPTION_UNSUPPORTED_FORMAT:                                  \
101
0
      recycle();                                                               \
102
0
      return LIBRAW_FILE_UNSUPPORTED;                                          \
103
848
    default:                                                                   \
104
0
      return LIBRAW_UNSPECIFIED_ERROR;                                         \
105
1.18k
    }                                                                          \
106
1.18k
  } while (0)
107
108
// copy-n-paste from image pipe
109
1.94k
#define MIN(a, b) ((a) < (b) ? (a) : (b))
110
3.13G
#define MAX(a, b) ((a) > (b) ? (a) : (b))
111
1.56G
#define LIM(x, min, max) MAX(min, MIN(x, max))
112
#ifndef CLIP
113
#define CLIP(x) LIM(x, 0, 65535)
114
#endif
115
577
#define THUMB_READ_BEYOND 16384
116
117
72.2k
#define ZERO(a) memset(&a, 0, sizeof(a))
118
119
#endif