[Ffmpeg-devel] mpegaudiodec.c and armv5te optimizations

Siarhei Siamashka siarhei.siamashka
Tue Oct 3 21:11:59 CEST 2006

Hello All,

I would like to ask those who are familiar with mp3 decoding algorithm
in mpegaudiodec.c better if there could be any really nasty things
happening after changing current

#define MULH(a,b) (((int64_t)(a) * (int64_t)(b))>>32)
#define FIXHR(a) ((int)((a) * (1LL<<32) + 0.5))

to something like

#define MULH(a,b) (((int64_t)(a) * (int16_t)(b))>>16)
#define FIXHR(a) ((int16_t)((a) * (1LL<<16) + 0.5))

in low quality decoding mode.

I tried to decode a few mp3 files and the difference does not seem to be very
noticeable (samples seem to differ +-4 at most).

I'm asking this because armv5te has an instruction for performing fast 
single cycle 32bit * 16bit multiplication with a result 16 bits shifted (gets
top 32bits of the result). Using this instruction, MULH operations can be
implemented extremely efficiently with just one cycle each (with an option 
to do such multiply-accumulate in a single cycle too).  Also it will allow
loading constants at double speed improving performance even more. 
Using  these optimizations and implementing dct functions in arm assembler, 
ffmpeg decoder can get a really huge performance boost and outperform 
libmad in low quality mode.

More information about the ffmpeg-devel mailing list