diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-12-19 21:50:33 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-12-19 21:50:33 +1100 |
| commit | 8a260dad05f068727e538092ef9c56e714a7edb4 (patch) | |
| tree | 1b35d431f0e85148ac211a2b6b3383123ec10239 /src/codecs/include | |
| parent | 62d51a304eb02f0eab0645488c0b922b4a45e1c9 (diff) | |
| download | tangara-fw-8a260dad05f068727e538092ef9c56e714a7edb4.tar.gz | |
Fix sample::FromSigned to not shift by a negative amount
Diffstat (limited to 'src/codecs/include')
| -rw-r--r-- | src/codecs/include/sample.hpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/codecs/include/sample.hpp b/src/codecs/include/sample.hpp index f77284bb..937b6b79 100644 --- a/src/codecs/include/sample.hpp +++ b/src/codecs/include/sample.hpp @@ -34,9 +34,9 @@ constexpr auto Clip(int64_t v) -> Sample { constexpr auto FromSigned(int32_t src, uint_fast8_t bits) -> Sample { if (bits > 16) { - return src << (sizeof(Sample) * 8 - bits); + return src >> (bits - sizeof(Sample) * 8); } else if (bits < 16) { - return src << (bits - (sizeof(Sample) * 8)); + return src << (sizeof(Sample) * 8 - bits); } return src; } |
