From 03f7de77a4ac7a0e83ba99c0d1fdb111404f92ca Mon Sep 17 00:00:00 2001 From: Gregory Maxwell Date: Mon, 15 Aug 2011 17:25:59 -0400 Subject: [PATCH] Strip off trailing zero bytes when in LPC mode. Saves about 60 bits/sec for 20ms frames. --- src/opus_encoder.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/opus_encoder.c b/src/opus_encoder.c index dc8c85f5..3d509eff 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -568,6 +568,14 @@ int opus_encode(OpusEncoder *st, const opus_int16 *pcm, int frame_size, { ret = (ec_tell(&enc)+7)>>3; ec_enc_done(&enc); + /*When in LPC only mode it's perfectly + reasonable to strip off trailing zero bytes as + the required range decoder behavior is to + fill these in. This can't be done when the MDCT + modes are used because the decoder needs to know + the actual length for allocation purposes.*/ + if(!redundancy) + while(ret>2&&data[ret-1]==0)ret--; nb_compr_bytes = ret; }