summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2016-01-04 22:35:13 -0500
committerJean-Marc Valin <jmvalin@jmvalin.ca>2016-07-26 14:37:17 -0400
commit147dc279b17481bacde4cad5ef6ca1634b1687f9 (patch)
tree6c15a35295f91498d6bc28028b86189aee809ccb
parent11b6d60c9275314684ce8b323ce2a0e01fe498bc (diff)
downloadopus-147dc279b17481bacde4cad5ef6ca1634b1687f9.tar.gz
controlling rounding
-rw-r--r--celt/bands.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/celt/bands.c b/celt/bands.c
index 36f1004e..44e9074d 100644
--- a/celt/bands.c
+++ b/celt/bands.c
@@ -658,6 +658,7 @@ struct band_ctx {
const celt_ener *bandE;
opus_uint32 seed;
int arch;
+ int theta_round;
};
struct split_ctx {
@@ -715,8 +716,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)
@@ -1482,6 +1489,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);