include/freerdp/primitives.h) provides a dispatch layer for performance-critical pixel and signal-processing routines. At runtime FreeRDP selects the fastest available implementation: generic C, SSE2/SSSE3/AVX2, ARM NEON, or OpenCL.
Getting the Primitives Instance
primitive_hints enum controls selection:
Global hint control
primitives_set_hints() before the first primitives_get() to override autodetection.
Flags
The primitives_t Struct
All operations are function pointers within aprimitives_t struct. Call them through the instance returned by primitives_get(). All functions return pstatus_t (INT32); PRIMITIVES_SUCCESS (0) means success, negative values indicate errors.
Memory Operations
fn_copy_t
memcpy-equivalent. May use SIMD movnt stores.fn_copy_8u_t
copy.fn_copy_8u_AC4r_t
srcStep/dstStep are row strides in bytes.fn_copy_no_overlap_t
fn_set_8u_t
memset-equivalent for byte arrays.fn_set_32u_t
val.fn_zero_t
bzero / memset(0) equivalent.Alpha Compositing
fn_alphaComp_argb_t
srcStep/dstStep are row strides in bytes.Arithmetic
fn_add_16s_t
INT16 arrays: pDst[i] = pSrc1[i] + pSrc2[i].fn_add_16s_inplace_t
pSrcDst1 = pSrcDst2 = pSrcDst1 + pSrcDst2. Since version 3.6.0.Bitwise Operations
fn_andC_32u_t
pDst[i] = pSrc[i] & val.fn_orC_32u_t
pDst[i] = pSrc[i] | val.Shift Operations
fn_lShiftC_16s_t
val bits.fn_rShiftC_16s_t
fn_lShiftC_16u_t
Logical left shift of an unsigned 16-bit array.
fn_rShiftC_16u_t
Logical right shift of an unsigned 16-bit array.
fn_lShiftC_16s_inplace_t
Color Conversions
The primitives struct also contains highly-optimised color space conversion routines used internally by the codec pipeline:SIMD Detection Flags
Use these compile-time constants to check what extensions are detected at build time:Example
OpenCL support (
PRIMITIVES_ONLY_GPU) requires building with -DWITH_OPENCL=ON. When unavailable, primitives_get_by_type(PRIMITIVES_ONLY_GPU) returns the CPU-optimized instance instead.