aboutsummaryrefslogtreecommitdiff
path: root/celt
diff options
context:
space:
mode:
authorHarish Mahendrakar <harish.mahendrakar@ittiam.com>2020-09-30 17:14:00 -0700
committerHarish Mahendrakar <harish.mahendrakar@ittiam.com>2020-10-01 21:14:45 +0000
commite2bcf2c247606463d138d18e0a7f413645c32550 (patch)
tree086b8caee09ec165e8b7a1700e63427b54d79e39 /celt
parent245786e6c1ea70350b1ebaeadf5bcaff3661bd60 (diff)
parentb83dd52868326a401c8578041e3dbea439d53f11 (diff)
downloadlibopus-e2bcf2c247606463d138d18e0a7f413645c32550.tar.gz
Merge branch 'upstream-master'
Bug: 167721530 Test: atest android.mediav2.cts Test: run vts -m VtsHalMediaC2V1_0TargetAudioDecTest Test: run vts -m VtsHalMediaC2V1_0TargetAudioEncTest Change-Id: Id6900a9d5084fb6ae840f44a2b9133f95e1b96bc
Diffstat (limited to 'celt')
-rw-r--r--celt/arch.h5
-rw-r--r--celt/arm/armcpu.c2
-rw-r--r--celt/bands.c4
-rw-r--r--celt/celt_decoder.c8
-rw-r--r--celt/celt_encoder.c2
-rw-r--r--celt/ecintrin.h4
-rw-r--r--celt/float_cast.h58
-rw-r--r--celt/mips/celt_mipsr1.h1
-rw-r--r--celt/mips/vq_mipsr1.h8
-rw-r--r--celt/os_support.h1
-rw-r--r--celt/rate.h2
-rw-r--r--celt/vq.c4
-rw-r--r--celt/vq.h4
13 files changed, 59 insertions, 44 deletions
diff --git a/celt/arch.h b/celt/arch.h
index c627a744..3845c3a0 100644
--- a/celt/arch.h
+++ b/celt/arch.h
@@ -73,6 +73,9 @@ __attribute__((noreturn))
void celt_fatal(const char *str, const char *file, int line)
{
fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str);
+#if defined(_MSC_VER)
+ _set_abort_behavior( 0, _WRITE_ABORT_MSG);
+#endif
abort();
}
#endif
@@ -160,7 +163,7 @@ static OPUS_INLINE opus_int16 SAT16(opus_int32 x) {
#ifdef OPUS_ARM_PRESUME_AARCH64_NEON_INTR
#include "arm/fixed_arm64.h"
-#elif OPUS_ARM_INLINE_EDSP
+#elif defined (OPUS_ARM_INLINE_EDSP)
#include "arm/fixed_armv5e.h"
#elif defined (OPUS_ARM_INLINE_ASM)
#include "arm/fixed_armv4.h"
diff --git a/celt/arm/armcpu.c b/celt/arm/armcpu.c
index 694a63b7..cce3ae3a 100644
--- a/celt/arm/armcpu.c
+++ b/celt/arm/armcpu.c
@@ -93,6 +93,8 @@ static OPUS_INLINE opus_uint32 opus_cpu_capabilities(void){
#elif defined(__linux__)
/* Linux based */
+#include <stdio.h>
+
opus_uint32 opus_cpu_capabilities(void)
{
opus_uint32 flags = 0;
diff --git a/celt/bands.c b/celt/bands.c
index f7bb66a9..2702963c 100644
--- a/celt/bands.c
+++ b/celt/bands.c
@@ -371,14 +371,14 @@ void anti_collapse(const CELTMode *m, celt_norm *X_, unsigned char *collapse_mas
static void compute_channel_weights(celt_ener Ex, celt_ener Ey, opus_val16 w[2])
{
celt_ener minE;
-#if FIXED_POINT
+#ifdef FIXED_POINT
int shift;
#endif
minE = MIN32(Ex, Ey);
/* Adjustment to make the weights a bit more conservative. */
Ex = ADD32(Ex, minE/3);
Ey = ADD32(Ey, minE/3);
-#if FIXED_POINT
+#ifdef FIXED_POINT
shift = celt_ilog2(EPSILON+MAX32(Ex, Ey))-14;
#endif
w[0] = VSHR32(Ex, shift);
diff --git a/celt/celt_decoder.c b/celt/celt_decoder.c
index e6efce93..74ca3b74 100644
--- a/celt/celt_decoder.c
+++ b/celt/celt_decoder.c
@@ -117,13 +117,19 @@ void validate_celt_decoder(CELTDecoder *st)
#ifndef CUSTOM_MODES
celt_assert(st->mode == opus_custom_mode_create(48000, 960, NULL));
celt_assert(st->overlap == 120);
+ celt_assert(st->end <= 21);
+#else
+/* From Section 4.3 in the spec: "The normal CELT layer uses 21 of those bands,
+ though Opus Custom (see Section 6.2) may use a different number of bands"
+
+ Check if it's within the maximum number of Bark frequency bands instead */
+ celt_assert(st->end <= 25);
#endif
celt_assert(st->channels == 1 || st->channels == 2);
celt_assert(st->stream_channels == 1 || st->stream_channels == 2);
celt_assert(st->downsample > 0);
celt_assert(st->start == 0 || st->start == 17);
celt_assert(st->start < st->end);
- celt_assert(st->end <= 21);
#ifdef OPUS_ARCHMASK
celt_assert(st->arch >= 0);
celt_assert(st->arch <= OPUS_ARCHMASK);
diff --git a/celt/celt_encoder.c b/celt/celt_encoder.c
index 44cb0850..d6f8afc2 100644
--- a/celt/celt_encoder.c
+++ b/celt/celt_encoder.c
@@ -1571,7 +1571,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm,
(tmp+4*mode->Fs)/(8*mode->Fs)-!!st->signalling));
effectiveBytes = nbCompressedBytes - nbFilledBytes;
}
- equiv_rate = ((opus_int32)nbCompressedBytes*8*50 >> (3-LM)) - (40*C+20)*((400>>LM) - 50);
+ equiv_rate = ((opus_int32)nbCompressedBytes*8*50 << (3-LM)) - (40*C+20)*((400>>LM) - 50);
if (st->bitrate != OPUS_BITRATE_MAX)
equiv_rate = IMIN(equiv_rate, st->bitrate - (40*C+20)*((400>>LM) - 50));
diff --git a/celt/ecintrin.h b/celt/ecintrin.h
index 2263cff6..66a4c36e 100644
--- a/celt/ecintrin.h
+++ b/celt/ecintrin.h
@@ -49,7 +49,11 @@
This macro should only be used for implementing ec_ilog(), if it is defined.
All other code should use EC_ILOG() instead.*/
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
+#if defined(_MSC_VER) && (_MSC_VER >= 1910)
+# include <intrin0.h> /* Improve compiler throughput. */
+#else
# include <intrin.h>
+#endif
/*In _DEBUG mode this is not an intrinsic by default.*/
# pragma intrinsic(_BitScanReverse)
diff --git a/celt/float_cast.h b/celt/float_cast.h
index f218e864..9d34976e 100644
--- a/celt/float_cast.h
+++ b/celt/float_cast.h
@@ -67,6 +67,38 @@
#include <xmmintrin.h>
static OPUS_INLINE opus_int32 float2int(float x) {return _mm_cvt_ss2si(_mm_set_ss(x));}
+#elif (defined(_MSC_VER) && _MSC_VER >= 1400) && (defined(_M_X64) || (defined(_M_IX86_FP) && _M_IX86_FP >= 1))
+
+ #include <xmmintrin.h>
+ static OPUS_INLINE opus_int32 float2int(float value)
+ {
+ /* _mm_load_ss will generate same code as _mm_set_ss
+ ** in _MSC_VER >= 1914 /02 so keep __mm_load__ss
+ ** for backward compatibility.
+ */
+ return _mm_cvtss_si32(_mm_load_ss(&value));
+ }
+
+#elif (defined(_MSC_VER) && _MSC_VER >= 1400) && defined (_M_IX86)
+
+ #include <math.h>
+
+ /* Win32 doesn't seem to have these functions.
+ ** Therefore implement OPUS_INLINE versions of these functions here.
+ */
+
+ static OPUS_INLINE opus_int32
+ float2int (float flt)
+ { int intgr;
+
+ _asm
+ { fld flt
+ fistp intgr
+ } ;
+
+ return intgr ;
+ }
+
#elif defined(HAVE_LRINTF)
/* These defines enable functionality introduced with the 1999 ISO C
@@ -96,32 +128,6 @@ static OPUS_INLINE opus_int32 float2int(float x) {return _mm_cvt_ss2si(_mm_set_s
#include <math.h>
#define float2int(x) lrint(x)
-#elif (defined(_MSC_VER) && _MSC_VER >= 1400) && (defined(_M_X64) || (defined(_M_IX86_FP) && _M_IX86_FP >= 1))
- #include <xmmintrin.h>
-
- __inline long int float2int(float value)
- {
- return _mm_cvtss_si32(_mm_load_ss(&value));
- }
-#elif (defined(_MSC_VER) && _MSC_VER >= 1400) && defined (_M_IX86)
- #include <math.h>
-
- /* Win32 doesn't seem to have these functions.
- ** Therefore implement OPUS_INLINE versions of these functions here.
- */
-
- __inline long int
- float2int (float flt)
- { int intgr;
-
- _asm
- { fld flt
- fistp intgr
- } ;
-
- return intgr ;
- }
-
#else
#if (defined(__GNUC__) && defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L)
diff --git a/celt/mips/celt_mipsr1.h b/celt/mips/celt_mipsr1.h
index e85661a6..c332fe04 100644
--- a/celt/mips/celt_mipsr1.h
+++ b/celt/mips/celt_mipsr1.h
@@ -53,6 +53,7 @@
#include "celt_lpc.h"
#include "vq.h"
+#define OVERRIDE_COMB_FILTER_CONST
#define OVERRIDE_comb_filter
void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N,
opus_val16 g0, opus_val16 g1, int tapset0, int tapset1,
diff --git a/celt/mips/vq_mipsr1.h b/celt/mips/vq_mipsr1.h
index fd18eab7..f26a33e7 100644
--- a/celt/mips/vq_mipsr1.h
+++ b/celt/mips/vq_mipsr1.h
@@ -36,8 +36,6 @@
#include "mathops.h"
#include "arch.h"
-static void renormalise_vector_mips(celt_norm *X, int N, opus_val16 gain, int arch);
-
#define OVERRIDE_vq_exp_rotation1
static void exp_rotation1(celt_norm *X, int len, int stride, opus_val16 c, opus_val16 s)
{
@@ -66,11 +64,7 @@ static void exp_rotation1(celt_norm *X, int len, int stride, opus_val16 c, opus_
}
#define OVERRIDE_renormalise_vector
-
-#define renormalise_vector(X, N, gain, arch) \
- (renormalise_vector_mips(X, N, gain, arch))
-
-void renormalise_vector_mips(celt_norm *X, int N, opus_val16 gain, int arch)
+void renormalise_vector(celt_norm *X, int N, opus_val16 gain, int arch)
{
int i;
#ifdef FIXED_POINT
diff --git a/celt/os_support.h b/celt/os_support.h
index a2171971..009bf861 100644
--- a/celt/os_support.h
+++ b/celt/os_support.h
@@ -39,7 +39,6 @@
#include "opus_defines.h"
#include <string.h>
-#include <stdio.h>
#include <stdlib.h>
/** Opus wrapper for malloc(). To do your own dynamic allocation, all you need to do is replace this function and opus_free */
diff --git a/celt/rate.h b/celt/rate.h
index 852b9d6f..fad5e412 100644
--- a/celt/rate.h
+++ b/celt/rate.h
@@ -95,7 +95,7 @@ static OPUS_INLINE int pulses2bits(const CELTMode *m, int band, int LM, int puls
@param pulses Number of pulses per band (returned)
@return Total number of bits allocated
*/
-int clt_compute_allocation(const CELTMode *m, int start, int end, const int *offsets, const int *cap, int alloc_trim, int *intensity, int *dual_stero,
+int clt_compute_allocation(const CELTMode *m, int start, int end, const int *offsets, const int *cap, int alloc_trim, int *intensity, int *dual_stereo,
opus_int32 total, opus_int32 *balance, int *pulses, int *ebits, int *fine_priority, int C, int LM, ec_ctx *ec, int encode, int prev, int signalBandwidth);
#endif
diff --git a/celt/vq.c b/celt/vq.c
index a6b5552d..8011e225 100644
--- a/celt/vq.c
+++ b/celt/vq.c
@@ -39,6 +39,10 @@
#include "rate.h"
#include "pitch.h"
+#if defined(MIPSr1_ASM)
+#include "mips/vq_mipsr1.h"
+#endif
+
#ifndef OVERRIDE_vq_exp_rotation1
static void exp_rotation1(celt_norm *X, int len, int stride, opus_val16 c, opus_val16 s)
{
diff --git a/celt/vq.h b/celt/vq.h
index 0dfe6af0..45ec5591 100644
--- a/celt/vq.h
+++ b/celt/vq.h
@@ -41,10 +41,6 @@
#include "x86/vq_sse.h"
#endif
-#if defined(MIPSr1_ASM)
-#include "mips/vq_mipsr1.h"
-#endif
-
void exp_rotation(celt_norm *X, int len, int dir, int stride, int K, int spread);
opus_val16 op_pvq_search_c(celt_norm *X, int *iy, int K, int N, int arch);