From 949f18010fdb720a79dfa926bb581622267360b1 Mon Sep 17 00:00:00 2001 From: "Timothy B. Terriberry" Date: Thu, 30 Dec 2010 08:38:48 -0800 Subject: [PATCH] Move fine_priority calculation after the bust cap. This way if a band doesn't get the fine bits we want because it wasn't allocated enough bits to start with, then we will still give it priority for any spare bits after PVQ. --- libcelt/rate.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libcelt/rate.c b/libcelt/rate.c index 28f3a8d16..58cc92bbd 100644 --- a/libcelt/rate.c +++ b/libcelt/rate.c @@ -320,10 +320,6 @@ static inline int interp_bits2pulses(const CELTMode *m, int start, int end, int /* Divide with rounding */ ebits[j] = IMAX(0, (bits[j] + offset + (den<<(BITRES-1))) / (den<= bits[j]+offset; - /* Make sure not to bust */ if (C*ebits[j] > (bits[j]>>BITRES)) ebits[j] = bits[j] >> stereo >> BITRES; @@ -332,6 +328,10 @@ static inline int interp_bits2pulses(const CELTMode *m, int start, int end, int if (ebits[j]>8) ebits[j]=8; + /* If we rounded down or capped this band, make it a candidate for the + final fine energy pass */ + fine_priority[j] = ebits[j]*(den<= bits[j]+offset; + } else { /* For N=1, all bits go to fine energy except for a single sign bit */ ebits[j] = IMIN(IMAX(0,(bits[j] >> stereo >> BITRES)-1),7); -- GitLab