From 66c612ef43baa3e2d7094b4a057c1370ce629dbb Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Mon, 15 Aug 2011 14:08:57 -0400 Subject: [PATCH] Fixes an encoder bugg when requesting a CBR rate over the allowable limit --- libcelt/mdct.c | 1 + libcelt/mdct.h | 2 +- src/opus_decoder.c | 2 -- src/opus_encoder.c | 3 ++- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libcelt/mdct.c b/libcelt/mdct.c index 1e310ad6..43af87c0 100644 --- a/libcelt/mdct.c +++ b/libcelt/mdct.c @@ -99,6 +99,7 @@ void clt_mdct_clear(mdct_lookup *l) #endif /* CUSTOM_MODES */ +/* Forward MDCT trashes the input array */ void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out, const opus_val16 *window, int overlap, int shift, int stride) { diff --git a/libcelt/mdct.h b/libcelt/mdct.h index 8df8db0a..bba627cc 100644 --- a/libcelt/mdct.h +++ b/libcelt/mdct.h @@ -55,7 +55,7 @@ typedef struct { int clt_mdct_init(mdct_lookup *l,int N, int maxshift); void clt_mdct_clear(mdct_lookup *l); -/** Compute a forward MDCT and scale by 4/N */ +/** Compute a forward MDCT and scale by 4/N, trashes the input array */ void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out, const opus_val16 *window, int overlap, int shift, int stride); diff --git a/src/opus_decoder.c b/src/opus_decoder.c index bbf8c039..d8f4af4b 100644 --- a/src/opus_decoder.c +++ b/src/opus_decoder.c @@ -39,8 +39,6 @@ #include "modes.h" #include "silk_API.h" -#define MAX_PACKET (1275) - /* Make sure everything's aligned to 4 bytes (this may need to be increased on really weird architectures) */ static inline int align(int i) diff --git a/src/opus_encoder.c b/src/opus_encoder.c index 1f89d0af..dc8c85f5 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -425,7 +425,7 @@ int opus_encode(OpusEncoder *st, const opus_int16 *pcm, int frame_size, st->silk_mode.maxInternalSampleRate = 16000; /* Call SILK encoder for the low band */ - nBytes = max_data_bytes-1; + nBytes = IMIN(1275, max_data_bytes-1); if (prefill) { int zero=0; @@ -515,6 +515,7 @@ int opus_encode(OpusEncoder *st, const opus_int16 *pcm, int frame_size, } } + nb_compr_bytes = IMIN(1275, nb_compr_bytes); ec_enc_shrink(&enc, nb_compr_bytes); } else { nb_compr_bytes = 0;