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

Method encode_image

engine/dlib/src/basis/encoder/basisu_backend.cpp:687–1485  ·  view source on GitHub ↗

TODO: Split this into multiple methods.

Source from the content-addressed store, hash-verified

685
686 // TODO: Split this into multiple methods.
687 bool basisu_backend::encode_image()
688 {
689 basisu_frontend& r = *m_pFront_end;
690 const bool is_video = r.get_params().m_tex_type == basist::cBASISTexTypeVideoFrames;
691
692 uint32_t total_used_selector_history_buf = 0;
693 uint32_t total_selector_indices_remapped = 0;
694
695 basist::approx_move_to_front selector_history_buf(basist::MAX_SELECTOR_HISTORY_BUF_SIZE);
696 histogram selector_history_buf_histogram(basist::MAX_SELECTOR_HISTORY_BUF_SIZE);
697 histogram selector_histogram(r.get_total_selector_clusters() + basist::MAX_SELECTOR_HISTORY_BUF_SIZE + 1);
698 histogram selector_history_buf_rle_histogram(1 << basist::SELECTOR_HISTORY_BUF_RLE_COUNT_BITS);
699
700 basisu::vector<uint_vec> selector_syms(m_slices.size());
701
702 const uint32_t SELECTOR_HISTORY_BUF_FIRST_SYMBOL_INDEX = r.get_total_selector_clusters();
703 const uint32_t SELECTOR_HISTORY_BUF_RLE_SYMBOL_INDEX = SELECTOR_HISTORY_BUF_FIRST_SYMBOL_INDEX + basist::MAX_SELECTOR_HISTORY_BUF_SIZE;
704
705 m_output.m_slice_image_crcs.resize(m_slices.size());
706
707 histogram delta_endpoint_histogram(r.get_total_endpoint_clusters());
708
709 histogram endpoint_pred_histogram(basist::ENDPOINT_PRED_TOTAL_SYMBOLS);
710 basisu::vector<uint_vec> endpoint_pred_syms(m_slices.size());
711
712 uint32_t total_endpoint_indices_remapped = 0;
713
714 uint_vec block_endpoint_indices, block_selector_indices;
715
716 interval_timer tm;
717 tm.start();
718
719 const int COLOR_DELTA_THRESH = 8;
720 const int SEL_DIFF_THRESHOLD = 11;
721
722 for (uint32_t slice_index = 0; slice_index < m_slices.size(); slice_index++)
723 {
724 //const int prev_frame_slice_index = is_video ? find_video_frame(slice_index, -1) : -1;
725 //const int next_frame_slice_index = is_video ? find_video_frame(slice_index, 1) : -1;
726 const uint32_t first_block_index = m_slices[slice_index].m_first_block_index;
727 //const uint32_t width = m_slices[slice_index].m_width;
728 //const uint32_t height = m_slices[slice_index].m_height;
729 const uint32_t num_blocks_x = m_slices[slice_index].m_num_blocks_x;
730 const uint32_t num_blocks_y = m_slices[slice_index].m_num_blocks_y;
731
732 selector_history_buf.reset();
733
734 int selector_history_buf_rle_count = 0;
735
736 int prev_endpoint_pred_sym_bits = -1, endpoint_pred_repeat_count = 0;
737
738 uint32_t prev_endpoint_index = 0;
739
740 vector2D<uint8_t> block_endpoints_are_referenced(num_blocks_x, num_blocks_y);
741
742 for (uint32_t block_y = 0; block_y < num_blocks_y; block_y++)
743 {
744 for (uint32_t block_x = 0; block_x < num_blocks_x; block_x++)

Callers

nothing calls this directly

Calls 15

iabsFunction · 0.85
color_distanceFunction · 0.85
debug_printfFunction · 0.85
error_printfFunction · 0.85
get_paramsMethod · 0.80
evaluate_etc1_errorMethod · 0.80
useMethod · 0.80
get_elapsed_secsMethod · 0.80

Tested by

no test coverage detected