Skip to content
Snippets Groups Projects
  1. Jan 11, 2011
  2. Jan 10, 2011
  3. Jan 09, 2011
    • Timothy B. Terriberry's avatar
      Prevent busts at low bitrates. · 76469c64
      Timothy B. Terriberry authored and Jean-Marc Valin's avatar Jean-Marc Valin committed
      This patch makes all symbols conditional on whether or not there's
       enough space left in the buffer to code them, and eliminates much
       of the redundancy in the side information.
      
      A summary of the major changes:
      * The isTransient flag is moved up to before the the coarse energy.
        If there are not enough bits to code the coarse energy, the flag
         would get forced to 0, meaning what energy values were coded
         would get interpreted incorrectly.
        This might not be the end of the world, and I'd be willing to
         move it back given a compelling argument.
      * Coarse energy switches coding schemes when there are less than 15
         bits left in the packet:
        - With at least 2 bits remaining, the change in energy is forced
           to the range [-1...1] and coded with 1 bit (for 0) or 2 bits
           (for +/-1).
        - With only 1 bit remaining, the change in energy is forced to
           the range [-1...0] and coded with one bit.
        - If there is less than 1 bit remaining, the change in energy is
           forced to -1.
          This effectively low-passes bands whose energy is consistently
           starved; this might be undesirable, but letting the default be
           zero is unstable, which is worse.
      * The tf_select flag gets moved back after the per-band tf_res
         flags again, and is now skipped entirely when none of the
         tf_res flags are set, and the default value is the same for
         either alternative.
      * dynalloc boosting is now limited so that it stops once it's given
         a band all the remaining bits in the frame, or when it hits the
         "stupid cap" of (64<<LM)*(C<<BITRES) used during allocation.
      * If dynalloc boosing has allocated all the remaining bits in the
         frame, the alloc trim parameter does not get encoded (it would
         have no effect).
      * The intensity stereo offset is now limited to the range
         [start...codedBands], and thus doesn't get coded until after
         all of the skip decisions.
        Some space is reserved for it up front, and gradually given back
         as each band is skipped.
      * The dual stereo flag is coded only if intensity>start, since
         otherwise it has no effect.
        It is now coded after the intensity flag.
      * The space reserved for the final skip flag, the intensity stereo
         offset, and the dual stereo flag is now redistributed to all
         bands equally if it is unused.
        Before, the skip flag's bit was given to the band that stopped
         skipping without it (usually a dynalloc boosted band).
      
      In order to enable simple interaction between VBR and these
       packet-size enforced limits, many of which are encountered before
       VBR is run, the maximum packet size VBR will allow is computed at
       the beginning of the encoding function, and the buffer reduced to
       that size immediately.
      Later, when it is time to make the VBR decision, the minimum packet
       size is set high enough to ensure that no decision made thus far
       will have been affected by the packet size.
      As long as this is smaller than the up-front maximum, all of the
       encoder's decisions will remain in-sync with the decoder.
      If it is larger than the up-front maximum, the packet size is kept
       at that maximum, also ensuring sync.
      The minimum used now is slightly larger than it used to be, because
       it also includes the bits added for dynalloc boosting.
      Such boosting is shut off by the encoder at low rates, and so
       should not cause any serious issues at the rates where we would
       actually run out of room before compute_allocation().
      76469c64
    • Timothy B. Terriberry's avatar
      Fix Jean-Marc's sqrt(0.5) constants. · 051e044d
      Timothy B. Terriberry authored and Jean-Marc Valin's avatar Jean-Marc Valin committed
      There were two different ones in use, one with less precision than
       a float, and the other missing a digit in the middle.
      051e044d
    • Jean-Marc Valin's avatar
      d0aa9f86
    • Timothy B. Terriberry's avatar
      Use B0 instead of B for decisions in quant_band(). · a714994b
      Timothy B. Terriberry authored and Jean-Marc Valin's avatar Jean-Marc Valin committed
      B contains the number of blocks _after_ splitting.
      We were using it to decide a) when to use a uniform PDF instead of a
       triangular one for theta and b) whether to bias the bit allocation
       towards the lower bins.
      Using B0 (the number of blocks before the split) instead for a)
       gives a PEAQ gain of 0.003 ODG (as high as 0.1 ODG on s02a samples
       006, 083, and 097) for 240-sample frames at 96kbps mono.
      Using B0 instead for b) gives a gain of only 0.00002.
      a714994b
  4. Jan 08, 2011
    • Timothy B. Terriberry's avatar
      Fix rounding in bits2pulses search. · 1cb32aa0
      Timothy B. Terriberry authored and Jean-Marc Valin's avatar Jean-Marc Valin committed
      The mid = (lo+hi)>>1 line in the binary search would allow hi to drop
       down to the same value as lo, meaning the rounding after the search
       would be choosing between the same two values.
      This patch changes it to (lo+hi+1)>>1.
      This will allow lo to increase up to the value hi, but only in the
       case that we can't possibly allocate enough pulses to meet the
       target number of bits (in which case the rounding doesn't matter).
      To pay for the extra add, this moves the +1 in the comparison to bits
       to the other side, which can then be taken outside the loop.
      The compiler can't normally do this because it might cause overflow
       which would change the results.
      
      This rarely mattered, but gives a 0.01 PEAQ improvement on 12-byte
       120 sample frames.
      It also makes the search process describable with a simple
       algorithm, rather than relying on this particular optimized
       implementation.
      I.e., the binary search loop can now be replaced with
        for(lo=0;lo+1<cache[0]&&cache[lo+1]<bits;lo++);
        hi=lo+1;
       and it will give equivalent results.
      This was not true before.
      1cb32aa0
    • Timothy B. Terriberry's avatar
      Changes to ec_dec_cdf() to support 8-bit tables. · 845dfa19
      Timothy B. Terriberry authored and Jean-Marc Valin's avatar Jean-Marc Valin committed
      This renames ec_dec_cdf() to ec_dec_icdf(), and changes the
       functionality to use an "inverse" CDF table, where
       icdf[i]=ft-cdf[i+1].
      The first entry is omitted entirely.
      It also adds a corresonding ec_enc_icdf() to the encoder, which uses
       the same table.
      One could use ec_encode_bin() by converting the values in the tables
       back to normal CDF values, but the icdf[] table already has them in
       the form ec_encode_bin() wants to use them, so there's no reason to
       translate them and then translate them back.
      
      This is done primarily to allow SILK to use the range coder with
       8-bit probability tables containing cumulative frequencies that
       span the full range 0...256.
      With an 8-bit table, the final 256 of a normal CDF becomes 0 in the
       "inverse" CDF.
      It's the 0 at the start of a normal CDF which would become 256, but
       this is the value we omit, as it already has to be special-cased in
       the encoder, and is not used at all in the decoder.
      845dfa19
  5. Dec 30, 2010
  6. Dec 29, 2010
  7. Dec 28, 2010
  8. Dec 27, 2010
  9. Dec 23, 2010
  10. Dec 22, 2010
    • Timothy B. Terriberry's avatar
      Update ec_dec_cdf() to use an unsigned cdf[]. · 1aaa50d1
      Timothy B. Terriberry authored and Jean-Marc Valin's avatar Jean-Marc Valin committed
      For our current usage, this doesn't matter, but is more consistent
       with the rest of the API.
      We may want to reduce this to an unsigned char[], but I'd rather
       coordinate that optimization with SILK's planned reduction to
       8-bit CDFs, as we may be able to use the same code.
      1aaa50d1
    • Timothy B. Terriberry's avatar
      Add test coverage for entropy coder compatibility. · de31e7e0
      Timothy B. Terriberry authored and Jean-Marc Valin's avatar Jean-Marc Valin committed
      This ensures that the various alternative routines in the entropy
       encoder and decoder (e.g., ec_{enc|dec}_bit_logp()) really are
       just specialized optimizations of the same general ec_encode()
       and ec_decode() routines.
      This is done by randomly picking one to encode with for each symbol,
       and randomly picking a different one to decode with.
      de31e7e0
    • Timothy B. Terriberry's avatar
      Fix a typo in ec_byte_write_done(). · 4e955ed3
      Timothy B. Terriberry authored and Jean-Marc Valin's avatar Jean-Marc Valin committed
      Introduced by 30df6cf3.
      This should have only affected the output in the case where the last
       few extra bits caused us to bust, and wouldn't have prevented us
       from detecting the error.
      4e955ed3
  11. Dec 21, 2010
    • Jean-Marc Valin's avatar
      7365c7d1
    • Timothy B. Terriberry's avatar
      Entropy coder clean-up. · 30df6cf3
      Timothy B. Terriberry authored
      This simplifies a good bit of the error handling, and should make it
       impossible to overrun the buffer in the encoder or decoder, while
       still allowing tell() to operate correctly after a bust.
      The encoder now tries to keep the range coder data intact after a
       bust instead of corrupting it with extra bits data, though this is
       not a guarantee (too many extra bits may have already been flushed).
      It also now correctly reports errors when the bust occurs merging the
       last byte of range coder and extra bits.
      
      A number of abstraction barrier violations were cleaned up, as well.
      This patch also includes a number of minor performance improvements:
       ec_{enc|dec}_bits() in particular should be much faster.
      
      Finally, tf_select was changed to be coded with the range coder
       rather than extra bits, so that it is at the front of the packet
       (for unequal error protection robustness).
      30df6cf3
    • Jean-Marc Valin's avatar
      Added highest allocation line possible · 59858633
      Jean-Marc Valin authored
      59858633
    • Jean-Marc Valin's avatar
      Ordering Hadamard frequencies when increasing the time-resolution. · dc6d69e6
      Jean-Marc Valin authored
      This means we're "time-ordered" in all cases except when increasing
      the time resolution on frames that already use short blocks.
      There's no reordering when increasing the frequency resolution
      on short blocks.
      dc6d69e6
    • Jean-Marc Valin's avatar
      Tuning the dynamic allocation probability and increment · 034efa52
      Jean-Marc Valin authored
      Dynalloc becomes 2x more likely every time we use it, until it
      reaches a probability of 1/4. Allocation increments now have
      a floor of 1/8 bit/sample and a ceiling of 1 bit/sample.
      034efa52
  12. Dec 20, 2010
Loading