Commit 8c2bde70 authored by Max Kellermann's avatar Max Kellermann

flac: added optimized converter for 16 bit

flac_convert_16() runs a lot faster than the generic (and quite buggy) function flac_convert(). flac_convert_16() is only used for non-stereo files, since there is already flac_convert_stereo16().
parent 7486c150
......@@ -219,6 +219,19 @@ static void flac_convert_stereo16(int16_t *dest,
}
}
static void
flac_convert_16(int16_t *dest,
unsigned int num_channels,
const FLAC__int32 * const buf[],
unsigned int position, unsigned int end)
{
unsigned int c_chan;
for (; position < end; ++position)
for (c_chan = 0; c_chan < num_channels; c_chan++)
*dest++ = buf[c_chan][position];
}
static void flac_convert(unsigned char *dest,
unsigned int num_channels,
unsigned int bytes_per_sample,
......@@ -265,6 +278,10 @@ flac_common_write(FlacData *data, const FLAC__Frame * frame,
flac_convert_stereo16((int16_t*)data->chunk,
buf, c_samp,
c_samp + num_samples);
else if (bytes_per_sample == 2)
flac_convert_16((int16_t*)data->chunk,
num_channels, buf, c_samp,
c_samp + num_samples);
else
flac_convert(data->chunk,
num_channels, bytes_per_sample, buf,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment