ref: 235c64b94dded15c841e9df955b232892531d181
parent: c52d76894337c64617104e697befb18ccf33b564
author: Jean-Marc Valin <[email protected]>
date: Tue Jan 11 12:05:07 EST 2011
Using a step pdf for the stereo itheta encoding
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -648,10 +648,30 @@
itheta = (itheta*qn+8192)>>14;
/* Entropy coding of the angle. We use a uniform pdf for the
- first stereo split but a triangular one for the rest. */
- if (stereo || B0>1)
+ time split, a step for stereo, and a triangular one for the rest. */
+ if (stereo && N>2)
{
+ int p0 = 3;
+ int x = itheta;
+ int x0 = qn/2;
+ int ft = p0*(x0+1) + x0;
+ /* Use a probability of p0 up to itheta=8192 and then use 1 after */
if (encode)
+ {
+ ec_encode((ec_enc*)ec,x<=x0?p0*x:(x-1-x0)+(x0+1)*p0,x<=x0?p0*(x+1):(x-x0)+(x0+1)*p0,ft);
+ } else {
+ int fs;
+ fs=ec_decode(ec,ft);
+ if (fs<(x0+1)*p0)
+ x=fs/p0;
+ else
+ x=x0+1+(fs-(x0+1)*p0);
+ ec_dec_update(ec,x<=x0?p0*x:(x-1-x0)+(x0+1)*p0,x<=x0?p0*(x+1):(x-x0)+(x0+1)*p0,ft);
+ itheta = x;
+ }
+ } else if (B0>1 || stereo) {
+ /* Uniform pdf */
+ if (encode)
ec_enc_uint((ec_enc*)ec, itheta, qn+1);
else
itheta = ec_dec_uint((ec_dec*)ec, qn+1);
@@ -668,6 +688,7 @@
ec_encode((ec_enc*)ec, fl, fl+fs, ft);
} else {
+ /* Triangular pdf */
int fl=0;
int fm;
fm = ec_decode((ec_dec*)ec, ft);