I noticed that 32-bit flac (from git) compiled with GCC 4.8.3 or 4.9.0 calculates incorrect ReplayGain values. The most common value it produces is -55.17 dB. It is possible to avoid this bug by compiling src/share/replaygain_analysis/replaygain_analysis.c a) either without -msse2 option b) or with -O2 instead of -O3 c) another solution is to add -mfpmath=sse option along with -msse2. For GCC 4.9.0 it's enough to add __attribute__ ((__target__ ("arch=i686"))) or __attribute__ ((__target__ ("fpmath=sse"))) to the following functions in replaygain_analysis.c: analyzeResult(), GetTitleGain() and GetAlbumGain(). Can anybody confirm this?
lvqcl
2014-Jun-01 10:58 UTC
[flac-dev] [PATCH] Re: Bug in FLAC or in GCC or somewhere else?
lvqcl wrote:> I noticed that 32-bit flac (from git) compiled with GCC 4.8.3 or 4.9.0 > calculates incorrect ReplayGain values. The most common value it produces > is -55.17 dB.It seems that it's a bug in GCC: it cannot correctly calculate the value of 'elems * (1. - RMS_PERCENTILE)' in the line upper = (Int32_t) ceil (elems * (1. - RMS_PERCENTILE)); Since elems * (1. - RMS_PERCENTILE) == elems * (1. - 0.95) = == elems * 0.05 == elems / 20.0 it is possible to replace ceil(...) with (elems / 20 + (elems % 20) ? 1 : 0). Patch attached. -------------- next part -------------- A non-text attachment was scrubbed... Name: rg_analysis.patch Type: application/octet-stream Size: 749 bytes Desc: not available Url : http://lists.xiph.org/pipermail/flac-dev/attachments/20140601/67c1035e/attachment.obj
Erik de Castro Lopo
2014-Jun-15 10:35 UTC
[flac-dev] [PATCH] Re: Bug in FLAC or in GCC or somewhere else?
lvqcl wrote:> It seems that it's a bug in GCC: it cannot correctly calculate the value > of 'elems * (1. - RMS_PERCENTILE)' in the line > > upper = (Int32_t) ceil (elems * (1. - RMS_PERCENTILE)); > > Since elems * (1. - RMS_PERCENTILE) == elems * (1. - 0.95) => == elems * 0.05 == elems / 20.0 it is possible to replace ceil(...) > with (elems / 20 + (elems % 20) ? 1 : 0). > > Patch attached.Patch applied. Thanks, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/