ESP-IDF Firmware
Firmware architecture and call graph
Loading...
Searching...
No Matches
dsps_ccorr_f32_ansi.c File Reference
#include "dsps_conv.h"
#include "esp_log.h"
Include dependency graph for dsps_ccorr_f32_ansi.c:

Go to the source code of this file.

Functions

esp_err_t dsps_ccorr_f32_ansi (const float *Signal, const int siglen, const float *Kernel, const int kernlen, float *corrvout)
 Cross correlation.

Variables

static const char * TAG = "dsps_conv"

Function Documentation

◆ dsps_ccorr_f32_ansi()

esp_err_t dsps_ccorr_f32_ansi ( const float * Signal,
const int siglen,
const float * Pattern,
const int patlen,
float * corrout )

Cross correlation.

The function make cross correlate between two ignals. The implementation use ANSI C and could be compiled and run on any platform

Parameters
[in]Signal1input array with input 1 signal values
[in]siglen1length of the input 1 signal array
[in]Signal2input array with input 2 signal values
[in]siglen2length of the input signal array
corroutoutput array with result of cross correlation. The size of dest array must be (siglen1 + siglen2 - 1) !!!
Returns
  • ESP_OK on success
  • One of the error codes from DSP library (one of the input array are NULL, or if (siglen < patlen))

Definition at line 20 of file dsps_ccorr_f32_ansi.c.

21{
22 if (NULL == Signal) {
24 }
25 if (NULL == Kernel) {
27 }
28 if (NULL == corrvout) {
30 }
31
32 float *sig = (float *)Signal;
33 float *kern = (float *)Kernel;
34 int lsig = siglen;
35 int lkern = kernlen;
36
37 if (siglen < kernlen) {
38 sig = (float *)Kernel;
39 kern = (float *)Signal;
40 lsig = kernlen;
41 lkern = siglen;
42 }
43
44 for (int n = 0; n < lkern; n++) {
45 int k;
46 int kmin = lkern - 1 - n;
47 corrvout[n] = 0;
48
49 for (k = 0; k <= n; k++) {
50 corrvout[n] += sig[k] * kern[kmin + k];
51 }
52 ESP_LOGV(TAG, "L1 k = %i, n = %i , kmin= %i, kmax= %i", 0, n, kmin, kmin + n);
53 }
54 for (int n = lkern; n < lsig; n++) {
55 int kmin, kmax, k;
56
57 corrvout[n] = 0;
58
59 kmin = n - lkern + 1;
60 kmax = n;
61 for (k = kmin; k <= kmax; k++) {
62 corrvout[n] += sig[k] * kern[k - kmin];
63 }
64 ESP_LOGV(TAG, "L2 n=%i, kmin = %i, kmax = %i , k-kmin = %i", n, kmin, kmax, 0);
65 }
66
67 for (int n = lsig; n < lsig + lkern - 1; n++) {
68 int kmin, kmax, k;
69
70 corrvout[n] = 0;
71
72 kmin = n - lkern + 1;
73 kmax = lsig - 1;
74
75 for (k = kmin; k <= kmax; k++) {
76 corrvout[n] += sig[k] * kern[k - kmin];
77 }
78 ESP_LOGV(TAG, "L3 n=%i, kmin = %i, kmax = %i , k - kmin = %i", n, kmin, kmax, kmax - kmin);
79 }
80 return ESP_OK;
81}
#define ESP_ERR_DSP_PARAM_OUTOFRANGE
#define ESP_OK
Definition esp_err.h:23
static const char * TAG
Definition main/main.c:31
const int n
Definition test_mmult.c:17
const int k
Definition test_mmult.c:18

References ESP_ERR_DSP_PARAM_OUTOFRANGE, ESP_OK, k, n, and TAG.

Variable Documentation

◆ TAG

const char* TAG = "dsps_conv"
static

Definition at line 18 of file dsps_ccorr_f32_ansi.c.