We did no real error checking to see if a mode is supported when it
is created.
This patch implements checks for Jean-Marc's rules:
1) A mode must have frames at least 1ms in length (no more than
1000 per second).
2) A mode must have shorts of at most 3.33 ms (at least 300 per
second).
It also adds error checking to dump_modes so we report the error
instead of crashing when we fail to create a mode.
The previous "dumb cap" of (64<<LM)*(C<<BITRES) was not actually
achievable by many (most) bands, and did not take the cost of
coding theta for splits into account, and so was too small for some
bands.
This patch adds code to compute a fairly accurate estimate of the
real maximum per-band rate (an estimate only because of rounding
effects and the fact that the bit usage for theta is variable),
which is then truncated and stored in an 8-bit table in the mode.
This gives improved quality at all rates over 160 kbps/channel,
prevents bits from being wasted all the way up to 255 kbps/channel
(the maximum rate allowed, and approximately the maximum number of
bits that can usefully be used regardless of the allocation), and
prevents dynalloc and trim from producing enormous waste
(eliminating the need for encoder logic to prevent this).
This tunes the entropy model for coarse energy introduced in commit
c1c40a76.
It uses a constant set of parameters, tuned from about an hour and a
half of randomly selected test data encoded for each frame size,
prediction type (inter/intra), and band number.
These will be slightly sub-optimal for different frame sizes, but
should be better than what we were using.
For inter, this saves an average of 2.8, 5.2, 7.1, and 6.7 bits/frame
for frame sizes of 120, 240, 480, and 960, respectively.
For intra, this saves an average of 1.5, 3.0, 4.5, and 5.3 bits/frame
(for the same frame sizes, respectively).
Prediction coefficient now depends on the frame size. Also, the pdfs and means
have been adjusted and better quantized. This breaks compatibility of course.
to make sure that stereo coupling is done at the band level. Previously
the stereo coupling was done all at once, but there were all kinds of
interactions with the prediction and folding.