diff options
author | Erik de Castro Lopo <erikd@mega-nerd.com> | 2014-02-02 09:00:27 +1100 |
---|---|---|
committer | Erik de Castro Lopo <erikd@mega-nerd.com> | 2014-02-02 09:00:32 +1100 |
commit | 96011ffa60d0386d56c697c670ca5e5721c9ae83 (patch) | |
tree | 87edf6c0ac6d3de373c908a56874fe0640294fc6 /src/flac/encode.c | |
parent | 26b9546149845a28308d61d1c9c3f5e620d0a68b (diff) | |
download | flac-96011ffa60d0386d56c697c670ca5e5721c9ae83.tar.gz |
src/flac/encode.c : Improve perf of format_input() when compiled with MSVC.
MSVS profiler shows that the encoder spends too much time inside format_input()
when the input is 24-bit. Increases encoding speed:
FLAC -5: from 27.1 to 24.2 seconds
FLAC -8: from 76.2 to 73.1 seconds
(MSVS 2010, 32-bit flac.exe, 24-bit stereo input file)
For GCC compiles the encoding speed remains the same. I suspect that GCC is
smart enough to use strict aliasing rule to optimize the code, and MSVS doesn't
even know about it.
Path-from: lvqcl <lvqcl.mail@gmail.com>
Diffstat (limited to 'src/flac/encode.c')
-rw-r--r-- | src/flac/encode.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/flac/encode.c b/src/flac/encode.c index 04f20cec..50f05df4 100644 --- a/src/flac/encode.c +++ b/src/flac/encode.c @@ -2395,19 +2395,23 @@ FLAC__bool format_input(FLAC__int32 *dest[], unsigned wide_samples, FLAC__bool i unsigned b; for(b = sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) for(channel = 0; channel < channels; channel++, sample++) { - out[channel][wide_sample] = ucbuffer_[b++]; out[channel][wide_sample] <<= 8; - out[channel][wide_sample] |= ucbuffer_[b++]; out[channel][wide_sample] <<= 8; - out[channel][wide_sample] |= ucbuffer_[b++]; - out[channel][wide_sample] -= 0x800000; + FLAC__int32 t; + t = ucbuffer_[b++]; t <<= 8; + t |= ucbuffer_[b++]; t <<= 8; + t |= ucbuffer_[b++]; + t -= 0x800000; + out[channel][wide_sample] = t; } } else { unsigned b; for(b = sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) for(channel = 0; channel < channels; channel++, sample++) { - out[channel][wide_sample] = scbuffer_[b++]; out[channel][wide_sample] <<= 8; - out[channel][wide_sample] |= ucbuffer_[b++]; out[channel][wide_sample] <<= 8; - out[channel][wide_sample] |= ucbuffer_[b++]; + FLAC__int32 t; + t = scbuffer_[b++]; t <<= 8; + t |= ucbuffer_[b++]; t <<= 8; + t |= ucbuffer_[b++]; + out[channel][wide_sample] = t; } } } |