diff options
author | Max Kellermann <max@duempel.org> | 2008-09-23 23:59:55 +0200 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-09-29 01:51:39 -0700 |
commit | 3c2c329e8450f59ccafb6ab973948d5da05951e5 (patch) | |
tree | 9b4ae238ce3af690149f0c93a50a0dd1beff112e /src | |
parent | 5947658caddf0de8288fbae43afaee3c75003ecd (diff) | |
download | mpd-3c2c329e8450f59ccafb6ab973948d5da05951e5.tar.gz mpd-3c2c329e8450f59ccafb6ab973948d5da05951e5.tar.xz mpd-3c2c329e8450f59ccafb6ab973948d5da05951e5.zip |
flac: added special functions for 8 and 32 bit
Same optimization for 8 and 32 bit files, like the previous patch for
16 bit. Along the way, this patch adds 24 bit FLAC support!
Diffstat (limited to 'src')
-rw-r--r-- | src/inputPlugins/_flac_common.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/inputPlugins/_flac_common.c b/src/inputPlugins/_flac_common.c index 7ccdce1ac..aedd78396 100644 --- a/src/inputPlugins/_flac_common.c +++ b/src/inputPlugins/_flac_common.c @@ -227,6 +227,35 @@ flac_convert_16(int16_t *dest, *dest++ = buf[c_chan][position]; } +/** + * Note: this function also handles 24 bit files! + */ +static void +flac_convert_32(int32_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_8(int8_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, @@ -276,6 +305,14 @@ flac_common_write(FlacData *data, const FLAC__Frame * frame, flac_convert_16((int16_t*)data->chunk, num_channels, buf, c_samp, c_samp + num_samples); + else if (bytes_per_sample == 4) + flac_convert_32((int32_t*)data->chunk, + num_channels, buf, c_samp, + c_samp + num_samples); + else if (bytes_per_sample == 1) + flac_convert_8((int8_t*)data->chunk, + num_channels, buf, c_samp, + c_samp + num_samples); else flac_convert(data->chunk, num_channels, bytes_per_sample, buf, |