aboutsummaryrefslogtreecommitdiffstats
path: root/src/pcm/Traits.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-12-02 11:45:03 +0100
committerMax Kellermann <max@duempel.org>2013-12-02 11:48:10 +0100
commitc6ef0e88879d2cd203a74cfda2a574e949486877 (patch)
tree8c20019846a355f23c3a6bf9d7c0e48e1fdb5ea3 /src/pcm/Traits.hxx
parentf761d583b579e4bdfe3013b52a46a76a8f31abf8 (diff)
downloadmpd-c6ef0e88879d2cd203a74cfda2a574e949486877.tar.gz
mpd-c6ef0e88879d2cd203a74cfda2a574e949486877.tar.xz
mpd-c6ef0e88879d2cd203a74cfda2a574e949486877.zip
pcm/Traits: add typedef "sum_type"
Allow 32 bit platforms to use 32 bit instead of 64 bit for summing 24 bit samples.
Diffstat (limited to 'src/pcm/Traits.hxx')
-rw-r--r--src/pcm/Traits.hxx11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/pcm/Traits.hxx b/src/pcm/Traits.hxx
index 7212b2dd6..0ec4aaf0a 100644
--- a/src/pcm/Traits.hxx
+++ b/src/pcm/Traits.hxx
@@ -51,6 +51,13 @@ struct SampleTraits<SampleFormat::S8> {
typedef const value_type *const_pointer_type;
/**
+ * A "long" type that is large and accurate enough for adding
+ * two values without risking an (integer) overflow or
+ * (floating point) precision loss.
+ */
+ typedef int sum_type;
+
+ /**
* A "long" type that is large and accurate enough for
* arithmetic without risking an (integer) overflow or
* (floating point) precision loss.
@@ -75,6 +82,7 @@ struct SampleTraits<SampleFormat::S16> {
typedef value_type *pointer_type;
typedef const value_type *const_pointer_type;
+ typedef int_least32_t sum_type;
typedef int_least32_t long_type;
static constexpr size_t SAMPLE_SIZE = sizeof(value_type);
@@ -87,6 +95,7 @@ struct SampleTraits<SampleFormat::S32> {
typedef value_type *pointer_type;
typedef const value_type *const_pointer_type;
+ typedef int_least64_t sum_type;
typedef int_least64_t long_type;
static constexpr size_t SAMPLE_SIZE = sizeof(value_type);
@@ -99,6 +108,7 @@ struct SampleTraits<SampleFormat::S24_P32> {
typedef value_type *pointer_type;
typedef const value_type *const_pointer_type;
+ typedef int_least32_t sum_type;
typedef int_least64_t long_type;
static constexpr size_t SAMPLE_SIZE = sizeof(value_type);
@@ -111,6 +121,7 @@ struct SampleTraits<SampleFormat::FLOAT> {
typedef value_type *pointer_type;
typedef const value_type *const_pointer_type;
+ typedef float sum_type;
typedef float long_type;
static constexpr size_t SAMPLE_SIZE = sizeof(value_type);