Skip to content

Commit 4c1bda3

Browse files
committed
Audio: MFCC: Fix 32 bit mode HiFi3/4 window multiply
In 32-bit FFT mode the input data is 16-bit stored in the lower half of a 32-bit icomplex32 container. The AE_MULFP32X16X2RS_L intrinsic performs a Q1.31 x Q1.15 fractional multiply, so the 16-bit sample must first be shifted left by 16 to Q1.31 format. Without this shift the multiply treats the value as having 16 zero fractional bits, producing near-zero windowed output and a corrupt FFT result. Add the missing AE_SLAI32S(sample, 16) before the multiply in both HiFi3 and HiFi4 mfcc_apply_window() 32-bit paths, matching the generic C implementation. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent 8aac15d commit 4c1bda3

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

src/audio/mfcc/mfcc_hifi3.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ void mfcc_apply_window(struct mfcc_state *state, int input_shift)
180180
for (j = 0; j < fft->fft_size; j++) {
181181
AE_L32_IP(sample, fft_in, 0);
182182
AE_L16_XP(win, win_in, win_inc);
183+
/* Data is 16-bit in 32-bit container, shift to Q1.31 for fractional multiply */
184+
sample = AE_SLAI32S(sample, 16);
183185
temp = AE_MULFP32X16X2RS_L(sample, win);
184186
temp = AE_SLAA32S(temp, input_shift);
185187
AE_S32_L_XP(temp, fft_in, fft_inc);

src/audio/mfcc/mfcc_hifi4.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ void mfcc_apply_window(struct mfcc_state *state, int input_shift)
176176
for (j = 0; j < fft->fft_size; j++) {
177177
AE_L32_IP(sample, fft_in, 0);
178178
AE_L16_XP(win, win_in, win_inc);
179+
/* Data is 16-bit in 32-bit container, shift to Q1.31 for fractional multiply */
180+
sample = AE_SLAI32S(sample, 16);
179181
temp = AE_MULFP32X16X2RS_L(sample, win);
180182
temp = AE_SLAA32S(temp, input_shift);
181183
AE_S32_L_XP(temp, fft_in, fft_inc);

0 commit comments

Comments
 (0)