aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2005-12-31 03:40:03 +0000
committerEric Wong <normalperson@yhbt.net>2005-12-31 03:40:03 +0000
commit0153a78906ca1e57961ea10e8a61cc11ca04e985 (patch)
treeefdcbfee9cd08ed4798b791a5be4727302a6187f /src
parent63475b5a684a5e622e22172e0cc22895e88a03c1 (diff)
downloadmpd-0153a78906ca1e57961ea10e8a61cc11ca04e985.tar.gz
mpd-0153a78906ca1e57961ea10e8a61cc11ca04e985.tar.xz
mpd-0153a78906ca1e57961ea10e8a61cc11ca04e985.zip
flac_plugin: revert the performance optimization we did a while ago
the performance optimization was broken for big-endian architectures. mpd-uclinux is doing using a slightly different optimization to flacWrite() that we may end up using here in the future. git-svn-id: https://svn.musicpd.org/mpd/trunk@3753 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/inputPlugins/flac_plugin.c42
1 files changed, 19 insertions, 23 deletions
diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c
index 6be7f43b3..455394888 100644
--- a/src/inputPlugins/flac_plugin.c
+++ b/src/inputPlugins/flac_plugin.c
@@ -407,11 +407,12 @@ FLAC__StreamDecoderWriteStatus flacWrite(const FLAC__SeekableStreamDecoder *dec,
{
FlacData * data = (FlacData *)vdata;
FLAC__uint32 samples = frame->header.blocksize;
- int c_samp;
- int c_chan;
+ FLAC__uint16 u16;
+ unsigned char * uc;
+ int c_samp, c_chan, d_samp;
+ int i;
float timeChange;
FLAC__uint64 newPosition = 0;
- const int bytesPerSample = data->dc->audioFormat.bits/8;
timeChange = ((float)samples)/frame->header.sample_rate;
data->time+= timeChange;
@@ -423,27 +424,22 @@ FLAC__StreamDecoderWriteStatus flacWrite(const FLAC__SeekableStreamDecoder *dec,
}
data->position = newPosition;
- for(c_samp = 0; c_samp < frame->header.blocksize; c_samp++) {
- for(c_chan = 0; c_chan < frame->header.channels; c_chan++) {
-#ifdef WORDS_BIGENDIAN
- memcpy(data->chunk+data->chunk_length,
- &buf[c_chan][c_samp]+4-bytesPerSample,
- bytesPerSample);
- data->chunk_length+=bytesPerSample;
-#else
- memcpy(data->chunk+data->chunk_length,
- &buf[c_chan][c_samp], bytesPerSample);
- data->chunk_length+=bytesPerSample;
-#endif
- if(FLAC_CHUNK_SIZE-data->chunk_length < bytesPerSample)
- {
- if(flacSendChunk(data)<0) {
- return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
- }
- data->chunk_length = 0;
- if(data->dc->seek) {
- return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
+ for(c_samp = d_samp = 0; c_samp < frame->header.blocksize; c_samp++) {
+ for(c_chan = 0; c_chan < frame->header.channels;
+ c_chan++, d_samp++) {
+ u16 = buf[c_chan][c_samp];
+ uc = (unsigned char *)&u16;
+ for(i=0;i<(data->dc->audioFormat.bits/8);i++) {
+ if(data->chunk_length>=FLAC_CHUNK_SIZE) {
+ if(flacSendChunk(data)<0) {
+ return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
+ }
+ data->chunk_length = 0;
+ if(data->dc->seek) {
+ return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
+ }
}
+ data->chunk[data->chunk_length++] = *(uc++);
}
}
}