From e8c323ed7e6cda5b96871d922e66f573059f8b62 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 7 Jan 2009 18:03:53 +0100 Subject: pcm_utils: export pcm_range() We are going to split the pcm_utils.c library, and pcm_range() will be useful for several sub libraries. --- src/pcm_utils.c | 14 -------------- src/pcm_utils.h | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/pcm_utils.c b/src/pcm_utils.c index b1178c7a2..43690ef89 100644 --- a/src/pcm_utils.c +++ b/src/pcm_utils.c @@ -41,20 +41,6 @@ pcm_dither(void) return (r & 511) - ((r >> 9) & 511); } -/** - * Check if the value is within the range of the provided bit size, - * and caps it if necessary. - */ -static int32_t -pcm_range(int32_t sample, unsigned bits) -{ - if (G_UNLIKELY(sample < (-1 << (bits - 1)))) - return -1 << (bits - 1); - if (G_UNLIKELY(sample >= (1 << (bits - 1)))) - return (1 << (bits - 1)) - 1; - return sample; -} - static void pcm_volume_change_8(int8_t *buffer, unsigned num_samples, int volume) { diff --git a/src/pcm_utils.h b/src/pcm_utils.h index 71398c015..44ea5aa16 100644 --- a/src/pcm_utils.h +++ b/src/pcm_utils.h @@ -22,6 +22,8 @@ #include "pcm_resample.h" #include "pcm_dither.h" +#include + #include #include @@ -41,6 +43,20 @@ struct pcm_convert_state { int error; }; +/** + * Check if the value is within the range of the provided bit size, + * and caps it if necessary. + */ +static inline int32_t +pcm_range(int32_t sample, unsigned bits) +{ + if (G_UNLIKELY(sample < (-1 << (bits - 1)))) + return -1 << (bits - 1); + if (G_UNLIKELY(sample >= (1 << (bits - 1)))) + return (1 << (bits - 1)) - 1; + return sample; +} + /** * Converts a float value (0.0 = silence, 1.0 = 100% volume) to an * integer volume value (1000 = 100%). -- cgit v1.2.3