MCPcopy Create free account
hub / github.com/KhronosGroup/KTX-Software / decode_palettes

Method decode_palettes

external/basisu/transcoder/basisu_transcoder.cpp:7524–7706  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7522 }
7523
7524 bool basisu_lowlevel_etc1s_transcoder::decode_palettes(
7525 uint32_t num_endpoints, const uint8_t* pEndpoints_data, uint32_t endpoints_data_size,
7526 uint32_t num_selectors, const uint8_t* pSelectors_data, uint32_t selectors_data_size)
7527 {
7528 if (m_pGlobal_codebook)
7529 {
7530 BASISU_DEVEL_ERROR("basisu_lowlevel_etc1s_transcoder::decode_palettes: fail 11\n");
7531 return false;
7532 }
7533 bitwise_decoder sym_codec;
7534
7535 huffman_decoding_table color5_delta_model0, color5_delta_model1, color5_delta_model2, inten_delta_model;
7536
7537 if (!sym_codec.init(pEndpoints_data, endpoints_data_size))
7538 {
7539 BASISU_DEVEL_ERROR("basisu_lowlevel_etc1s_transcoder::decode_palettes: fail 0\n");
7540 return false;
7541 }
7542
7543 if (!sym_codec.read_huffman_table(color5_delta_model0))
7544 {
7545 BASISU_DEVEL_ERROR("basisu_lowlevel_etc1s_transcoder::decode_palettes: fail 1\n");
7546 return false;
7547 }
7548
7549 if (!sym_codec.read_huffman_table(color5_delta_model1))
7550 {
7551 BASISU_DEVEL_ERROR("basisu_lowlevel_etc1s_transcoder::decode_palettes: fail 1a\n");
7552 return false;
7553 }
7554
7555 if (!sym_codec.read_huffman_table(color5_delta_model2))
7556 {
7557 BASISU_DEVEL_ERROR("basisu_lowlevel_etc1s_transcoder::decode_palettes: fail 2a\n");
7558 return false;
7559 }
7560
7561 if (!sym_codec.read_huffman_table(inten_delta_model))
7562 {
7563 BASISU_DEVEL_ERROR("basisu_lowlevel_etc1s_transcoder::decode_palettes: fail 2b\n");
7564 return false;
7565 }
7566
7567 if (!color5_delta_model0.is_valid() || !color5_delta_model1.is_valid() || !color5_delta_model2.is_valid() || !inten_delta_model.is_valid())
7568 {
7569 BASISU_DEVEL_ERROR("basisu_lowlevel_etc1s_transcoder::decode_palettes: fail 2b\n");
7570 return false;
7571 }
7572
7573 const bool endpoints_are_grayscale = sym_codec.get_bits(1) != 0;
7574
7575 m_local_endpoints.resize(num_endpoints);
7576
7577 color32 prev_color5(16, 16, 16, 0);
7578 uint32_t prev_inten = 0;
7579
7580 for (uint32_t i = 0; i < num_endpoints; i++)
7581 {

Callers 3

start_transcodingMethod · 0.45

Calls 9

read_huffman_tableMethod · 0.80
is_validMethod · 0.80
decode_huffmanMethod · 0.80
init_flagsMethod · 0.80
initMethod · 0.45
get_bitsMethod · 0.45
resizeMethod · 0.45
stopMethod · 0.45
set_selectorMethod · 0.45

Tested by

no test coverage detected