aboutsummaryrefslogtreecommitdiffstats
path: root/src/pcm/PcmResampleLibsamplerate.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-11-23 18:45:02 +0100
committerMax Kellermann <max@duempel.org>2013-11-23 18:45:02 +0100
commit99527051b5751d2ef7c6b593f1beda84d1bcc33f (patch)
tree39b08616c597fc173022164050ed557650c177b5 /src/pcm/PcmResampleLibsamplerate.cxx
parentbed98303a346dd98e2a239579c032d170440441d (diff)
parent57e0cc54424561499039967aa501c17d4b179019 (diff)
downloadmpd-99527051b5751d2ef7c6b593f1beda84d1bcc33f.tar.gz
mpd-99527051b5751d2ef7c6b593f1beda84d1bcc33f.tar.xz
mpd-99527051b5751d2ef7c6b593f1beda84d1bcc33f.zip
Merge branch 'v0.18.x'
Diffstat (limited to 'src/pcm/PcmResampleLibsamplerate.cxx')
-rw-r--r--src/pcm/PcmResampleLibsamplerate.cxx25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/pcm/PcmResampleLibsamplerate.cxx b/src/pcm/PcmResampleLibsamplerate.cxx
index 1986e8821..9eac2d545 100644
--- a/src/pcm/PcmResampleLibsamplerate.cxx
+++ b/src/pcm/PcmResampleLibsamplerate.cxx
@@ -19,6 +19,7 @@
#include "config.h"
#include "PcmResampleInternal.hxx"
+#include "PcmUtils.hxx"
#include "util/ASCII.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
@@ -283,3 +284,27 @@ pcm_resample_lsr_32(PcmResampler *state,
return dest_buffer;
}
+
+const int32_t *
+pcm_resample_lsr_24(PcmResampler *state,
+ unsigned channels,
+ unsigned src_rate,
+ const int32_t *src_buffer, size_t src_size,
+ unsigned dest_rate, size_t *dest_size_r,
+ Error &error)
+{
+ const auto result = pcm_resample_lsr_32(state, channels,
+ src_rate, src_buffer, src_size,
+ dest_rate, dest_size_r,
+ error);
+ if (result != nullptr)
+ /* src_float_to_int_array() clamps for 32 bit
+ integers; now make sure everything's fine for 24
+ bit */
+ /* TODO: eliminate the 32 bit clamp to reduce overhead */
+ PcmClampN<int32_t, int32_t, 24>(const_cast<int32_t *>(result),
+ result,
+ *dest_size_r / sizeof(*result));
+
+ return result;
+}