File i8_to_f32_core.h¶
FileList > i8_to_f32 > i8_to_f32_core.h
Go to the source code of this file
int8-to-float converter with configurable inverse scale. More...
#include "clib_common.h"#include "jm_perf.h"
Classes¶
| Type | Name |
|---|---|
| struct | i8_to_f32_state_t I8ToF32 state. |
Public Functions¶
| Type | Name |
|---|---|
| i8_to_f32_state_t * | i8_to_f32_create (float scale) Create a i8_to_f32 instance. |
| void | i8_to_f32_destroy (i8_to_f32_state_t * state) Destroy a i8_to_f32 instance and release all memory. |
| void | i8_to_f32_reset (i8_to_f32_state_t * state) Reset I8ToF32 to its post-create state. |
| JM_FORCEINLINE JM_HOT float | i8_to_f32_step (const i8_to_f32_state_t * state, int8_t x) Process one input sample. |
| void | i8_to_f32_steps (i8_to_f32_state_t * state, const int8_t * input, float * output, size_t n) Process a block of int8 samples to float32. |
Detailed Description¶
Multiplies each signed int8 sample by 1/scale and returns a float32. The default scale of 128.0 maps the full int8 range [-128, 127] to [-1.0, ~+1.0), which is the natural inverse of an 8-bit ADC path. This converter is used in the 8-bit IQ sample pipeline (e.g., RTL-SDR signed-8 I/Q streams) where samples arrive as int8 and must be converted to normalised complex floats. The inverse scale is pre-computed at construction time.
Lifecycle: create -> [step / steps / reset]* -> destroy
>>> from doppler.cvt import I8ToF32
>>> import numpy as np
>>> obj = I8ToF32(scale=128.0)
>>> float(obj.step(-128))
-1.0
>>> float(obj.step(0))
0.0
>>> x = np.array([-128, 0, 127], dtype=np.int8)
>>> [round(v, 7) for v in obj.steps(x).tolist()]
[-1.0, 0.0, 0.9921875]
Public Functions Documentation¶
function i8_to_f32_create¶
Create a i8_to_f32 instance.
Pre-computes iscale = 1.0f / scale.
Parameters:
scaleDenominator scale; 1/scale is applied to each sample (default: 128.0f). Use 128.0 to recover normalised floats from a signed 8-bit stream.
Returns:
Heap-allocated state, or NULL on allocation failure.
Note:
Caller must call i8_to_f32_destroy() when done.
function i8_to_f32_destroy¶
Destroy a i8_to_f32 instance and release all memory.
Parameters:
stateMay be NULL.
function i8_to_f32_reset¶
Reset I8ToF32 to its post-create state.
No mutable state exists beyond the immutable iscale; reset is a no-op provided for lifecycle symmetry with other converters.
Parameters:
stateMust be non-NULL.
function i8_to_f32_step¶
Process one input sample.
Returns ``(float)x * iscale.
Parameters:
stateMust be non-NULL.xSigned int8 input sample.
Returns:
Scaled float32 output.
function i8_to_f32_steps¶
Process a block of int8 samples to float32.
Applies step() to every element. Accepts an optional pre-allocated output array; allocates a fresh one when output is NULL.
Parameters:
stateMust be non-NULL.inputInput int8 array; must contain at leastnelements.outputOutput float32 array; must contain at leastnelements.nNumber of samples to process.
>>> from doppler.cvt import I8ToF32
>>> import numpy as np
>>> I8ToF32().steps(np.array([0, 64, -128], dtype=np.int8)).tolist()
[0.0, 0.5, -1.0]
The documentation for this class was generated from the following file native/inc/i8_to_f32/i8_to_f32_core.h