ESP-IDF Firmware
Firmware architecture and call graph
Loading...
Searching...
No Matches
dsps_ccorr_f32_ansi.c
Go to the documentation of this file.
1
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#include "
dsps_conv.h
"
16
#include "
esp_log.h
"
17
18
static
const
char
*
TAG
=
"dsps_conv"
;
19
20
esp_err_t
dsps_ccorr_f32_ansi
(
const
float
*Signal,
const
int
siglen,
const
float
*Kernel,
const
int
kernlen,
float
*corrvout)
21
{
22
if
(NULL == Signal) {
23
return
ESP_ERR_DSP_PARAM_OUTOFRANGE
;
24
}
25
if
(NULL == Kernel) {
26
return
ESP_ERR_DSP_PARAM_OUTOFRANGE
;
27
}
28
if
(NULL == corrvout) {
29
return
ESP_ERR_DSP_PARAM_OUTOFRANGE
;
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
}
ESP_ERR_DSP_PARAM_OUTOFRANGE
#define ESP_ERR_DSP_PARAM_OUTOFRANGE
Definition
dsp_err_codes.h:22
dsps_ccorr_f32_ansi
esp_err_t dsps_ccorr_f32_ansi(const float *Signal, const int siglen, const float *Kernel, const int kernlen, float *corrvout)
Cross correlation.
Definition
dsps_ccorr_f32_ansi.c:20
dsps_conv.h
esp_err_t
int esp_err_t
Definition
esp_err.h:21
ESP_OK
#define ESP_OK
Definition
esp_err.h:23
esp_log.h
TAG
static const char * TAG
Definition
main/main.c:31
n
const int n
Definition
test_mmult.c:17
k
const int k
Definition
test_mmult.c:18
components
espressif__esp-dsp
modules
conv
float
dsps_ccorr_f32_ansi.c
Generated by
1.16.1