From fbb6b49dabc3398440c6dfa838aa090a7a6ebc0d Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sun, 13 Feb 2011 14:49:50 -0500 Subject: ac3enc: Add x86-optimized function to speed up log2_tab(). AC3DSPContext.ac3_max_msb_abs_int16() finds the maximum MSB of the absolute value of each element in an array of int16_t. Signed-off-by: Ronald S. Bultje --- libavcodec/ac3enc_fixed.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'libavcodec/ac3enc_fixed.c') diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c index 0db41df..3de00ee 100644 --- a/libavcodec/ac3enc_fixed.c +++ b/libavcodec/ac3enc_fixed.c @@ -270,14 +270,9 @@ static void apply_window(DSPContext *dsp, int16_t *output, const int16_t *input, * @param n number of values in the array * @return log2(max(abs(tab[]))) */ -static int log2_tab(int16_t *tab, int n) +static int log2_tab(AC3EncodeContext *s, int16_t *src, int len) { - int i, v; - - v = 0; - for (i = 0; i < n; i++) - v |= abs(tab[i]); - + int v = s->ac3dsp.ac3_max_msb_abs_int16(src, len); return av_log2(v); } @@ -308,7 +303,7 @@ static void lshift_tab(int16_t *tab, int n, unsigned int lshift) */ static int normalize_samples(AC3EncodeContext *s) { - int v = 14 - log2_tab(s->windowed_samples, AC3_WINDOW_SIZE); + int v = 14 - log2_tab(s, s->windowed_samples, AC3_WINDOW_SIZE); lshift_tab(s->windowed_samples, AC3_WINDOW_SIZE, v); return v - 9; } -- cgit v1.1