Skip to content

Commit

Permalink
ipc4: mixin: Fix HiFi5 impl of 24-bit mixing
Browse files Browse the repository at this point in the history
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. Our other implementations of 24-bit mixing
all 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>
  • Loading branch information
serhiy-katsyuba-intel committed Jan 30, 2025
1 parent d0e54b2 commit cad6f82
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/audio/mixin_mixout/mixin_mixout_hifi5.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ static void mix_s24(struct cir_buf_ptr *sink, int32_t start_sample, int32_t mixe
AE_LA32X2X2_IP(in_sample, in_sample1, inu, in);
AE_LA32X2X2_IP(out_sample, out_sample1, outu1, out);
out--;
out_sample = AE_ADD24S(in_sample, out_sample);
/* sign extent in samples as AE_ADD24S expects Q9.23 arguments */
in_sample = AE_SLAI24S(AE_MOVF24X2_FROMINT32X2(in_sample), 0);
in_sample1 = AE_SLAI24S(AE_MOVF24X2_FROMINT32X2(in_sample1), 0);
/* out samples are already sign extended by other mixin in a loop below */
out_sample = AE_ADD24S(in_sample, out_sample);
out_sample1 = AE_ADD24S(in_sample1, out_sample1);
AE_SA32X2X2_IP(out_sample, out_sample1, outu2, out);
}
Expand All @@ -152,6 +156,8 @@ static void mix_s24(struct cir_buf_ptr *sink, int32_t start_sample, int32_t mixe
for (i = 0; i < left; i++) {
AE_L32_IP(in_sample, (ae_int32 *)in, sizeof(ae_int32));
AE_L32_IP(out_sample, (ae_int32 *)out, 0);
/* sign extension */
in_sample = AE_SLAI24S(AE_MOVF24X2_FROMINT32X2(in_sample), 0);
out_sample = AE_ADD24S(in_sample, out_sample);
AE_S32_L_IP(out_sample, (ae_int32 *)out, sizeof(ae_int32));
}
Expand All @@ -171,12 +177,17 @@ static void mix_s24(struct cir_buf_ptr *sink, int32_t start_sample, int32_t mixe
left = n & 3;
for (i = 0; i < m; i++) {
AE_LA32X2X2_IP(in_sample, in_sample1, inu, in);
/* sign extension */
in_sample = AE_SLAI24S(AE_MOVF24X2_FROMINT32X2(in_sample), 0);
in_sample1 = AE_SLAI24S(AE_MOVF24X2_FROMINT32X2(in_sample1), 0);
AE_SA32X2X2_IP(in_sample, in_sample1, outu2, out);
}
AE_SA128POS_FP(outu2, out);
/* process the left samples to avoid memory access overrun */
for (i = 0; i < left; i++) {
AE_L32_IP(in_sample, (ae_int32 *)in, sizeof(ae_int32));
/* sign extension */
in_sample = AE_SLAI24S(AE_MOVF24X2_FROMINT32X2(in_sample), 0);
AE_S32_L_IP(in_sample, (ae_int32 *)out, sizeof(ae_int32));
}
}
Expand Down

0 comments on commit cad6f82

Please sign in to comment.