Vector Optimized Library of Kernels 3.2.0
Architecture-tuned implementations of math kernels
Loading...
Searching...
No Matches
volk_32f_s32f_x2_convert_8u

Overview

Converts a floating point number to an 8-bit unsigned int after applying a multiplicative scaling factor and an additive bias.

Dispatcher Prototype

void volk_32f_s32f_x2_convert_8u(uint8_t* outputVector, const float* inputVector,
const float scale, const float bias, unsigned int num_points)

Inputs

  • inputVector: the input vector of floats.
  • scale: The value multiplied against each point in the input buffer.
  • bias: The value added to each multiplication by the scale.
  • num_points: The number of data points.

Outputs

  • outputVector: The output vector.

Example Convert floats from [-1,1] to 8-bit unsigend integers with a scale of 128 and a bias of 128 int N = 10; unsigned int alignment = volk_get_alignment(); float* increasing = (float*)volk_malloc(sizeof(float)*N, alignment); uint8_t* out = (uint8_t*)volk_malloc(sizeof(uint8_t)*N, alignment);

for(unsigned int ii = 0; ii < N; ++ii){ increasing[ii] = 2.f * ((float)ii / (float)N) - 1.f; }

float scale = 128.0f; float bias = 128.0f;

volk_32f_s32f_x2_convert_8u(out, increasing, scale, bias, N);

for(unsigned int ii = 0; ii < N; ++ii){ printf("out[%u] = %i\n", ii, out[ii]); }

volk_free(increasing); volk_free(out);