commit 9de6f72c02fd8330f42b2b171bd5f8ffc2d1edc8
parent 57190359f45e31756bbeb06d143407f797b9d882
Author: Updatebot <updatebot@mozilla.com>
Date: Sun, 21 Dec 2025 22:24:41 +0000
Bug 2007308 - Update opus to 807c93d1b539e6e097e1e437b6d4603b67a7bc10 r=kinetik
Differential Revision: https://phabricator.services.mozilla.com/D277298
Diffstat:
11 files changed, 63 insertions(+), 19 deletions(-)
diff --git a/media/libopus/celt/arch.h b/media/libopus/celt/arch.h
@@ -177,7 +177,6 @@ typedef opus_val16 opus_res;
#endif
#define RES2VAL16(a) RES2INT16(a)
-#define FLOAT2SIG(a) float2int(((opus_int32)32768<<SIG_SHIFT)*(a))
#define INT16TOSIG(a) SHL32(EXTEND32(a), SIG_SHIFT)
#define INT24TOSIG(a) SHL32(a, SIG_SHIFT-8)
diff --git a/media/libopus/celt/celt_encoder.c b/media/libopus/celt/celt_encoder.c
@@ -595,6 +595,13 @@ void celt_preemphasis(const opus_res * OPUS_RESTRICT pcmp, celt_sig * OPUS_RESTR
for (i=0;i<Nu;i++)
inp[i*upsample] = MAX32(-65536.f, MIN32(65536.f,inp[i*upsample]));
}
+#elif defined(ENABLE_RES24)
+ if (clip)
+ {
+ /* Clip input to avoid encoding non-portable files */
+ for (i=0;i<Nu;i++)
+ inp[i*upsample] = MAX32(-(65536<<SIG_SHIFT), MIN32(65536<<SIG_SHIFT,inp[i*upsample]));
+ }
#else
(void)clip; /* Avoids a warning about clip being unused. */
#endif
@@ -2000,7 +2007,9 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in
}
c=0; do {
int need_clip=0;
-#ifndef FIXED_POINT
+#ifdef FIXED_POINT
+ need_clip = st->clip && sample_max>65536<<RES_SHIFT;
+#else
need_clip = st->clip && sample_max>65536.f;
#endif
celt_preemphasis(pcm+c, in+c*(N+overlap)+overlap, N, CC, st->upsample,
diff --git a/media/libopus/celt/float_cast.h b/media/libopus/celt/float_cast.h
@@ -162,6 +162,15 @@ static OPUS_INLINE opus_int32 FLOAT2INT24(float x)
x = MIN32(x, 16777216);
return float2int(x);
}
+#ifdef FIXED_POINT
+static OPUS_INLINE opus_int32 FLOAT2SIG(float x)
+{
+ x = x*((opus_int32)32768<<SIG_SHIFT);
+ x = MAX32(x, -(65536<<SIG_SHIFT));
+ x = MIN32(x, 65536<<SIG_SHIFT);
+ return float2int(x);
+}
+#endif
#endif /* DISABLE_FLOAT_API */
#endif /* FLOAT_CAST_H */
diff --git a/media/libopus/celt/stack_alloc.h b/media/libopus/celt/stack_alloc.h
@@ -123,6 +123,25 @@ extern char *global_stack;
extern char *scratch_ptr;
#endif /* CELT_C */
+#if __STDC_VERSION__ >= 201112L
+# include <stdalign.h>
+# define ALIGNOF(T) alignof(T)
+#elif defined(__GNUC__) || defined(__clang__)
+# define ALIGNOF(T) __alignof__(T)
+#else
+# include <stddef.h>
+# ifdef __cplusplus
+template <typename T>
+struct alignment_helper {
+ char c;
+ T member;
+};
+# define ALIGNOF(T) (offsetof(alignment_helper<T>, member))
+# else
+# define ALIGNOF(T) (offsetof(struct { char c; T member; }, member))
+# endif
+#endif
+
#ifdef ENABLE_VALGRIND
#include <valgrind/memcheck.h>
@@ -134,18 +153,18 @@ extern char *global_stack_top;
#endif /* CELT_C */
#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1))
-#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))))
+#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))))
#define RESTORE_STACK ((global_stack = _saved_stack),VALGRIND_MAKE_MEM_NOACCESS(global_stack, global_stack_top-global_stack))
-#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;
+#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;
#else
#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1))
#ifdef ENABLE_HARDENING
#include "arch.h"
-#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)))))
+#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)))))
#else
-#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)))))
+#define PUSH(stack, size, type) (ALIGN((stack),ALIGNOF(type)),(stack)+=(size)*(sizeof(type)/(sizeof(char))),(type*)(void*)((stack)-(size)*(sizeof(type)/(sizeof(char)))))
#endif
#if 0 /* Set this to 1 to instrument pseudostack usage */
@@ -153,7 +172,7 @@ extern char *global_stack_top;
#else
#define RESTORE_STACK (global_stack = _saved_stack)
#endif
-#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;
+#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;
#endif /* ENABLE_VALGRIND */
diff --git a/media/libopus/moz.build b/media/libopus/moz.build
@@ -21,7 +21,7 @@ FINAL_LIBRARY = "gkcodecs"
NoVisibilityFlags()
DEFINES["OPUS_BUILD"] = True
-DEFINES["OPUS_VERSION"] = "206eeee0ebb3cccb67ff69e5afa5ef6ecf7e43d3"
+DEFINES["OPUS_VERSION"] = "807c93d1b539e6e097e1e437b6d4603b67a7bc10"
DEFINES["USE_ALLOCA"] = True
DEFINES["ENABLE_HARDENING"] = True
diff --git a/media/libopus/moz.yaml b/media/libopus/moz.yaml
@@ -20,11 +20,11 @@ origin:
# Human-readable identifier for this version/release
# Generally "version NNN", "tag SSS", "bookmark SSS"
- release: 206eeee0ebb3cccb67ff69e5afa5ef6ecf7e43d3 (2025-12-16T16:33:37.000-05:00).
+ release: 807c93d1b539e6e097e1e437b6d4603b67a7bc10 (2025-12-20T21:52:39.000-05:00).
# Revision to pull in
# Must be a long or short commit SHA (long preferred)
- revision: 206eeee0ebb3cccb67ff69e5afa5ef6ecf7e43d3
+ revision: 807c93d1b539e6e097e1e437b6d4603b67a7bc10
# The package's license, where possible using the mnemonic from
# https://spdx.org/licenses/
diff --git a/media/libopus/silk/dec_API.c b/media/libopus/silk/dec_API.c
@@ -158,7 +158,7 @@ opus_int silk_Decode( /* O Returns error co
opus_int has_side;
opus_int stereo_to_mono;
#ifdef ENABLE_OSCE_BWE
- ALLOC(resamp_buffer, 3 * MAX_FRAME_LENGTH, opus_int16);
+ VARDECL( opus_int16, resamp_buffer );
#endif
SAVE_STACK;
@@ -382,6 +382,10 @@ opus_int silk_Decode( /* O Returns error co
ALLOC( samplesOut2_tmp, *nSamplesOut, opus_int16 );
resample_out_ptr = samplesOut2_tmp;
+#ifdef ENABLE_OSCE_BWE
+ ALLOC(resamp_buffer, 3 * MAX_FRAME_LENGTH, opus_int16);
+#endif
+
for( n = 0; n < silk_min( decControl->nChannelsAPI, decControl->nChannelsInternal ); n++ ) {
#ifdef ENABLE_OSCE_BWE
diff --git a/media/libopus/silk/fixed/encode_frame_FIX.c b/media/libopus/silk/fixed/encode_frame_FIX.c
@@ -401,13 +401,14 @@ static OPUS_INLINE void silk_LBRR_encode_FIX(
VARDECL(silk_nsq_state, sNSQ_LBRR);
SAVE_STACK;
- /* Using ALLOC() instead of a regular stack allocation to minimize real stack use when using the pseudostack.
- This is useful on some embedded systems. */
- ALLOC(sNSQ_LBRR, 1, silk_nsq_state);
/*******************************************/
/* Control use of inband LBRR */
/*******************************************/
if( psEnc->sCmn.LBRR_enabled && psEnc->sCmn.speech_activity_Q8 > SILK_FIX_CONST( LBRR_SPEECH_ACTIVITY_THRES, 8 ) ) {
+ /* Using ALLOC() instead of a regular stack allocation to minimize real stack use when using the pseudostack.
+ This is useful on some embedded systems. */
+ ALLOC(sNSQ_LBRR, 1, silk_nsq_state);
+
psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesEncoded ] = 1;
/* Copy noise shaping quantizer state and quantization indices from regular encoding */
diff --git a/media/libopus/silk/float/encode_frame_FLP.c b/media/libopus/silk/float/encode_frame_FLP.c
@@ -399,13 +399,14 @@ static OPUS_INLINE void silk_LBRR_encode_FLP(
VARDECL(silk_nsq_state, sNSQ_LBRR);
SAVE_STACK;
- /* Using ALLOC() instead of a regular stack allocation to minimize real stack use when using the pseudostack.
- This is useful on some embedded systems. */
- ALLOC(sNSQ_LBRR, 1, silk_nsq_state);
/*******************************************/
/* Control use of inband LBRR */
/*******************************************/
if( psEnc->sCmn.LBRR_enabled && psEnc->sCmn.speech_activity_Q8 > SILK_FIX_CONST( LBRR_SPEECH_ACTIVITY_THRES, 8 ) ) {
+ /* Using ALLOC() instead of a regular stack allocation to minimize real stack use when using the pseudostack.
+ This is useful on some embedded systems. */
+ ALLOC(sNSQ_LBRR, 1, silk_nsq_state);
+
psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesEncoded ] = 1;
/* Copy noise shaping quantizer state and quantization indices from regular encoding */
diff --git a/media/libopus/src/opus_encoder.c b/media/libopus/src/opus_encoder.c
@@ -766,6 +766,7 @@ void downmix_float(const void *_x, opus_val32 *y, int subframe, int offset, int
y[j] += FLOAT2SIG(x[(j+offset)*C+c]);
}
}
+#ifndef FIXED_POINT
/* Cap signal to +6 dBFS to avoid problems in the analysis. */
for (j=0;j<subframe;j++)
{
@@ -773,6 +774,7 @@ void downmix_float(const void *_x, opus_val32 *y, int subframe, int offset, int
if (y[j] > 65536.f) y[j] = 65536.f;
if (celt_isnan(y[j])) y[j] = 0;
}
+#endif
}
#endif
@@ -1920,7 +1922,7 @@ static opus_int32 opus_encode_frame_native(OpusEncoder *st, const opus_res *pcm,
else if (st->mode == MODE_CELT_ONLY) {
opus_val32 noise_energy = compute_frame_energy(pcm, frame_size, st->channels, st->arch);
/* Boosting peak energy a bit because we didn't just average the active frames. */
- activity = 2*st->peak_signal_energy < (QCONST16(PSEUDO_SNR_THRESHOLD, 0) * (opus_val64)noise_energy);
+ activity = st->peak_signal_energy < (QCONST16(PSEUDO_SNR_THRESHOLD, 0) * (opus_val64)HALF32(noise_energy));
}
/* For the first frame at a new SILK bandwidth */
diff --git a/media/libopus/src/repacketizer.c b/media/libopus/src/repacketizer.c
@@ -264,7 +264,7 @@ opus_int32 opus_repacketizer_out_range_impl(OpusRepacketizer *rp, int begin, int
all_extensions, ext_count, count, 0);
if (ext_len < 0) return ext_len;
if (!pad)
- pad_amount = ext_len + ext_len/254 + 1;
+ pad_amount = ext_len + (ext_len ? (ext_len+253)/254 : 1);
}
if (pad_amount != 0)
{