diff --git a/NEWS b/NEWS index f21b4224c..cb932c430 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ ver 0.20.12 (not yet released) * input - curl: fix seeking +* decoder + - vorbis: fix Tremor support * player - log message when decoder is too slow diff --git a/src/decoder/plugins/VorbisDecoderPlugin.cxx b/src/decoder/plugins/VorbisDecoderPlugin.cxx index a01a92d31..4c86b3cab 100644 --- a/src/decoder/plugins/VorbisDecoderPlugin.cxx +++ b/src/decoder/plugins/VorbisDecoderPlugin.cxx @@ -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; } }