I've been asked to elaborate a bit on Replay Gain and the issues surrounding it, as they relate to MAD and LAME.
The Replay Gain proposed standard was set forth in 2001 by David Robinson and can be viewed here:
First it's important to understand that Replay Gain has absolutely no bearing on the libmad proper; it doesn't affect the actual decoding process whatsoever, and libmad has no knowledge of Replay Gain structures or semantics.
By cooperative agreement with encoders and other tools, applications can use Replay Gain information to adjust the volume of decoded audio to achieve approximately equal loudness across an entire collection of music. madplay does this when enabled with the -G (--replay-gain) option.
The proposed standard describes a method for computing Replay Gain adjustments, which in any case are just decibel scalefactors. Essentially the energy of the encoded signal is calibrated against a reference level, and the difference is stored as the Replay Gain adjustment value. The reference level set forth in the proposed standard is the SMPTE-sanctioned 83 dB SPL, representing a comfortable average listening level.
When Replay Gain is enabled, players are encouraged to supply a default pre-amp gain of at least +6 dB in addition to the Replay Gain adjustment. This is so pop music for example does not sound too quiet, but the pre-amp might be reduced or disabled for other types of music. madplay supports this with the existing -a (--amplify, --attenuate) option, which now has a default value of +6 dB when Replay Gain is enabled.
Replay Gain information can be stored in a variety of possible locations, for example in an ID3v2 tag. Recent versions of LAME automatically compute Replay Gain data and store it in the LAME info tag:
http://gabriel.mp3-tech.org/mp3infotag.html
When enabled, madplay reads and honors Replay Gain from either of these locations.
So what was the purpose of the changes in madplay 0.15.2b?
It turns out that versions of LAME since 3.95.1 do not strictly follow the Replay Gain proposed standard. Instead of using the specified 83 dB SPL reference level (as LAME did in version 3.95) LAME now uses a reference of 89 dB SPL. That means the Replay Gain adjustment computed by LAME is now 6 dB greater than what is specified by the proposed standard, and players that implement the recommended pre-amp gain on top of that will amplify the signal too much -- and often cause clipping.
Why did LAME do this? According to Gabriel Bouvigne, one of the LAME developers, "we had a discussion about it with David (ReplayGain author), and reached the conclusion that as the vast majority of implementations are using 89dB, we should take this infortunate situation into consideration and update the standard to 89dB." (But to my knowledge the proposed standard has yet to be updated.)
The unfortunate effect of this heresy is that players have to know what reference value the Replay Gain adjustment was computed relative to, for it can no longer be assumed to be the 83 dB SPL specified in the proposed standard. Accordingly, special logic was added to madplay to detect LAME tags written since 3.95.1.
And there you have it.
Cheers,