From 60212cf3870ed403d8ce8c335669b7426827d353 Mon Sep 17 00:00:00 2001 From: Serhiy Katsyuba Date: Wed, 22 Nov 2023 12:59:33 +0100 Subject: [PATCH] ipc4: mixin/mixout: Fix naming after channel remapping removal Previously when channel remapping was supported processing was done iterating by frames. After channel remapping was removed processing was changed to iterate by samples, however, for some reason the code still uses confusing "frame" variables. Signed-off-by: Serhiy Katsyuba --- src/audio/mixin_mixout/mixin_mixout.h | 6 +- src/audio/mixin_mixout/mixin_mixout_generic.c | 72 +++++++++---------- src/audio/mixin_mixout/mixin_mixout_hifi3.c | 66 ++++++++--------- 3 files changed, 72 insertions(+), 72 deletions(-) diff --git a/src/audio/mixin_mixout/mixin_mixout.h b/src/audio/mixin_mixout/mixin_mixout.h index 3c6997b0f526..6b097df99b16 100644 --- a/src/audio/mixin_mixout/mixin_mixout.h +++ b/src/audio/mixin_mixout/mixin_mixout.h @@ -105,10 +105,10 @@ struct ipc4_mixer_mode_config { /** * \brief mixin processing function interface */ -typedef void (*mix_func)(struct audio_stream *sink, int32_t start_frame, - int32_t mixed_frames, +typedef void (*mix_func)(struct audio_stream *sink, int32_t start_sample, + int32_t mixed_samples, const struct audio_stream *source, - int32_t frame_count, uint16_t gain); + int32_t sample_count, uint16_t gain); /** * @brief mixin processing functions map. diff --git a/src/audio/mixin_mixout/mixin_mixout_generic.c b/src/audio/mixin_mixout/mixin_mixout_generic.c index 04184a0d06bc..3c9895d18d45 100644 --- a/src/audio/mixin_mixout/mixin_mixout_generic.c +++ b/src/audio/mixin_mixout/mixin_mixout_generic.c @@ -12,28 +12,28 @@ #ifdef MIXIN_MIXOUT_GENERIC #if CONFIG_FORMAT_S16LE -static void mix_s16(struct audio_stream *sink, int32_t start_frame, int32_t mixed_frames, +static void mix_s16(struct audio_stream *sink, int32_t start_sample, int32_t mixed_samples, const struct audio_stream *source, - int32_t frame_count, uint16_t gain) + int32_t sample_count, uint16_t gain) { - int32_t frames_to_mix, frames_to_copy, left_frames; + int32_t samples_to_mix, samples_to_copy, left_samples; int32_t n, nmax, i; /* audio_stream_wrap() is required and is done below in a loop */ - int16_t *dst = (int16_t *)audio_stream_get_wptr(sink) + start_frame; + int16_t *dst = (int16_t *)audio_stream_get_wptr(sink) + start_sample; int16_t *src = audio_stream_get_rptr(source); - assert(mixed_frames >= start_frame); - frames_to_mix = mixed_frames - start_frame; - frames_to_mix = MIN(frames_to_mix, frame_count); - frames_to_copy = frame_count - frames_to_mix; + assert(mixed_samples >= start_sample); + samples_to_mix = mixed_samples - start_sample; + samples_to_mix = MIN(samples_to_mix, sample_count); + samples_to_copy = sample_count - samples_to_mix; - for (left_frames = frames_to_mix; left_frames > 0; left_frames -= n) { + for (left_samples = samples_to_mix; left_samples > 0; left_samples -= n) { src = audio_stream_wrap(source, src); dst = audio_stream_wrap(sink, dst); /* calculate the remaining samples*/ nmax = audio_stream_samples_without_wrap_s16(source, src); - n = MIN(left_frames, nmax); + n = MIN(left_samples, nmax); nmax = audio_stream_samples_without_wrap_s16(sink, dst); n = MIN(n, nmax); for (i = 0; i < n; i++) { @@ -42,11 +42,11 @@ static void mix_s16(struct audio_stream *sink, int32_t start_frame, int32_t mixe } } - for (left_frames = frames_to_copy; left_frames > 0; left_frames -= n) { + for (left_samples = samples_to_copy; left_samples > 0; left_samples -= n) { src = audio_stream_wrap(source, src); dst = audio_stream_wrap(sink, dst); nmax = audio_stream_samples_without_wrap_s16(source, src); - n = MIN(left_frames, nmax); + n = MIN(left_samples, nmax); nmax = audio_stream_samples_without_wrap_s16(sink, dst); n = MIN(n, nmax); memcpy_s(dst, n * sizeof(int16_t), src, n * sizeof(int16_t)); @@ -57,27 +57,27 @@ static void mix_s16(struct audio_stream *sink, int32_t start_frame, int32_t mixe #endif /* CONFIG_FORMAT_S16LE */ #if CONFIG_FORMAT_S24LE -static void mix_s24(struct audio_stream *sink, int32_t start_frame, int32_t mixed_frames, +static void mix_s24(struct audio_stream *sink, int32_t start_sample, int32_t mixed_samples, const struct audio_stream *source, - int32_t frame_count, uint16_t gain) + int32_t sample_count, uint16_t gain) { - int32_t frames_to_mix, frames_to_copy, left_frames; + int32_t samples_to_mix, samples_to_copy, left_samples; int32_t n, nmax, i; /* audio_stream_wrap() is required and is done below in a loop */ - int32_t *dst = (int32_t *)audio_stream_get_wptr(sink) + start_frame; + int32_t *dst = (int32_t *)audio_stream_get_wptr(sink) + start_sample; int32_t *src = audio_stream_get_rptr(source); - assert(mixed_frames >= start_frame); - frames_to_mix = mixed_frames - start_frame; - frames_to_mix = MIN(frames_to_mix, frame_count); - frames_to_copy = frame_count - frames_to_mix; + assert(mixed_samples >= start_sample); + samples_to_mix = mixed_samples - start_sample; + samples_to_mix = MIN(samples_to_mix, sample_count); + samples_to_copy = sample_count - samples_to_mix; - for (left_frames = frames_to_mix; left_frames > 0; left_frames -= n) { + for (left_samples = samples_to_mix; left_samples > 0; left_samples -= n) { src = audio_stream_wrap(source, src); dst = audio_stream_wrap(sink, dst); /* calculate the remaining samples*/ nmax = audio_stream_samples_without_wrap_s24(source, src); - n = MIN(left_frames, nmax); + n = MIN(left_samples, nmax); nmax = audio_stream_samples_without_wrap_s24(sink, dst); n = MIN(n, nmax); for (i = 0; i < n; i++) { @@ -86,11 +86,11 @@ static void mix_s24(struct audio_stream *sink, int32_t start_frame, int32_t mixe } } - for (left_frames = frames_to_copy; left_frames > 0; left_frames -= n) { + for (left_samples = samples_to_copy; left_samples > 0; left_samples -= n) { src = audio_stream_wrap(source, src); dst = audio_stream_wrap(sink, dst); nmax = audio_stream_samples_without_wrap_s24(source, src); - n = MIN(left_frames, nmax); + n = MIN(left_samples, nmax); nmax = audio_stream_samples_without_wrap_s24(sink, dst); n = MIN(n, nmax); memcpy_s(dst, n * sizeof(int32_t), src, n * sizeof(int32_t)); @@ -102,26 +102,26 @@ static void mix_s24(struct audio_stream *sink, int32_t start_frame, int32_t mixe #endif /* CONFIG_FORMAT_S24LE */ #if CONFIG_FORMAT_S32LE -static void mix_s32(struct audio_stream *sink, int32_t start_frame, int32_t mixed_frames, +static void mix_s32(struct audio_stream *sink, int32_t start_sample, int32_t mixed_samples, const struct audio_stream *source, - int32_t frame_count, uint16_t gain) + int32_t sample_count, uint16_t gain) { - int32_t frames_to_mix, frames_to_copy, left_frames; + int32_t samples_to_mix, samples_to_copy, left_samples; int32_t n, nmax, i; - int32_t *dst = (int32_t *)audio_stream_get_wptr(sink) + start_frame; + int32_t *dst = (int32_t *)audio_stream_get_wptr(sink) + start_sample; int32_t *src = audio_stream_get_rptr(source); - assert(mixed_frames >= start_frame); - frames_to_mix = mixed_frames - start_frame; - frames_to_mix = MIN(frames_to_mix, frame_count); - frames_to_copy = frame_count - frames_to_mix; + assert(mixed_samples >= start_sample); + samples_to_mix = mixed_samples - start_sample; + samples_to_mix = MIN(samples_to_mix, sample_count); + samples_to_copy = sample_count - samples_to_mix; - for (left_frames = frames_to_mix; left_frames > 0; left_frames -= n) { + for (left_samples = samples_to_mix; left_samples > 0; left_samples -= n) { src = audio_stream_wrap(source, src); dst = audio_stream_wrap(sink, dst); /* calculate the remaining samples*/ nmax = audio_stream_samples_without_wrap_s32(source, src); - n = MIN(left_frames, nmax); + n = MIN(left_samples, nmax); nmax = audio_stream_samples_without_wrap_s32(sink, dst); n = MIN(n, nmax); for (i = 0; i < n; i++) { @@ -130,11 +130,11 @@ static void mix_s32(struct audio_stream *sink, int32_t start_frame, int32_t mixe } } - for (left_frames = frames_to_copy; left_frames > 0; left_frames -= n) { + for (left_samples = samples_to_copy; left_samples > 0; left_samples -= n) { src = audio_stream_wrap(source, src); dst = audio_stream_wrap(sink, dst); nmax = audio_stream_samples_without_wrap_s32(source, src); - n = MIN(left_frames, nmax); + n = MIN(left_samples, nmax); nmax = audio_stream_samples_without_wrap_s32(sink, dst); n = MIN(n, nmax); memcpy_s(dst, n * sizeof(int32_t), src, n * sizeof(int32_t)); diff --git a/src/audio/mixin_mixout/mixin_mixout_hifi3.c b/src/audio/mixin_mixout/mixin_mixout_hifi3.c index 6b352f2a97e1..c03e43779b11 100644 --- a/src/audio/mixin_mixout/mixin_mixout_hifi3.c +++ b/src/audio/mixin_mixout/mixin_mixout_hifi3.c @@ -11,11 +11,11 @@ #ifdef MIXIN_MIXOUT_HIFI3 #if CONFIG_FORMAT_S16LE -static void mix_s16(struct audio_stream *sink, int32_t start_frame, int32_t mixed_frames, +static void mix_s16(struct audio_stream *sink, int32_t start_sample, int32_t mixed_samples, const struct audio_stream *source, - int32_t frame_count, uint16_t gain) + int32_t sample_count, uint16_t gain) { - int frames_to_mix, frames_to_copy, left_frames; + int samples_to_mix, samples_to_copy, left_samples; int n, nmax, i, m, left; ae_int16x4 in_sample; ae_int16x4 out_sample; @@ -25,20 +25,20 @@ static void mix_s16(struct audio_stream *sink, int32_t start_frame, int32_t mixe ae_valign outu1 = AE_ZALIGN64(); ae_valign outu2 = AE_ZALIGN64(); /* audio_stream_wrap() is required and is done below in a loop */ - ae_int16 *dst = (ae_int16 *)audio_stream_get_wptr(sink) + start_frame; + ae_int16 *dst = (ae_int16 *)audio_stream_get_wptr(sink) + start_sample; ae_int16 *src = audio_stream_get_rptr(source); - assert(mixed_frames >= start_frame); - frames_to_mix = AE_MIN_32_signed(mixed_frames - start_frame, frame_count); - frames_to_copy = frame_count - frames_to_mix; + assert(mixed_samples >= start_sample); + samples_to_mix = AE_MIN_32_signed(mixed_samples - start_sample, sample_count); + samples_to_copy = sample_count - samples_to_mix; n = 0; - for (left_frames = frames_to_mix; left_frames > 0; left_frames -= n) { + for (left_samples = samples_to_mix; left_samples > 0; left_samples -= n) { src = audio_stream_wrap(source, src + n); dst = audio_stream_wrap(sink, dst + n); /* calculate the remaining samples*/ nmax = audio_stream_samples_without_wrap_s16(source, src); - n = AE_MIN_32_signed(left_frames, nmax); + n = AE_MIN_32_signed(left_samples, nmax); nmax = audio_stream_samples_without_wrap_s16(sink, dst); n = AE_MIN_32_signed(n, nmax); in = (ae_int16x4 *)src; @@ -68,12 +68,12 @@ static void mix_s16(struct audio_stream *sink, int32_t start_frame, int32_t mixe } } - for (left_frames = frames_to_copy; left_frames > 0; left_frames -= n) { + for (left_samples = samples_to_copy; left_samples > 0; left_samples -= n) { src = audio_stream_wrap(source, src + n); dst = audio_stream_wrap(sink, dst + n); /* calculate the remaining samples*/ nmax = audio_stream_samples_without_wrap_s16(source, src); - n = AE_MIN_32_signed(left_frames, nmax); + n = AE_MIN_32_signed(left_samples, nmax); nmax = audio_stream_samples_without_wrap_s16(sink, dst); n = AE_MIN_32_signed(n, nmax); in = (ae_int16x4 *)src; @@ -100,11 +100,11 @@ static void mix_s16(struct audio_stream *sink, int32_t start_frame, int32_t mixe #endif /* CONFIG_FORMAT_S16LE */ #if CONFIG_FORMAT_S24LE -static void mix_s24(struct audio_stream *sink, int32_t start_frame, int32_t mixed_frames, +static void mix_s24(struct audio_stream *sink, int32_t start_sample, int32_t mixed_samples, const struct audio_stream *source, - int32_t frame_count, uint16_t gain) + int32_t sample_count, uint16_t gain) { - int frames_to_mix, frames_to_copy, left_frames; + int samples_to_mix, samples_to_copy, left_samples; int n, nmax, i, m, left; ae_int32x2 in_sample; ae_int32x2 out_sample; @@ -114,20 +114,20 @@ static void mix_s24(struct audio_stream *sink, int32_t start_frame, int32_t mixe ae_valign outu1 = AE_ZALIGN64(); ae_valign outu2 = AE_ZALIGN64(); /* audio_stream_wrap() is required and is done below in a loop */ - int32_t *dst = (int32_t *)audio_stream_get_wptr(sink) + start_frame; + int32_t *dst = (int32_t *)audio_stream_get_wptr(sink) + start_sample; int32_t *src = audio_stream_get_rptr(source); - assert(mixed_frames >= start_frame); - frames_to_mix = AE_MIN_32_signed(mixed_frames - start_frame, frame_count); - frames_to_copy = frame_count - frames_to_mix; + assert(mixed_samples >= start_sample); + samples_to_mix = AE_MIN_32_signed(mixed_samples - start_sample, sample_count); + samples_to_copy = sample_count - samples_to_mix; n = 0; - for (left_frames = frames_to_mix; left_frames > 0; left_frames -= n) { + for (left_samples = samples_to_mix; left_samples > 0; left_samples -= n) { src = audio_stream_wrap(source, src + n); dst = audio_stream_wrap(sink, dst + n); /* calculate the remaining samples*/ nmax = audio_stream_samples_without_wrap_s24(source, src); - n = AE_MIN_32_signed(left_frames, nmax); + n = AE_MIN_32_signed(left_samples, nmax); nmax = audio_stream_samples_without_wrap_s24(sink, dst); n = AE_MIN_32_signed(n, nmax); in = (ae_int32x2 *)src; @@ -155,11 +155,11 @@ static void mix_s24(struct audio_stream *sink, int32_t start_frame, int32_t mixe } } - for (left_frames = frames_to_copy; left_frames > 0; left_frames -= n) { + for (left_samples = samples_to_copy; left_samples > 0; left_samples -= n) { src = audio_stream_wrap(source, src + n); dst = audio_stream_wrap(sink, dst + n); nmax = audio_stream_samples_without_wrap_s24(source, src); - n = AE_MIN_32_signed(left_frames, nmax); + n = AE_MIN_32_signed(left_samples, nmax); nmax = audio_stream_samples_without_wrap_s24(sink, dst); n = AE_MIN_32_signed(n, nmax); in = (ae_int32x2 *)src; @@ -183,11 +183,11 @@ static void mix_s24(struct audio_stream *sink, int32_t start_frame, int32_t mixe #endif /* CONFIG_FORMAT_S24LE */ #if CONFIG_FORMAT_S32LE -static void mix_s32(struct audio_stream *sink, int32_t start_frame, int32_t mixed_frames, +static void mix_s32(struct audio_stream *sink, int32_t start_sample, int32_t mixed_samples, const struct audio_stream *source, - int32_t frame_count, uint16_t gain) + int32_t sample_count, uint16_t gain) { - int frames_to_mix, frames_to_copy, left_frames; + int samples_to_mix, samples_to_copy, left_samples; int n, nmax, i, m, left; ae_int32x2 in_sample; ae_int32x2 out_sample; @@ -197,20 +197,20 @@ static void mix_s32(struct audio_stream *sink, int32_t start_frame, int32_t mixe ae_valign outu1 = AE_ZALIGN64(); ae_valign outu2 = AE_ZALIGN64(); /* audio_stream_wrap() is required and is done below in a loop */ - int32_t *dst = (int32_t *)audio_stream_get_wptr(sink) + start_frame; + int32_t *dst = (int32_t *)audio_stream_get_wptr(sink) + start_sample; int32_t *src = audio_stream_get_rptr(source); - assert(mixed_frames >= start_frame); - frames_to_mix = AE_MIN_32_signed(mixed_frames - start_frame, frame_count); - frames_to_copy = frame_count - frames_to_mix; + assert(mixed_samples >= start_sample); + samples_to_mix = AE_MIN_32_signed(mixed_samples - start_sample, sample_count); + samples_to_copy = sample_count - samples_to_mix; n = 0; - for (left_frames = frames_to_mix; left_frames > 0; left_frames -= n) { + for (left_samples = samples_to_mix; left_samples > 0; left_samples -= n) { src = audio_stream_wrap(source, src + n); dst = audio_stream_wrap(sink, dst + n); /* calculate the remaining samples*/ nmax = audio_stream_samples_without_wrap_s32(source, src); - n = AE_MIN_32_signed(left_frames, nmax); + n = AE_MIN_32_signed(left_samples, nmax); nmax = audio_stream_samples_without_wrap_s32(sink, dst); n = AE_MIN_32_signed(n, nmax); in = (ae_int32x2 *)src; @@ -237,12 +237,12 @@ static void mix_s32(struct audio_stream *sink, int32_t start_frame, int32_t mixe } } - for (left_frames = frames_to_copy; left_frames > 0; left_frames -= n) { + for (left_samples = samples_to_copy; left_samples > 0; left_samples -= n) { src = audio_stream_wrap(source, src + n); dst = audio_stream_wrap(sink, dst + n); /* calculate the remaining samples*/ nmax = audio_stream_samples_without_wrap_s32(source, src); - n = AE_MIN_32_signed(left_frames, nmax); + n = AE_MIN_32_signed(left_samples, nmax); nmax = audio_stream_samples_without_wrap_s32(sink, dst); n = AE_MIN_32_signed(n, nmax); in = (ae_int32x2 *)src;