Commit 7b499048 authored by Timothy B. Terriberry's avatar Timothy B. Terriberry

Small cleanups of the soft clipping code.

- Made OP_SOFT_CLIP defined only when using floating point (libopus
   handles clipping when using the fixed-point API).
- Struct rearrangement for theoretically better packing on some
   platforms.
- Reset the state tracking channel count when re-initializing a
   decoder (and not the dither mute, because that gets reset for
   free).
parent bf06c4f2
......@@ -32,17 +32,22 @@
# include <opusfile.h>
typedef struct OggOpusLink OggOpusLink;
# if defined(OP_FIXED_POINT)
typedef opus_int16 op_sample;
# else
typedef float op_sample;
# endif
/*We're using this define to test for libopus 1.1 or later until libopus
provides a better mechanism.*/
# if defined(OPUS_GET_EXPERT_FRAME_DURATION_REQUEST)
# if defined(OPUS_GET_EXPERT_FRAME_DURATION_REQUEST)
/*Enable soft clipping prevention in 16-bit decodes.*/
# define OP_SOFT_CLIP (1)
# define OP_SOFT_CLIP (1)
# endif
# endif
# if OP_GNUC_PREREQ(4,2)
......@@ -217,8 +222,8 @@ struct OggOpusFile{
# endif
float dither_a[OP_NCHANNELS_MAX*4];
float dither_b[OP_NCHANNELS_MAX*4];
int dither_mute;
opus_uint32 dither_seed;
int dither_mute;
/*The number of channels represented by the internal state.
This gets set to 0 whenever anything that would prevent state propagation
occurs (switching between the float/short APIs, or between the
......
......@@ -1333,7 +1333,7 @@ static int op_make_decode_ready(OggOpusFile *_of){
_of->bytes_tracked=0;
_of->samples_tracked=0;
#if !defined(OP_FIXED_POINT)
_of->dither_mute=65;
_of->state_channel_count=0;
/*Use the serial number for the PRNG seed to get repeatable output for
straight play-throughs.*/
_of->dither_seed=_of->links[li].serialno;
......
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