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

Function get_block_count_safe

Source/astcenc_mathlib.h:516–530  ·  view source on GitHub ↗

* @brief Get the number of blocks along a single axis. * * This function is implemented so that intermediate values will not overflow, * which may occur when input values are not trusted. Implementation is * obviously slower than one that does not do this, so don't use for values * we know cannot overflow. * * @param dim_axis The axis dimension, in pixels. * @param dim_block The block

Source from the content-addressed store, hash-verified

514 * @return The number of blocks needed in this dimension.
515 */
516static inline size_t get_block_count_safe(
517 size_t dim_axis,
518 size_t dim_block
519) {
520 // Compute number of whole blocks
521 size_t blocks = dim_axis / dim_block;
522
523 // Add in any residual partial block
524 if (dim_axis != (dim_block * blocks))
525 {
526 blocks++;
527 }
528
529 return blocks;
530}
531
532/**
533 * @brief Initialize the seed structure for a random number generator.

Callers 4

init_compute_averagesFunction · 0.85
compress_imageFunction · 0.85
astcenc_compress_imageFunction · 0.85
astcenc_decompress_imageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected