Skip to content

File hbdecim_r2c_core.h

FileList > hbdecim > hbdecim_r2c_core.h

Go to the source code of this file

Real-to-complex halfband 2:1 decimator (Architecture D2). More...

  • #include "clib_common.h"
  • #include "dp_state.h"

Public Types

Type Name
typedef struct hbdecim_r2c_state hbdecim_r2c_state_t

Public Functions

Type Name
hbdecim_r2c_state_t * hbdecim_r2c_create (size_t num_taps, const float * h)
Allocate a real-to-complex halfband decimator.
void hbdecim_r2c_destroy (hbdecim_r2c_state_t * r)
size_t hbdecim_r2c_execute (hbdecim_r2c_state_t * r, const float * in, size_t num_in, float _Complex * out, size_t max_out)
Decimate real float32 input by 2, producing CF32.
size_t hbdecim_r2c_get_num_taps (const hbdecim_r2c_state_t * r)
double hbdecim_r2c_get_rate (const hbdecim_r2c_state_t * r)
void hbdecim_r2c_get_state (const hbdecim_r2c_state_t * r, void * blob)
Serialize r's mutable state intoblob .
void hbdecim_r2c_reset (hbdecim_r2c_state_t * r)
int hbdecim_r2c_set_state (hbdecim_r2c_state_t * r, const void * blob)
Restore mutable state from blob (same num_taps).
size_t hbdecim_r2c_state_bytes (const hbdecim_r2c_state_t * r)
Bytes hbdecim_r2c_get_state() writes forr (envelope+payload).

Macros

Type Name
define HBDECIM_R2C_STATE_MAGIC [**DP\_FOURCC**](dp__state_8h.md#define-dp_fourcc) ('H', 'B', 'R', '2')
define HBDECIM_R2C_STATE_VERSION 1u

Detailed Description

Lifted from dp_hbdecim_r2cf32_t (c/src/hbdecim.c). Accepts real float32 input and produces CF32 IQ at half the input rate, with an embedded fs/4 frequency shift (same effect as mixing with e^{jπn/2} before decimating, at zero extra multiplications).

The output at sample m is: y(m) = (FIR(even) + j·delay(odd)) · (-1)^m

where the sign pattern (-1)^m provides the fs/4 shift correction.

Lifecycle:

hbdecim_r2c_state_t *r = hbdecim_r2c_create(num_taps, h);
size_t n = hbdecim_r2c_execute(r, in, num_in, out, max_out);
hbdecim_r2c_destroy(r);

Public Types Documentation

typedef hbdecim_r2c_state_t

typedef struct hbdecim_r2c_state hbdecim_r2c_state_t;

Public Functions Documentation

function hbdecim_r2c_create

Allocate a real-to-complex halfband decimator.

hbdecim_r2c_state_t * hbdecim_r2c_create (
    size_t num_taps,
    const float * h
) 

Parameters:

  • num_taps FIR branch length.
  • h FIR coefficients, float32, length num_taps.

Returns:

Non-NULL on success, NULL on invalid args or OOM.


function hbdecim_r2c_destroy

void hbdecim_r2c_destroy (
    hbdecim_r2c_state_t * r
) 

Free all resources. NULL is a no-op.


function hbdecim_r2c_execute

Decimate real float32 input by 2, producing CF32.

size_t hbdecim_r2c_execute (
    hbdecim_r2c_state_t * r,
    const float * in,
    size_t num_in,
    float _Complex * out,
    size_t max_out
) 

Parameters:

  • r Must be non-NULL.
  • in Real input samples.
  • num_in Number of input samples.
  • out CF32 output buffer.
  • max_out Capacity in samples.

Returns:

Number of output samples written.


function hbdecim_r2c_get_num_taps

size_t hbdecim_r2c_get_num_taps (
    const hbdecim_r2c_state_t * r
) 

Returns the FIR branch length passed to hbdecim_r2c_create.


function hbdecim_r2c_get_rate

double hbdecim_r2c_get_rate (
    const hbdecim_r2c_state_t * r
) 

Always returns 0.5.


function hbdecim_r2c_get_state

Serialize r's mutable state intoblob .

void hbdecim_r2c_get_state (
    const hbdecim_r2c_state_t * r,
    void * blob
) 


function hbdecim_r2c_reset

void hbdecim_r2c_reset (
    hbdecim_r2c_state_t * r
) 

Zero history and output parity without freeing.


function hbdecim_r2c_set_state

Restore mutable state from blob (same num_taps).

int hbdecim_r2c_set_state (
    hbdecim_r2c_state_t * r,
    const void * blob
) 

Returns:

DP_OK, or DP_ERR_INVALID if the blob's envelope rejects.


function hbdecim_r2c_state_bytes

Bytes hbdecim_r2c_get_state() writes forr (envelope+payload).

size_t hbdecim_r2c_state_bytes (
    const hbdecim_r2c_state_t * r
) 


Macro Definition Documentation

define HBDECIM_R2C_STATE_MAGIC

#define HBDECIM_R2C_STATE_MAGIC `DP_FOURCC ('H', 'B', 'R', '2')`

define HBDECIM_R2C_STATE_VERSION

#define HBDECIM_R2C_STATE_VERSION `1u`


The documentation for this class was generated from the following file native/inc/hbdecim/hbdecim_r2c_core.h