Skip to content

Commit 71cf21b

Browse files
authored
Merge branch 'xiph:main' into main
2 parents 4f14337 + 22244de commit 71cf21b

50 files changed

Lines changed: 313 additions & 257 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

celt/_kiss_fft_guts.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
#define SAMP_MIN -SAMP_MAX
5656

5757
#ifdef ENABLE_QEXT
58-
# define S_MUL(a,b) MULT32_32_P31(b, a)
59-
# define S_MUL2(a,b) MULT32_32_P31(b, a)
58+
# define S_MUL(a,b) MULT32_32_P31_ovflw(b, a)
59+
# define S_MUL2(a,b) MULT32_32_P31_ovflw(b, a)
6060
#else
6161
# define S_MUL(a,b) MULT16_32_Q15(b, a)
6262
# define S_MUL2(a,b) MULT16_32_Q16(b, a)

celt/arch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ typedef opus_val16 opus_res;
177177
#endif
178178

179179
#define RES2VAL16(a) RES2INT16(a)
180-
#define FLOAT2SIG(a) float2int(((opus_int32)32768<<SIG_SHIFT)*(a))
181180
#define INT16TOSIG(a) SHL32(EXTEND32(a), SIG_SHIFT)
182181
#define INT24TOSIG(a) SHL32(a, SIG_SHIFT-8)
183182

@@ -348,6 +347,7 @@ static OPUS_INLINE int celt_isnan(float x)
348347
#define MULT32_32_Q16(a,b) ((a)*(b))
349348
#define MULT32_32_Q31(a,b) ((a)*(b))
350349
#define MULT32_32_P31(a,b) ((a)*(b))
350+
#define MULT32_32_P31_ovflw(a,b) ((a)*(b))
351351

352352
#define MAC16_32_Q15(c,a,b) ((c)+(a)*(b))
353353
#define MAC16_32_Q16(c,a,b) ((c)+(a)*(b))

celt/celt.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@
5454
#include "lpcnet.h"
5555
#endif
5656

57-
#ifdef __cplusplus
58-
extern "C" {
59-
#endif
60-
6157
#define CELTEncoder OpusCustomEncoder
6258
#define CELTDecoder OpusCustomDecoder
6359
#define CELTMode OpusCustomMode
@@ -275,8 +271,4 @@ void celt_synthesis(const CELTMode *mode, celt_norm *X, celt_sig * out_syn[],
275271
#define QEXT_SCALE2(x, qext_scale) (x)
276272
#endif
277273

278-
#ifdef __cplusplus
279-
}
280-
#endif
281-
282274
#endif /* CELT_H */

celt/celt_encoder.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,13 @@ void celt_preemphasis(const opus_res * OPUS_RESTRICT pcmp, celt_sig * OPUS_RESTR
595595
for (i=0;i<Nu;i++)
596596
inp[i*upsample] = MAX32(-65536.f, MIN32(65536.f,inp[i*upsample]));
597597
}
598+
#elif defined(ENABLE_RES24)
599+
if (clip)
600+
{
601+
/* Clip input to avoid encoding non-portable files */
602+
for (i=0;i<Nu;i++)
603+
inp[i*upsample] = MAX32(-(65536<<SIG_SHIFT), MIN32(65536<<SIG_SHIFT,inp[i*upsample]));
604+
}
598605
#else
599606
(void)clip; /* Avoids a warning about clip being unused. */
600607
#endif
@@ -1363,7 +1370,7 @@ static opus_val16 tone_detect(const celt_sig *in, int CC, int N, opus_val32 *ton
13631370
ALLOC(x, N, opus_val16);
13641371
/* Shift by SIG_SHIFT+2 (+3 for stereo) to account for HF gain of the preemphasis filter. */
13651372
if (CC==2) {
1366-
for (i=0;i<N;i++) x[i] = PSHR32(ADD32(in[i], in[i+N]), SIG_SHIFT+3);
1373+
for (i=0;i<N;i++) x[i] = PSHR32(ADD32(SHR32(in[i], 1), SHR32(in[i+N], 1)), SIG_SHIFT+2);
13671374
} else {
13681375
for (i=0;i<N;i++) x[i] = PSHR32(in[i], SIG_SHIFT+2);
13691376
}
@@ -2000,7 +2007,9 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in
20002007
}
20012008
c=0; do {
20022009
int need_clip=0;
2003-
#ifndef FIXED_POINT
2010+
#ifdef FIXED_POINT
2011+
need_clip = st->clip && sample_max>65536<<RES_SHIFT;
2012+
#else
20042013
need_clip = st->clip && sample_max>65536.f;
20052014
#endif
20062015
celt_preemphasis(pcm+c, in+c*(N+overlap)+overlap, N, CC, st->upsample,

celt/fixed_debug.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ extern opus_int64 celt_mips;
4545
#define MULT16_16SU(a,b) ((opus_val32)(opus_val16)(a)*(opus_val32)(opus_uint16)(b))
4646
#define MULT32_32_Q31(a,b) ADD32(ADD32(SHL32(MULT16_16(SHR32((a),16),SHR((b),16)),1), SHR32(MULT16_16SU(SHR32((a),16),((b)&0x0000ffff)),15)), SHR32(MULT16_16SU(SHR32((b),16),((a)&0x0000ffff)),15))
4747
#define MULT32_32_P31(a,b) ADD32(SHL32(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR32(128+(opus_int32)(MULT16_16U(((a)&0x0000ffff),((b)&0x0000ffff))>>(16+7)) + SHR32(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),7) + SHR32(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),7), 8) )
48+
#define MULT32_32_P31_ovflw(a,b) ADD32_ovflw(SHL32(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR32(128+(opus_int32)(MULT16_16U(((a)&0x0000ffff),((b)&0x0000ffff))>>(16+7)) + SHR32(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),7) + SHR32(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),7), 8) )
4849
#define MULT32_32_Q32(a,b) ADD32(ADD32(MULT16_16(SHR((a),16),SHR((b),16)), SHR(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),16)), SHR(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),16))
4950

5051
/** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */

celt/fixed_generic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,11 @@
7474
/** 32x32 multiplication, followed by a 31-bit shift right (with rounding). Results fits in 32 bits */
7575
#if OPUS_FAST_INT64
7676
#define MULT32_32_P31(a,b) ((opus_val32)SHR(1073741824+(opus_int64)(a)*(opus_int64)(b),31))
77+
#define MULT32_32_P31_ovflw(a,b) MULT32_32_P31(a,b)
7778
#else
7879
#define MULT16_16U(a,b) ((opus_uint32)(a)*(opus_uint32)(b))
7980
#define MULT32_32_P31(a,b) ADD32(SHL(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR32(128+(opus_int32)SHR(MULT16_16U(((a)&0x0000ffff),((b)&0x0000ffff)),16+7) + SHR32(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),7) + SHR32(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),7), 8) )
81+
#define MULT32_32_P31_ovflw(a,b) ADD32_ovflw(SHL(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR32(128+(opus_int32)SHR(MULT16_16U(((a)&0x0000ffff),((b)&0x0000ffff)),16+7) + SHR32(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),7) + SHR32(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),7), 8) )
8082
#endif
8183

8284
/** 32x32 multiplication, followed by a 32-bit shift right. Results fits in 32 bits */

celt/float_cast.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,15 @@ static OPUS_INLINE opus_int32 FLOAT2INT24(float x)
162162
x = MIN32(x, 16777216);
163163
return float2int(x);
164164
}
165+
#ifdef FIXED_POINT
166+
static OPUS_INLINE opus_int32 FLOAT2SIG(float x)
167+
{
168+
x = x*((opus_int32)32768<<SIG_SHIFT);
169+
x = MAX32(x, -(65536<<SIG_SHIFT));
170+
x = MIN32(x, 65536<<SIG_SHIFT);
171+
return float2int(x);
172+
}
173+
#endif
165174
#endif /* DISABLE_FLOAT_API */
166175

167176
#endif /* FLOAT_CAST_H */

celt/kiss_fft.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@
3434
#include "arch.h"
3535
#include "cpu_support.h"
3636

37-
#ifdef __cplusplus
38-
extern "C" {
39-
#endif
40-
4137
#ifdef USE_SIMD
4238
# include <xmmintrin.h>
4339
# define kiss_fft_scalar __m128
@@ -210,8 +206,4 @@ extern void (*const OPUS_IFFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg,
210206
#endif /* end if defined(OPUS_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) */
211207
#endif /* end if !defined(OVERRIDE_OPUS_FFT) */
212208

213-
#ifdef __cplusplus
214-
}
215-
#endif
216-
217209
#endif

celt/tests/test_unit_mathops.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545

4646
#ifdef FIXED_POINT
4747
#define WORD "%d"
48-
#define FIX_INT_TO_DOUBLE(x,q) ((double)(x) / (double)(1L << q))
49-
#define DOUBLE_TO_FIX_INT(x,q) (((double)x * (double)(1L << q)))
48+
#define FIX_INT_TO_DOUBLE(x,q) (ldexp((double)(x), -(q)))
49+
#define DOUBLE_TO_FIX_INT(x,q) (ldexp((double)(x), (q)))
5050
#else
5151
#define WORD "%f"
5252
#endif
@@ -68,7 +68,7 @@ void testdiv(void)
6868
#endif
6969
if (fabs(prod-1) > .00025)
7070
{
71-
fprintf (stderr, "div failed: 1/%d="WORD" (product = %f)\n", i, val, prod);
71+
fprintf (stderr, "div failed: 1/%d=" WORD " (product = %f)\n", i, val, prod);
7272
ret = 1;
7373
}
7474
}
@@ -85,7 +85,7 @@ void testsqrt(void)
8585
ratio = val/sqrt(i);
8686
if (fabs(ratio - 1) > .0005 && fabs(val-sqrt(i)) > 2)
8787
{
88-
fprintf (stderr, "sqrt failed: sqrt(%d)="WORD" (ratio = %f)\n", i, val, ratio);
88+
fprintf (stderr, "sqrt failed: sqrt(%d)=" WORD " (ratio = %f)\n", i, val, ratio);
8989
ret = 1;
9090
}
9191
i+= i>>10;
@@ -178,7 +178,7 @@ void testexp2(void)
178178
float max_error = 0;
179179
for (x=-11.0;x<24.0;x+=0.0007f)
180180
{
181-
float error = fabs(x-(1.442695040888963387*log(celt_exp2(x))));
181+
float error = fabs(x-(1.442695040888963387*log((double)celt_exp2(x))));
182182
if (max_error < error)
183183
{
184184
max_error = error;
@@ -259,7 +259,7 @@ void test_atan2(void) {
259259
/* atan2(0,0) is undefined behavior. */
260260
continue;
261261
}
262-
float error = fabs(0.636619772367581f*(float)atan2(y, x) - celt_atan2p_norm(y, x));
262+
float error = fabs(0.636619772367581f*(float)atan2((double)y, (double)x) - celt_atan2p_norm(y, x));
263263
if (max_error < error)
264264
{
265265
max_error = error;
@@ -332,7 +332,7 @@ void testexp2(void)
332332
float error2 = fabs(exp(0.6931471805599453094*x/1024.0)-celt_exp2(x)/65536.0);
333333
if (error1>0.0002&&error2>0.00004)
334334
{
335-
fprintf (stderr, "celt_exp2 failed: x = "WORD", error1 = %f, error2 = %f\n", x,error1,error2);
335+
fprintf (stderr, "celt_exp2 failed: x = " WORD ", error1 = %f, error2 = %f\n", x,error1,error2);
336336
ret = 1;
337337
}
338338
}
@@ -425,7 +425,7 @@ void testrsqrt(void)
425425
x = DOUBLE_TO_FIX_INT(fx, 31);
426426
quantized_fx = FIX_INT_TO_DOUBLE(x, 31);
427427
error = fabs(FIX_INT_TO_DOUBLE(celt_rsqrt_norm32(x), 29) -
428-
1/sqrt(quantized_fx));
428+
1/sqrt((double)quantized_fx));
429429
if (max_error < error)
430430
{
431431
max_error = error;

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
2323
# For libtool.
2424
dnl Please update these for releases.
2525
OPUS_LT_CURRENT=11
26-
OPUS_LT_REVISION=0
26+
OPUS_LT_REVISION=1
2727
OPUS_LT_AGE=11
2828

2929
AC_SUBST(OPUS_LT_CURRENT)

0 commit comments

Comments
 (0)