Skip to content

Commit

Permalink
ipc4: mixin: Add gain support (generic)
Browse files Browse the repository at this point in the history
Restore gain support which was accidentally removed during previous
HIFI optimization/refactoring.

This commit only adds gain supports to "generic" mixin implementation.

Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>
  • Loading branch information
serhiy-katsyuba-intel committed Apr 12, 2024
1 parent bb0d3a8 commit dd0f19b
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions src/audio/mixin_mixout/mixin_mixout_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ static void mix_s16(struct cir_buf_ptr *sink, int32_t start_sample, int32_t mixe
nmax = (int16_t *)sink->buf_end - dst;
n = MIN(n, nmax);
for (i = 0; i < n; i++) {
*dst = sat_int16(*dst + *src++);
*dst = sat_int16((int32_t)*dst +
q_mults_16x16(*src, gain, IPC4_MIXIN_GAIN_SHIFT));
src++;
dst++;
}
}
Expand All @@ -49,9 +51,12 @@ static void mix_s16(struct cir_buf_ptr *sink, int32_t start_sample, int32_t mixe
n = MIN(left_samples, nmax);
nmax = (int16_t *)sink->buf_end - dst;
n = MIN(n, nmax);
memcpy_s(dst, n * sizeof(int16_t), src, n * sizeof(int16_t));
dst += n;
src += n;

for (i = 0; i < n; i++) {
*dst = q_mults_16x16(*src, gain, IPC4_MIXIN_GAIN_SHIFT);
src++;
dst++;
}
}
}
#endif /* CONFIG_FORMAT_S16LE */
Expand Down Expand Up @@ -81,7 +86,10 @@ static void mix_s24(struct cir_buf_ptr *sink, int32_t start_sample, int32_t mixe
nmax = (int32_t *)sink->buf_end - dst;
n = MIN(n, nmax);
for (i = 0; i < n; i++) {
*dst = sat_int24(sign_extend_s24(*dst) + sign_extend_s24(*src++));
*dst = sat_int24(sign_extend_s24(*dst) +
(int32_t)q_mults_32x32(sign_extend_s24(*src),
gain, IPC4_MIXIN_GAIN_SHIFT));
src++;
dst++;
}
}
Expand All @@ -93,9 +101,11 @@ static void mix_s24(struct cir_buf_ptr *sink, int32_t start_sample, int32_t mixe
n = MIN(left_samples, nmax);
nmax = (int32_t *)sink->buf_end - dst;
n = MIN(n, nmax);
memcpy_s(dst, n * sizeof(int32_t), src, n * sizeof(int32_t));
dst += n;
src += n;
for (i = 0; i < n; i++) {
*dst = q_mults_32x32(sign_extend_s24(*src), gain, IPC4_MIXIN_GAIN_SHIFT);
src++;
dst++;
}
}
}

Expand Down Expand Up @@ -125,7 +135,9 @@ static void mix_s32(struct cir_buf_ptr *sink, int32_t start_sample, int32_t mixe
nmax = (int32_t *)sink->buf_end - dst;
n = MIN(n, nmax);
for (i = 0; i < n; i++) {
*dst = sat_int32((int64_t)*dst + (int64_t)*src++);
*dst = sat_int32((int64_t)*dst +
q_mults_32x32(*src, gain, IPC4_MIXIN_GAIN_SHIFT));
src++;
dst++;
}
}
Expand All @@ -137,9 +149,11 @@ static void mix_s32(struct cir_buf_ptr *sink, int32_t start_sample, int32_t mixe
n = MIN(left_samples, nmax);
nmax = (int32_t *)sink->buf_end - dst;
n = MIN(n, nmax);
memcpy_s(dst, n * sizeof(int32_t), src, n * sizeof(int32_t));
dst += n;
src += n;
for (i = 0; i < n; i++) {
*dst = q_mults_32x32(*src, gain, IPC4_MIXIN_GAIN_SHIFT);
src++;
dst++;
}
}
}

Expand Down

0 comments on commit dd0f19b

Please sign in to comment.