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

Method pick_side

engine/dlib/src/basis/encoder/basisu_enc.cpp:1352–1374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1350 }
1351
1352 float palette_index_reorderer::pick_side(uint32_t num_syms, uint32_t entry_to_move, pEntry_dist_func pDist_func, void *pCtx, float dist_func_weight)
1353 {
1354 float which_side = 0;
1355
1356 int l_count = 0, r_count = 0;
1357 for (uint32_t j = 0; j < m_entries_picked.size(); j++)
1358 {
1359 const int count = get_hist(entry_to_move, m_entries_picked[j], num_syms), r = ((int)m_entries_picked.size() + 1 - 2 * (j + 1));
1360 which_side += static_cast<float>(r * count);
1361 if (r >= 0)
1362 l_count += r * count;
1363 else
1364 r_count += -r * count;
1365 }
1366
1367 if (pDist_func)
1368 {
1369 float w_left = lerp(1.0f - dist_func_weight, 1.0f + dist_func_weight, (*pDist_func)(entry_to_move, m_entries_picked.front(), pCtx));
1370 float w_right = lerp(1.0f - dist_func_weight, 1.0f + dist_func_weight, (*pDist_func)(entry_to_move, m_entries_picked.back(), pCtx));
1371 which_side = w_left * l_count - w_right * r_count;
1372 }
1373 return which_side;
1374 }
1375
1376 void image_metrics::calc(const image &a, const image &b, uint32_t first_chan, uint32_t total_chans, bool avg_comp_error, bool use_601_luma)
1377 {

Callers

nothing calls this directly

Calls 2

lerpFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected