File indexing completed on 2025-01-05 03:56:45

0001 /* -*- C++ -*-
0002  * File: internal/libraw_cxx_defs.h
0003  * Copyright 2008-2021 LibRaw LLC (info@libraw.org)
0004  * Created: Sat Aug  17, 2020
0005 
0006 LibRaw is free software; you can redistribute it and/or modify
0007 it under the terms of the one of two licenses as you choose:
0008 
0009 1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
0010    (See file LICENSE.LGPL provided in LibRaw distribution archive for details).
0011 
0012 2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
0013    (See file LICENSE.CDDL provided in LibRaw distribution archive for details).
0014 
0015  */
0016 
0017 #ifndef _LIBRAW_CXX_DEFS_H
0018 #define _LIBRAW_CXX_DEFS_H
0019 
0020 #include <math.h>
0021 #include <errno.h>
0022 #include <float.h>
0023 #include <new>
0024 #include <exception>
0025 #include <sys/types.h>
0026 #include <sys/stat.h>
0027 #define LIBRAW_LIBRARY_BUILD
0028 #include "libraw/libraw.h"
0029 #include "internal/defines.h"
0030 #ifdef USE_ZLIB
0031 #include <zlib.h>
0032 #endif
0033 
0034 #ifndef LIBRAW_WIN32_CALLS
0035 #include <netinet/in.h>
0036 #else
0037 #ifndef LIBRAW_NO_WINSOCK2
0038 #include <winsock2.h>
0039 #endif
0040 #include <io.h>
0041 #endif
0042 
0043 #ifdef USE_RAWSPEED
0044 #include <RawSpeed/StdAfx.h>
0045 #include <RawSpeed/FileMap.h>
0046 #include <RawSpeed/RawParser.h>
0047 #include <RawSpeed/RawDecoder.h>
0048 #include <RawSpeed/CameraMetaData.h>
0049 #include <RawSpeed/ColorFilterArray.h>
0050 extern const char *_rawspeed_data_xml[];
0051 extern const int RAWSPEED_DATA_COUNT;
0052 class CameraMetaDataLR : public RawSpeed::CameraMetaData
0053 {
0054 public:
0055   CameraMetaDataLR() : CameraMetaData() {}
0056   CameraMetaDataLR(char *filename) : RawSpeed::CameraMetaData(filename) {}
0057   CameraMetaDataLR(char *data, int sz);
0058 };
0059 
0060 CameraMetaDataLR *make_camera_metadata();
0061 
0062 #endif
0063 
0064 #ifdef USE_DNGSDK
0065 #include "dng_host.h"
0066 #include "dng_negative.h"
0067 #include "dng_simple_image.h"
0068 #include "dng_info.h"
0069 #endif
0070 
0071 #define P1 imgdata.idata
0072 #define S  imgdata.sizes
0073 #define O  imgdata.params
0074 #define C  imgdata.color
0075 #define T  imgdata.thumbnail
0076 #define MN imgdata.makernotes
0077 #define IO libraw_internal_data.internal_output_params
0078 #define ID libraw_internal_data.internal_data
0079 
0080 #define makeIs(idx) (imgdata.idata.maker_index == idx)
0081 #define mnCamID imgdata.lens.makernotes.CamID
0082 
0083 #define EXCEPTION_HANDLER(e)                                                   \
0084   do                                                                           \
0085   {                                                                            \
0086     switch (e)                                                                 \
0087     {                                                                          \
0088     case LIBRAW_EXCEPTION_MEMPOOL:                                             \
0089       recycle();                                                               \
0090       return LIBRAW_MEMPOOL_OVERFLOW;                                          \
0091     case LIBRAW_EXCEPTION_ALLOC:                                               \
0092       recycle();                                                               \
0093       return LIBRAW_UNSUFFICIENT_MEMORY;                                       \
0094     case LIBRAW_EXCEPTION_TOOBIG:                                              \
0095       recycle();                                                               \
0096       return LIBRAW_TOO_BIG;                                                   \
0097     case LIBRAW_EXCEPTION_DECODE_RAW:                                          \
0098     case LIBRAW_EXCEPTION_DECODE_JPEG:                                         \
0099       recycle();                                                               \
0100       return LIBRAW_DATA_ERROR;                                                \
0101     case LIBRAW_EXCEPTION_DECODE_JPEG2000:                                     \
0102       recycle();                                                               \
0103       return LIBRAW_DATA_ERROR;                                                \
0104     case LIBRAW_EXCEPTION_IO_EOF:                                              \
0105     case LIBRAW_EXCEPTION_IO_CORRUPT:                                          \
0106       recycle();                                                               \
0107       return LIBRAW_IO_ERROR;                                                  \
0108     case LIBRAW_EXCEPTION_CANCELLED_BY_CALLBACK:                               \
0109       recycle();                                                               \
0110       return LIBRAW_CANCELLED_BY_CALLBACK;                                     \
0111     case LIBRAW_EXCEPTION_BAD_CROP:                                            \
0112       recycle();                                                               \
0113       return LIBRAW_BAD_CROP;                                                  \
0114     case LIBRAW_EXCEPTION_UNSUPPORTED_FORMAT:                                  \
0115       recycle();                                                               \
0116       return LIBRAW_FILE_UNSUPPORTED;                                          \
0117     default:                                                                   \
0118       return LIBRAW_UNSPECIFIED_ERROR;                                         \
0119     }                                                                          \
0120   } while (0)
0121 
0122 // copy-n-paste from image pipe
0123 #define MIN(a, b) ((a) < (b) ? (a) : (b))
0124 #define MAX(a, b) ((a) > (b) ? (a) : (b))
0125 #define LIM(x, min, max) MAX(min, MIN(x, max))
0126 #ifndef CLIP
0127 #define CLIP(x) LIM(x, 0, 65535)
0128 #endif
0129 #define THUMB_READ_BEYOND 16384
0130 
0131 #define ZERO(a) memset(&a, 0, sizeof(a))
0132 
0133 #endif