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

Function astc_img_from_floatx4_array

Source/astcenccli_image.cpp:197–228  ·  view source on GitHub ↗

See header for documentation. */

Source from the content-addressed store, hash-verified

195
196/* See header for documentation. */
197astcenc_image_ptr astc_img_from_floatx4_array(
198 const float* data,
199 unsigned int dim_x,
200 unsigned int dim_y,
201 bool y_flip
202) {
203 auto img = alloc_image(16, dim_x, dim_y, 1);
204
205 for (unsigned int y = 0; y < dim_y; y++)
206 {
207 uint16_t* data16 = static_cast<uint16_t*>(img->data[0]);
208 unsigned int y_src = y_flip ? (dim_y - y - 1) : y;
209 const float* src = data + 4 * dim_x * y_src;
210
211 for (unsigned int x = 0; x < dim_x; x++)
212 {
213 vint4 colorf16 = float_to_float16(vfloat4(
214 src[4 * x ],
215 src[4 * x + 1],
216 src[4 * x + 2],
217 src[4 * x + 3]
218 ));
219
220 data16[(4 * dim_x * y) + (4 * x )] = static_cast<uint16_t>(colorf16.lane<0>());
221 data16[(4 * dim_x * y) + (4 * x + 1)] = static_cast<uint16_t>(colorf16.lane<1>());
222 data16[(4 * dim_x * y) + (4 * x + 2)] = static_cast<uint16_t>(colorf16.lane<2>());
223 data16[(4 * dim_x * y) + (4 * x + 3)] = static_cast<uint16_t>(colorf16.lane<3>());
224 }
225 }
226
227 return img;
228}
229
230/* See header for documentation. */
231astcenc_image_ptr astc_img_from_unorm8x4_array(

Callers 2

load_image_with_tinyexrFunction · 0.85
load_image_with_stbFunction · 0.85

Calls 3

alloc_imageFunction · 0.85
float_to_float16Function · 0.70
vfloat4Class · 0.70

Tested by

no test coverage detected