[FFmpeg-devel] [PATCH] Another optimization for mp3 decoder
Måns Rullgård
mans
Thu Jul 1 00:41:25 CEST 2010
Vitor Sessak <vitor1001 at gmail.com> writes:
> $subj, it replaces writing two consecutive identical 16-bit values by
> a single 32-bit one (note that the table band_size_long[] has only
> even values).
>
> -Vitor
>
> Index: libavcodec/mpegaudiodec.c
> ===================================================================
> --- libavcodec/mpegaudiodec.c (revision 23840)
> +++ libavcodec/mpegaudiodec.c (working copy)
> @@ -1410,6 +1410,11 @@
> slen[0] = sf;
> }
>
> +static av_always_inline uint32_t dup16to32(int a)
> +{
> + return (a&0xFFFF) + (a<<16);
> +}
This is PACK_2S16(a, a).
> static void exponents_from_scale_factors(MPADecodeContext *s,
> GranuleDef *g,
> int16_t *exponents)
> @@ -1425,10 +1430,14 @@
> bstab = band_size_long[s->sample_rate_index];
> pretab = mpa_pretab[g->preflag];
> for(i=0;i<g->long_end;i++) {
> + int v1;
> v0 = gain - ((g->scale_factors[i] + pretab[i]) << shift) + 400;
> - len = bstab[i];
> - for(j=len;j>0;j--)
> - *exp_ptr++ = v0;
> + v1 = dup16to32(v0);
> + len = bstab[i] >> 1;
> + for(j=len;j>0;j--) {
> + AV_WN32A(exp_ptr, v1);
> + exp_ptr += 2;
> + }
> }
>
> if (g->short_start < 13) {
> @@ -1979,7 +1988,7 @@
> int nb_granules, main_data_begin, private_bits;
> int gr, ch, blocksplit_flag, i, j, k, n, bits_pos;
> GranuleDef *g;
> - int16_t exponents[576]; //FIXME try INTFLOAT
> + LOCAL_ALIGNED(4, int16_t, exponents, [576]); //FIXME try INTFLOAT
LOCAL_ALIGNED() is meant for alignments greater than what can be
achieved by normal means.
I also wonder if it wouldn't be better still to halve the size of this
array and adjust the indexing.
--
M?ns Rullg?rd
mans at mansr.com
More information about the ffmpeg-devel
mailing list