diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2016-01-05 06:35:13 +0300 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2016-07-25 22:21:29 +0300 |
commit | 829fdba1029ae828b7ef91d6c2831dfeab9af8e5 (patch) | |
tree | 62a8a62a7e9a8289532cc4dcb5434ee6c392d948 | |
parent | 1fe23d85917264cf7584bcf475b7b5de48e65fa5 (diff) |
controlling rounding
-rw-r--r-- | celt/bands.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/celt/bands.c b/celt/bands.c index 0960895e..5ebeb666 100644 --- a/celt/bands.c +++ b/celt/bands.c @@ -657,6 +657,7 @@ struct band_ctx { const celt_ener *bandE; opus_uint32 seed; int arch; + int theta_round; }; struct split_ctx { @@ -714,8 +715,14 @@ static void compute_theta(struct band_ctx *ctx, struct split_ctx *sctx, if (qn!=1) { if (encode) - itheta = (itheta*(opus_int32)qn+8192)>>14; - + { + 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; + } /* 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. */ if (stereo && N>2) @@ -1492,6 +1499,7 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, } else { if (Y!=NULL) { + ctx.theta_round = 0; x_cm = quant_band_stereo(&ctx, X, Y, N, b, B, effective_lowband != -1 ? norm+effective_lowband : NULL, LM, last?NULL:norm+M*eBands[i]-norm_offset, lowband_scratch, x_cm|y_cm); |