From 321c3138364fb3fa679f56d296a052ac3e7fc910 Mon Sep 17 00:00:00 2001 From: Vitor Sessak Date: Thu, 30 Aug 2007 16:04:00 +0000 Subject: [PATCH] Replace two #define's by inline functions Originally committed as revision 10264 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/alac.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/libavcodec/alac.c b/libavcodec/alac.c index b9edf596a9..354c92303f 100644 --- a/libavcodec/alac.c +++ b/libavcodec/alac.c @@ -269,12 +269,15 @@ static void bastardized_rice_decompress(ALACContext *alac, } } -#define SIGN_EXTENDED32(val, bits) ((val << (32 - bits)) >> (32 - bits)) +static inline int32_t sign_extended32(int32_t val, int bits) +{ + return (val << (32 - bits)) >> (32 - bits); +} -#define SIGN_ONLY(v) \ - ((v < 0) ? (-1) : \ - ((v > 0) ? (1) : \ - (0))) +static inline int sign_only(int v) +{ + return v ? FFSIGN(v) : 0; +} static void predictor_decompress_fir_adapt(int32_t *error_buffer, int32_t *buffer_out, @@ -310,7 +313,7 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer, prev_value = buffer_out[i]; error_value = error_buffer[i+1]; buffer_out[i+1] = - SIGN_EXTENDED32((prev_value + error_value), readsamplesize); + sign_extended32((prev_value + error_value), readsamplesize); } return; } @@ -321,7 +324,7 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer, int32_t val; val = buffer_out[i] + error_buffer[i+1]; - val = SIGN_EXTENDED32(val, readsamplesize); + val = sign_extended32(val, readsamplesize); buffer_out[i+1] = val; } @@ -356,7 +359,7 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer, outval = (1 << (predictor_quantitization-1)) + sum; outval = outval >> predictor_quantitization; outval = outval + buffer_out[0] + error_val; - outval = SIGN_EXTENDED32(outval, readsamplesize); + outval = sign_extended32(outval, readsamplesize); buffer_out[predictor_coef_num+1] = outval; @@ -365,7 +368,7 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer, while (predictor_num >= 0 && error_val > 0) { int val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num]; - int sign = SIGN_ONLY(val); + int sign = sign_only(val); predictor_coef_table[predictor_num] -= sign; @@ -381,7 +384,7 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer, while (predictor_num >= 0 && error_val < 0) { int val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num]; - int sign = - SIGN_ONLY(val); + int sign = - sign_only(val); predictor_coef_table[predictor_num] -= sign; @@ -570,7 +573,7 @@ static int alac_decode_frame(AVCodecContext *avctx, int32_t audiobits; audiobits = get_bits(&alac->gb, alac->setinfo_sample_size); - audiobits = SIGN_EXTENDED32(audiobits, readsamplesize); + audiobits = sign_extended32(audiobits, readsamplesize); alac->outputsamples_buffer[chan][i] = audiobits; }