MCPcopy Create free account
hub / github.com/ARM-software/astc-encoder / load_image_block_fast_ldr

Function load_image_block_fast_ldr

Source/astcenc_image.cpp:278–342  ·  view source on GitHub ↗

See header for documentation. */

Source from the content-addressed store, hash-verified

276
277/* See header for documentation. */
278void load_image_block_fast_ldr(
279 astcenc_profile decode_mode,
280 const astcenc_image& img,
281 image_block& blk,
282 const block_size_descriptor& bsd,
283 size_t pos_x,
284 size_t pos_y,
285 size_t pos_z,
286 const astcenc_swizzle& swz
287) {
288 (void)swz;
289 (void)decode_mode;
290
291 size_t size_x = img.dim_x;
292 size_t size_y = img.dim_y;
293
294 blk.pos_x = pos_x;
295 blk.pos_y = pos_y;
296 blk.pos_z = pos_z;
297
298 vfloat4 data_min(1e38f);
299 vfloat4 data_mean = vfloat4::zero();
300 vfloat4 data_max(-1e38f);
301 vmask4 grayscalev(true);
302 size_t idx = 0;
303
304 const uint8_t* plane = static_cast<const uint8_t*>(img.data[0]);
305 for (size_t y = pos_y; y < pos_y + bsd.dim_y; y++)
306 {
307 size_t yi = astc::min(y, size_y - 1);
308
309 for (size_t x = pos_x; x < pos_x + bsd.dim_x; x++)
310 {
311 size_t xi = astc::min(x, size_x - 1);
312
313 vint4 datavi = vint4(plane + (4 * size_x * yi) + (4 * xi));
314 vfloat4 datav = int_to_float(datavi) * (65535.0f / 255.0f);
315
316 // Compute block metadata
317 data_min = min(data_min, datav);
318 data_mean += datav;
319 data_max = max(data_max, datav);
320
321 grayscalev = grayscalev & (datav.swz<0,0,0,0>() == datav.swz<1,1,2,2>());
322
323 blk.data_r[idx] = datav.lane<0>();
324 blk.data_g[idx] = datav.lane<1>();
325 blk.data_b[idx] = datav.lane<2>();
326 blk.data_a[idx] = datav.lane<3>();
327
328 idx++;
329 }
330 }
331
332 // Reverse the encoding so we store origin block in the original format
333 blk.origin_texel = blk.texel(0) / 65535.0f;
334
335 // Store block metadata

Callers

nothing calls this directly

Calls 6

texelMethod · 0.80
minFunction · 0.70
vint4Class · 0.70
int_to_floatFunction · 0.70
maxFunction · 0.70
allFunction · 0.70

Tested by

no test coverage detected