Blender V5.3
logImageCore.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 1999-2001 David Hodson <hodsond@acm.org>.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
13
14#pragma once
15
16#include <cstdio>
17
19#include "BLI_sys_types.hh"
20
21namespace blender {
22
23#ifdef _WIN32
24# define PATHSEP_CHAR '\\'
25#else
26# define PATHSEP_CHAR '/'
27#endif
28
29/*
30 * Image structure
31 */
32
34 int depth;
40 unsigned int refLowData;
41 unsigned int refHighData;
44 float maxValue; /* = 2^bitsPerSample - 1 (used internally, doesn't come from the file header) */
45};
46
48 /* specified in header */
49 int width;
50 int height;
52 int depth;
54
55 /* used for log <-> lin conversion */
58 float gamma;
59
60 /* IO stuff. */
61 FILE *file;
62 unsigned char *memBuffer;
64 unsigned char *memCursor;
65
66 /* is the file LSB or MSB ? */
67 int isMSB;
68};
69
70/* Transfer characteristics, as defined by SMPTE. */
75
76/* Element descriptors, as defined by SMPTE. */
84
85/* int functions return 0 for OK */
86
87void logImageSetVerbose(int verbosity);
88int logImageIsCineon(const void *buffer, unsigned int size);
89LogImageFile *logImageOpenFromMemory(const unsigned char *buffer, unsigned int size);
90void logImageGetSize(const LogImageFile *logImage, int *width, int *height, int *depth);
91/* Create a 10 bit RGB Cineon file. */
92LogImageFile *logImageCreate(const char *filepath, int width, int height, const char *creator);
93void logImageClose(LogImageFile *logImage);
94
95/* Data handling */
96size_t getRowLength(size_t width, const LogImageElement *logElement);
97int logImageSetDataRGBA(LogImageFile *logImage, const float *data, int dataIsLinearRGB);
98int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB);
99
100/*
101 * Inline routines
102 */
103
104/* Endianness swapping */
105
106BLI_INLINE unsigned short swap_ushort(unsigned short x, int swap)
107{
108 if (swap != 0) {
109 return (x >> 8) | (x << 8);
110 }
111 return x;
112}
113
114BLI_INLINE unsigned int swap_uint(unsigned int x, int swap)
115{
116 if (swap != 0) {
117 return (x >> 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24);
118 }
119 return x;
120}
121
122BLI_INLINE float swap_float(float x, int swap)
123{
124 if (swap != 0) {
125 union {
126 float f;
127 unsigned char b[4];
128 } dat1, dat2;
129
130 dat1.f = x;
131 dat2.b[0] = dat1.b[3];
132 dat2.b[1] = dat1.b[2];
133 dat2.b[2] = dat1.b[1];
134 dat2.b[3] = dat1.b[0];
135 return dat2.f;
136 }
137 return x;
138}
139
140/* Other */
141
142BLI_INLINE float clamp_float(float x, float low, float high)
143{
144 if (x > high) {
145 return high;
146 }
147 if (x < low) {
148 return low;
149 }
150 return x;
151}
152
153BLI_INLINE unsigned int float_uint(float value, unsigned int max)
154{
155 if (value < 0.0f) {
156 return 0;
157 }
158 if (value > (1.0f - 0.5f / float(max))) {
159 return max;
160 }
161 return static_cast<unsigned int>((float(max) * value) + 0.5f);
162}
163
164} // namespace blender
#define BLI_INLINE
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
btScalar max
BMesh Iterators.
size_t getRowLength(size_t width, const LogImageElement *logElement)
BLI_INLINE float clamp_float(float x, float low, float high)
void logImageClose(LogImageFile *logImage)
int logImageIsCineon(const void *buffer, const uint size)
void logImageGetSize(const LogImageFile *logImage, int *width, int *height, int *depth)
BLI_INLINE unsigned int float_uint(float value, unsigned int max)
void logImageSetVerbose(int verbosity)
BLI_INLINE unsigned int swap_uint(unsigned int x, int swap)
LogImageFile * logImageOpenFromMemory(const uchar *buffer, uint size)
BMesh const char void * data
LogImageFile * logImageCreate(const char *filepath, int width, int height, const char *creator)
int logImageSetDataRGBA(LogImageFile *logImage, const float *data, int dataIsLinearRGB)
@ descriptor_Red
@ descriptor_Green
@ descriptor_Blue
@ descriptor_RGB
@ descriptor_Luminance
@ transfer_PrintingDensity
@ transfer_Linear
_W64 unsigned int uintptr_t
Definition BKE_text.h:120
int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB)
BLI_INLINE float swap_float(float x, int swap)
BLI_INLINE unsigned short swap_ushort(unsigned short x, int swap)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
#define swap(a, b)
Definition sort.cc:61
unsigned char * memCursor
LogImageElement element[8]
unsigned char * memBuffer