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

Function astcenc_config_init

Source/astcenc_entry.cpp:504–723  ·  view source on GitHub ↗

See header for documentation. */

Source from the content-addressed store, hash-verified

502
503/* See header for documentation. */
504astcenc_error astcenc_config_init(
505 astcenc_profile profile,
506 unsigned int block_x,
507 unsigned int block_y,
508 unsigned int block_z,
509 float quality,
510 unsigned int flags,
511 astcenc_config* configp
512) {
513 astcenc_error status;
514
515 status = validate_cpu_float();
516 if (status != ASTCENC_SUCCESS)
517 {
518 return status;
519 }
520
521 // Zero init all config fields; although most of will be overwritten
522 astcenc_config& config = *configp;
523 std::memset(&config, 0, sizeof(config));
524
525 // Process the block size
526 // For 2D blocks Z==0 is accepted, but convert to 1
527 block_z = astc::max(block_z, 1u);
528 status = validate_block_size(block_x, block_y, block_z);
529 if (status != ASTCENC_SUCCESS)
530 {
531 return status;
532 }
533
534 config.block_x = block_x;
535 config.block_y = block_y;
536 config.block_z = block_z;
537
538 float texels = static_cast<float>(block_x * block_y * block_z);
539 float ltexels = logf(texels) / logf(10.0f);
540
541 // Process the performance quality level or preset; note that this must be done before we
542 // process any additional settings, such as color profile and flags, which may replace some of
543 // these settings with more use case tuned values
544 if (quality < ASTCENC_PRE_FASTEST ||
545 quality > ASTCENC_PRE_EXHAUSTIVE)
546 {
547 return ASTCENC_ERR_BAD_QUALITY;
548 }
549
550 static const std::array<astcenc_preset_config, 6>* preset_configs;
551 size_t texels_int = block_x * block_y * block_z;
552 if (texels_int < 25)
553 {
554 preset_configs = &preset_configs_high;
555 }
556 else if (texels_int < 64)
557 {
558 preset_configs = &preset_configs_mid;
559 }
560 else
561 {

Callers 8

mainFunction · 0.85
init_astcenc_configFunction · 0.85
LLVMFuzzerTestOneInputFunction · 0.85
LLVMFuzzerTestOneInputFunction · 0.85
TESTFunction · 0.85
test_decode.cppFile · 0.85
TESTFunction · 0.85
run_positive_testFunction · 0.85

Calls 5

validate_cpu_floatFunction · 0.85
validate_block_sizeFunction · 0.85
validate_flagsFunction · 0.85
maxFunction · 0.70
minFunction · 0.70

Tested by 3

TESTFunction · 0.68
TESTFunction · 0.68
run_positive_testFunction · 0.68