Skip to content

Commit

Permalink
ipc4: mixin/mixout: Fix naming after channel remapping removal
Browse files Browse the repository at this point in the history
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 <serhiy.katsyuba@intel.com>
  • Loading branch information
serhiy-katsyuba-intel committed Dec 20, 2023
1 parent 24a419a commit 8468dd7
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 72 deletions.
6 changes: 3 additions & 3 deletions src/audio/mixin_mixout/mixin_mixout.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
72 changes: 36 additions & 36 deletions src/audio/mixin_mixout/mixin_mixout_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -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));
Expand All @@ -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++) {
Expand All @@ -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));
Expand All @@ -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++) {
Expand All @@ -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));
Expand Down
66 changes: 33 additions & 33 deletions src/audio/mixin_mixout/mixin_mixout_hifi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 8468dd7

Please sign in to comment.