ESP-IDF Firmware
Firmware architecture and call graph
Loading...
Searching...
No Matches
dsps_conv_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
18static const char *TAG = "dsps_conv";
19
20esp_err_t dsps_conv_f32_ansi(const float *Signal, const int siglen, const float *Kernel, const int kernlen, float *convout)
21{
22 if (NULL == Signal) {
24 }
25 if (NULL == Kernel) {
27 }
28 if (NULL == convout) {
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 size_t k;
46
47 convout[n] = 0;
48
49 for (k = 0; k <= n; k++) {
50 convout[n] += sig[k] * kern[n - k];
51 }
52 ESP_LOGV(TAG, "L1 kmin = %i, kmax = %i , n-kmin = %i", 0, n, n);
53 }
54 for (int n = lkern; n < lsig; n++) {
55 int kmin, kmax, k;
56
57 convout[n] = 0;
58
59 kmin = n - lkern + 1;
60 kmax = n;
61 ESP_LOGV(TAG, "L2 n=%i, kmin = %i, kmax = %i , n-kmin = %i", n, kmin, kmax, n - kmin);
62 for (k = kmin; k <= kmax; k++) {
63 convout[n] += sig[k] * kern[n - k];
64 }
65 }
66
67 for (int n = lsig; n < lsig + lkern - 1; n++) {
68 int kmin, kmax, k;
69
70 convout[n] = 0;
71
72 kmin = n - lkern + 1;
73 kmax = lsig - 1;
74
75 for (k = kmin; k <= kmax; k++) {
76 convout[n] += sig[k] * kern[n - k];
77 }
78 ESP_LOGV(TAG, "L3 n=%i, kmin = %i, kmax = %i , n-kmin = %i", n, kmin, kmax, n - kmin);
79 }
80 return ESP_OK;
81}
#define ESP_ERR_DSP_PARAM_OUTOFRANGE
esp_err_t dsps_conv_f32_ansi(const float *Signal, const int siglen, const float *Kernel, const int kernlen, float *convout)
int esp_err_t
Definition esp_err.h:21
#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