[FFmpeg-devel] [PATCH 1/5] AAC: use table for cbrtf(n)*n
Alex Converse
alex.converse
Mon Jan 11 14:03:03 CET 2010
On Mon, Jan 11, 2010 at 7:37 AM, Mans Rullgard <mans at mansr.com> wrote:
> Up to 10% faster on Cortex-A8.
> ---
> ?libavcodec/aac.c | ? ?6 +++++-
> ?1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/libavcodec/aac.c b/libavcodec/aac.c
> index 2bb05b8..14849d4 100644
> --- a/libavcodec/aac.c
> +++ b/libavcodec/aac.c
> @@ -101,6 +101,7 @@ union float754 {
> ?static VLC vlc_scalefactors;
> ?static VLC vlc_spectral[11];
>
> +static float cbrt_tab[1<<15];
>
> ?static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
> ?{
> @@ -555,6 +556,9 @@ static av_cold int aac_decode_init(AVCodecContext *avccontext)
> ? ? ff_init_ff_sine_windows(10);
> ? ? ff_init_ff_sine_windows( 7);
>
> + ? ?for (i = 0; i < 1<<15; i++)
> + ? ? ? ?cbrt_tab[i] = cbrtf(i) * i;
> +
> ? ? return 0;
> ?}
>
This 2**15 value seems big.
"""
4.6.3.3 Decoding process
The ESC codebook is a special case. It represents values from 0 to 16
inclusive, but values from 0 to 15 encode actual data values, and the
value16 is an escape_flag that signals the presence of hcod_esc_y or
hcod_esc_z, either of which will be denoted as an escape_sequence.
This escape_sequence permits quantized spectral elements of LAV>15 to
be encoded. It consists of an escape_prefix of N 1?s, followed by an
escape_separator of one zero, followed by an escape_word of N+4 bits
representing an unsigned integer value. The escape_sequence has a
decoded value of 2^(N+4)+escape_word. The desired quantized spectral
coefficient is then the sign indicated by the pair_sign_bits applied
to the value of the escape_sequence. In other words, an
escape_sequence of 00000 would decode as 16, an escape_sequence of
01111 as 31, an escape_sequence of 1000000 as 32, one of 1011111 as
63, and so on. Note that restrictions in subclause 4.6.1.3 dictate
that the length of the escape_sequence is always less than 22 bits.
For escape Huffman codewords the ordering of data elements is Huffman
codeword followed by 0 to 2 sign bits followed by 0 to 2 escape
sequences.
4.6.1.3 Decoding process
...
The maximum allowed absolute amplitude for x_quant is 8191....
"""
It seems that a 22-bit escape sequence the maximum value encoded could
be 111111110111111111111 -> 2^(8+4)+(2^12-1) = 8191. Going bigger
wasn't as much of an issue with a free function call but we can save
96K of table space by tightening this constraint.
Regards,
Alex Converse
More information about the ffmpeg-devel
mailing list