Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2012-01-31 11:03:39 +0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2012-01-31 11:18:05 +0400
commit66820f350d14fa3a65b73b6f1c2be1eb03ba47f3 (patch)
treea6e890bbd82619665e8ebc06b8229eed70439d49
parent54518c879a6541eab749bc19628f1795daaad1e3 (diff)
Tweaks the CELT fractional resampling delay to get perfect alignment
Also using the same int->float conversion functions for SILK as for CELT and changed encoder implementation default to constrained VBR just to be safe when VBR gets more aggressive.
-rw-r--r--celt/celt.c3
-rw-r--r--celt/float_cast.h3
-rw-r--r--silk/float/SigProc_FLP.h15
-rw-r--r--src/opus_encoder.c2
4 files changed, 10 insertions, 13 deletions
diff --git a/celt/celt.c b/celt/celt.c
index eeed05a0..6c1eb6b8 100644
--- a/celt/celt.c
+++ b/celt/celt.c
@@ -472,9 +472,10 @@ static void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsa
x++;
/* Technically the store could be moved outside of the if because
the stores we don't want will just be overwritten */
+ if (count==0)
+ *y = SCALEOUT(SIG2WORD16(tmp));
if (++count==downsample)
{
- *y = SCALEOUT(SIG2WORD16(tmp));
y+=C;
count=0;
}
diff --git a/celt/float_cast.h b/celt/float_cast.h
index 39f63d42..079307a0 100644
--- a/celt/float_cast.h
+++ b/celt/float_cast.h
@@ -29,6 +29,9 @@
#ifndef FLOAT_CAST_H
#define FLOAT_CAST_H
+
+#include "arch.h"
+
/*============================================================================
** On Intel Pentium processors (especially PIII and probably P4), converting
** from float to int is very slow. To meet the C specs, the code produced by
diff --git a/silk/float/SigProc_FLP.h b/silk/float/SigProc_FLP.h
index 0d70ca1b..7c7601fb 100644
--- a/silk/float/SigProc_FLP.h
+++ b/silk/float/SigProc_FLP.h
@@ -29,6 +29,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define SILK_SIGPROC_FLP_H
#include "SigProc_FIX.h"
+#include "float_cast.h"
#include <math.h>
#ifdef __cplusplus
@@ -163,12 +164,7 @@ static inline silk_float silk_sigmoid( silk_float x )
/* floating-point to integer conversion (rounding) */
static inline opus_int32 silk_float2int( double x )
{
-#ifdef _WIN32
- double t = x + 6755399441055744.0;
- return *((opus_int32 *)( &t ));
-#else
- return (opus_int32)( ( x > 0 ) ? x + 0.5 : x - 0.5 );
-#endif
+ return (opus_int32)float2int( x );
}
/* floating-point to integer conversion (rounding) */
@@ -180,13 +176,8 @@ static inline void silk_float2short_array(
{
opus_int32 k;
for( k = length - 1; k >= 0; k-- ) {
-#ifdef _WIN32
- double t = in[k] + 6755399441055744.0;
- out[k] = (opus_int16)silk_SAT16(*(( opus_int32 * )( &t )));
-#else
double x = in[k];
- out[k] = (opus_int16)silk_SAT16( ( x > 0 ) ? x + 0.5 : x - 0.5 );
-#endif
+ out[k] = silk_SAT16( (opus_int32)float2int( x ) );
}
}
diff --git a/src/opus_encoder.c b/src/opus_encoder.c
index b95cf288..805bffb0 100644
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -194,6 +194,8 @@ int opus_encoder_init(OpusEncoder* st, opus_int32 Fs, int channels, int applicat
celt_encoder_ctl(celt_enc, OPUS_SET_COMPLEXITY(10));
st->use_vbr = 1;
+ /* Makes constrained VBR the default (safer for real-time use) */
+ st->vbr_constraint = 1;
st->user_bitrate_bps = OPUS_AUTO;
st->bitrate_bps = 3000+Fs*channels;
st->application = application;