Commit graph

133 commits

Author SHA1 Message Date
Jean-Marc Valin
c39bb8ab8c Removes unused function parameters 2011-01-26 10:50:55 -05:00
Jean-Marc Valin
4610d18305 Should avoid running log2Amp on uninitialized data 2011-01-26 10:00:28 -05:00
Jean-Marc Valin
72e86fa26e Remove // comment 2011-01-25 21:43:23 -05:00
Jean-Marc Valin
495114b755 Moving energy floor to coarse quantization
By moving the energy floor to the encoder, we can use a different
floor for prediction than for the decay level. Also, the fixed-point
dynamic range has been increased to avoid overflows when a fixed-point
decoder is used on a stream encoded in floating-point.
2011-01-24 15:53:17 -05:00
Jean-Marc Valin
2293e4613e Considering "badness" in two-pass quant_coarse_energy().
The most important thing is to not screw up the energy. Then we
compare the bit-rates.
2011-01-22 22:29:25 -05:00
Gregory Maxwell
8f02c482ba Correct an encoder/decoder mismatch at low volume levels. Relax some low level clamps so that the dynamic range can extend further below the 16bit floor. 2011-01-22 19:50:36 -05:00
Jean-Marc Valin
a66b7574f6 Defines MAX_FINE_BITS to ensure that we're using the same value everywhere 2011-01-10 13:21:04 -05:00
Timothy B. Terriberry
76469c64b4 Prevent busts at low bitrates.
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().
2011-01-09 02:06:53 -05:00
Timothy B. Terriberry
fe40ddd999 Update the maximum fine bits everywhere.
cf874373 raised the limit from 7 to 8 for N>1 bands in
 interp_bits2pulses(), but did not raise the corresponding limits
 for N=1 bands, or for [un]quant_energy_finalise().
This commit raises all of the limits to the same value, 8.
2010-12-30 12:47:28 -05:00
Timothy B. Terriberry
30df6cf3f8 Entropy coder clean-up.
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).
2010-12-21 14:23:45 -05:00
Timothy B. Terriberry
e86fb268b0 Replace ec_{enc|dec}_bit_prob() with ec_{enc|dec}_bit_logp().
All of our usage of ec_{enc|dec}_bit_prob had the probability of a
 "one" being a power of two.
This adds a new ec_{enc|dec}_bit_logp() function that takes this
 explicitly into account.
It introduces less rounding error than the bit_prob version, does not
 require 17-bit integers to be emulated by ec_{encode|decode}_bin(),
 and does not require any multiplies or divisions at all.
It is exactly equivalent to
 ec_encode_bin(enc,_val?0:(1<<_logp)-1,(1<<_logp)-(_val?1:0),1<<_logp)

The old ec_{enc|dec}_bit_prob functions are left in place for now,
 because I am not sure if SILK is still using them or not when
 combined in Opus.
2010-12-18 09:06:06 -05:00
Jean-Marc Valin
034172baa6 Making the encoder fail less often at stupidly low bit-rates 2010-12-16 14:40:14 -05:00
Timothy B. Terriberry
ef2e650592 Add coarse energy entropy model tuning.
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).
2010-11-09 17:54:41 +08:00
Gregory Maxwell
9743bf38ca Switch iteration over channels to the do{}while(); construct in order to inform the compiler that the these loops execute at least once. (This results in more intelligent output from the clang static analysis tool and should also produce faster code on at least some architectures.) 2010-11-04 23:52:43 -04:00
Jean-Marc Valin
27fc0c4290 s/const/static const/ 2010-10-18 15:10:33 -04:00
Jean-Marc Valin
844f00def9 Don't take into account silence for the coarse energy means 2010-10-12 22:18:09 -04:00
Jean-Marc Valin
8226ac083e Retrained coarse energy mean and beta coefficients 2010-10-09 21:07:51 -04:00
Jean-Marc Valin
b1fe4f60e6 Fixes a fixed-point overflow on 16-bit architectures 2010-09-29 18:05:20 -04:00
Jean-Marc Valin
cb2c77c68e Add an extra safety bit in intra_decision() 2010-09-14 16:43:35 -04:00
Jean-Marc Valin
ba760bc525 Fixes rare overflow in intra_decision() 2010-09-14 16:06:22 -04:00
Jean-Marc Valin
1b36d6c8b6 Complexity setting now controls two-pass coarse energy quantization 2010-08-31 17:21:52 -04:00
Jean-Marc Valin
736efd6909 Fixes some MSVC warnings 2010-08-31 11:52:45 -04:00
Jean-Marc Valin
5d937c0223 Disabling mdct and fft init code with static modes 2010-08-26 02:04:03 -04:00
Jean-Marc Valin
bb5288174d coarse probability model in static modes too 2010-08-25 22:12:18 -04:00
Jean-Marc Valin
6ac26ecf2d Fixes a stereo bug introduced in the previous commit 2010-08-11 20:38:19 -04:00
Jean-Marc Valin
bb338a9317 Choosing intra frame energy when it's cheaper than inter 2010-08-10 13:20:21 -04:00
Jean-Marc Valin
5e7f02de2c Moving intra decision to quant_coarse_energy() 2010-08-08 09:48:22 -04:00
Jean-Marc Valin
f412a99e2a comments 2010-08-06 17:04:13 -04:00
Jean-Marc Valin
0777135275 eMeans[] quantized to 8 bits 2010-08-06 16:34:58 -04:00
Jean-Marc Valin
504fb3c189 Using the real spectral means instead of the ones
after inter-band prediction
2010-08-06 15:56:22 -04:00
Jean-Marc Valin
bc272de74b Code simplifications for log->amplitude conversion 2010-08-02 09:41:31 -04:00
Jean-Marc Valin
617af25e5c Cleaning up intra_decision() 2010-07-23 16:54:45 -04:00
Jean-Marc Valin
ca6533cd88 Energy quantization tuning.
Prediction coefficient now depends on the frame size. Also, the pdfs and means
have been adjusted and better quantized. This breaks compatibility of course.
2010-07-23 16:10:36 -04:00
Jean-Marc Valin
6bf3b0a7a1 The coarse energy budget is no longer part of the bit-stream.
It is now the encoder's responsability to take care of it to avoid
busting the budget.
2010-07-19 14:32:40 -04:00
Jean-Marc Valin
9d785afb67 Encoder now has a way to check whether an error has occurred 2010-07-18 09:42:05 -04:00
Jean-Marc Valin
525d7cfdc4 Support for adjusting the end band 2010-07-13 18:18:23 -04:00
Jean-Marc Valin
a01106587c Improved quality of small frame sizes at low bitrate.
Adding a temporal energy floor to prevent extremely small values when there's
only one bin in the band.
2010-06-23 15:22:54 -04:00
Jean-Marc Valin
47ad4a0938 Doing the log2Amp() just in one place 2010-06-05 01:18:40 -04:00
Jean-Marc Valin
c4ac57023c Fixed a long-standing rare mismatch
In cases where the coarse energy quantizer wasn't able to
go down fast enough, we could have a negative error that didn't
get clamped.
2010-05-26 15:04:41 -04:00
Jean-Marc Valin
b450ed48ae Removed unnecessary calls to log2Amp() 2010-04-18 22:47:58 -04:00
Jean-Marc Valin
8974f00d53 fixed-point: improving accuracy of the energy prediction 2010-03-20 00:41:39 -04:00
Jean-Marc Valin
c7b01bad50 fixed-point: slightly increasing the decoder accuracy again 2010-03-19 23:17:28 -04:00
Jean-Marc Valin
bd0610d21b Increasing log energy resolution 2010-03-13 10:04:19 -05:00
Jean-Marc Valin
5503f11a3d Using the mean energy even when start>0 2010-03-12 22:00:10 -05:00
Jean-Marc Valin
210ccafaff Improves fixed-point precision for quant_coarse_energy 2010-03-11 22:20:19 -05:00
Jean-Marc Valin
3a0bc3d95c Allowing CELT to skip the low frequencies 2010-02-25 22:46:55 -05:00
George de Vries
6fd0270621 Fixing (read) array overrun for 1024-sample frames. 2009-12-02 20:59:44 -05:00
Jean-Marc Valin
ab4dcc5c90 Allow coarse energy to take almost all the bits. Also, fixed a some issues with
the VBR rate controller.
2009-10-21 07:08:27 -04:00
Jean-Marc Valin
328b8bd7fc fixed a few trivial bugs: exporting celt_strerror(), changed DB_SCALING to a
shift and removed the chec for DISABLE_STEREO in the mode creation.
2009-10-19 19:07:38 -04:00
Jean-Marc Valin
234969c903 Removed the _t from all the celt*_t types to avoid clashing with POSIX 2009-10-17 22:12:42 -04:00