#include "dsps_conv.h"
#include "esp_log.h"
Go to the source code of this file.
|
| esp_err_t | dsps_ccorr_f32_ansi (const float *Signal, const int siglen, const float *Kernel, const int kernlen, float *corrvout) |
| | Cross correlation.
|
|
| static const char * | TAG = "dsps_conv" |
◆ 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] | Signal1 | input array with input 1 signal values |
| [in] | siglen1 | length of the input 1 signal array |
| [in] | Signal2 | input array with input 2 signal values |
| [in] | siglen2 | length of the input signal array |
| corrout | output 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++) {
46 int kmin = lkern - 1 -
n;
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++) {
56
58
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++) {
69
71
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 }
81}
#define ESP_ERR_DSP_PARAM_OUTOFRANGE
References ESP_ERR_DSP_PARAM_OUTOFRANGE, ESP_OK, k, n, and TAG.
◆ TAG
| const char* TAG = "dsps_conv" |
|
static |