Commit graph

579 commits

Author SHA1 Message Date
Jean-Marc Valin
37e788c185 Fixes return value on lost packet 2011-03-16 20:56:28 -04:00
Jean-Marc Valin
dd2973dd6c Fix missing break statements 2011-03-11 17:46:02 -05:00
Jean-Marc Valin
e6acfe07cb Adds in-band signalling of the CELT frame size and bandwidth 2011-03-11 16:38:49 -05:00
Jean-Marc Valin
f62b3bb96d Fix for global stack 2011-03-09 11:56:29 -05:00
Timothy B. Terriberry
9bac8c17d5 Eliminate the ec_int32 and ec_uint32 typedefs.
These were used because the entropy coder originally came from
 outside libcelt, and thus did not have a common type system.
It's now undergone enough modification that it's not ever likely to
 be used as-is in another codec without some porting effort, so
 there's no real reason to maintain the typedefs separately.
Hopefully we'll replace these all again somedate with a common set
 of Opus typedefs, but for now this will do.

This fixes an issue caused by commit 6c8acbf1, which moved the
 ec_ilog() prototype from entcode.h to ecintrin.h, where the
 ec_uint32 typedef was not yet available.
Thanks to John Ridges for the report.
2011-03-02 21:14:19 -05:00
Timothy B. Terriberry
115fa35a9d Fix CNG when effEBands is less than nbEBands.
We were trying to normalize bands that didn't actually exist (e.g.,
 the last band with 320-sample frames at 32kHz).
Thanks to John Ridges for the report.
2011-03-02 21:14:04 -05:00
Jean-Marc Valin
168888f7a3 A float variable and a bug left in transient_analysis() 2011-03-02 17:26:48 -05:00
Jean-Marc Valin
3beb70e549 Fix effectiveBytes computation for VBR 2011-03-01 18:08:15 -05:00
Jean-Marc Valin
64805fd246 Fix post-filter for the case where overlap!=shortMdctSize 2011-02-12 00:50:53 -05:00
Jean-Marc Valin
a14e86d904 Fixes post-filter for transitions between 2.5ms and other frame sizes 2011-02-11 16:27:27 -05:00
Jean-Marc Valin
3806c1d738 Relicensing under the simplified (2-clause) BSD license
Got authorization from all copyright holders
2011-02-09 22:37:41 -05:00
Gregory Maxwell
1928f8df65 CELT_SET_END_BAND_REQUEST in the decoder was performing the wrong bounds check and not allowing a change to fullband. 2011-02-08 22:35:29 -05:00
Gregory Maxwell
7007f1b823 Encoder fixes for NB/WB/SWB modes. 2011-02-08 16:31:21 -05:00
Timothy B. Terriberry
285bc372ca 16-bit int fixes.
This fixes a number of issues for platforms with a 16-bit int, but
 by no means all of them.
The type change for ec_window (for platforms where sizeof(size_t)==2)
 will break ABI (but not API) compatibility with libsilk and libopus,
 and reduce speed on x86-64, but allows the code to work in real-mode
 DOS without using the huge memory model, which is useful for testing
 16-bit int compliance.
2011-02-06 17:32:58 -05:00
Jean-Marc Valin
b570f1a910 Fix previous commit by still capping what the encoder will produce 2011-02-06 17:32:30 -05:00
Jean-Marc Valin
b3dae4b026 Allowing maxCompressedBytes to be as large as one wants
Though the encoder will still never use more than 1275 bytes
2011-02-04 21:50:54 -05:00
Jean-Marc Valin
0b405d1170 Making encoder-side clipping optional 2011-02-04 01:18:42 -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
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
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
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
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
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
7e983194a3 Fixing the global stack -- and an overflow in collapse_mask 2011-02-01 18:00:29 -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
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
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
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
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
Jean-Marc Valin
d6c3d3ceae Error handling in _create() functions 2011-01-30 11:00:24 -05:00
Jean-Marc Valin
913a1742b9 Adding resampling support
We use the MDCT as low-pass filter.
2011-01-29 11:35:19 -05:00
Jean-Marc Valin
c97b258c62 celt_encoder_create() now defaults to Opus standard mode
The old constructor is renamed celt_encoder_create_custom(). Same
for the decoder.
2011-01-28 23:07:32 -05:00
Gregory Maxwell
420c325875 Prevent VBR from shooting up to the maximum rate if set to very low target rates, and prevent the encoder VBR from producing 1 byte frames (which are no longer allowed). 2011-01-27 22:58:12 -05:00
Jean-Marc Valin
47e905dce7 Making anti-collapse a bit more conservative again
The energy memory can be lowered (not increased) during a transient
2011-01-27 18:05:47 -05:00
Jean-Marc Valin
b417d8392e Changing some double constants to float 2011-01-27 17:19:49 -05:00
Jean-Marc Valin
61f40418fa Adjusting post-filter coefficients to be exact in 13 bit precision.
That way they can be exact in 16 bits once multiplied by the gain
2011-01-27 17:14:33 -05:00
Jean-Marc Valin
65d35a35cf Only allowing silence in non-hybrid mode.
Also defining a 1-byte packet as triggering the PLC/CNG
2011-01-26 22:04:59 -05:00
Timothy B. Terriberry
a396e153b9 More anti-collapse fixes, as well as a fold fix.
This changes folding so that the LCG is never used on transients
 (either short blocks or long blocks with increased time
 resolution), except in the case that there's not enough decoded
 spectrum to fold yet.

It also now only subtracts the anti-collapse bit from the total
 allocation in quant_all_bands() when space has actually been
 reserved for it.

Finally, it cleans up some of the fill and collapse_mask tracking
 (this tracking was originally made intentionally sloppy to save
 work, but then converted to replace the existing fill flag at the
 last minute, which can have a number of logical implications).
The changes, in particular:
1) Splits of less than a block now correctly mark the second half
    as filled only if the whole block was filled (previously it
    would also mark it filled if the next block was filled).
2) Splits of less than a block now correctly mark a block as
    un-collapsed if either half was un-collapsed, instead of marking
    the next block as un-collapsed when the high half was.
3) The N=2 stereo special case now keeps its fill mask even when
    itheta==16384; previously this would have gotten cleared,
    despite the fact that we fold into the side in this case.
4) The test against fill for folding now only considers the bits
    corresponding to the current set of blocks.
   Previously it would still fold if any later block was filled.
5) The collapse mask used for the LCG fold data is now correctly
    initialized when B=16 on platforms with a 16-bit int.
6) The high bits on a collapse mask are now cleared after the TF
    resolution changes and interleaving at level 0, instead of
    waiting until the very end.
   This prevents extraneous high flags set on mid from being mixed
    into the side flags for mid-side stereo.
2011-01-26 20:54:13 -05:00
Jean-Marc Valin
4b000c37e7 Setting bandE[] to zero after log2Amp when silence=1 2011-01-26 20:30:21 -05:00
Gregory Maxwell
8b631f2c5f Fixes for silence handling in VBR mode, plus an encoder/decoder desync triggered by silent frames. 2011-01-26 20:26:31 -05:00