Skip to content

Commit e648b12

Browse files
singalsulgirdwood
authored andcommitted
Audio: Selector: Add saturation to process frame functions
The mix coefficients are Q6.10 with max amplification of +32 dB, so the result need to be checked and saturated by 16 and 32 bit saturation functions. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent 9c4bd10 commit e648b12

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/audio/selector/selector_generic.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <sof/audio/buffer.h>
1414
#include <sof/audio/component.h>
15+
#include <sof/audio/format.h>
1516
#include <sof/audio/selector.h>
1617
#include <sof/common.h>
1718
#include <ipc/stream.h>
@@ -191,7 +192,7 @@ static void process_frame_s16le(int16_t dst[], int dst_channels,
191192
accum += (int32_t)src[j] * (int32_t)coeffs_config->coeffs[i][j];
192193

193194
/* shift out 10 LSbits with rounding to get 16-bit result */
194-
dst[i] = (int16_t)((accum + (1 << 9)) >> 10);
195+
dst[i] = sat_int16((accum + (1 << 9)) >> 10);
195196
}
196197
}
197198

@@ -262,7 +263,7 @@ static void process_frame_s32le(int32_t dst[], int dst_channels,
262263
accum += (int64_t)src[j] * (int64_t)coeffs_config->coeffs[i][j];
263264

264265
/* shift out 10 LSbits with rounding to get 32-bit result */
265-
dst[i] = (int32_t)((accum + (1 << 9)) >> 10);
266+
dst[i] = sat_int32((accum + (1 << 9)) >> 10);
266267
}
267268
}
268269

0 commit comments

Comments
 (0)