File hbdecim_core.h¶
FileList > hbdecim > hbdecim_core.h
Go to the source code of this file
Halfband 2:1 decimator for CF32 IQ samples. More...
#include "clib_common.h"#include "dp_state.h"
Classes¶
| Type | Name |
|---|---|
| struct | hbdecim_state_t |
Public Functions¶
| Type | Name |
|---|---|
| hbdecim_state_t * | hbdecim_create (size_t num_taps, const float * h) Allocate and initialise a halfband 2:1 decimator. |
| void | hbdecim_destroy (hbdecim_state_t * r) |
| size_t | hbdecim_execute (hbdecim_state_t * r, const float _Complex * in, size_t num_in, float _Complex * out, size_t max_out) Decimate a block of CF32 samples by 2. |
| size_t | hbdecim_get_num_taps (const hbdecim_state_t * r) |
| double | hbdecim_get_rate (const hbdecim_state_t * r) |
| void | hbdecim_get_state (const hbdecim_state_t * r, void * blob) Serialize r's mutable state intoblob . |
| void | hbdecim_reset (hbdecim_state_t * r) |
| int | hbdecim_set_state (hbdecim_state_t * r, const void * blob) Restore mutable state from blob (same num_taps). |
| size_t | hbdecim_state_bytes (const hbdecim_state_t * r) Bytes hbdecim_get_state() writes for r (envelope + payload). |
Macros¶
| Type | Name |
|---|---|
| define | HBDECIM_STATE_MAGIC [**DP\_FOURCC**](dp__state_8h.md#define-dp_fourcc) ('H', 'B', 'D', 'C') |
| define | HBDECIM_STATE_VERSION 1u |
Detailed Description¶
Lifted from dp_hbdecim_cf32_t (c/src/hbdecim.c). Only the cf32 variant is ported; dp_hbdecim_r2cf32 (real-input D2) is a separate object and a separate session.
Algorithm: two dual-write circular delay lines hold even-indexed and odd-indexed input samples separately. Per output sample: * Push x(2m) → even delay line. * Push x(2m+1) → odd delay line. * Compute symmetric FIR (N/2 paired multiplies) + scaled delay tap.
Which delay line carries the FIR is determined by N: N even (fir_on_even=1): FIR on even_dl; delay from odd_dl(centre). N odd (fir_on_even=0): FIR on odd_dl at offset +1; delay from even_dl(centre).
Coefficients are scaled by 0.5 inside hbdecim_create — this is the polyphase identity normalisation; do not remove it.
Lifecycle:
hbdecim_state_t *r = hbdecim_create(num_taps, h_fir);
size_t n = hbdecim_execute(r, in, num_in, out, max_out);
hbdecim_destroy(r);
Public Functions Documentation¶
function hbdecim_create¶
Allocate and initialise a halfband 2:1 decimator.
Parameters:
num_tapsLength of the FIR branch (the row from kaiser_prototype(phases=2) that has more than one significant coefficient).hFIR coefficients, length num_taps (float32). Copied internally and scaled by 0.5.
Returns:
Non-NULL on success, NULL on invalid args or OOM.
function hbdecim_destroy¶
Free all resources. NULL is a no-op.
function hbdecim_execute¶
Decimate a block of CF32 samples by 2.
size_t hbdecim_execute (
hbdecim_state_t * r,
const float _Complex * in,
size_t num_in,
float _Complex * out,
size_t max_out
)
Processes input pairs (even, odd); one output per pair. If num_in is odd, the trailing even sample is buffered and consumed on the next call.
Output-buffer sizing: allocate at least (num_in + 1) / 2 samples.
Parameters:
rMust be non-NULL.inInput CF32 samples.num_inNumber of input samples.outOutput buffer.max_outCapacity of out in samples.
Returns:
Number of output samples written.
function hbdecim_get_num_taps¶
Returns the FIR branch length passed to hbdecim_create.
function hbdecim_get_rate¶
Always returns 0.5 (rate is fixed by design).
function hbdecim_get_state¶
Serialize r's mutable state intoblob .
function hbdecim_reset¶
Zero both delay lines and clear the pending-sample flag. num_taps and coefficients are preserved.
function hbdecim_set_state¶
Restore mutable state from blob (same num_taps).
Returns:
DP_OK, or DP_ERR_INVALID if the blob's envelope rejects.
function hbdecim_state_bytes¶
Bytes hbdecim_get_state() writes forr (envelope + payload).
Macro Definition Documentation¶
define HBDECIM_STATE_MAGIC¶
define HBDECIM_STATE_VERSION¶
The documentation for this class was generated from the following file native/inc/hbdecim/hbdecim_core.h