diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2013-03-01 15:18:23 -0500 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2013-03-01 15:23:01 -0500 |
commit | 32c4a0c96e239bee7623aef8ae592a5c7f7ec753 (patch) | |
tree | a0125b967107e50702851b1bb7007a18ee01e23f /include | |
parent | 69c3dcd105432a72220478cbde851cc7917e5768 (diff) | |
download | opus-32c4a0c96e239bee7623aef8ae592a5c7f7ec753.tar.gz |
Applies soft-clipping to the int decoder API.
opus_decode() and opus_multistream_decode() now apply soft clipping
before converting to 16-bit int. This should produce better a higher
quality result than hard clipping like we were doing before. The _float()
API isn't affected, but the clipping function is exported so users can
manually apply the soft clipping.
Diffstat (limited to 'include')
-rw-r--r-- | include/opus.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/opus.h b/include/opus.h index 02033a9d..180146ae 100644 --- a/include/opus.h +++ b/include/opus.h @@ -592,6 +592,20 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_samples(const unsigne * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type */ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_nb_samples(const OpusDecoder *dec, const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2); + +/** Applies soft-clipping to bring a float signal within the [-1,1] range. If + * the signal is already in that range, nothing is done. If there are values + * outside of [-1,1], then the signal is clipped as smoothly as possible to + * both fit in the range and avoid creating excessive distortion in the + * process. + * @param [in,out] pcm <tt>float*</tt>: Input PCM and modified PCM + * @param [in] frame_size <tt>int</tt> Number of samples per channel to process + * @param [in] channels <tt>int</tt>: Number of channels + * @param [in,out] softclip_mem <tt>float*</tt>: State memory for the soft clipping process + */ +OPUS_EXPORT void opus_soft_clip(float *pcm, int frame_size, int channels, float *softclip_mem); + + /**@}*/ /** @defgroup opus_repacketizer Repacketizer |