[FFmpeg-devel] [PATCH 09/12] WMA: store level_table as floats, use type punning for sign flip in decode

Måns Rullgård mans
Tue Sep 29 02:03:38 CEST 2009


Alex Converse <alex.converse at gmail.com> writes:

> On Sun, Sep 27, 2009 at 6:49 AM, Mans Rullgard <mans at mansr.com> wrote:
>> ---
>> ?libavcodec/wma.c ? ? ? ?| ? 19 +++++++++++++------
>> ?libavcodec/wma.h ? ? ? ?| ? ?4 ++--
>> ?libavcodec/wmaprodata.h | ? ?4 ++--
>> ?libavcodec/wmaprodec.c ?| ? ?2 +-
>> ?4 files changed, 18 insertions(+), 11 deletions(-)
>>
>
>> @@ -465,19 +469,22 @@ unsigned int ff_wma_get_large_val(GetBitContext* gb)
>> ?*/
>> ?int ff_wma_run_level_decode(AVCodecContext* avctx, GetBitContext* gb,
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? VLC *vlc,
>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ?const uint16_t *level_table, const uint16_t *run_table,
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ?const float *level_table, const uint16_t *run_table,
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? int version, WMACoef *ptr, int offset,
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? int num_coefs, int block_len, int frame_len_bits,
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? int coef_nb_bits)
>> ?{
>> ? ? int code, level, sign;
>> + ? ?const uint32_t *ilvl = (const uint32_t*)level_table;
>> + ? ?uint32_t *iptr = (uint32_t*)ptr;
>> ? ? const unsigned int coef_mask = block_len - 1;
>> ? ? for (; offset < num_coefs; offset++) {
>> ? ? ? ? code = get_vlc2(gb, vlc->table, VLCBITS, VLCMAX);
>> ? ? ? ? if (code > 1) {
>> ? ? ? ? ? ? /** normal code */
>> ? ? ? ? ? ? offset += run_table[code];
>
> Is this legitimate under strict aliasing rules?

Since this function is never inlined (called only from other files),
and each memory location is only written as either int or float, it
should be impossible for the compiler to get it wrong.  The speedup on
Cortex-A8 is substantial, so I think we should go with this.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list