aboutsummaryrefslogtreecommitdiffstats
path: root/src/pcm/PcmFormat.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/pcm/PcmFormat.cxx')
-rw-r--r--src/pcm/PcmFormat.cxx51
1 files changed, 3 insertions, 48 deletions
diff --git a/src/pcm/PcmFormat.cxx b/src/pcm/PcmFormat.cxx
index 4565c71c6..a0e0bb2de 100644
--- a/src/pcm/PcmFormat.cxx
+++ b/src/pcm/PcmFormat.cxx
@@ -22,51 +22,7 @@
#include "PcmDither.hxx"
#include "PcmBuffer.hxx"
#include "PcmUtils.hxx"
-
-#include <type_traits>
-
-template<SampleFormat F>
-struct SampleTraits {};
-
-template<>
-struct SampleTraits<SampleFormat::S8> {
- typedef int8_t value_type;
- typedef value_type *pointer_type;
- typedef const value_type *const_pointer_type;
-
- static constexpr size_t SAMPLE_SIZE = sizeof(value_type);
- static constexpr unsigned BITS = sizeof(value_type) * 8;
-};
-
-template<>
-struct SampleTraits<SampleFormat::S16> {
- typedef int16_t value_type;
- typedef value_type *pointer_type;
- typedef const value_type *const_pointer_type;
-
- static constexpr size_t SAMPLE_SIZE = sizeof(value_type);
- static constexpr unsigned BITS = sizeof(value_type) * 8;
-};
-
-template<>
-struct SampleTraits<SampleFormat::S32> {
- typedef int32_t value_type;
- typedef value_type *pointer_type;
- typedef const value_type *const_pointer_type;
-
- static constexpr size_t SAMPLE_SIZE = sizeof(value_type);
- static constexpr unsigned BITS = sizeof(value_type) * 8;
-};
-
-template<>
-struct SampleTraits<SampleFormat::S24_P32> {
- typedef int32_t value_type;
- typedef value_type *pointer_type;
- typedef const value_type *const_pointer_type;
-
- static constexpr size_t SAMPLE_SIZE = sizeof(value_type);
- static constexpr unsigned BITS = 24;
-};
+#include "Traits.hxx"
static void
pcm_convert_8_to_16(int16_t *out, const int8_t *in, const int8_t *in_end)
@@ -100,8 +56,8 @@ ConvertFromFloat(typename Traits::pointer_type dest,
const float factor = 1 << (bits - 1);
while (src != end) {
- int sample(*src++ * factor);
- *dest++ = PcmClamp<typename Traits::value_type, int, bits>(sample);
+ typename Traits::long_type sample(*src++ * factor);
+ *dest++ = PcmClamp<F, Traits>(sample);
}
}
@@ -442,7 +398,6 @@ ConvertToFloat(float *dest,
constexpr float factor = 0.5 / (1 << (Traits::BITS - 2));
while (src != end)
*dest++ = float(*src++) * factor;
-
}
template<SampleFormat F, class Traits=SampleTraits<F>>