Commit graph

1584 commits

Author SHA1 Message Date
Jean-Marc Valin
4305ab6bfb Bump LT_CURRENT and fix configure output messages 2011-02-04 00:16:40 -05:00
Jean-Marc Valin
f89f01fd00 STATIC_MODES no longer used 2011-02-04 00:09:05 -05:00
Jean-Marc Valin
5aa57e4f07 Configure option for custom modes 2011-02-04 00:04:26 -05:00
Gregory Maxwell
4d3e105a6c 1275 byte packets is the absolute maximum packet size we're going to support. This makes the encoder and decoder refuse to operate outside of these boundaries. 2011-02-03 23:57:30 -05:00
Jean-Marc Valin
8430a75b2f Skipping most of the PLC code for DTX
Also cap the encoder bit-rate to 260 kb/s per channel.
2011-02-03 23:54:37 -05:00
Jean-Marc Valin
d922fe1cf2 Version number bump 2011-02-03 23:27:09 -05:00
Gregory Maxwell
b8a6b31205 This removes some pointless/dead code. 2011-02-03 23:25:13 -05:00
Jean-Marc Valin
23340e2249 Fixes an int overflow in the VBR code
Also properly applies the MDCT filtering for resampling
2011-02-03 23:21:00 -05:00
Timothy B. Terriberry
752287825c Check for mode creation failure before we try to use it.
Not after.
2011-02-03 22:43:53 -05:00
Gregory Maxwell
95becbeec8 This fixes the frame_size check on the encoder and decoder and removes some unused variable warnings when compiling without custom modes. 2011-02-03 22:38:28 -05:00
Timothy B. Terriberry
a093f4df74 Refactor the entropy coder.
This unifies the byte buffer, encoder, and decoder into a single
 struct.
The common encoder and decoder functions (such as ec_tell()) can
 operate on either one, simplifying code which uses both.
The precision argument to ec_tell() has been removed.
It now comes in two precisions:
  ec_tell() gives 1 bit precision in two operations, and
  ec_tell_frac() gives 1/8th bit precision in... somewhat more.
ec_{enc|dec}_bit_prob() were removed (they are no longer needed).
Some of the byte buffer access functions were made static and
 removed from the cross-module API.
All of the code in rangeenc.c and rangedec.c was merged into
 entenc.c and entdec.c, respectively, as we are no longer
 considering alternative backends.
rangeenc.c and rangede.c have been removed entirely.

This passes make check, after disabling the modes that we removed
 support for in cf5d3a8c.
2011-02-03 21:48:52 -05:00
Jean-Marc Valin
ef986e4421 Increasing the pitch gain resolution 2011-02-03 15:47:10 -05:00
Ron
c33c3d6ce5 Align the sample buffer for short 2011-02-03 14:23:49 -05:00
Jean-Marc Valin
d539c6b9c5 Disabling the postfilter when complexity<5 or when CELT_SET_PREDICTION<=1 2011-02-03 13:36:03 -05:00
Jean-Marc Valin
ec6588ae14 Replaces previous commit with something safer 2011-02-03 10:34:30 -05:00
Jean-Marc Valin
ff4116ccb5 Patch from Tim: Prevents bits2 from going negative 2011-02-03 09:16:13 -05:00
Jean-Marc Valin
9a7540b673 Revert -export-symbols-regex 'celt_'. That probably wasn't a good idea
And it somehow prevents Opus from building shared libraries
2011-02-03 07:05:30 -05:00
Jean-Marc Valin
ea93c01a24 Renormalize in anti-collapse only when needed 2011-02-03 06:42:54 -05:00
Timothy B. Terriberry
57854e816a Fix collapse mask tracking for recombine steps.
The recombine loop for cm was correct if one started at 1 block,
 but was wrong otherwise (for a test case, convert 2 recombined
 blocks back to 4 with an initial cm of 0x3; the result should be
 0xF, but instead you get 0x7).
The recombine loop for fill was always wrong (for a test case,
 combine 8 blocks down to 1 with an initial fill=0xFE; the low bit
 remains unset).
This now properly interleaves and deinterleaves bits for these
 steps, which avoids declaring collapses (and skipping folding)
 where none, in fact, occurred.
2011-02-03 06:31:51 -05:00
Timothy B. Terriberry
cf5d3a8cf2 Fix short length detection.
aa6fec66 added a check to reject modes with shorts longer than
 3.33 ms (less than 300 per second).
However, it only rejected modes which could not be split at all.
This expands the check to also reject modes which, even after
 splitting the maximum amount, still do not have shorts less than
 3.33 ms.
2011-02-03 01:07:27 -05:00
Jean-Marc Valin
51c786241b More Opus build work 2011-02-03 00:43:37 -05:00
Jean-Marc Valin
3a8f04db17 Enabling the post-filter and exporting the ec functions for Opus 2011-02-02 23:02:25 -05:00
Jean-Marc Valin
b44e94ef58 Also fixing the DoFs for intensity stereo 2011-02-02 21:23:21 -05:00
Jean-Marc Valin
0889e2ac15 Getting the right DoFs for dual stereo 2011-02-02 21:03:31 -05:00
Jean-Marc Valin
9cc56bf0af Removing ancient allocation matrix 2011-02-01 22:03:26 -05:00
Timothy B. Terriberry
ce6d0904a1 Increase caps/allocation accuracy.
This stores the caps array in 32nd bits/sample instead of 1/2 bits
 scaled by LM and the channel count, which is slightly less
 less accurate for the last two bands, and much more accurate for
 all the other bands.
A constant offset is subtracted to allow it to represent values
 larger than 255 in 8 bits (the range of unoffset values is
 77...304).
In addition, this replaces the last modeline in the allocation table
 with the caps array, allowing the initial interpolation to
 allocate 8 bits/sample or more, which was otherwise impossible.
2011-02-01 21:17:57 -05:00
Jean-Marc Valin
424eb74279 Only checking for a mismatch when RESYNTH is defined 2011-02-01 20:33:17 -05:00
Timothy B. Terriberry
aa6fec669e Limit mode creation to supported modes.
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.
2011-02-01 18:58:07 -05:00
Jean-Marc Valin
7e983194a3 Fixing the global stack -- and an overflow in collapse_mask 2011-02-01 18:00:29 -05:00
Timothy B. Terriberry
2799c29792 Add assertions for band size restrictions.
The way folding is implemented requires two restrictions:
1. The last band must be the largest (so we can use its size to
 allocate a temporary buffer to handle interleaving/TF changes).
2. No band can be larger than twice the size of the previous band
 (so that once we have enough data to start folding, we will always
 have enough data to fold).

Mode creation makes a heuristic attempt to satisfy these
 conditions, but nothing actually guarantees it.
This adds some asserts to check them during mode creation.
They current pass for all supported custom modes.
2011-02-01 17:06:58 -05:00
Timothy B. Terriberry
cb8f366af6 Don't allow empty eBands.
Currently compute_ebands()'s attempts to round bands to even sizes
 and enforce size constraints on consecutive bands can leave some
 bands entirely empty (e.g., Fs=8000, frame_size=64, i=11).
This adds a simple post-processing loop to remove such bands.
2011-02-01 17:06:28 -05:00
Jean-Marc Valin
7bb26e13ca Adds a generic CELT_SET_BITRATE() ctl() API for CBR and VBR 2011-02-01 17:04:27 -05:00
Jean-Marc Valin
263e271948 Tuning the split threshold 2011-02-01 11:20:09 -05:00
Timothy B. Terriberry
411a84faea Add a seprate qtheta offset for two-phase stereo.
9b34bd83 caused serious regressions for 240-sample frame stereo,
 because the previous qb limit was _always_ hit for two-phase
 stereo.
Two-phase stereo really does operate with a different model (for
 example, the single bit allocated to the side should really
 probably be thought of as a sign bit for qtheta, but we don't
 count it as part of qtheta's allocation).
The old code was equivalent to a separate two-phase offset of 12,
 however Greg Maxwell's testing demonstrates that 16 performs
 best.
2011-02-01 06:35:14 -05:00
Timothy B. Terriberry
4499263b44 Adjust the splitting threshold.
Previously, we would only split a band if it was allocated more than
 32 bits.
However, the N=4 codebook can only produce about 22.5 bits, and two
 N=2 bands combined can only produce 26 bits, including 8 bits for
 qtheta, so if we wait until we allocate 32, we're guaranteed to fall
 short.
Several of the larger bands come pretty far from filling 32 bits as
 well, though their split versions will.

Greg Maxwell also suggested adding an offset to the threshold to
 account for the inefficiency of using qtheta compared to another
 VQ dimension.
This patch uses 1 bit as a placeholder, as it's a clear
 improvement, but we may adjust this later after collecting data on
 more possibilities over more files.
2011-01-31 22:42:12 -05:00
Jean-Marc Valin
5cf41c9d1f Including static_mode* files in the distribution 2011-01-31 17:34:46 -05:00
Jean-Marc Valin
a350bf5262 Stop collapsing the background noise channels when switching to mono 2011-01-31 17:30:15 -05:00
Timothy B. Terriberry
682b6cf1ad Don't destroy stereo history when switching to mono.
The first version of the mono decoder with stereo output collapsed
 the historic energy values stored for anti-collapse down to one
 channel (by taking the max).
This means that a subsequent switch back would continue on using
 the the maximum of the two values instead of the original history,
 which would make anti-collapse produce louder noise (and
 potentially more pre-echo than otherwise).

This patch moves the max into the anti_collapse function itself,
 and does not store the values back into the source array, so the
 full stereo history is maintained if subsequent frames switch
 back.
It also fixes an encoder mismatch, which never took the max
 (assuming, apparently, that the output channel count would never
 change).
2011-01-31 17:26:02 -05:00
Timothy B. Terriberry
948d27c9bc Propagate balance from compute_allocation() to quant_all_bands().
Instead of just dumping excess bits into the first band after
 allocation, use them to initialize the rebalancing loop in
 quant_all_bands().
This allows these bits to be redistributed over several bands, like
 normal.
2011-01-31 15:37:01 -05:00
Jean-Marc Valin
713d7a4ce9 Fix sample type conversion when resampling 2011-01-31 13:41:01 -05:00
Jean-Marc Valin
b35807d75a No longer extracting the frame size from the mode to build the header 2011-01-31 13:27:21 -05:00
Jean-Marc Valin
00a98f5deb Making the stereo encoder capable of encoding in mono 2011-01-31 11:19:03 -05:00
Jean-Marc Valin
f1916a14fd Making it possible for the stereo decoder to decode a mono stream 2011-01-31 10:51:30 -05:00
Timothy B. Terriberry
89039a3ff9 Apply band caps to the band allocation table.
The average caps over all values of LM and C are well below the
 target allocations of the last two modelines.
Lower them to the caps, to prevent hitting them quite so early.
This helps quality at medium-high rates, in the 180-192 kbps range.
2011-01-31 01:38:52 -05:00
Timothy B. Terriberry
b5d123a5f5 More band caps updates.
Use measured cross-entropy to estimate the real cost of coding
 qtheta given the allocated qb parameter, instead of the entropy of
 the PDF.
This is generally much lower, and reduces waste at high rates.
This patch also removes some intermediate rounding from this
 computation.
2011-01-31 01:37:51 -05:00
Timothy B. Terriberry
13bffd288d Add generic fine-energy rebalancing.
This extends the previous rebalancing for fine energy in N=1 bands
 to also allocate extra fine bits for bands that go over their cap.
2011-01-31 00:52:42 -05:00
Jean-Marc Valin
8cf29f0991 Custom and non-custom versions of the get_size() functions 2011-01-30 23:38:28 -05:00
Jean-Marc Valin
aaca4a713f Making sure that itheta=0 or 16384 really cuts allocation to one band 2011-01-30 21:19:06 -05:00
Jean-Marc Valin
665da0ba4d Merge branch 'exp_api_change' 2011-01-30 13:39:56 -05:00
Timothy B. Terriberry
c564307463 Use a smarter per-band bitrate cap.
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).
2011-01-30 11:42:38 -05:00