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

Function get_blocks_count

Source/astcenc_entry.cpp:182–202  ·  view source on GitHub ↗

* @brief Get the total number of blocks in an image. * * This function also validates that the total size of the compressed image, * in bytes, would fit in a size_t. * * @param blocks_x Number of blocks in the X axis. * @param blocks_y Number of blocks in the Y axis. * @param blocks_z Number of blocks in the Z axis. * * @return The number of blocks in the image, or zero if total siz

Source from the content-addressed store, hash-verified

180 * fit into a size_t.
181 */
182static size_t get_blocks_count(
183 size_t blocks_x,
184 size_t blocks_y,
185 size_t blocks_z
186) {
187 bool overflow { false };
188
189 // Compute block count
190 size_t blocks_count = astc::mul_safe(blocks_x, blocks_y, overflow);
191 blocks_count = astc::mul_safe(blocks_count, blocks_z, overflow);
192
193 // Also compute byte count, but we only use overflow and not the result
194 astc::mul_safe(blocks_count, 16, overflow);
195
196 if (overflow)
197 {
198 return 0;
199 }
200
201 return blocks_count;
202}
203
204/**
205 * @brief Validate CPU floating point meets assumptions made in the codec.

Callers 3

compress_imageFunction · 0.85
astcenc_compress_imageFunction · 0.85
astcenc_decompress_imageFunction · 0.85

Calls 1

mul_safeFunction · 0.85

Tested by

no test coverage detected