MCPcopy Create free account
hub / github.com/ARM-software/astc-encoder / load_uncomp_file

Function load_uncomp_file

Source/astcenccli_toplevel.cpp:341–452  ·  view source on GitHub ↗

* @brief Load a non-astc image file from memory. * * @param filename The file to load, or a pattern for array loads. * @param dim_z The number of slices to load. * @param y_flip Should this image be Y flipped? * @param[out] is_hdr Is the loaded image HDR? * @param[out] component_count The number of components in the loaded image. *

Source from the content-addressed store, hash-verified

339 * @return The astc image file, or nullptr on error.
340 */
341static astcenc_image_ptr load_uncomp_file(
342 const char* filename,
343 unsigned int dim_z,
344 bool y_flip,
345 bool& is_hdr,
346 unsigned int& component_count
347) {
348 astcenc_image_ptr image;
349
350 // For a 2D image just load the image directly
351 if (dim_z == 1)
352 {
353 return load_ncimage(filename, y_flip, is_hdr, component_count);
354 }
355 else
356 {
357 bool slice_is_hdr;
358 unsigned int slice_component_count;
359 std::vector<astcenc_image_ptr> slices;
360
361 // For a 3D image load an array of slices
362 for (unsigned int image_index = 0; image_index < dim_z; image_index++)
363 {
364 bool error;
365 std::string slice_name = get_slice_filename(filename, image_index, error);
366 if (error)
367 {
368 print_error("ERROR: Image pattern does not contain file extension: %s\n", filename);
369 break;
370 }
371
372 auto slice = load_ncimage(slice_name.c_str(), y_flip,
373 slice_is_hdr, slice_component_count);
374 if (!slice)
375 {
376 break;
377 }
378
379 // Check it is not a 3D image
380 if (slice->dim_z != 1)
381 {
382 print_error("ERROR: Image arrays do not support 3D sources: %s\n", slice_name.c_str());
383 break;
384 }
385
386 // Check slices are consistent with each other
387 if (image_index != 0)
388 {
389 if ((is_hdr != slice_is_hdr) || (component_count != slice_component_count))
390 {
391 print_error("ERROR: Image array[0] and [%u] are different formats\n", image_index);
392 break;
393 }
394
395 if ((slices[0]->dim_x != slice->dim_x) ||
396 (slices[0]->dim_y != slice->dim_y) ||
397 (slices[0]->dim_z != slice->dim_z))
398 {

Callers 1

astcenc_mainFunction · 0.85

Calls 4

load_ncimageFunction · 0.85
get_slice_filenameFunction · 0.85
alloc_imageFunction · 0.85
print_errorFunction · 0.70

Tested by

no test coverage detected