MCPcopy Create free account
hub / github.com/defold/defold / unpack_etc1

Function unpack_etc1

engine/dlib/src/basis/encoder/basisu_etc.cpp:604–710  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

602 }
603
604 bool unpack_etc1(const etc_block& block, color_rgba *pDst, bool preserve_alpha)
605 {
606 const bool diff_flag = block.get_diff_bit();
607 const bool flip_flag = block.get_flip_bit();
608 const uint32_t table_index0 = block.get_inten_table(0);
609 const uint32_t table_index1 = block.get_inten_table(1);
610
611 color_rgba subblock_colors0[4];
612 color_rgba subblock_colors1[4];
613
614 if (diff_flag)
615 {
616 const uint16_t base_color5 = block.get_base5_color();
617 const uint16_t delta_color3 = block.get_delta3_color();
618 etc_block::get_diff_subblock_colors(subblock_colors0, base_color5, table_index0);
619
620 if (!etc_block::get_diff_subblock_colors(subblock_colors1, base_color5, delta_color3, table_index1))
621 return false;
622 }
623 else
624 {
625 const uint16_t base_color4_0 = block.get_base4_color(0);
626 etc_block::get_abs_subblock_colors(subblock_colors0, base_color4_0, table_index0);
627
628 const uint16_t base_color4_1 = block.get_base4_color(1);
629 etc_block::get_abs_subblock_colors(subblock_colors1, base_color4_1, table_index1);
630 }
631
632 if (preserve_alpha)
633 {
634 if (flip_flag)
635 {
636 for (uint32_t y = 0; y < 2; y++)
637 {
638 pDst[0].set_rgb(subblock_colors0[block.get_selector(0, y)]);
639 pDst[1].set_rgb(subblock_colors0[block.get_selector(1, y)]);
640 pDst[2].set_rgb(subblock_colors0[block.get_selector(2, y)]);
641 pDst[3].set_rgb(subblock_colors0[block.get_selector(3, y)]);
642 pDst += 4;
643 }
644
645 for (uint32_t y = 2; y < 4; y++)
646 {
647 pDst[0].set_rgb(subblock_colors1[block.get_selector(0, y)]);
648 pDst[1].set_rgb(subblock_colors1[block.get_selector(1, y)]);
649 pDst[2].set_rgb(subblock_colors1[block.get_selector(2, y)]);
650 pDst[3].set_rgb(subblock_colors1[block.get_selector(3, y)]);
651 pDst += 4;
652 }
653 }
654 else
655 {
656 for (uint32_t y = 0; y < 4; y++)
657 {
658 pDst[0].set_rgb(subblock_colors0[block.get_selector(0, y)]);
659 pDst[1].set_rgb(subblock_colors0[block.get_selector(1, y)]);
660 pDst[2].set_rgb(subblock_colors1[block.get_selector(2, y)]);
661 pDst[3].set_rgb(subblock_colors1[block.get_selector(3, y)]);

Callers 5

evaluate_etc1_errorMethod · 0.85
get_subblock_pixelsMethod · 0.85
unpack_blockFunction · 0.85
create_encoder_blocksMethod · 0.85

Calls 7

get_diff_bitMethod · 0.45
get_flip_bitMethod · 0.45
get_inten_tableMethod · 0.45
get_base5_colorMethod · 0.45
get_delta3_colorMethod · 0.45
get_base4_colorMethod · 0.45
get_selectorMethod · 0.45

Tested by

no test coverage detected