Skip to content

Commit 12f5f21

Browse files
committed
Merged revision(s) 24797 from trunk/OpenMPT:
[Var] Opus: Update to v1.6.1 (2026-01-14). ........ git-svn-id: https://source.openmpt.org/svn/openmpt/branches/OpenMPT-1.32@24798 56274372-70c3-4bfc-bfc3-4c3a0b034d27
1 parent abbaefe commit 12f5f21

Some content is hidden

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

55 files changed

+365646
-705513
lines changed

include/opus/OpenMPT.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
libopus library version 1.6 (2025-12-15).
1+
libopus library version 1.6.1 (2026-01-15).
22
The following changes have been made:
3-
* Commits
4-
<https://gitlab.xiph.org/xiph/opus/-/commit/ae5f6927893c752b43e56ab8f768759387959f14>,
5-
<https://gitlab.xiph.org/xiph/opus/-/commit/206eeee0ebb3cccb67ff69e5afa5ef6ecf7e43d3>,
6-
and
7-
<https://gitlab.xiph.org/xiph/opus/-/commit/516feba5f56fb0682f9c7f727fda4b88e2be99b1>
8-
have been applied.
93
* Obviously, unnecessary folders and files have been removed.
104
* celt/float_cast.h has been modified to compile on ARM64EC.
115
* celt/x86/vq_sse2.c has been modified to check for OPUS_X86_MAY_HAVE_SSE2.

include/opus/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)

include/opus/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))

include/opus/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 */

include/opus/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,

include/opus/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 */

include/opus/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 */

include/opus/celt/float_cast.h

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

168177
#endif /* FLOAT_CAST_H */

include/opus/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

include/opus/celt/stack_alloc.h

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,25 @@ extern char *global_stack;
123123
extern char *scratch_ptr;
124124
#endif /* CELT_C */
125125

126+
#if __STDC_VERSION__ >= 201112L
127+
# include <stdalign.h>
128+
# define ALIGNOF(T) alignof(T)
129+
#elif defined(__GNUC__) || defined(__clang__)
130+
# define ALIGNOF(T) __alignof__(T)
131+
#else
132+
# include <stddef.h>
133+
# ifdef __cplusplus
134+
template <typename T>
135+
struct alignment_helper {
136+
char c;
137+
T member;
138+
};
139+
# define ALIGNOF(T) (offsetof(alignment_helper<T>, member))
140+
# else
141+
# define ALIGNOF(T) (offsetof(struct { char c; T member; }, member))
142+
# endif
143+
#endif
144+
126145
#ifdef ENABLE_VALGRIND
127146

128147
#include <valgrind/memcheck.h>
@@ -134,26 +153,26 @@ extern char *global_stack_top;
134153
#endif /* CELT_C */
135154

136155
#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1))
137-
#define PUSH(stack, size, type) (VALGRIND_MAKE_MEM_NOACCESS(stack, global_stack_top-stack),ALIGN((stack),sizeof(type)/sizeof(char)),VALGRIND_MAKE_MEM_UNDEFINED(stack, ((size)*sizeof(type)/sizeof(char))),(stack)+=(2*(size)*sizeof(type)/sizeof(char)),(type*)((stack)-(2*(size)*sizeof(type)/sizeof(char))))
156+
#define PUSH(stack, size, type) (VALGRIND_MAKE_MEM_NOACCESS(stack, global_stack_top-stack),ALIGN((stack),ALIGNOF(type)),VALGRIND_MAKE_MEM_UNDEFINED(stack, ((size)*sizeof(type)/sizeof(char))),(stack)+=(2*(size)*sizeof(type)/sizeof(char)),(type*)((stack)-(2*(size)*sizeof(type)/sizeof(char))))
138157
#define RESTORE_STACK ((global_stack = _saved_stack),VALGRIND_MAKE_MEM_NOACCESS(global_stack, global_stack_top-global_stack))
139-
#define ALLOC_STACK char *_saved_stack; ((global_stack = (global_stack==0) ? ((global_stack_top=opus_alloc_scratch(GLOBAL_STACK_SIZE*2)+(GLOBAL_STACK_SIZE*2))-(GLOBAL_STACK_SIZE*2)) : global_stack),VALGRIND_MAKE_MEM_NOACCESS(global_stack, global_stack_top-global_stack)); _saved_stack = global_stack;
158+
#define ALLOC_STACK char *_saved_stack; ((global_stack = (global_stack==0) ? ((global_stack_top=(char*)opus_alloc_scratch(GLOBAL_STACK_SIZE*2)+(GLOBAL_STACK_SIZE*2))-(GLOBAL_STACK_SIZE*2)) : global_stack),VALGRIND_MAKE_MEM_NOACCESS(global_stack, global_stack_top-global_stack)); _saved_stack = global_stack;
140159

141160
#else
142161

143162
#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1))
144163
#ifdef ENABLE_HARDENING
145164
#include "arch.h"
146-
#define PUSH(stack, size, type) (ALIGN((stack),sizeof(type)/(sizeof(char))),(void)(((int)((size)*(sizeof(type)/(sizeof(char)))) <= (scratch_ptr)+GLOBAL_STACK_SIZE-(stack))?0:CELT_FATAL("pseudostack overflow")),(stack)+=(size)*(sizeof(type)/(sizeof(char))),(type*)(void*)((stack)-(size)*(sizeof(type)/(sizeof(char)))))
165+
#define PUSH(stack, size, type) (ALIGN((stack),ALIGNOF(type)),(void)(((int)((size)*(sizeof(type)/(sizeof(char)))) <= (scratch_ptr)+GLOBAL_STACK_SIZE-(stack))?0:CELT_FATAL("pseudostack overflow")),(stack)+=(size)*(sizeof(type)/(sizeof(char))),(type*)(void*)((stack)-(size)*(sizeof(type)/(sizeof(char)))))
147166
#else
148-
#define PUSH(stack, size, type) (ALIGN((stack),sizeof(type)/(sizeof(char))),(stack)+=(size)*(sizeof(type)/(sizeof(char))),(type*)(void*)((stack)-(size)*(sizeof(type)/(sizeof(char)))))
167+
#define PUSH(stack, size, type) (ALIGN((stack),ALIGNOF(type)),(stack)+=(size)*(sizeof(type)/(sizeof(char))),(type*)(void*)((stack)-(size)*(sizeof(type)/(sizeof(char)))))
149168
#endif
150169

151170
#if 0 /* Set this to 1 to instrument pseudostack usage */
152171
#define RESTORE_STACK (printf("%ld %s:%d\n", global_stack-scratch_ptr, __FILE__, __LINE__),global_stack = _saved_stack)
153172
#else
154173
#define RESTORE_STACK (global_stack = _saved_stack)
155174
#endif
156-
#define ALLOC_STACK char *_saved_stack; (global_stack = (global_stack==0) ? (scratch_ptr=opus_alloc_scratch(GLOBAL_STACK_SIZE)) : global_stack); _saved_stack = global_stack;
175+
#define ALLOC_STACK char *_saved_stack; (global_stack = (global_stack==0) ? (scratch_ptr=(char*)opus_alloc_scratch(GLOBAL_STACK_SIZE)) : global_stack); _saved_stack = global_stack;
157176

158177
#endif /* ENABLE_VALGRIND */
159178

0 commit comments

Comments
 (0)