40 const char *bc5normal =
"dds:bc5normal";
41 const char *oiio_env =
BLI_getenv(
"OPENIMAGEIO_OPTIONS");
43 OIIO::attribute(bc5normal, 1);
54 ImageSpec config, spec;
60 if (ibuf && (flags &
IB_test) == 0) {
61 Filesystem::IOMemReader mem_reader(cspan<uchar>(mem,
size));
162 uint line_0_1 = block[2] + 256 * (block[3] + 256 * block[4]);
163 uint line_2_3 = block[5] + 256 * (block[6] + 256 * block[7]);
165 uint line_1_0 = ((line_0_1 & 0x000fff) << 12) | ((line_0_1 & 0xfff000) >> 12);
167 uint line_3_2 = ((line_2_3 & 0x000fff) << 12) | ((line_2_3 & 0xfff000) >> 12);
169 block[2] = line_3_2 & 0xff;
170 block[3] = (line_3_2 & 0xff00) >> 8;
171 block[4] = (line_3_2 & 0xff0000) >> 16;
172 block[5] = line_1_0 & 0xff;
173 block[6] = (line_1_0 & 0xff00) >> 8;
174 block[7] = (line_1_0 & 0xff0000) >> 16;
184 uint line_0_1 = block[2] + 256 * (block[3] + 256 * block[4]);
185 uint line_1_0 = ((line_0_1 & 0x000fff) << 12) | ((line_0_1 & 0xfff000) >> 12);
186 block[2] = line_1_0 & 0xff;
187 block[3] = (line_1_0 & 0xff00) >> 8;
188 block[4] = (line_1_0 & 0xff0000) >> 16;
207 *num_valid_levels = 0;
210 if (width == 0 || height == 0) {
223 uint block_bytes = 0;
245 *num_valid_levels = levels;
247 uint mip_width = width;
248 uint mip_height = height;
252 for (
uint level = 0; level < levels; level++) {
253 uint blocks_per_row = (mip_width + 3) / 4;
254 uint blocks_per_col = (mip_height + 3) / 4;
255 uint blocks = blocks_per_row * blocks_per_col;
257 if (
data + block_bytes * blocks > data_end) {
260 *num_valid_levels = level;
264 if (mip_height == 1) {
268 if (mip_height == 2) {
270 for (
uint i = 0; i < blocks_per_row; i++) {
271 half_block_function(
data + i * block_bytes);
276 for (
uint i = 0; i < blocks; i++) {
277 full_block_function(
data + i * block_bytes);
283 uint row_bytes = block_bytes * blocks_per_row;
286 for (
uint y = 0;
y < blocks_per_col / 2;
y++) {
288 uint8_t *line2 =
data + (blocks_per_col -
y - 1) * row_bytes;
290 memcpy(temp_line, line1, row_bytes);
291 memcpy(line1, line2, row_bytes);
292 memcpy(line2, temp_line, row_bytes);
299 data += block_bytes * blocks;
300 mip_width = std::max(1U, mip_width >> 1);
301 mip_height = std::max(1U, mip_height >> 1);
310 mem_reader.pread(&flags,
sizeof(
uint32_t), 8);
318 const uint32_t DDSD_MIPMAPCOUNT = 0x00020000U;
319 if ((flags & DDSD_MIPMAPCOUNT) == 0) {
327 dds_header_size += 20;
330 ibuf->
dds_data.
size = mem_reader.size() - dds_header_size;
BLI_INLINE void BLI_endian_switch_uint32(unsigned int *val) ATTR_NONNULL(1)
MINLINE int is_power_of_2_i(int n)
const char * BLI_getenv(const char *env) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
int char * BLI_strcasestr(const char *s, const char *find) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
Contains defines and structs used throughout the imbuf module.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
ImBuf * imb_oiio_read(const ReadContext &ctx, const ImageSpec &config, char colorspace[IM_MAX_SPACE], ImageSpec &r_newspec)
bool imb_oiio_check(const uchar *mem, size_t mem_size, const char *file_format)