Blender V4.5
IMB_imbuf_types.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 * SPDX-FileCopyrightText: 2025 Blender Authors
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later */
5
6#pragma once
7
13
14#include "DNA_vec_types.h" /* for rcti */
15
16#include "IMB_imbuf_enums.h"
17
18struct ColormanageCache;
19struct GPUTexture;
20struct IDProperty;
21
22namespace blender::ocio {
23class ColorSpace;
24}
26
27#define IMB_MIPMAP_LEVELS 20
28#define IMB_FILEPATH_SIZE 1024
29
36
41
42#define OPENEXR_HALF (1 << 8)
43/* Lowest bits of foptions.flag / exr_codec contain actual codec enum. */
44#define OPENEXR_CODEC_MASK (0xF)
45
46#ifdef WITH_IMAGE_CINEON
47# define CINEON_LOG (1 << 8)
48# define CINEON_16BIT (1 << 7)
49# define CINEON_12BIT (1 << 6)
50# define CINEON_10BIT (1 << 5)
51#endif
52
53#ifdef WITH_IMAGE_OPENJPEG
54# define JP2_12BIT (1 << 9)
55# define JP2_16BIT (1 << 8)
56# define JP2_YCC (1 << 7)
57# define JP2_CINE (1 << 6)
58# define JP2_CINE_48FPS (1 << 5)
59# define JP2_JP2 (1 << 4)
60# define JP2_J2K (1 << 3)
61#endif
62
63#define PNG_16BIT (1 << 10)
64
65#define RAWTGA 1
66
67#define TIF_16BIT (1 << 8)
68#define TIF_COMPRESS_NONE (1 << 7)
69#define TIF_COMPRESS_DEFLATE (1 << 6)
70#define TIF_COMPRESS_LZW (1 << 5)
71#define TIF_COMPRESS_PACKBITS (1 << 4)
72
74 short flag;
76 char quality;
77};
78
79/* -------------------------------------------------------------------- */
83
86 IB_byte_data = 1 << 0,
87 IB_test = 1 << 1,
88 IB_mem = 1 << 4,
90 IB_float_data = 1 << 5,
91 IB_multilayer = 1 << 7,
92 IB_metadata = 1 << 8,
99
104 /* alpha channel is unrelated to RGB and should not affect it */
108 IB_thumbnail = 1 << 16,
109};
110
112
113/* -------------------------------------------------------------------- */
116
117/* Specialization of an ownership whenever a bare pointer is provided to the ImBuf buffers
118 * assignment API. */
120 /* The ImBuf simply shares pointer with data owned by someone else, and will not perform any
121 * memory management when the ImBuf frees the buffer. */
123
124 /* The ImBuf takes ownership of the buffer data, and will use MEM_freeN() to free this memory
125 * when the ImBuf needs to free the data. */
127};
128
129struct DDSData {
131 unsigned int fourcc;
133 unsigned int nummipmaps;
135 unsigned char *data;
137 unsigned int size;
140};
141
142/* Different storage specialization.
143 *
144 * NOTE: Avoid direct assignments and allocations, use the buffer utilities from the IMB_imbuf.hh
145 * instead.
146 *
147 * Accessing the data pointer directly is fine and is an expected way of accessing it. */
148
155
162
163struct ImBufGPU {
164 /* Texture which corresponds to the state of the ImBug on the GPU.
165 *
166 * Allocation is supposed to happen outside of the ImBug module from a proper GPU context.
167 * De-referencing the ImBuf or its GPU texture can happen from any state. */
168 /* TODO(sergey): This should become a list of textures, to support having high-res ImBuf on GPU
169 * without hitting hardware limitations. */
170 GPUTexture *texture;
171};
172
174
175/* -------------------------------------------------------------------- */
178
179struct ImBuf {
180 /* dimensions */
185 int x, y;
186
188 unsigned char planes;
191
192 /* flags */
194 int flags;
195
196 /* pixels */
197
204
213
214 /* Image buffer on the GPU. */
216
218 double ppm[2];
219
221 float dither;
222
223 /* mipmapping */
227
228 /* externally used data */
230 int index;
236 void *userdata;
237
238 /* file information */
245 /* For movie files, the frame number loaded from the file. */
247
250
251 /* some parameters to pass along for packing images */
255 unsigned int encoded_size;
258
259 /* color management */
261 unsigned int *display_buffer_flags;
266
267 /* information for compressed textures */
269};
270
274
275enum {
277 IB_BITMAPDIRTY = (1 << 1),
281 IB_RECT_INVALID = (1 << 3),
285 IB_PERSISTENT = (1 << 5),
286};
287
289
290/* -------------------------------------------------------------------- */
295
296#define IB_PROFILE_NONE 0
297#define IB_PROFILE_LINEAR_RGB 1
298#define IB_PROFILE_SRGB 2
299#define IB_PROFILE_CUSTOM 3
300
302
303/* dds */
304#ifndef DDS_MAKEFOURCC
305# define DDS_MAKEFOURCC(ch0, ch1, ch2, ch3) \
306 ((unsigned long)(unsigned char)(ch0) | ((unsigned long)(unsigned char)(ch1) << 8) | \
307 ((unsigned long)(unsigned char)(ch2) << 16) | ((unsigned long)(unsigned char)(ch3) << 24))
308#endif /* DDS_MAKEFOURCC */
309
310/*
311 * FOURCC codes for DX compressed-texture pixel formats.
312 */
313
314#define FOURCC_DDS (DDS_MAKEFOURCC('D', 'D', 'S', ' '))
315#define FOURCC_DX10 (DDS_MAKEFOURCC('D', 'X', '1', '0'))
316#define FOURCC_DXT1 (DDS_MAKEFOURCC('D', 'X', 'T', '1'))
317#define FOURCC_DXT2 (DDS_MAKEFOURCC('D', 'X', 'T', '2'))
318#define FOURCC_DXT3 (DDS_MAKEFOURCC('D', 'X', 'T', '3'))
319#define FOURCC_DXT4 (DDS_MAKEFOURCC('D', 'X', 'T', '4'))
320#define FOURCC_DXT5 (DDS_MAKEFOURCC('D', 'X', 'T', '5'))
321
328extern const char *imb_ext_image[];
329extern const char *imb_ext_movie[];
330extern const char *imb_ext_audio[];
331
332/* -------------------------------------------------------------------- */
337
338enum {
340};
341
blender::ocio::ColorSpace ColorSpace
eImbFileType
#define IMB_FILEPATH_SIZE
const char * imb_ext_movie[]
@ IB_PERSISTENT
@ IB_RECT_INVALID
@ IB_BITMAPDIRTY
@ IB_MIPMAP_INVALID
@ IB_DISPLAY_BUFFER_INVALID
#define IMB_MIPMAP_LEVELS
ImBufOwnership
@ IB_DO_NOT_TAKE_OWNERSHIP
@ IB_TAKE_OWNERSHIP
const char * imb_ext_audio[]
eImBufFlags
@ IB_animdeinterlace
@ IB_float_data
@ IB_alphamode_channel_packed
@ IB_alphamode_premul
@ IB_byte_data
@ IB_alphamode_ignore
@ IB_uninitialized_pixels
@ IB_metadata
@ IB_multilayer
@ IB_alphamode_detect
@ IB_thumbnail
@ IB_mem
@ IB_test
const char * imb_ext_image[]
@ IMB_COLORMANAGE_IS_DATA
unsigned int size
unsigned int nummipmaps
ImBufOwnership ownership
unsigned char * data
unsigned int fourcc
const ColorSpace * colorspace
ImBufOwnership ownership
const ColorSpace * colorspace
ImBufOwnership ownership
GPUTexture * texture
void * userdata
rcti invalid_rect
ImBufGPU gpu
char filepath[IMB_FILEPATH_SIZE]
DDSData dds_data
ImBufFloatBuffer float_buffer
ImbFormatOptions foptions
ImBufByteBuffer byte_buffer
int colormanage_flag
unsigned char planes
enum eImbFileType ftype
ImBuf * mipmap[IMB_MIPMAP_LEVELS]
unsigned int encoded_buffer_size
unsigned int * display_buffer_flags
IDProperty * metadata
ColormanageCache * colormanage_cache
ImBufByteBuffer encoded_buffer
int32_t refcounter
double ppm[2]
unsigned int encoded_size