Skip to content

Commit d2cf265

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 f92af28 commit d2cf265

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
@@ -144,6 +144,8 @@ void mfcc_apply_window(struct mfcc_state *state, int input_shift)
144144
for (j = 0; j < fft->fft_size; j++) {
145145
AE_L32_IP(sample, fft_in, 0);
146146
AE_L16_XP(win, win_in, win_inc);
147+
/* Data is 16-bit in 32-bit container, shift to Q1.31 for fractional multiply */
148+
sample = AE_SLAI32S(sample, 16);
147149
temp = AE_MULFP32X16X2RS_L(sample, win);
148150
temp = AE_SLAA32S(temp, input_shift);
149151
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
@@ -140,6 +140,8 @@ void mfcc_apply_window(struct mfcc_state *state, int input_shift)
140140
for (j = 0; j < fft->fft_size; j++) {
141141
AE_L32_IP(sample, fft_in, 0);
142142
AE_L16_XP(win, win_in, win_inc);
143+
/* Data is 16-bit in 32-bit container, shift to Q1.31 for fractional multiply */
144+
sample = AE_SLAI32S(sample, 16);
143145
temp = AE_MULFP32X16X2RS_L(sample, win);
144146
temp = AE_SLAA32S(temp, input_shift);
145147
AE_S32_L_XP(temp, fft_in, fft_inc);

0 commit comments

Comments
 (0)