Coverage Report

Created: 2025-07-11 06:35

/src/libraw/internal/libraw_cxx_defs.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- C++ -*-
2
 * File: internal/libraw_cxx_defs.h
3
 * Copyright 2008-2024 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
16.5M
#define P1 imgdata.idata
54
11.8G
#define S  imgdata.sizes
55
#ifndef LIBRAW_DNGSDK_CONFLICT
56
938k
#define O  imgdata.params
57
185M
#define C  imgdata.color
58
47.8M
#define T  imgdata.thumbnail
59
8.38M
#define MN imgdata.makernotes
60
#ifndef LIBRAW_EXPAT_CONFLICT
61
2.73G
#define IO libraw_internal_data.internal_output_params
62
133k
#define ID libraw_internal_data.internal_data
63
#endif
64
#endif
65
66
1.42M
#define makeIs(idx) (imgdata.idata.maker_index == idx)
67
1.87k
#define mnCamID imgdata.lens.makernotes.CamID
68
69
#define EXCEPTION_HANDLER(e)                                                   \
70
15.1k
  do                                                                           \
71
15.1k
  {                                                                            \
72
15.1k
    switch (e)                                                                 \
73
15.1k
    {                                                                          \
74
11
    case LIBRAW_EXCEPTION_MEMPOOL:                                             \
75
11
      recycle();                                                               \
76
11
      return LIBRAW_MEMPOOL_OVERFLOW;                                          \
77
4
    case LIBRAW_EXCEPTION_ALLOC:                                               \
78
4
      recycle();                                                               \
79
4
      return LIBRAW_UNSUFFICIENT_MEMORY;                                       \
80
373
    case LIBRAW_EXCEPTION_TOOBIG:                                              \
81
373
      recycle();                                                               \
82
373
      return LIBRAW_TOO_BIG;                                                   \
83
20
    case LIBRAW_EXCEPTION_DECODE_RAW:                                          \
84
20
    case LIBRAW_EXCEPTION_DECODE_JPEG:                                         \
85
20
      recycle();                                                               \
86
20
      return LIBRAW_DATA_ERROR;                                                \
87
20
    case LIBRAW_EXCEPTION_DECODE_JPEG2000:                                     \
88
0
      recycle();                                                               \
89
0
      return LIBRAW_DATA_ERROR;                                                \
90
13.8k
    case LIBRAW_EXCEPTION_IO_EOF:                                              \
91
14.7k
    case LIBRAW_EXCEPTION_IO_CORRUPT:                                          \
92
14.7k
      recycle();                                                               \
93
14.7k
      return LIBRAW_IO_ERROR;                                                  \
94
13.8k
    case LIBRAW_EXCEPTION_CANCELLED_BY_CALLBACK:                               \
95
0
      recycle();                                                               \
96
0
      return LIBRAW_CANCELLED_BY_CALLBACK;                                     \
97
13.8k
    case LIBRAW_EXCEPTION_BAD_CROP:                                            \
98
0
      recycle();                                                               \
99
0
      return LIBRAW_BAD_CROP;                                                  \
100
13.8k
    case LIBRAW_EXCEPTION_UNSUPPORTED_FORMAT:                                  \
101
1
      recycle();                                                               \
102
1
      return LIBRAW_FILE_UNSUPPORTED;                                          \
103
13.8k
    default:                                                                   \
104
4
      return LIBRAW_UNSPECIFIED_ERROR;                                         \
105
15.1k
    }                                                                          \
106
15.1k
  } while (0)
107
108
// copy-n-paste from image pipe
109
12.8k
#define MIN(a, b) ((a) < (b) ? (a) : (b))
110
9.38G
#define MAX(a, b) ((a) > (b) ? (a) : (b))
111
4.69G
#define LIM(x, min, max) MAX(min, MIN(x, max))
112
#ifndef CLIP
113
#define CLIP(x) LIM(x, 0, 65535)
114
#endif
115
2.91k
#define THUMB_READ_BEYOND 16384
116
117
993k
#define ZERO(a) memset(&a, 0, sizeof(a))
118
119
#endif