espressif / esp-dsp

DSP library for ESP-IDF
Apache License 2.0
442 stars 87 forks source link

Different output when choosing optimised or ansi function for FIR filtering. (DSP-100) #63

Closed herculanodavi closed 11 months ago

herculanodavi commented 1 year ago

Environment

Problem Description

The dsps_fird_s16_aes3 function does not show the same results as the dsps_fird_s16_ansi given the same parameters.

Expected Behavior

This code

fir_s16_t handle;
alignas(16) int16_t coeffs[1] = {1};
alignas(16) int16_t delay[1] = {0};
int16_t coeffs_len = 1;
int16_t decimation = 2;
dsps_fird_init_s16(&handle, coeffs, delay, coeffs_len, decimation, 0, 15);

alignas(16) int16_t input[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
alignas(16) int16_t output[5] = {0, 0, 0, 0, 0};
dsps_fird_s16(&fir_handle.handle, input, output, 5);

should have the result {1, 3, 5, 7, 9} independently of the flag CONFIG_DSP_OPTIMIZED.

Actual Behavior

When CONFIG_DSP_OPTIMIZED is enabled, the function chosen when calling dsps_fird_s16 is dsps_fird_s16_aes3, and the resulting output is `

Steps to repropduce

Run the code below.

Code to reproduce this issue

int16_t coeffs_len = 1;
int16_t decimation = 2;

fir_s16_t handle_ansi;
alignas(16) int16_t delay_ansi[1] = {0};

fir_s16_t handle_s3;
alignas(16) int16_t delay_s3[1] = {0};

alignas(16) int16_t coeffs[1] = {1};

dsps_fird_init_s16(&handle_ansi, coeffs, delay, coeffs_len, decimation, 0, 15);
dsps_fird_init_s16(&handle_s3, coeffs, delay, coeffs_len, decimation, 0, 15);

alignas(16) int16_t input[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
alignas(16) int16_t output_ansi[5] = {0, 0, 0, 0, 0};
alignas(16) int16_t output_s3[5] = {0, 0, 0, 0, 0};

dsps_fird_s16_ansi(&fir_handle.handle, input, output_ansi, 5);
dsps_fird_s16_aes3(&fir_handle.handle, input, output_s3, 5);

for(int i = 0; i < 5; i++) {
  assert(output_ansi[i] == output_s3[i]);
}
dmitry1945 commented 1 year ago

@herculanodavi thank you for the issue, we will look.

dmitry1945 commented 11 months ago

Hi @herculanodavi,

We have fix the issue in the last releases. Please take a look.

Thank you, Dmitry