Mercurial > libavcodec.hg
changeset 5616:cb5999c836af libavcodec
Replace two #define's by inline functions
author | vitor |
---|---|
date | Thu, 30 Aug 2007 16:04:00 +0000 |
parents | 7ffc96c9ab1a |
children | 4051bdeecabf |
files | alac.c |
diffstat | 1 files changed, 14 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/alac.c Thu Aug 30 15:16:52 2007 +0000 +++ b/alac.c Thu Aug 30 16:04:00 2007 +0000 @@ -269,12 +269,15 @@ } } -#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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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; }