Commit 3b23cf02 authored by Marcin Jurkowski's avatar Marcin Jurkowski Committed by Max Kellermann

decoder/vorbis: scale and clip tremor-decoded samples to 15 bits

Tremor decoder is unusable since commit 2ee43c40. Sound is distorted to the point where it's nothing but noise. The data from vorbis_synthesis_pcmout() needs to be scaled and clipped for 16 bit sample size. For reference see http://lists.xiph.org/pipermail/tremor/2010-April/001642.html and http://lists.xiph.org/pipermail/vorbis/2006-October/026513.html. Signed-off-by: 's avatarMarcin Jurkowski <marcin1j@gmail.com>
parent 28e864e0
ver 0.20.12 (not yet released)
* input
- curl: fix seeking
* decoder
- vorbis: fix Tremor support
* player
- log message when decoder is too slow
......
......@@ -178,6 +178,20 @@ VorbisDecoder::SubmitInit()
client.Ready(audio_format, eos_granulepos > 0, duration);
}
#ifdef HAVE_TREMOR
static inline int16_t tremor_clip_sample(int32_t x)
{
x >>= 9;
if (x < INT16_MIN)
return INT16_MIN;
if (x > INT16_MAX)
return INT16_MAX;
return x;
}
#endif
bool
VorbisDecoder::SubmitSomePcm()
{
......@@ -197,7 +211,7 @@ VorbisDecoder::SubmitSomePcm()
auto *dest = &buffer[c];
for (size_t i = 0; i < n_frames; ++i) {
*dest = *src++;
*dest = tremor_clip_sample(*src++);
dest += channels;
}
}
......
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