Skip to content
  • Timothy B. Terriberry's avatar
    Use a smarter per-band bitrate cap. · c5643074
    Timothy B. Terriberry authored and Jean-Marc Valin's avatar Jean-Marc Valin committed
    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).
    c5643074