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) No-op reset, provided only for lifecycle symmetry. |
| JM_FORCEINLINE JM_HOT float | i8_to_f32_step (const i8_to_f32_state_t * state, int8_t x) Convert one signed int8 sample to a normalised float via 1/scale . |
| 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¶
No-op reset, provided only for lifecycle symmetry.
No mutable state exists beyond the immutable iscale, so there is nothing to clear; the method exists so every converter in the module presents the same create / step / reset / destroy lifecycle.
Parameters:
stateMust be non-NULL.
>>> from doppler.cvt import I8ToF32
>>> c = I8ToF32()
>>> c.reset() # stateless converter -> reset is a no-op
>>> round(c.step(-128), 4)
-1.0
function i8_to_f32_step¶
Convert one signed int8 sample to a normalised float via 1/scale .
Returns `(float)x \* iscale, a single multiply on the hot path. At the default scale of 128 the full int8 range recovers[-1.0, ~+1.0)` — the front end of an 8-bit IQ path (e.g. a signed-8 RTL-SDR stream) into normalised floats.
Parameters:
stateMust be non-NULL.xSigned int8 code in[-128, 127].
Returns:
Normalised float, x / scale.
>>> from doppler.cvt import I8ToF32
>>> c = I8ToF32(scale=128.0) # signed 8-bit -> normalised float
>>> round(c.step(64), 4) # 64 / 128
0.5
>>> round(c.step(-128), 4) # full-negative code -> -1.0
-1.0
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