Skip to content

Commit

Permalink
Avoid a rare case of busting the QEXT EC
Browse files Browse the repository at this point in the history
Reproduced with:
CFLAGS='-g -DRESYNTH -std=c90 -O1 -march=core2 -DSMALL_FOOTPRINT   -DENABLE_RES24 -DENABLE_QEXT' ../configure --disable-static --enable-fixed-point --enable-fixed-point-debug --enable-opus-custom-api --disable-intrinsics --enable-hardening --enable-fuzzing --enable-check-asm --disable-rfc8251 --enable-float-approx
./tests/test_opus_custom 2222058735
  • Loading branch information
jmvalin committed Feb 24, 2025
1 parent 7de1145 commit 940ff78
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions celt/bands.c
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,9 @@ static unsigned quant_band_stereo(struct band_ctx *ctx, celt_norm *X, celt_norm
if (rebalance > 3<<BITRES && itheta!=0)
sbits += rebalance - (3<<BITRES);

/* Guard against overflowing the EC with the angle if the cubic quant used too many bits for the mid. */
if (ctx->extra_bands) sbits = IMIN(sbits, ctx->remaining_bits);

/* For a stereo split, the high bits of fill are always zero, so no
folding will be done to the side. */
cm |= quant_band(ctx, Y, N, sbits, B, NULL, LM, NULL, side, NULL, fill>>B ARG_QEXT(ext_b/2-qext_extra));
Expand All @@ -1542,6 +1545,10 @@ static unsigned quant_band_stereo(struct band_ctx *ctx, celt_norm *X, celt_norm
rebalance = sbits - (rebalance-ctx->remaining_bits);
if (rebalance > 3<<BITRES && itheta!=16384)
mbits += rebalance - (3<<BITRES);

/* Guard against overflowing the EC with the angle if the cubic quant used too many bits for the side. */
if (ctx->extra_bands) mbits = IMIN(mbits, ctx->remaining_bits);

/* In stereo mode, we do not apply a scaling to the mid because we need the normalized
mid for folding later. */
cm |= quant_band(ctx, X, N, mbits, B, lowband, LM, lowband_out, Q31ONE,
Expand Down

0 comments on commit 940ff78

Please sign in to comment.