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

Function astcenc_compress_image

Source/astcenc_entry.cpp:1113–1228  ·  view source on GitHub ↗

See header for documentation. */

Source from the content-addressed store, hash-verified

1111
1112/* See header for documentation. */
1113astcenc_error astcenc_compress_image(
1114 astcenc_context* ctxo,
1115 astcenc_image* imagep,
1116 const astcenc_swizzle* swizzle,
1117 uint8_t* data_out,
1118 size_t data_len,
1119 unsigned int thread_index
1120) {
1121#if defined(ASTCENC_DECOMPRESS_ONLY)
1122 (void)ctxo;
1123 (void)imagep;
1124 (void)swizzle;
1125 (void)data_out;
1126 (void)data_len;
1127 (void)thread_index;
1128 return ASTCENC_ERR_BAD_CONTEXT;
1129#else
1130 astcenc_contexti* ctx = &ctxo->context;
1131 astcenc_error status;
1132 astcenc_image& image = *imagep;
1133
1134 if (ctx->config.flags & ASTCENC_FLG_DECOMPRESS_ONLY)
1135 {
1136 return ASTCENC_ERR_BAD_CONTEXT;
1137 }
1138
1139 status = validate_compression_swizzle(*swizzle);
1140 if (status != ASTCENC_SUCCESS)
1141 {
1142 return status;
1143 }
1144
1145 if (thread_index >= ctx->thread_count)
1146 {
1147 return ASTCENC_ERR_BAD_PARAM;
1148 }
1149
1150 size_t dim_x = image.dim_x;
1151 size_t dim_y = image.dim_y;
1152 size_t dim_z = image.dim_z;
1153
1154 size_t texel_count = get_texels_count(dim_x, dim_y, dim_z);
1155 // Cumulative texel sizes would overflow a size_t
1156 if (texel_count == 0)
1157 {
1158 return ASTCENC_ERR_BAD_PARAM;
1159 }
1160
1161 size_t block_x = ctx->config.block_x;
1162 size_t block_y = ctx->config.block_y;
1163 size_t block_z = ctx->config.block_z;
1164
1165 size_t blocks_x = astc::get_block_count_safe(dim_x, block_x);
1166 size_t blocks_y = astc::get_block_count_safe(dim_y, block_y);
1167 size_t blocks_z = astc::get_block_count_safe(dim_z, block_z);
1168
1169 size_t block_count = get_blocks_count(blocks_x, blocks_y, blocks_z);
1170 // Cumulative block sizes would overflow a size_t

Callers 6

mainFunction · 0.85
astcenc_mainFunction · 0.85
LLVMFuzzerTestOneInputFunction · 0.85
TESTFunction · 0.85
run_positive_testFunction · 0.85

Calls 11

get_texels_countFunction · 0.85
get_block_count_safeFunction · 0.85
get_blocks_countFunction · 0.85
astcenc_compress_resetFunction · 0.85
init_compute_averagesFunction · 0.85
compute_averagesFunction · 0.85
compress_imageFunction · 0.85
initMethod · 0.80
waitMethod · 0.80
termMethod · 0.80

Tested by 2

TESTFunction · 0.68
run_positive_testFunction · 0.68