Attempt to fix differences between x86 FPU and SSE calculations.

The x86 FPU holds intermediate results in larger registers than what
the SSE unit uses, resulting in slighlty different encodings of audio
data. Attempt to fix this by modifying libFLAC/lpc.c to store calculation
results in a FLAC__read before adding it to a sum.

At the moment this works, but I could easily imagine a new version of
the compiler optimising this store to the FLAC__real away leaving us
in the same situation we have now.

Patch-from: Oliver Stöneberg on sourceforge.net
Closes: https://sourceforge.net/p/flac/bugs/409/
This commit is contained in:
Erik de Castro Lopo
2014-03-21 19:25:55 +11:00
parent bc2b8c6e16
commit 70b078cfd5

View File

@@ -99,7 +99,7 @@ void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], unsigned data_le
* this version tends to run faster because of better data locality
* ('data_len' is usually much larger than 'lag')
*/
FLAC__real d;
FLAC__real d, tmp;
unsigned sample, coeff;
const unsigned limit = data_len - lag;
@@ -110,13 +110,17 @@ void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], unsigned data_le
autoc[coeff] = 0.0;
for(sample = 0; sample <= limit; sample++) {
d = data[sample];
for(coeff = 0; coeff < lag; coeff++)
autoc[coeff] += d * data[sample+coeff];
for(coeff = 0; coeff < lag; coeff++) {
tmp = d * data[sample+coeff];
autoc[coeff] += tmp;
}
}
for(; sample < data_len; sample++) {
d = data[sample];
for(coeff = 0; coeff < data_len - sample; coeff++)
autoc[coeff] += d * data[sample+coeff];
for(coeff = 0; coeff < data_len - sample; coeff++) {
tmp = d * data[sample+coeff];
autoc[coeff] += tmp;
}
}
}