Skip to content

Commit

Permalink
mixin_mixout: remove all related code for remap function
Browse files Browse the repository at this point in the history
remove remap code since there is no requirement for this.

Signed-off-by: Baofeng Tian <[email protected]>
  • Loading branch information
btian1 authored and lgirdwood committed Aug 16, 2023
1 parent babb16b commit ff717ae
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 452 deletions.
5 changes: 1 addition & 4 deletions src/audio/mixin_mixout/mixin_mixout.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ struct mixin_sink_config {
/* mixin component private data */
struct mixin_data {
normal_mix_func normal_mix_channel;
remap_mix_func remap_mix_channel;
mute_func mute_channel;
struct mixin_sink_config sink_config[MIXIN_MAX_SINKS];
};
Expand Down Expand Up @@ -532,7 +531,6 @@ static int mixin_reset(struct processing_module *mod)
comp_dbg(dev, "mixin_reset()");

mixin_data->normal_mix_channel = NULL;
mixin_data->remap_mix_channel = NULL;
mixin_data->mute_channel = NULL;

return 0;
Expand Down Expand Up @@ -670,15 +668,14 @@ static int mixin_prepare(struct processing_module *mod,
case SOF_IPC_FRAME_S24_4LE:
case SOF_IPC_FRAME_S32_LE:
md->normal_mix_channel = normal_mix_get_processing_function(fmt);
md->remap_mix_channel = remap_mix_get_processing_function(fmt);
md->mute_channel = mute_mix_get_processing_function(fmt);
break;
default:
comp_err(dev, "unsupported data format %d", fmt);
return -EINVAL;
}

if (!md->normal_mix_channel || !md->remap_mix_channel || !md->mute_channel) {
if (!md->normal_mix_channel || !md->mute_channel) {
comp_err(dev, "have not found the suitable processing function");
return -EINVAL;
}
Expand Down
185 changes: 3 additions & 182 deletions src/audio/mixin_mixout/mixin_mixout_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,65 +61,6 @@ static void normal_mix_channel_s16(struct audio_stream __sparse_cache *sink, int
}
}

static void remap_mix_channel_s16(struct audio_stream __sparse_cache *sink,
int32_t sink_channel_index, int32_t sink_channel_count,
int32_t start_frame, int32_t mixed_frames,
const struct audio_stream __sparse_cache *source,
int32_t source_channel_index, int32_t source_channel_count,
int32_t frame_count, uint16_t gain)
{
int16_t *dst, *src;
int32_t frames_to_mix, frames_to_copy, left_frames;
int32_t n, nmax, frames, i, samples;

/* audio_stream_wrap() is required and is done below in a loop */
dst = (int16_t *)audio_stream_get_wptr(sink) + start_frame * sink_channel_count +
sink_channel_index;
src = (int16_t *)audio_stream_get_rptr(source) + source_channel_index;

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;

for (left_frames = frames_to_mix; left_frames > 0; left_frames -= frames) {
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);
samples = left_frames * source_channel_count;
n = MIN(samples, nmax);
nmax = audio_stream_samples_without_wrap_s16(sink, dst);
n = MIN(n, nmax);
/* frames is the processed frame count in this loop*/
frames = 0;
for (i = 0; i < n; i += source_channel_count) {
*dst = sat_int16((int32_t)*dst +
q_mults_16x16(*src, gain, IPC4_MIXIN_GAIN_SHIFT));
src += source_channel_count;
dst += sink_channel_count;
frames++;
}
}

for (left_frames = frames_to_copy; left_frames > 0; left_frames -= frames) {
src = audio_stream_wrap(source, src);
dst = audio_stream_wrap(sink, dst);
nmax = audio_stream_samples_without_wrap_s16(source, src);
samples = left_frames * source_channel_count;
n = MIN(samples, nmax);
nmax = audio_stream_samples_without_wrap_s16(sink, dst);
n = MIN(n, nmax);
frames = 0;
for (i = 0; i < n; i += source_channel_count) {
*dst = (int16_t)q_mults_16x16(*src, gain, IPC4_MIXIN_GAIN_SHIFT);
src += source_channel_count;
dst += sink_channel_count;
frames++;
}
}
}

static void mute_channel_s16(struct audio_stream __sparse_cache *stream, int32_t channel_index,
int32_t start_frame, int32_t mixed_frames, int32_t frame_count)
{
Expand Down Expand Up @@ -203,67 +144,6 @@ static void normal_mix_channel_s24(struct audio_stream __sparse_cache *sink, int
}
}

static void remap_mix_channel_s24(struct audio_stream __sparse_cache *sink,
int32_t sink_channel_index, int32_t sink_channel_count,
int32_t start_frame, int32_t mixed_frames,
const struct audio_stream __sparse_cache *source,
int32_t source_channel_index, int32_t source_channel_count,
int32_t frame_count, uint16_t gain)
{
int32_t *dst, *src;
int32_t frames_to_mix, frames_to_copy, left_frames;
int32_t n, nmax, i, frames, samples;

/* audio_stream_wrap() is required and is done below in a loop */
dst = (int32_t *)audio_stream_get_wptr(sink) + start_frame * sink_channel_count +
sink_channel_index;
src = (int32_t *)audio_stream_get_rptr(source) + source_channel_index;

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;

for (left_frames = frames_to_mix; left_frames > 0; left_frames -= frames) {
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);
samples = left_frames * source_channel_count;
n = MIN(samples, nmax);
nmax = audio_stream_samples_without_wrap_s24(sink, dst);
n = MIN(n, nmax);
/* frames is the processed frame count in this loop*/
frames = 0;
for (i = 0; i < n; i += source_channel_count) {
*dst = sat_int24(sign_extend_s24(*dst) +
(int32_t)q_mults_32x32(sign_extend_s24(*src),
gain, IPC4_MIXIN_GAIN_SHIFT));
src += source_channel_count;
dst += sink_channel_count;
frames++;
}
}

for (left_frames = frames_to_copy; left_frames > 0; left_frames -= frames) {
src = audio_stream_wrap(source, src);
dst = audio_stream_wrap(sink, dst);
nmax = audio_stream_samples_without_wrap_s24(source, src);
samples = left_frames * source_channel_count;
n = MIN(samples, nmax);
nmax = audio_stream_samples_without_wrap_s24(sink, dst);
n = MIN(n, nmax);
frames = 0;
for (i = 0; i < n; i += source_channel_count) {
*dst = (int32_t)q_mults_32x32(sign_extend_s24(*src),
gain, IPC4_MIXIN_GAIN_SHIFT);
src += source_channel_count;
dst += sink_channel_count;
frames++;
}
}
}

#endif /* CONFIG_FORMAT_S24LE */

#if CONFIG_FORMAT_S32LE
Expand Down Expand Up @@ -315,65 +195,6 @@ static void normal_mix_channel_s32(struct audio_stream __sparse_cache *sink, int
}
}

static void remap_mix_channel_s32(struct audio_stream __sparse_cache *sink,
int32_t sink_channel_index, int32_t sink_channel_count,
int32_t start_frame, int32_t mixed_frames,
const struct audio_stream __sparse_cache *source,
int32_t source_channel_index, int32_t source_channel_count,
int32_t frame_count, uint16_t gain)
{
int32_t frames_to_mix, frames_to_copy, left_frames;
int32_t n, nmax, frames, i, samples;
int32_t *dst, *src;

/* audio_stream_wrap() is required and is done below in a loop */
dst = (int32_t *)audio_stream_get_wptr(sink) + start_frame * sink_channel_count +
sink_channel_index;
src = (int32_t *)audio_stream_get_rptr(source) + source_channel_index;

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;

for (left_frames = frames_to_mix; left_frames > 0; left_frames -= frames) {
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);
samples = left_frames * source_channel_count;
n = MIN(samples, nmax);
nmax = audio_stream_samples_without_wrap_s32(sink, dst);
n = MIN(n, nmax);
/* frames is the processed frame count in this loop*/
frames = 0;
for (i = 0; i < n; i += source_channel_count) {
*dst = sat_int32((int64_t)*dst +
q_mults_32x32(*src, gain, IPC4_MIXIN_GAIN_SHIFT));
src += source_channel_count;
dst += sink_channel_count;
frames++;
}
}

for (left_frames = frames_to_copy; left_frames > 0; left_frames -= frames) {
src = audio_stream_wrap(source, src);
dst = audio_stream_wrap(sink, dst);
nmax = audio_stream_samples_without_wrap_s32(source, src);
samples = left_frames * source_channel_count;
n = MIN(samples, nmax);
nmax = audio_stream_samples_without_wrap_s32(sink, dst);
n = MIN(n, nmax);
frames = 0;
for (i = 0; i < n; i += source_channel_count) {
*dst = (int32_t)q_mults_32x32(*src, gain, IPC4_MIXIN_GAIN_SHIFT);
src += source_channel_count;
dst += sink_channel_count;
frames++;
}
}
}

#endif /* CONFIG_FORMAT_S32LE */

#if CONFIG_FORMAT_S32LE || CONFIG_FORMAT_S24LE
Expand Down Expand Up @@ -413,13 +234,13 @@ static void mute_channel_s32(struct audio_stream __sparse_cache *stream, int32_t

const struct mix_func_map mix_func_map[] = {
#if CONFIG_FORMAT_S16LE
{ SOF_IPC_FRAME_S16_LE, normal_mix_channel_s16, remap_mix_channel_s16, mute_channel_s16},
{ SOF_IPC_FRAME_S16_LE, normal_mix_channel_s16, mute_channel_s16},
#endif
#if CONFIG_FORMAT_S24LE
{ SOF_IPC_FRAME_S24_4LE, normal_mix_channel_s24, remap_mix_channel_s24, mute_channel_s32},
{ SOF_IPC_FRAME_S24_4LE, normal_mix_channel_s24, mute_channel_s32},
#endif
#if CONFIG_FORMAT_S32LE
{ SOF_IPC_FRAME_S32_LE, normal_mix_channel_s32, remap_mix_channel_s32, mute_channel_s32}
{ SOF_IPC_FRAME_S32_LE, normal_mix_channel_s32, mute_channel_s32}
#endif
};

Expand Down
Loading

0 comments on commit ff717ae

Please sign in to comment.