From 78202631e76680fc3dc9913fdf24c06a412dbcfe Mon Sep 17 00:00:00 2001 From: Karol Trzcinski Date: Thu, 27 Aug 2020 13:56:20 +0200 Subject: [PATCH] pcm_converter: Reduce modulo operations Module is expensive operation, so usage them in processing code should be reduced. Signed-off-by: Karol Trzcinski --- src/audio/pcm_converter/pcm_converter_hifi3.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/audio/pcm_converter/pcm_converter_hifi3.c b/src/audio/pcm_converter/pcm_converter_hifi3.c index 919707f27..5f4f94632 100644 --- a/src/audio/pcm_converter/pcm_converter_hifi3.c +++ b/src/audio/pcm_converter/pcm_converter_hifi3.c @@ -480,7 +480,7 @@ static void pcm_convert_s24_to_s32(const struct audio_stream *source, } /* main loop processes 2 samples at a time */ - for (i = 0; i < samples / 2; i++) { + for (i = 0; i < samples - 1; i += 2) { /* set source as circular buffer */ pcm_converter_setup_circular(source); @@ -498,7 +498,7 @@ static void pcm_convert_s24_to_s32(const struct audio_stream *source, AE_SA64POS_FC(align_out, out); /* no more samples to process */ - if (!(samples % 2)) + if (i == samples) return; /* set source as circular buffer */ @@ -570,7 +570,7 @@ static void pcm_convert_s32_to_s24(const struct audio_stream *source, } /* main loop processes 2 samples at a time */ - for (i = 0; i < samples / 2; i++) { + for (i = 0; i < samples - 1; i += 2) { /* set source as circular buffer */ pcm_converter_setup_circular(source); @@ -589,7 +589,7 @@ static void pcm_convert_s32_to_s24(const struct audio_stream *source, AE_SA64POS_FC(align_out, out); /* no more samples to process */ - if (!(samples % 2)) + if (i == samples) return; /* set source as circular buffer */