35 const char *bc5normal =
"dds:bc5normal";
36 const char *oiio_env =
BLI_getenv(
"OPENIMAGEIO_OPTIONS");
38 OIIO::attribute(bc5normal, 1);
49 ImageSpec config, spec;
55 if (ibuf && (flags &
IB_test) == 0) {
56 Filesystem::IOMemReader mem_reader(cspan<uchar>(mem,
size));
75 uint8_t tmp = block[4];
87 uint8_t tmp = block[4];
100 uint8_t tmp = block[0];
122 uint8_t tmp = block[0];
157 uint line_0_1 = block[2] + 256 * (block[3] + 256 * block[4]);
158 uint line_2_3 = block[5] + 256 * (block[6] + 256 * block[7]);
160 uint line_1_0 = ((line_0_1 & 0x000fff) << 12) | ((line_0_1 & 0xfff000) >> 12);
162 uint line_3_2 = ((line_2_3 & 0x000fff) << 12) | ((line_2_3 & 0xfff000) >> 12);
164 block[2] = line_3_2 & 0xff;
165 block[3] = (line_3_2 & 0xff00) >> 8;
166 block[4] = (line_3_2 & 0xff0000) >> 16;
167 block[5] = line_1_0 & 0xff;
168 block[6] = (line_1_0 & 0xff00) >> 8;
169 block[7] = (line_1_0 & 0xff0000) >> 16;
179 uint line_0_1 = block[2] + 256 * (block[3] + 256 * block[4]);
180 uint line_1_0 = ((line_0_1 & 0x000fff) << 12) | ((line_0_1 & 0xfff000) >> 12);
181 block[2] = line_1_0 & 0xff;
182 block[3] = (line_1_0 & 0xff00) >> 8;
183 block[4] = (line_1_0 & 0xff0000) >> 16;
194 uint32_t width = ibuf->
x;
195 uint32_t height = ibuf->
y;
202 *num_valid_levels = 0;
205 if (width == 0 || height == 0) {
218 uint block_bytes = 0;
240 *num_valid_levels = levels;
242 uint mip_width = width;
243 uint mip_height = height;
245 const uint8_t *data_end =
data + data_size;
247 for (
uint level = 0; level < levels; level++) {
248 uint blocks_per_row = (mip_width + 3) / 4;
249 uint blocks_per_col = (mip_height + 3) / 4;
250 uint blocks = blocks_per_row * blocks_per_col;
252 if (
data + block_bytes * blocks > data_end) {
255 *num_valid_levels = level;
259 if (mip_height == 1) {
263 if (mip_height == 2) {
265 for (
uint i = 0;
i < blocks_per_row;
i++) {
266 half_block_function(
data +
i * block_bytes);
271 for (
uint i = 0;
i < blocks;
i++) {
272 full_block_function(
data +
i * block_bytes);
278 uint row_bytes = block_bytes * blocks_per_row;
279 uint8_t *temp_line =
new uint8_t[row_bytes];
281 for (
uint y = 0;
y < blocks_per_col / 2;
y++) {
282 uint8_t *line1 =
data +
y * row_bytes;
283 uint8_t *line2 =
data + (blocks_per_col -
y - 1) * row_bytes;
285 memcpy(temp_line, line1, row_bytes);
286 memcpy(line1, line2, row_bytes);
287 memcpy(line2, temp_line, row_bytes);
294 data += block_bytes * blocks;
295 mip_width = std::max(1U, mip_width >> 1);
296 mip_height = std::max(1U, mip_height >> 1);
305 mem_reader.pread(&flags,
sizeof(uint32_t), 8);
311 const uint32_t DDSD_MIPMAPCOUNT = 0x00020000U;
312 if ((flags & DDSD_MIPMAPCOUNT) == 0) {
318 uint32_t dds_header_size = 128;
320 dds_header_size += 20;
323 ibuf->
dds_data.
size = mem_reader.size() - dds_header_size;
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)