Skip to content
This repository was archived by the owner on May 7, 2020. It is now read-only.

Fix Pcm8 conversions #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/DspChunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,39 +29,39 @@ namespace SaneAudioRenderer
typename DspFormatTraits<OutputFormat>::SampleType& output);

template <>
__forceinline void ConvertSample<DspFormat::Pcm8, DspFormat::Pcm8>(const int8_t& input, int8_t& output)
__forceinline void ConvertSample<DspFormat::Pcm8, DspFormat::Pcm8>(const uint8_t& input, uint8_t& output)
{
output = input;
}

template <>
__forceinline void ConvertSample<DspFormat::Pcm8, DspFormat::Pcm16>(const int8_t& input, int16_t& output)
__forceinline void ConvertSample<DspFormat::Pcm8, DspFormat::Pcm16>(const uint8_t& input, int16_t& output)
{
output = (int16_t)input << 8;
output = ((int16_t)input - 0x80) << 8;
}

template <>
__forceinline void ConvertSample<DspFormat::Pcm8, DspFormat::Pcm24>(const int8_t& input, int24_t& output)
__forceinline void ConvertSample<DspFormat::Pcm8, DspFormat::Pcm24>(const uint8_t& input, int24_t& output)
{
PackPcm24((int32_t)input << 24, output);
PackPcm24(((int32_t)input - 0x80) << 24, output);
}

template <>
__forceinline void ConvertSample<DspFormat::Pcm8, DspFormat::Pcm32>(const int8_t& input, int32_t& output)
__forceinline void ConvertSample<DspFormat::Pcm8, DspFormat::Pcm32>(const uint8_t& input, int32_t& output)
{
output = (int32_t)input << 24;
output = ((int32_t)input - 0x80) << 24;
}

template <>
__forceinline void ConvertSample<DspFormat::Pcm8, DspFormat::Float>(const int8_t& input, float& output)
__forceinline void ConvertSample<DspFormat::Pcm8, DspFormat::Float>(const uint8_t& input, float& output)
{
output = (float)input / ((int32_t)INT8_MAX + 1);
output = ((int32_t)input - 0x80) / ((float)INT8_MAX + 1);
}

template <>
__forceinline void ConvertSample<DspFormat::Pcm8, DspFormat::Double>(const int8_t& input, double& output)
__forceinline void ConvertSample<DspFormat::Pcm8, DspFormat::Double>(const uint8_t& input, double& output)
{
output = (double)input / ((int32_t)INT8_MAX + 1);
output = ((int32_t)input - 0x80) / ((double)INT8_MAX + 1);
}

template <>
Expand Down
2 changes: 1 addition & 1 deletion src/DspFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace SaneAudioRenderer
template <>
struct DspFormatTraits<DspFormat::Pcm8>
{
typedef int8_t SampleType;
typedef uint8_t SampleType;
};

template <>
Expand Down