Commit 321c3138 authored by Vitor Sessak's avatar Vitor Sessak

Replace two #define's by inline functions

Originally committed as revision 10264 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 14da6549
...@@ -269,12 +269,15 @@ static void bastardized_rice_decompress(ALACContext *alac, ...@@ -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) \ static inline int sign_only(int v)
((v < 0) ? (-1) : \ {
((v > 0) ? (1) : \ return v ? FFSIGN(v) : 0;
(0))) }
static void predictor_decompress_fir_adapt(int32_t *error_buffer, static void predictor_decompress_fir_adapt(int32_t *error_buffer,
int32_t *buffer_out, int32_t *buffer_out,
...@@ -310,7 +313,7 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer, ...@@ -310,7 +313,7 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer,
prev_value = buffer_out[i]; prev_value = buffer_out[i];
error_value = error_buffer[i+1]; error_value = error_buffer[i+1];
buffer_out[i+1] = buffer_out[i+1] =
SIGN_EXTENDED32((prev_value + error_value), readsamplesize); sign_extended32((prev_value + error_value), readsamplesize);
} }
return; return;
} }
...@@ -321,7 +324,7 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer, ...@@ -321,7 +324,7 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer,
int32_t val; int32_t val;
val = buffer_out[i] + error_buffer[i+1]; val = buffer_out[i] + error_buffer[i+1];
val = SIGN_EXTENDED32(val, readsamplesize); val = sign_extended32(val, readsamplesize);
buffer_out[i+1] = val; buffer_out[i+1] = val;
} }
...@@ -356,7 +359,7 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer, ...@@ -356,7 +359,7 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer,
outval = (1 << (predictor_quantitization-1)) + sum; outval = (1 << (predictor_quantitization-1)) + sum;
outval = outval >> predictor_quantitization; outval = outval >> predictor_quantitization;
outval = outval + buffer_out[0] + error_val; outval = outval + buffer_out[0] + error_val;
outval = SIGN_EXTENDED32(outval, readsamplesize); outval = sign_extended32(outval, readsamplesize);
buffer_out[predictor_coef_num+1] = outval; buffer_out[predictor_coef_num+1] = outval;
...@@ -365,7 +368,7 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer, ...@@ -365,7 +368,7 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer,
while (predictor_num >= 0 && error_val > 0) { while (predictor_num >= 0 && error_val > 0) {
int val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num]; 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; predictor_coef_table[predictor_num] -= sign;
...@@ -381,7 +384,7 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer, ...@@ -381,7 +384,7 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer,
while (predictor_num >= 0 && error_val < 0) { while (predictor_num >= 0 && error_val < 0) {
int val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num]; 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; predictor_coef_table[predictor_num] -= sign;
...@@ -570,7 +573,7 @@ static int alac_decode_frame(AVCodecContext *avctx, ...@@ -570,7 +573,7 @@ static int alac_decode_frame(AVCodecContext *avctx,
int32_t audiobits; int32_t audiobits;
audiobits = get_bits(&alac->gb, alac->setinfo_sample_size); 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; alac->outputsamples_buffer[chan][i] = audiobits;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment