Blender V4.3
IMB_imbuf_types.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include "DNA_vec_types.h" /* for rcti */
8
9#include "BLI_sys_types.h"
10
11#include "IMB_imbuf_enums.h"
12
13struct ColormanageCache;
14struct ColorSpace;
15struct GPUTexture;
16struct IDProperty;
17
34#define IMB_MIPMAP_LEVELS 20
35#define IMB_FILEPATH_SIZE 1024
36
48#define OPENEXR_HALF (1 << 8)
49/* careful changing this, it's used in DNA as well */
50#define OPENEXR_COMPRESS (15)
51
52#ifdef WITH_CINEON
53# define CINEON_LOG (1 << 8)
54# define CINEON_16BIT (1 << 7)
55# define CINEON_12BIT (1 << 6)
56# define CINEON_10BIT (1 << 5)
57#endif
58
59#ifdef WITH_OPENJPEG
60# define JP2_12BIT (1 << 9)
61# define JP2_16BIT (1 << 8)
62# define JP2_YCC (1 << 7)
63# define JP2_CINE (1 << 6)
64# define JP2_CINE_48FPS (1 << 5)
65# define JP2_JP2 (1 << 4)
66# define JP2_J2K (1 << 3)
67#endif
68
69#define PNG_16BIT (1 << 10)
70
71#define RAWTGA 1
72
73#define TIF_16BIT (1 << 8)
74#define TIF_COMPRESS_NONE (1 << 7)
75#define TIF_COMPRESS_DEFLATE (1 << 6)
76#define TIF_COMPRESS_LZW (1 << 5)
77#define TIF_COMPRESS_PACKBITS (1 << 4)
78
80 short flag;
82 char quality;
83};
84
85/* -------------------------------------------------------------------- */
91 IB_rect = 1 << 0,
92 IB_test = 1 << 1,
93 IB_mem = 1 << 4,
94 IB_rectfloat = 1 << 5,
95 IB_multilayer = 1 << 7,
96 IB_metadata = 1 << 8,
103
108 /* alpha channel is unrelated to RGB and should not affect it */
112 IB_thumbnail = 1 << 16,
113 IB_multiview = 1 << 17,
114 IB_halffloat = 1 << 18,
115};
116
119/* -------------------------------------------------------------------- */
123/* Specialization of an ownership whenever a bare pointer is provided to the ImBuf buffers
124 * assignment API. */
126 /* The ImBuf simply shares pointer with data owned by someone else, and will not perform any
127 * memory management when the ImBuf frees the buffer. */
129
130 /* The ImBuf takes ownership of the buffer data, and will use MEM_freeN() to free this memory
131 * when the ImBuf needs to free the data. */
133};
134
135struct DDSData {
137 unsigned int fourcc;
139 unsigned int nummipmaps;
141 unsigned char *data;
143 unsigned int size;
146};
147
148/* Different storage specialization.
149 *
150 * NOTE: Avoid direct assignments and allocations, use the buffer utilities from the IMB_imbuf.hh
151 * instead.
152 *
153 * Accessing the data pointer directly is fine and is an expected way of accessing it. */
154
161
168
169struct ImBufGPU {
170 /* Texture which corresponds to the state of the ImBug on the GPU.
171 *
172 * Allocation is supposed to happen outside of the ImBug module from a proper GPU context.
173 * De-referencing the ImBuf or its GPU texture can happen from any state. */
174 /* TODO(sergey): This should become a list of textures, to support having high-res ImBuf on GPU
175 * without hitting hardware limitations. */
176 GPUTexture *texture;
177};
178
181/* -------------------------------------------------------------------- */
185struct ImBuf {
186 /* dimensions */
191 int x, y;
192
194 unsigned char planes;
197
198 /* flags */
200 int flags;
201
202 /* pixels */
203
210
219
220 /* Image buffer on the GPU. */
222
224 double ppm[2];
225
226 /* parameters used by conversion between byte and float */
228 float dither;
229
230 /* mipmapping */
234
235 /* externally used data */
237 int index;
243 void *userdata;
244
245 /* file information */
252
253 /* memory cache limiter */
256
257 /* some parameters to pass along for packing images */
261 unsigned int encoded_size;
264
265 /* color management */
267 unsigned int *display_buffer_flags;
272
273 /* information for compressed textures */
275};
276
281enum {
283 IB_BITMAPDIRTY = (1 << 1),
287 IB_RECT_INVALID = (1 << 3),
291 IB_PERSISTENT = (1 << 5),
292};
293
296/* -------------------------------------------------------------------- */
302#define IB_PROFILE_NONE 0
303#define IB_PROFILE_LINEAR_RGB 1
304#define IB_PROFILE_SRGB 2
305#define IB_PROFILE_CUSTOM 3
306
309/* dds */
310#ifndef DDS_MAKEFOURCC
311# define DDS_MAKEFOURCC(ch0, ch1, ch2, ch3) \
312 ((unsigned long)(unsigned char)(ch0) | ((unsigned long)(unsigned char)(ch1) << 8) | \
313 ((unsigned long)(unsigned char)(ch2) << 16) | ((unsigned long)(unsigned char)(ch3) << 24))
314#endif /* DDS_MAKEFOURCC */
315
316/*
317 * FOURCC codes for DX compressed-texture pixel formats.
318 */
319
320#define FOURCC_DDS (DDS_MAKEFOURCC('D', 'D', 'S', ' '))
321#define FOURCC_DX10 (DDS_MAKEFOURCC('D', 'X', '1', '0'))
322#define FOURCC_DXT1 (DDS_MAKEFOURCC('D', 'X', 'T', '1'))
323#define FOURCC_DXT2 (DDS_MAKEFOURCC('D', 'X', 'T', '2'))
324#define FOURCC_DXT3 (DDS_MAKEFOURCC('D', 'X', 'T', '3'))
325#define FOURCC_DXT4 (DDS_MAKEFOURCC('D', 'X', 'T', '4'))
326#define FOURCC_DXT5 (DDS_MAKEFOURCC('D', 'X', 'T', '5'))
327
328extern const char *imb_ext_image[];
329extern const char *imb_ext_movie[];
330extern const char *imb_ext_audio[];
331
332/* -------------------------------------------------------------------- */
338enum {
340};
341
eImbFileType
#define IMB_FILEPATH_SIZE
const char * imb_ext_movie[]
#define IMB_MIPMAP_LEVELS
@ IMB_COLORMANAGE_IS_DATA
ImBufOwnership
@ IB_DO_NOT_TAKE_OWNERSHIP
@ IB_TAKE_OWNERSHIP
const char * imb_ext_audio[]
eImBufFlags
@ IB_animdeinterlace
@ IB_alphamode_channel_packed
@ IB_halffloat
@ IB_alphamode_premul
@ IB_alphamode_ignore
@ IB_rectfloat
@ IB_uninitialized_pixels
@ IB_metadata
@ IB_multilayer
@ IB_alphamode_detect
@ IB_thumbnail
@ IB_multiview
@ IB_mem
@ IB_test
@ IB_rect
@ IB_PERSISTENT
@ IB_RECT_INVALID
@ IB_BITMAPDIRTY
@ IB_MIPMAP_INVALID
@ IB_DISPLAY_BUFFER_INVALID
const char * imb_ext_image[]
unsigned char uint8_t
Definition stdint.h:78
unsigned int size
unsigned int nummipmaps
ImBufOwnership ownership
unsigned char * data
unsigned int fourcc
ImBufOwnership ownership
ColorSpace * colorspace
ImBufOwnership ownership
ColorSpace * colorspace
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
double ppm[2]
unsigned int encoded_size