Blender V5.0
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 ExrHandle;
20namespace blender::gpu {
21class Texture;
22}
23struct IDProperty;
24
25namespace blender::ocio {
26class ColorSpace;
27}
29
30#define IMB_FILEPATH_SIZE 1024
31
38
43
44#define OPENEXR_HALF (1 << 8)
45#define OPENEXR_MULTIPART (1 << 9)
46/* Lowest bits of foptions.flag / exr_codec contain actual codec enum. */
47#define OPENEXR_CODEC_MASK (0xF)
48
49#ifdef WITH_IMAGE_CINEON
50# define CINEON_LOG (1 << 8)
51# define CINEON_16BIT (1 << 7)
52# define CINEON_12BIT (1 << 6)
53# define CINEON_10BIT (1 << 5)
54#endif
55
56#ifdef WITH_IMAGE_OPENJPEG
57# define JP2_12BIT (1 << 9)
58# define JP2_16BIT (1 << 8)
59# define JP2_YCC (1 << 7)
60# define JP2_CINE (1 << 6)
61# define JP2_CINE_48FPS (1 << 5)
62# define JP2_JP2 (1 << 4)
63# define JP2_J2K (1 << 3)
64#endif
65
66#define PNG_16BIT (1 << 10)
67
68#define RAWTGA 1
69
70#define TIF_16BIT (1 << 8)
71#define TIF_COMPRESS_NONE (1 << 7)
72#define TIF_COMPRESS_DEFLATE (1 << 6)
73#define TIF_COMPRESS_LZW (1 << 5)
74#define TIF_COMPRESS_PACKBITS (1 << 4)
75
77 short flag;
79 char quality;
80};
81
82/* -------------------------------------------------------------------- */
86
89 IB_byte_data = 1 << 0,
90 IB_test = 1 << 1,
91 IB_mem = 1 << 4,
93 IB_float_data = 1 << 5,
94 IB_multilayer = 1 << 7,
95 IB_metadata = 1 << 8,
102
107 /* alpha channel is unrelated to RGB and should not affect it */
111 IB_thumbnail = 1 << 16,
112};
113
115
116/* -------------------------------------------------------------------- */
119
120/* Specialization of an ownership whenever a bare pointer is provided to the ImBuf buffers
121 * assignment API. */
123 /* The ImBuf simply shares pointer with data owned by someone else, and will not perform any
124 * memory management when the ImBuf frees the buffer. */
126
127 /* The ImBuf takes ownership of the buffer data, and will use MEM_freeN() to free this memory
128 * when the ImBuf needs to free the data. */
130};
131
132struct DDSData {
134 unsigned int fourcc;
136 unsigned int nummipmaps;
138 unsigned char *data;
140 unsigned int size;
143};
144
145/* Different storage specialization.
146 *
147 * NOTE: Avoid direct assignments and allocations, use the buffer utilities from the IMB_imbuf.hh
148 * instead.
149 *
150 * Accessing the data pointer directly is fine and is an expected way of accessing it. */
151
158
165
166struct ImBufGPU {
167 /* Texture which corresponds to the state of the ImBug on the GPU.
168 *
169 * Allocation is supposed to happen outside of the ImBug module from a proper GPU context.
170 * De-referencing the ImBuf or its GPU texture can happen from any state. */
171 /* TODO(sergey): This should become a list of textures, to support having high-res ImBuf on GPU
172 * without hitting hardware limitations. */
174};
175
177
178/* -------------------------------------------------------------------- */
181
182struct ImBuf {
183 /* dimensions */
188 int x, y;
189
191 unsigned char planes;
194
195 /* flags */
197 int flags;
198
199 /* pixels */
200
207
216
217 /* Image buffer on the GPU. */
219
221 double ppm[2];
222
224 float dither;
225
226 /* externally used data */
228 int index;
235
236 /* file information */
243 /* For movie files, the frame number loaded from the file. */
245
248
249 /* some parameters to pass along for packing images */
253 unsigned int encoded_size;
256
257 /* color management */
259 unsigned int *display_buffer_flags;
264
265 /* information for compressed textures */
267};
268
272
273enum {
275 IB_BITMAPDIRTY = (1 << 1),
277 IB_RECT_INVALID = (1 << 3),
281 IB_PERSISTENT = (1 << 5),
282};
283
285
286/* -------------------------------------------------------------------- */
291
292#define IB_PROFILE_NONE 0
293#define IB_PROFILE_LINEAR_RGB 1
294#define IB_PROFILE_SRGB 2
295#define IB_PROFILE_CUSTOM 3
296
298
299/* dds */
300#ifndef DDS_MAKEFOURCC
301# define DDS_MAKEFOURCC(ch0, ch1, ch2, ch3) \
302 ((unsigned long)(unsigned char)(ch0) | ((unsigned long)(unsigned char)(ch1) << 8) | \
303 ((unsigned long)(unsigned char)(ch2) << 16) | ((unsigned long)(unsigned char)(ch3) << 24))
304#endif /* DDS_MAKEFOURCC */
305
306/*
307 * FOURCC codes for DX compressed-texture pixel formats.
308 */
309
310#define FOURCC_DDS (DDS_MAKEFOURCC('D', 'D', 'S', ' '))
311#define FOURCC_DX10 (DDS_MAKEFOURCC('D', 'X', '1', '0'))
312#define FOURCC_DXT1 (DDS_MAKEFOURCC('D', 'X', 'T', '1'))
313#define FOURCC_DXT2 (DDS_MAKEFOURCC('D', 'X', 'T', '2'))
314#define FOURCC_DXT3 (DDS_MAKEFOURCC('D', 'X', 'T', '3'))
315#define FOURCC_DXT4 (DDS_MAKEFOURCC('D', 'X', 'T', '4'))
316#define FOURCC_DXT5 (DDS_MAKEFOURCC('D', 'X', 'T', '5'))
317
324extern const char *imb_ext_image[];
325extern const char *imb_ext_movie[];
326extern const char *imb_ext_audio[];
327
328/* -------------------------------------------------------------------- */
333
334enum {
336};
337
blender::ocio::ColorSpace ColorSpace
Definition BLF_api.hh:38
eImbFileType
#define IMB_FILEPATH_SIZE
@ IB_PERSISTENT
@ IB_RECT_INVALID
@ IB_BITMAPDIRTY
@ IB_DISPLAY_BUFFER_INVALID
const char * imb_ext_movie[]
ImBufOwnership
@ IB_DO_NOT_TAKE_OWNERSHIP
@ IB_TAKE_OWNERSHIP
const char * imb_ext_audio[]
@ IMB_COLORMANAGE_IS_DATA
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[]
unsigned int size
unsigned int nummipmaps
ImBufOwnership ownership
unsigned char * data
unsigned int fourcc
const ColorSpace * colorspace
ImBufOwnership ownership
const ColorSpace * colorspace
ImBufOwnership ownership
blender::gpu::Texture * texture
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
unsigned int encoded_buffer_size
unsigned int * display_buffer_flags
IDProperty * metadata
ColormanageCache * colormanage_cache
ImBufByteBuffer encoded_buffer
ExrHandle * exrhandle
int32_t refcounter
double ppm[2]
unsigned int encoded_size