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

Function get_texels_count

Source/astcenc_entry.cpp:150–167  ·  view source on GitHub ↗

* @brief Get the total number of texels in an image. * * This function validates that the total size would fit in a size_t and returns * 0 if it does not. * * @param texels_x Number of texels in the X axis. * @param texels_y Number of texels in the Y axis. * @param texels_z Number of texels in the Z axis. * * @return The number of texels in the image, or zero if total size would not

Source from the content-addressed store, hash-verified

148 * fit into a size_t.
149 */
150static size_t get_texels_count(
151 size_t texels_x,
152 size_t texels_y,
153 size_t texels_z
154) {
155 bool overflow { false };
156
157 // Compute texel count
158 size_t texels_count = astc::mul_safe(texels_x, texels_y, overflow);
159 texels_count = astc::mul_safe(texels_count, texels_z, overflow);
160
161 if (overflow)
162 {
163 return 0;
164 }
165
166 return texels_count;
167}
168
169/**
170 * @brief Get the total number of blocks in an image.

Callers 2

astcenc_compress_imageFunction · 0.85
astcenc_decompress_imageFunction · 0.85

Calls 1

mul_safeFunction · 0.85

Tested by

no test coverage detected