[Ffmpeg-devel] Fixed point arithmetic RealAudio G2 (cook) decoder

Ian Braithwaite ian
Thu Mar 8 14:16:28 CET 2007


Hi,


OK - here's my fixed point patch for the cook audio decoder.


>> I know that Rich is always interested in integer implementation for
>> his slow K6-III+. You're gonna make at least one user happy ;-)
>
> not only rich, 25x speedup for ARM is interresting, though we of course
> cannot unconditionally replace the float decoder so the patch must be
> clean to be accepted in svn, clean hear means that common code
> is not duplicated and that both float and integer can be selected by the
> users (at compile time is ok)

Just to be clear - the fixed point decoder is _slower_ than the floating
point version, by about a factor of two, on my Athlon.
So, no, replacing the float decoder isn't an option.

The 25x speedup on ARM is perhaps not so suprising, since to run the float
version, it has to use a software FPU emulator.


To avoid duplication of common code, here's what I did.

The current decoder consists of two files, "cook.c" and "cookdata.h".
I factored out the floating point math from "cook.c", and put it into
inline functions in a new file, "cook_float.h".
Then I implemented fixed point versions, and put them in "cook_fixpoint.h".
Then I repeated the same trick for "cookdata.h".
Finally, I conditionally include the appropriate two files in "cook.c".
There's a define in "cook.c" to choose between float and fixed -
presumably this could be integrated into the configuration system.


Some of the patch isn't directly related to the fixed point implementation,
so I've split it up into 4 (in my opinion!) improvements, and then the
patch itself. The improvements came about by me figuring out how
the whole thing works.

Here's a run down of the 5 patches.


Patch 1.
Don't output the first two frames, since they don't contain valid audio.
This also eases comparison of decoded output with Real's binary decoder.

 cook.c |    3 +++
 1 file changed, 3 insertions(+)


Patch 2.
Simplify gain block handling.
No effect on output.

 cook.c |  152
++++++++++++++++++++++-------------------------------------------
 1 file changed, 52 insertions(+), 100 deletions(-)


Patch 3.
Replace custom modified discrete cosine transform with ffmpeg's own.
This does alter the decoded output, although not to my ears.
The new output is closer to that produced by Real's "official" decoder,
and the decoder runs slightly faster.

 cook.c |   98
+++++++++++++++++++----------------------------------------------
 1 file changed, 30 insertions(+), 68 deletions(-)


Patch 4.
Simplify subband coefficient handling.
No effect on output.

 cook.c |   95
+++++++++++++++++++++++++++++------------------------------------
 1 file changed, 43 insertions(+), 52 deletions(-)


Patch 5.
Fixed point decoder.
A define in "cook.c" chooses between fixed and floating point
implementations.
With floating point, no efect on output.
With fixed point, output difference is about 0.25rms, max +-1, at 16bit.

 cook.c              |  279 +++++---------------------
 cook_fixp_mdct.h    |  545
++++++++++++++++++++++++++++++++++++++++++++++++++++
 cook_fixpoint.h     |  243 +++++++++++++++++++++++
 cook_float.h        |  226 +++++++++++++++++++++
 cookdata.h          |   66 ------
 cookdata_fixpoint.h |  433 +++++++++++++++++++++++++++++++++++++++++
 cookdata_float.h    |  113 ++++++++++
 7 files changed, 1614 insertions(+), 291 deletions(-)


regards,
Ian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1_drop.patch
Type: text/x-patch
Size: 427 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070308/b5512400/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2_gain.patch
Type: text/x-patch
Size: 8818 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070308/b5512400/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 3_mlt.patch
Type: text/x-patch
Size: 6666 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070308/b5512400/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 4_coef.patch
Type: text/x-patch
Size: 7596 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070308/b5512400/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 5_fixpoint.patch
Type: text/x-patch
Size: 81555 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070308/b5512400/attachment-0004.bin>



More information about the ffmpeg-devel mailing list