Skip to content

File corr_core.h

File List > corr > corr_core.h

Go to the documentation of this file

#ifndef DP_CORR_CORE_H
#define DP_CORR_CORE_H

#include "doppler/clib_common.h"
#include "doppler/dp_state.h"
#include "doppler/fft/fft_core.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
  dp_fft_state_t *fwd;         
  dp_fft_state_t *inv;         
  float _Complex *ref_spec;  
  float _Complex *work_fft;  
  float _Complex *accum;     
  float _Complex *work_pad;  
  size_t n;                 
  size_t n_out;             
  size_t dwell;             
  size_t count;             
  float _Complex *work_trunc;
} dp_corr_state_t;

dp_corr_state_t *dp_corr_create(const float _Complex *ref, size_t ref_len, size_t dwell,
                          int nthreads, size_t n_out);

void dp_corr_destroy(dp_corr_state_t *state);

void dp_corr_reset(dp_corr_state_t *state);

void dp_corr_set_ref(dp_corr_state_t *state, const float _Complex *ref);

size_t dp_corr_execute_max_out(dp_corr_state_t *state);

size_t dp_corr_execute(dp_corr_state_t *state, const float _Complex *in, size_t n_in,
                    float _Complex *out, size_t max_out);

/* ── Serializable state (standard bytes interface; see dp_state.h) ──────────
 * running product-spectrum accumulator + frame count;
 * FFT plans + ref_spec are config, rebuilt by create. */
#define CORR_STATE_MAGIC DP_FOURCC ('C','O','R','R')
#define CORR_STATE_VERSION 1u
size_t dp_corr_state_bytes (const dp_corr_state_t *state);
void dp_corr_get_state (const dp_corr_state_t *state, void *blob);
int dp_corr_set_state (dp_corr_state_t *state, const void *blob);

#ifdef __cplusplus
}
#endif

#endif /* CORR_CORE_H */