aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-23 23:59:55 +0200
committerEric Wong <normalperson@yhbt.net>2008-09-29 01:51:18 -0700
commit5947658caddf0de8288fbae43afaee3c75003ecd (patch)
tree7201c2196af264390edb0916d380d8919fe35b7e /src
parent1fb82d55a7a1d2c378cab79b03342b8ac471ab64 (diff)
downloadmpd-5947658caddf0de8288fbae43afaee3c75003ecd.tar.gz
mpd-5947658caddf0de8288fbae43afaee3c75003ecd.tar.xz
mpd-5947658caddf0de8288fbae43afaee3c75003ecd.zip
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().
Diffstat (limited to 'src')
-rw-r--r--src/inputPlugins/_flac_common.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/inputPlugins/_flac_common.c b/src/inputPlugins/_flac_common.c
index 3085660b3..7ccdce1ac 100644
--- a/src/inputPlugins/_flac_common.c
+++ b/src/inputPlugins/_flac_common.c
@@ -214,6 +214,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,
@@ -259,6 +272,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,