Commit 28ad79c9 authored by Max Kellermann's avatar Max Kellermann

pcm/Traits: add typedef long_type

parent 7661ad66
...@@ -51,6 +51,13 @@ struct SampleTraits<SampleFormat::S8> { ...@@ -51,6 +51,13 @@ struct SampleTraits<SampleFormat::S8> {
typedef const value_type *const_pointer_type; typedef const value_type *const_pointer_type;
/** /**
* A "long" type that is large and accurate enough for
* arithmetic without risking an (integer) overflow or
* (floating point) precision loss.
*/
typedef int long_type;
/**
* The size of one sample in bytes. * The size of one sample in bytes.
*/ */
static constexpr size_t SAMPLE_SIZE = sizeof(value_type); static constexpr size_t SAMPLE_SIZE = sizeof(value_type);
...@@ -68,6 +75,8 @@ struct SampleTraits<SampleFormat::S16> { ...@@ -68,6 +75,8 @@ struct SampleTraits<SampleFormat::S16> {
typedef value_type *pointer_type; typedef value_type *pointer_type;
typedef const value_type *const_pointer_type; typedef const value_type *const_pointer_type;
typedef int long_type;
static constexpr size_t SAMPLE_SIZE = sizeof(value_type); static constexpr size_t SAMPLE_SIZE = sizeof(value_type);
static constexpr unsigned BITS = sizeof(value_type) * 8; static constexpr unsigned BITS = sizeof(value_type) * 8;
}; };
...@@ -78,6 +87,8 @@ struct SampleTraits<SampleFormat::S32> { ...@@ -78,6 +87,8 @@ struct SampleTraits<SampleFormat::S32> {
typedef value_type *pointer_type; typedef value_type *pointer_type;
typedef const value_type *const_pointer_type; typedef const value_type *const_pointer_type;
typedef int64_t long_type;
static constexpr size_t SAMPLE_SIZE = sizeof(value_type); static constexpr size_t SAMPLE_SIZE = sizeof(value_type);
static constexpr unsigned BITS = sizeof(value_type) * 8; static constexpr unsigned BITS = sizeof(value_type) * 8;
}; };
...@@ -88,6 +99,8 @@ struct SampleTraits<SampleFormat::S24_P32> { ...@@ -88,6 +99,8 @@ struct SampleTraits<SampleFormat::S24_P32> {
typedef value_type *pointer_type; typedef value_type *pointer_type;
typedef const value_type *const_pointer_type; typedef const value_type *const_pointer_type;
typedef int long_type;
static constexpr size_t SAMPLE_SIZE = sizeof(value_type); static constexpr size_t SAMPLE_SIZE = sizeof(value_type);
static constexpr unsigned BITS = 24; static constexpr unsigned BITS = 24;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment