shithub: opusfile

Download patch

ref: 7b49904805150793a0cb8a9219da60b1bb276877
parent: bf06c4f2ede23e23ff92ee9fb0fbedd84e69fb01
author: Timothy B. Terriberry <[email protected]>
date: Fri Apr 5 17:06:28 EDT 2013

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).

--- a/src/internal.h
+++ b/src/internal.h
@@ -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 @@
 # 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
--- a/src/opusfile.c
+++ b/src/opusfile.c
@@ -1333,7 +1333,7 @@
   _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;