Skip to content

Commit 503ae3e

Browse files
serhiy-katsyuba-intelkv2019i
authored andcommitted
ipc4: mixin: Fix HiFi3 impl of 24-bit mixing
AE_ADD24S() expects input arguments to be Q9.23 values. Therefore, negative 24-bit values in a 32-bit container should have their sign extended to the upper 8 bits. All other five implementations of 24-bit mixing (IPC3 mixer's generic and HIFI3, IPC4 mixin's generic, IPC4 mixin's mix with gain generic and HIFI3) perform sign extension prior to mixing and do not rely on samples being already sign-extended. Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>
1 parent e3075f5 commit 503ae3e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/audio/mixin_mixout/mixin_mixout_hifi3.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ static void mix_s24(struct cir_buf_ptr *sink, int32_t start_sample, int32_t mixe
255255
AE_LA32X2_IP(in_sample, inu, in);
256256
AE_LA32X2_IP(out_sample, outu1, out);
257257
out--;
258+
/* sign extent in_sample as AE_ADD24S expects Q9.23 arguments */
259+
in_sample = AE_SLAI24S(AE_MOVF24X2_FROMINT32X2(in_sample), 0);
260+
/* out_sample is already sign extended by other mixin in a loop below */
258261
out_sample = AE_ADD24S(in_sample, out_sample);
259262
AE_SA32X2_IP(out_sample, outu2, out);
260263
}
@@ -264,6 +267,8 @@ static void mix_s24(struct cir_buf_ptr *sink, int32_t start_sample, int32_t mixe
264267
if (left) {
265268
AE_L32_IP(in_sample, (ae_int32 *)in, sizeof(ae_int32));
266269
AE_L32_IP(out_sample, (ae_int32 *)out, 0);
270+
/* sign extension */
271+
in_sample = AE_SLAI24S(AE_MOVF24X2_FROMINT32X2(in_sample), 0);
267272
out_sample = AE_ADD24S(in_sample, out_sample);
268273
AE_S32_L_IP(out_sample, (ae_int32 *)out, sizeof(ae_int32));
269274
}
@@ -283,12 +288,16 @@ static void mix_s24(struct cir_buf_ptr *sink, int32_t start_sample, int32_t mixe
283288
left = n & 1;
284289
for (i = 0; i < m; i++) {
285290
AE_LA32X2_IP(in_sample, inu, in);
291+
/* sign extension */
292+
in_sample = AE_SLAI24S(AE_MOVF24X2_FROMINT32X2(in_sample), 0);
286293
AE_SA32X2_IP(in_sample, outu2, out);
287294
}
288295
AE_SA64POS_FP(outu2, out);
289296
/* process the left sample to avoid memory access overrun */
290297
if (left) {
291298
AE_L32_IP(in_sample, (ae_int32 *)in, sizeof(ae_int32));
299+
/* sign extension */
300+
in_sample = AE_SLAI24S(AE_MOVF24X2_FROMINT32X2(in_sample), 0);
292301
AE_S32_L_IP(in_sample, (ae_int32 *)out, sizeof(ae_int32));
293302
}
294303
}

0 commit comments

Comments
 (0)