From 411a84faeada5092e2e94d8116b8adba45808183 Mon Sep 17 00:00:00 2001 From: "Timothy B. Terriberry" Date: Tue, 1 Feb 2011 01:55:01 -0800 Subject: Add a seprate qtheta offset for two-phase stereo. 9b34bd83 caused serious regressions for 240-sample frame stereo, because the previous qb limit was _always_ hit for two-phase stereo. Two-phase stereo really does operate with a different model (for example, the single bit allocated to the side should really probably be thought of as a sign bit for qtheta, but we don't count it as part of qtheta's allocation). The old code was equivalent to a separate two-phase offset of 12, however Greg Maxwell's testing demonstrates that 16 performs best. --- libcelt/bands.c | 2 +- libcelt/rate.c | 2 +- libcelt/rate.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libcelt/bands.c b/libcelt/bands.c index 2102dfd..64e53fd 100644 --- a/libcelt/bands.c +++ b/libcelt/bands.c @@ -769,7 +769,7 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c /* Decide on the resolution to give to the split parameter theta */ pulse_cap = m->logN[i]+(LM<>1) - (stereo ? QTHETA_OFFSET_STEREO : QTHETA_OFFSET); + offset = (pulse_cap>>1) - (stereo&&N==2 ? QTHETA_OFFSET_TWOPHASE : QTHETA_OFFSET); qn = compute_qn(N, b, offset, pulse_cap, stereo); if (stereo && i>=intensity) qn = 1; diff --git a/libcelt/rate.c b/libcelt/rate.c index 2235013..15f1a88 100644 --- a/libcelt/rate.c +++ b/libcelt/rate.c @@ -212,7 +212,7 @@ void compute_pulse_cache(CELTMode *m, int LM) if (C==2) { max_bits <<= 1; - offset = (m->logN[j]+(i<>1)-QTHETA_OFFSET_STEREO; + offset = (m->logN[j]+(i<>1)-(N==2?QTHETA_OFFSET_TWOPHASE:QTHETA_OFFSET); ndof = 2*N-1-(N==2); /* The average measured cost for theta with the step PDF is 0.95164 times qb, approximated here as 487/512. */ diff --git a/libcelt/rate.h b/libcelt/rate.h index eabba93..d5f188d 100644 --- a/libcelt/rate.h +++ b/libcelt/rate.h @@ -43,7 +43,7 @@ #define BITRES 3 #define FINE_OFFSET 21 #define QTHETA_OFFSET 4 -#define QTHETA_OFFSET_STEREO 4 +#define QTHETA_OFFSET_TWOPHASE 16 #define BITOVERFLOW 30000 -- cgit v1.2.3