diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2016-07-29 13:47:07 -0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2016-08-05 21:14:46 -0400 |
commit | 416611cfa127df360d6902794b36e426477061a0 (patch) | |
tree | 751615dc58e856b0cb9c4af81dc0bc8c277c1b26 /celt | |
parent | a01feba028f6ccf2af294b02a3982876551fe38a (diff) | |
download | opus-416611cfa127df360d6902794b36e426477061a0.tar.gz |
biasing quantization
Diffstat (limited to 'celt')
-rw-r--r-- | celt/bands.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/celt/bands.c b/celt/bands.c index fa2d2a65..87791b4a 100644 --- a/celt/bands.c +++ b/celt/bands.c @@ -742,11 +742,18 @@ static void compute_theta(struct band_ctx *ctx, struct split_ctx *sctx, if (encode) { if (!stereo || ctx->theta_round == 0) + { itheta = (itheta*(opus_int32)qn+8192)>>14; - else if (ctx->theta_round < 0) - itheta = (itheta*(opus_int32)qn)>>14; - else - itheta = (itheta*(opus_int32)qn+16383)>>14; + } else { + int down; + /* Bias quantization towards itheta=0 and itheta=16384. */ + int bias = itheta > 8192 ? 32767/qn : -32767/qn; + down = IMIN(qn-1, IMAX(0, (itheta*(opus_int32)qn + bias)>>14)); + if (ctx->theta_round < 0) + itheta = down; + else + itheta = down+1; + } } /* Entropy coding of the angle. We use a uniform pdf for the time split, a step for stereo, and a triangular one for the rest. */ |