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
This commit is contained in:
parent
63475b5a68
commit
0153a78906
@ -407,11 +407,12 @@ FLAC__StreamDecoderWriteStatus flacWrite(const FLAC__SeekableStreamDecoder *dec,
|
|||||||
{
|
{
|
||||||
FlacData * data = (FlacData *)vdata;
|
FlacData * data = (FlacData *)vdata;
|
||||||
FLAC__uint32 samples = frame->header.blocksize;
|
FLAC__uint32 samples = frame->header.blocksize;
|
||||||
int c_samp;
|
FLAC__uint16 u16;
|
||||||
int c_chan;
|
unsigned char * uc;
|
||||||
|
int c_samp, c_chan, d_samp;
|
||||||
|
int i;
|
||||||
float timeChange;
|
float timeChange;
|
||||||
FLAC__uint64 newPosition = 0;
|
FLAC__uint64 newPosition = 0;
|
||||||
const int bytesPerSample = data->dc->audioFormat.bits/8;
|
|
||||||
|
|
||||||
timeChange = ((float)samples)/frame->header.sample_rate;
|
timeChange = ((float)samples)/frame->header.sample_rate;
|
||||||
data->time+= timeChange;
|
data->time+= timeChange;
|
||||||
@ -423,20 +424,13 @@ FLAC__StreamDecoderWriteStatus flacWrite(const FLAC__SeekableStreamDecoder *dec,
|
|||||||
}
|
}
|
||||||
data->position = newPosition;
|
data->position = newPosition;
|
||||||
|
|
||||||
for(c_samp = 0; c_samp < frame->header.blocksize; c_samp++) {
|
for(c_samp = d_samp = 0; c_samp < frame->header.blocksize; c_samp++) {
|
||||||
for(c_chan = 0; c_chan < frame->header.channels; c_chan++) {
|
for(c_chan = 0; c_chan < frame->header.channels;
|
||||||
#ifdef WORDS_BIGENDIAN
|
c_chan++, d_samp++) {
|
||||||
memcpy(data->chunk+data->chunk_length,
|
u16 = buf[c_chan][c_samp];
|
||||||
&buf[c_chan][c_samp]+4-bytesPerSample,
|
uc = (unsigned char *)&u16;
|
||||||
bytesPerSample);
|
for(i=0;i<(data->dc->audioFormat.bits/8);i++) {
|
||||||
data->chunk_length+=bytesPerSample;
|
if(data->chunk_length>=FLAC_CHUNK_SIZE) {
|
||||||
#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) {
|
if(flacSendChunk(data)<0) {
|
||||||
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
||||||
}
|
}
|
||||||
@ -445,6 +439,8 @@ FLAC__StreamDecoderWriteStatus flacWrite(const FLAC__SeekableStreamDecoder *dec,
|
|||||||
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
data->chunk[data->chunk_length++] = *(uc++);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user