Skip to main content
The primitives API (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

The primitive_hints enum controls selection:

Global hint control

Call primitives_set_hints() before the first primitives_get() to override autodetection.

Flags

Returns a bitmask:

The primitives_t Struct

All operations are function pointers within a primitives_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
Optimised memcpy-equivalent. May use SIMD movnt stores.
fn_copy_8u_t
Byte-typed copy, more strongly typed than copy.
fn_copy_8u_AC4r_t
Copies a 2-D 4-byte-per-pixel region. srcStep/dstStep are row strides in bytes.
fn_copy_no_overlap_t
Copies a sub-image rectangle, optionally converting pixel formats. Requires non-overlapping source and destination. Since version 3.6.0.
fn_set_8u_t
memset-equivalent for byte arrays.
fn_set_32u_t
Fills a 32-bit unsigned integer array with val.
fn_zero_t
Fast bzero / memset(0) equivalent.

Alpha Compositing

fn_alphaComp_argb_t
Blends two ARGB pixel regions using standard Porter-Duff source-over alpha compositing. srcStep/dstStep are row strides in bytes.

Arithmetic

fn_add_16s_t
Element-wise addition of two INT16 arrays: pDst[i] = pSrc1[i] + pSrc2[i].
fn_add_16s_inplace_t
In-place addition: pSrcDst1 = pSrcDst2 = pSrcDst1 + pSrcDst2. Since version 3.6.0.

Bitwise Operations

fn_andC_32u_t
Element-wise AND with scalar constant: pDst[i] = pSrc[i] & val.
fn_orC_32u_t
Element-wise OR with scalar constant: pDst[i] = pSrc[i] | val.

Shift Operations

fn_lShiftC_16s_t
Left shift each element of a signed 16-bit array by val bits.
fn_rShiftC_16s_t
Arithmetic right shift of a signed 16-bit array.
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
In-place left shift. Since version 3.6.0.

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

Call primitives_set_hints(PRIMITIVES_PURE_SOFT) before the first use to disable SIMD acceleration — useful for debugging correctness issues.
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.