pcm/FloatConvert: add static_assert
on the factor
This assertion currently fails for S32 due to integer overflow (#380).
This commit is contained in:
parent
7aa1dceef6
commit
b0a6a569df
@ -35,6 +35,7 @@ struct FloatToIntegerSampleConvert {
|
|||||||
typedef typename DstTraits::value_type DV;
|
typedef typename DstTraits::value_type DV;
|
||||||
|
|
||||||
static constexpr SV factor = 1 << (DstTraits::BITS - 1);
|
static constexpr SV factor = 1 << (DstTraits::BITS - 1);
|
||||||
|
static_assert(factor > 0, "Wrong factor");
|
||||||
|
|
||||||
gcc_const
|
gcc_const
|
||||||
static DV Convert(SV src) noexcept {
|
static DV Convert(SV src) noexcept {
|
||||||
@ -54,6 +55,7 @@ struct IntegerToFloatSampleConvert {
|
|||||||
typedef typename DstTraits::value_type DV;
|
typedef typename DstTraits::value_type DV;
|
||||||
|
|
||||||
static constexpr DV factor = 0.5 / (1 << (SrcTraits::BITS - 2));
|
static constexpr DV factor = 0.5 / (1 << (SrcTraits::BITS - 2));
|
||||||
|
static_assert(factor > 0, "Wrong factor");
|
||||||
|
|
||||||
gcc_const
|
gcc_const
|
||||||
static DV Convert(SV src) noexcept {
|
static DV Convert(SV src) noexcept {
|
||||||
|
Loading…
Reference in New Issue
Block a user