Commit c1c40a76 authored by Committed by Jean-Marc ValinBrowse files
Rework coarse energy coding.
This changes how the PDF used to code coarse energy. New features: 1) The probability of 0 (p0) is now indepedent of the decay rate of the remaining values; this additional flexibility will allow us to model the actual distribution better, though that improvement is not part of this patch. 2) There is a guaranteed minimum number of encodable energy deltas. This ensures that even the most extreme sudden volume changes can be accurately represented. 3) The tail end of the distribution has an adjustable (through a constant in the code) minimum probability. This allows us to lower the worst-case bit cost of a single delta. 4) The codebook is interleaved as 0, -1, +1, -2, +2, ... instead of the 0, +1, -1, +2, -2, ... order used before (see 5). 5) There is no restriction that p0 be even. Any remaining, unused part of the code is assigned to an additional negative value (collected inter data suggests that very large negative deltas are more common than very large positive ones). If the minimum probability is greater than 1, then an additional positive delta with a smaller probablity may also be added. 6) Once the tail of the distribution is reached, the energy delta is computed directly, instead of continuing to loop through the codebook. This reduces the worst-case computational cost.