[FFmpeg-devel] [PATCH] Add x86-optimized function ac3_or_abs_int16() and use in log2_tab().
Måns Rullgård
mans
Sat Feb 12 02:48:29 CET 2011
Justin Ruggles <justin.ruggles at gmail.com> writes:
> diff --git a/libavcodec/ac3dsp.h b/libavcodec/ac3dsp.h
> index 7f13b11..a6a9af4 100644
> --- a/libavcodec/ac3dsp.h
> +++ b/libavcodec/ac3dsp.h
> @@ -35,6 +35,17 @@ typedef struct AC3DSPContext {
> * @param nb_coefs number of frequency coefficients.
> */
> void (*ac3_exponent_min)(uint8_t *exp, int num_reuse_blocks, int nb_coefs);
> +
> + /**
> + * Calculate the logical 'or' of the absolute value of each element in an
> + * array of int16_t.
> + * @param src input array
> + * constraints: align 16
> + * @param len number of values in the array
> + * constraints: multiple of 16 greater than 0
> + * @return abs(src[0]) | abs(src[1]) | ... | abs(src[len-1])
> + */
> + int (*ac3_or_abs_int16)(const int16_t *src, int len);
> } AC3DSPContext;
What is the range of the input values? Specifically, is INT16_MIN allowed?
Whatever the answer, please mention it in the comment.
> void ff_ac3dsp_init (AC3DSPContext *c);
> diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c
> index 0db41df..d1f15ac 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 *tab, int n)
> {
> - int i, v;
> -
> - v = 0;
> - for (i = 0; i < n; i++)
> - v |= abs(tab[i]);
> -
> + int v = s->ac3dsp.ac3_or_abs_int16(tab, n);
> 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;
> }
C parts look OK. I'm leaving x86 bits to someone else.
--
M?ns Rullg?rd
mans at mansr.com
More information about the ffmpeg-devel
mailing list