| 316 | } |
| 317 | |
| 318 | bool basisu_frontend::init_global_codebooks() |
| 319 | { |
| 320 | const basist::basisu_lowlevel_etc1s_transcoder* pTranscoder = m_params.m_pGlobal_codebooks; |
| 321 | |
| 322 | const basist::basisu_lowlevel_etc1s_transcoder::endpoint_vec& endpoints = pTranscoder->get_endpoints(); |
| 323 | const basist::basisu_lowlevel_etc1s_transcoder::selector_vec& selectors = pTranscoder->get_selectors(); |
| 324 | |
| 325 | m_endpoint_cluster_etc_params.resize(endpoints.size()); |
| 326 | for (uint32_t i = 0; i < endpoints.size(); i++) |
| 327 | { |
| 328 | m_endpoint_cluster_etc_params[i].m_inten_table[0] = endpoints[i].m_inten5; |
| 329 | m_endpoint_cluster_etc_params[i].m_inten_table[1] = endpoints[i].m_inten5; |
| 330 | |
| 331 | m_endpoint_cluster_etc_params[i].m_color_unscaled[0].set(endpoints[i].m_color5.r, endpoints[i].m_color5.g, endpoints[i].m_color5.b, 255); |
| 332 | m_endpoint_cluster_etc_params[i].m_color_used[0] = true; |
| 333 | m_endpoint_cluster_etc_params[i].m_valid = true; |
| 334 | } |
| 335 | |
| 336 | m_optimized_cluster_selectors.resize(selectors.size()); |
| 337 | for (uint32_t i = 0; i < m_optimized_cluster_selectors.size(); i++) |
| 338 | { |
| 339 | for (uint32_t y = 0; y < 4; y++) |
| 340 | for (uint32_t x = 0; x < 4; x++) |
| 341 | m_optimized_cluster_selectors[i].set_selector(x, y, selectors[i].get_selector(x, y)); |
| 342 | } |
| 343 | |
| 344 | m_block_endpoint_clusters_indices.resize(m_total_blocks); |
| 345 | |
| 346 | m_orig_encoded_blocks.resize(m_total_blocks); |
| 347 | |
| 348 | m_block_selector_cluster_index.resize(m_total_blocks); |
| 349 | |
| 350 | #if 0 |
| 351 | for (uint32_t block_index_iter = 0; block_index_iter < m_total_blocks; block_index_iter += N) |
| 352 | { |
| 353 | const uint32_t first_index = block_index_iter; |
| 354 | const uint32_t last_index = minimum<uint32_t>(m_total_blocks, first_index + N); |
| 355 | |
| 356 | #ifndef __EMSCRIPTEN__ |
| 357 | m_params.m_pJob_pool->add_job([this, first_index, last_index] { |
| 358 | #endif |
| 359 | |
| 360 | for (uint32_t block_index = first_index; block_index < last_index; block_index++) |
| 361 | { |
| 362 | const etc_block& blk = m_etc1_blocks_etc1s[block_index]; |
| 363 | |
| 364 | const uint32_t block_endpoint_index = m_block_endpoint_clusters_indices[block_index][0]; |
| 365 | |
| 366 | etc_block trial_blk; |
| 367 | trial_blk.set_block_color5_etc1s(blk.m_color_unscaled[0]); |
| 368 | trial_blk.set_flip_bit(true); |
| 369 | |
| 370 | uint64_t best_err = UINT64_MAX; |
| 371 | uint32_t best_index = 0; |
| 372 | |
| 373 | for (uint32_t i = 0; i < m_optimized_cluster_selectors.size(); i++) |
| 374 | { |
| 375 | trial_blk.set_raw_selector_bits(m_optimized_cluster_selectors[i].get_raw_selector_bits()); |
nothing calls this directly
no test coverage detected