internal static int ec_laplace_decode(EntropyCoder dec, uint fs, int decay) { int val = 0; uint fl; uint fm; fm = dec.decode_bin(15); fl = 0; if (fm >= fs) { val++; fl = fs; fs = ec_laplace_get_freq1(fs, decay) + LAPLACE_MINP; /* Search the decaying part of the PDF.*/ while (fs > LAPLACE_MINP && fm >= fl + 2 * fs) { fs *= 2; fl += fs; fs = (uint)(((fs - 2 * LAPLACE_MINP) * (int)decay) >> 15); fs += LAPLACE_MINP; val++; } /* Everything beyond that has probability LAPLACE_MINP. */ if (fs <= LAPLACE_MINP) { int di; di = (int)(fm - fl) >> (LAPLACE_LOG_MINP + 1); val += di; fl += (uint)(2 * di * LAPLACE_MINP); } if (fm < fl + fs) { val = -val; } else { fl += fs; } } Inlines.OpusAssert(fl < 32768); Inlines.OpusAssert(fs > 0); Inlines.OpusAssert(fl <= fm); Inlines.OpusAssert(fm < Inlines.IMIN(fl + fs, 32768)); dec.dec_update(fl, Inlines.IMIN(fl + fs, 32768), 32768); return(val); }