39 const char *bc5normal =
"dds:bc5normal";
40 const char *oiio_env =
BLI_getenv(
"OPENIMAGEIO_OPTIONS");
42 OIIO::attribute(bc5normal, 1);
53 ImageSpec config, spec;
59 if (ibuf && (flags &
IB_test) == 0) {
60 Filesystem::IOMemReader mem_reader(cspan<uchar>(mem,
size));
79 uint8_t tmp = block[4];
91 uint8_t tmp = block[4];
104 uint8_t tmp = block[0];
126 uint8_t tmp = block[0];
161 uint line_0_1 = block[2] + 256 * (block[3] + 256 * block[4]);
162 uint line_2_3 = block[5] + 256 * (block[6] + 256 * block[7]);
164 uint line_1_0 = ((line_0_1 & 0x000fff) << 12) | ((line_0_1 & 0xfff000) >> 12);
166 uint line_3_2 = ((line_2_3 & 0x000fff) << 12) | ((line_2_3 & 0xfff000) >> 12);
168 block[2] = line_3_2 & 0xff;
169 block[3] = (line_3_2 & 0xff00) >> 8;
170 block[4] = (line_3_2 & 0xff0000) >> 16;
171 block[5] = line_1_0 & 0xff;
172 block[6] = (line_1_0 & 0xff00) >> 8;
173 block[7] = (line_1_0 & 0xff0000) >> 16;
183 uint line_0_1 = block[2] + 256 * (block[3] + 256 * block[4]);
184 uint line_1_0 = ((line_0_1 & 0x000fff) << 12) | ((line_0_1 & 0xfff000) >> 12);
185 block[2] = line_1_0 & 0xff;
186 block[3] = (line_1_0 & 0xff00) >> 8;
187 block[4] = (line_1_0 & 0xff0000) >> 16;
198 uint32_t width = ibuf->
x;
199 uint32_t height = ibuf->
y;
206 *num_valid_levels = 0;
209 if (width == 0 || height == 0) {
222 uint block_bytes = 0;
244 *num_valid_levels = levels;
246 uint mip_width = width;
247 uint mip_height = height;
249 const uint8_t *data_end =
data + data_size;
251 for (
uint level = 0; level < levels; level++) {
252 uint blocks_per_row = (mip_width + 3) / 4;
253 uint blocks_per_col = (mip_height + 3) / 4;
254 uint blocks = blocks_per_row * blocks_per_col;
256 if (
data + block_bytes * blocks > data_end) {
259 *num_valid_levels = level;
263 if (mip_height == 1) {
267 if (mip_height == 2) {
269 for (
uint i = 0;
i < blocks_per_row;
i++) {
270 half_block_function(
data +
i * block_bytes);
275 for (
uint i = 0;
i < blocks;
i++) {
276 full_block_function(
data +
i * block_bytes);
282 uint row_bytes = block_bytes * blocks_per_row;
283 uint8_t *temp_line =
new uint8_t[row_bytes];
285 for (
uint y = 0;
y < blocks_per_col / 2;
y++) {
286 uint8_t *line1 =
data +
y * row_bytes;
287 uint8_t *line2 =
data + (blocks_per_col -
y - 1) * row_bytes;
289 memcpy(temp_line, line1, row_bytes);
290 memcpy(line1, line2, row_bytes);
291 memcpy(line2, temp_line, row_bytes);
298 data += block_bytes * blocks;
299 mip_width = std::max(1U, mip_width >> 1);
300 mip_height = std::max(1U, mip_height >> 1);
309 mem_reader.pread(&flags,
sizeof(uint32_t), 8);
317 const uint32_t DDSD_MIPMAPCOUNT = 0x00020000U;
318 if ((flags & DDSD_MIPMAPCOUNT) == 0) {
324 uint32_t dds_header_size = 128;
326 dds_header_size += 20;
329 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
BMesh const char void * data
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
ImBuf * imb_oiio_read(const ReadContext &ctx, const ImageSpec &config, ImFileColorSpace &r_colorspace, ImageSpec &r_newspec)
bool imb_oiio_check(const uchar *mem, size_t mem_size, const char *file_format)