[ scummvm-Patches-1717419 ] Optimisation for sound rate conversion code

SourceForge.net noreply at sourceforge.net
Fri May 11 21:00:01 CEST 2007


Patches item #1717419, was opened at 2007-05-11 19:00
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=418822&aid=1717419&group_id=37116

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Robin Watts (robinwatts)
Assigned to: Nobody/Anonymous (nobody)
Summary: Optimisation for sound rate conversion code

Initial Comment:
This patch introduces various optimisations in the sound rate conversion code. Although inspired mainly by the needs of the WinCE port, the optimisations in here apply to all platforms.

The first change is to the "LinearRateController" class; we amalgamate the opos and ipos members by storing "opos-ipos" in opos. This means one less member to have to keep reading/writing, and tests simply become against zero.

Next, we remove the loop for reading samples and replace it with a simple if. (This is partly a personal taste thing, and partly down to my distrust of compilers; I trust a compiler to remove an if when the templated variable says it's never needed much more than I trust it to remove a loop).

The logic forming the "out" values is also simplified a bit - again in an effort to ease the compilers task when optimising for the different instances of the template.

The next change is to both the "LinearRateController" and "CopyRateController" classes; we spot the case where vol_l and vol_r are both full, and handle this in a separate loop. In this case we can avoid the per sample multiplication/division.

The final change is to introduce a new rate control method that is used when the inrate is a direct multiple of the output rate. This "SimpleRateController" does exactly what the "LinearRateController" did, but dispenses with the need to interpolate.

The SimpleRateController is basically a copy of the LinearRateController code with the interpolation logic removed, and a few simple optimisations done.

My tests seem to indicate that the most games (DOTT, BS1, MI1, DIG, STS) either play audio at the intended rate, or an exact multiple of it, and a significant amount of that time appears to be at full volume.

Only BASS (out of the games I have tested) needs rate interpolation, so it makes sense to relieve the processor of that burden when it is unnecessary.

I hope this all makes sense and adequately describes the changes. If not, please let me know.

Robin


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=418822&aid=1717419&group_id=37116




More information about the Scummvm-tracker mailing list