celt.git
7 years agoStop adjusting the VBR drift during silent frames, this prevents overshoot after...
Gregory Maxwell [Wed, 13 Apr 2011 21:08:22 +0000 (17:08 -0400)]
Stop adjusting the VBR drift during silent frames, this prevents overshoot after silent spans. This also results in undershoot on files with lots of silence, but this is desirable in terms of increasing quality consistency. It will be even better if we later include some open-loop correction of the targets.

7 years agoFixes a declaration-after-statement error when using ALLOC_STACK
Jean-Marc Valin [Tue, 29 Mar 2011 05:54:27 +0000 (07:54 +0200)]
Fixes a declaration-after-statement error when using ALLOC_STACK

7 years agoTypo in C5X macro
Jean-Marc Valin [Tue, 29 Mar 2011 05:43:51 +0000 (07:43 +0200)]
Typo in C5X macro

7 years agoAdds support for decoding stereo streams with a mono decoder
Jean-Marc Valin [Mon, 28 Mar 2011 05:39:41 +0000 (01:39 -0400)]
Adds support for decoding stereo streams with a mono decoder

We don't allow *encoding* a stereo stream with a mono encoder
because that's just silly.

7 years agoUpdated MSVC project file
Jean-Marc Valin [Wed, 23 Mar 2011 00:32:49 +0000 (20:32 -0400)]
Updated MSVC project file

7 years agoMaking CELT_GET_MODE "private"
Jean-Marc Valin [Mon, 21 Mar 2011 17:26:03 +0000 (13:26 -0400)]
Making CELT_GET_MODE "private"

7 years agoRemoves the celt_mode_info() call.
Jean-Marc Valin [Mon, 21 Mar 2011 15:32:50 +0000 (11:32 -0400)]
Removes the celt_mode_info() call.

Adds a CELT_GET_LOOKAHEAD() ctl() call instead. Other uses of
celt_mode_info() should not be needed anymore.

7 years agoUsing the Opus header in 48k/2.5-20 ms modes
Jean-Marc Valin [Mon, 21 Mar 2011 11:06:09 +0000 (07:06 -0400)]
Using the Opus header in 48k/2.5-20 ms modes

7 years agoFixes tandem-test.c
Jean-Marc Valin [Fri, 18 Mar 2011 19:47:53 +0000 (15:47 -0400)]
Fixes tandem-test.c

7 years agoBump version number
Jean-Marc Valin [Fri, 18 Mar 2011 19:42:56 +0000 (15:42 -0400)]
Bump version number

7 years agoNon-fatal bit-stream errors are now reported through ctl()
Jean-Marc Valin [Fri, 18 Mar 2011 19:34:11 +0000 (15:34 -0400)]
Non-fatal bit-stream errors are now reported through ctl()

7 years agoMSVC files
Jean-Marc Valin [Fri, 18 Mar 2011 10:40:03 +0000 (06:40 -0400)]
MSVC files

7 years agoTaking into account the start and end bands in CNG
Jean-Marc Valin [Thu, 17 Mar 2011 02:03:15 +0000 (22:03 -0400)]
Taking into account the start and end bands in CNG

7 years agoFixes return value on lost packet
Jean-Marc Valin [Thu, 17 Mar 2011 00:56:28 +0000 (20:56 -0400)]
Fixes return value on lost packet

7 years agoversion bump v0.11.3
Jean-Marc Valin [Mon, 14 Mar 2011 22:06:23 +0000 (18:06 -0400)]
version bump

7 years agoRenamed --noltp to --nopf in celtenc.c
Jean-Marc Valin [Mon, 14 Mar 2011 18:52:54 +0000 (14:52 -0400)]
Renamed --noltp to --nopf in celtenc.c

7 years agoceltdec update for change in celt_decode() return value
Jean-Marc Valin [Sun, 13 Mar 2011 01:36:26 +0000 (20:36 -0500)]
celtdec update for change in celt_decode() return value

7 years agoFix missing break statements
Jean-Marc Valin [Fri, 11 Mar 2011 22:46:02 +0000 (17:46 -0500)]
Fix missing break statements

7 years agoAdds in-band signalling of the CELT frame size and bandwidth
Jean-Marc Valin [Fri, 11 Mar 2011 21:31:24 +0000 (16:31 -0500)]
Adds in-band signalling of the CELT frame size and bandwidth

7 years agoSpeeds up compute_allocation() by removing potential aliasing
Jean-Marc Valin [Fri, 11 Mar 2011 15:36:11 +0000 (10:36 -0500)]
Speeds up compute_allocation() by removing potential aliasing

7 years agoBump version to 0.11.2 v0.11.2
Jean-Marc Valin [Wed, 9 Mar 2011 21:47:34 +0000 (16:47 -0500)]
Bump version to 0.11.2

7 years agoFix for global stack
Jean-Marc Valin [Wed, 9 Mar 2011 16:56:29 +0000 (11:56 -0500)]
Fix for global stack

7 years agoEliminate the ec_int32 and ec_uint32 typedefs.
Timothy B. Terriberry [Thu, 3 Mar 2011 00:24:32 +0000 (16:24 -0800)]
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.

7 years agoFix CNG when effEBands is less than nbEBands.
Timothy B. Terriberry [Wed, 2 Mar 2011 23:28:08 +0000 (15:28 -0800)]
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.

7 years agoA float variable and a bug left in transient_analysis()
Jean-Marc Valin [Wed, 2 Mar 2011 22:26:48 +0000 (17:26 -0500)]
A float variable and a bug left in transient_analysis()

7 years agoEC_ILOG cleanups.
Timothy B. Terriberry [Tue, 1 Mar 2011 20:54:04 +0000 (12:54 -0800)]
EC_ILOG cleanups.

Mark _BitScanReverse as an intrinsic, as this is not done by default
 in _DEBUG mode (thanks to Bjoern D. Rasmussen for the suggestion).
Move the declaration of ec_ilog() to where the macro using it is
 defined, to ensure it is available when the macro is used.
Thanks to John Ridges for the report.

7 years agoFix effectiveBytes computation for VBR
Jean-Marc Valin [Tue, 1 Mar 2011 23:08:15 +0000 (18:08 -0500)]
Fix effectiveBytes computation for VBR

7 years agoFixes a prototype mismatch in compute_allocation()
Jean-Marc Valin [Wed, 16 Feb 2011 18:21:13 +0000 (13:21 -0500)]
Fixes a prototype mismatch in compute_allocation()

7 years agoVersion bump v0.11.1
Jean-Marc Valin [Tue, 15 Feb 2011 04:57:54 +0000 (23:57 -0500)]
Version bump

7 years agoMSVC project files
Jean-Marc Valin [Tue, 15 Feb 2011 02:10:25 +0000 (21:10 -0500)]
MSVC project files

7 years agoRefactor ec_enc_patch_initial_bits().
Timothy B. Terriberry [Mon, 14 Feb 2011 21:26:05 +0000 (13:26 -0800)]
Refactor ec_enc_patch_initial_bits().

The return code has been eliminated in favor of using the existing
 error flag in the ec_enc struct.
This also adds the declaration to the header, which JM's importation
 of Koen's adaptation of my original code in b3c05b6b omitted.

7 years agoCorrect a number of uninitialized value problems when end!=nbEBands. Now 8khz/20ms...
Gregory Maxwell [Mon, 14 Feb 2011 20:27:52 +0000 (15:27 -0500)]
Correct a number of uninitialized value problems when end!=nbEBands. Now 8khz/20ms audio can be decoded at 48kHz and vice versa (with the PF turned off).

7 years agoImplements ec_enc_patch_initial_bits()
Timothy B. Terriberry [Mon, 14 Feb 2011 19:40:27 +0000 (14:40 -0500)]
Implements ec_enc_patch_initial_bits()

7 years agousing "end" rather than nbEBands for trim_offset[]
Jean-Marc Valin [Mon, 14 Feb 2011 18:54:59 +0000 (13:54 -0500)]
using "end" rather than nbEBands for trim_offset[]

7 years agoFixes the inversion of SPREAD_LIGHT and SPREAD_AGGRESSIVE
Jean-Marc Valin [Mon, 14 Feb 2011 18:50:20 +0000 (13:50 -0500)]
Fixes the inversion of SPREAD_LIGHT and SPREAD_AGGRESSIVE

Change the bit-stream (without causing desync)

7 years agoFix post-filter for the case where overlap!=shortMdctSize
Jean-Marc Valin [Sat, 12 Feb 2011 05:50:53 +0000 (00:50 -0500)]
Fix post-filter for the case where overlap!=shortMdctSize

7 years agoFix for layouts of 22 band and more
Jean-Marc Valin [Sat, 12 Feb 2011 02:56:11 +0000 (21:56 -0500)]
Fix for layouts of 22 band and more

7 years agoFixes post-filter for transitions between 2.5ms and other frame sizes
Jean-Marc Valin [Fri, 11 Feb 2011 21:27:27 +0000 (16:27 -0500)]
Fixes post-filter for transitions between 2.5ms and other frame sizes

7 years agoAdding a tiny amount of noise when folding to prevent/reduce numerical issues
Jean-Marc Valin [Thu, 10 Feb 2011 15:50:26 +0000 (10:50 -0500)]
Adding a tiny amount of noise when folding to prevent/reduce numerical issues

7 years agoOops, forgot COPYING and the tandem test
Jean-Marc Valin [Thu, 10 Feb 2011 04:14:03 +0000 (23:14 -0500)]
Oops, forgot COPYING and the tandem test

7 years agoRelicensing under the simplified (2-clause) BSD license
Jean-Marc Valin [Thu, 10 Feb 2011 03:37:41 +0000 (22:37 -0500)]
Relicensing under the simplified (2-clause) BSD license

Got authorization from all copyright holders

7 years agoCELT_SET_END_BAND_REQUEST in the decoder was performing the wrong bounds check and...
Gregory Maxwell [Wed, 9 Feb 2011 03:32:56 +0000 (22:32 -0500)]
CELT_SET_END_BAND_REQUEST in the decoder was performing the wrong bounds check and not allowing a change to fullband.

7 years agoEncoder fixes for NB/WB/SWB modes.
Gregory Maxwell [Tue, 8 Feb 2011 21:17:47 +0000 (16:17 -0500)]
Encoder fixes for NB/WB/SWB modes.

7 years agoUpdate celtclient to the new API.
Gregory Maxwell [Tue, 8 Feb 2011 02:30:40 +0000 (21:30 -0500)]
Update celtclient to the new API.

7 years agominor detail with the last patch
Jean-Marc Valin [Mon, 7 Feb 2011 01:23:19 +0000 (20:23 -0500)]
minor detail with the last patch

7 years ago16-bit int fixes.
Timothy B. Terriberry [Sun, 6 Feb 2011 21:29:00 +0000 (13:29 -0800)]
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.

7 years agoFix previous commit by still capping what the encoder will produce
Jean-Marc Valin [Sun, 6 Feb 2011 22:32:30 +0000 (17:32 -0500)]
Fix previous commit by still capping what the encoder will produce

7 years agoAllowing maxCompressedBytes to be as large as one wants
Jean-Marc Valin [Sat, 5 Feb 2011 02:50:54 +0000 (21:50 -0500)]
Allowing maxCompressedBytes to be as large as one wants

Though the encoder will still never use more than 1275 bytes

7 years agoMaking encoder-side clipping optional v0.11
Jean-Marc Valin [Fri, 4 Feb 2011 06:03:42 +0000 (01:03 -0500)]
Making encoder-side clipping optional

7 years agoBump LT_CURRENT and fix configure output messages
Jean-Marc Valin [Fri, 4 Feb 2011 05:13:06 +0000 (00:13 -0500)]
Bump LT_CURRENT and fix configure output messages

7 years agoSTATIC_MODES no longer used
Jean-Marc Valin [Fri, 4 Feb 2011 05:09:05 +0000 (00:09 -0500)]
STATIC_MODES no longer used

7 years agoConfigure option for custom modes
Jean-Marc Valin [Fri, 4 Feb 2011 05:04:26 +0000 (00:04 -0500)]
Configure option for custom modes

7 years ago1275 byte packets is the absolute maximum packet size we're going to support. This...
Gregory Maxwell [Fri, 4 Feb 2011 04:26:38 +0000 (23:26 -0500)]
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.

7 years agoSkipping most of the PLC code for DTX
Jean-Marc Valin [Fri, 4 Feb 2011 04:54:37 +0000 (23:54 -0500)]
Skipping most of the PLC code for DTX

Also cap the encoder bit-rate to 260 kb/s per channel.

7 years agoVersion number bump
Jean-Marc Valin [Fri, 4 Feb 2011 04:27:09 +0000 (23:27 -0500)]
Version number bump

7 years agoThis removes some pointless/dead code.
Gregory Maxwell [Fri, 4 Feb 2011 03:56:01 +0000 (22:56 -0500)]
This removes some pointless/dead code.

7 years agoFixes an int overflow in the VBR code
Jean-Marc Valin [Fri, 4 Feb 2011 04:21:00 +0000 (23:21 -0500)]
Fixes an int overflow in the VBR code

Also properly applies the MDCT filtering for resampling

7 years agoCheck for mode creation failure before we try to use it.
Timothy B. Terriberry [Thu, 3 Feb 2011 23:32:06 +0000 (15:32 -0800)]
Check for mode creation failure before we try to use it.

Not after.

7 years agoThis fixes the frame_size check on the encoder and decoder and removes some unused...
Gregory Maxwell [Fri, 4 Feb 2011 02:06:43 +0000 (21:06 -0500)]
This fixes the frame_size check on the encoder and decoder and removes some unused variable warnings when compiling without custom modes.

7 years agoRefactor the entropy coder.
Timothy B. Terriberry [Thu, 3 Feb 2011 22:22:15 +0000 (14:22 -0800)]
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.

7 years agoIncreasing the pitch gain resolution
Jean-Marc Valin [Thu, 3 Feb 2011 20:47:10 +0000 (15:47 -0500)]
Increasing the pitch gain resolution

7 years agoAlign the sample buffer for short
Ron [Thu, 3 Feb 2011 19:14:15 +0000 (05:44 +1030)]
Align the sample buffer for short

7 years agoDisabling the postfilter when complexity<5 or when CELT_SET_PREDICTION<=1
Jean-Marc Valin [Thu, 3 Feb 2011 18:36:03 +0000 (13:36 -0500)]
Disabling the postfilter when complexity<5 or when CELT_SET_PREDICTION<=1

7 years agoReplaces previous commit with something safer
Jean-Marc Valin [Thu, 3 Feb 2011 15:34:30 +0000 (10:34 -0500)]
Replaces previous commit with something safer

7 years agoPatch from Tim: Prevents bits2 from going negative
Jean-Marc Valin [Thu, 3 Feb 2011 14:16:13 +0000 (09:16 -0500)]
Patch from Tim: Prevents bits2 from going negative

7 years agoRevert -export-symbols-regex 'celt_'. That probably wasn't a good idea
Jean-Marc Valin [Thu, 3 Feb 2011 12:05:30 +0000 (07:05 -0500)]
Revert -export-symbols-regex 'celt_'. That probably wasn't a good idea

And it somehow prevents Opus from building shared libraries

7 years agoRenormalize in anti-collapse only when needed
Jean-Marc Valin [Thu, 3 Feb 2011 11:42:54 +0000 (06:42 -0500)]
Renormalize in anti-collapse only when needed

7 years agoFix collapse mask tracking for recombine steps.
Timothy B. Terriberry [Thu, 3 Feb 2011 09:57:57 +0000 (01:57 -0800)]
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.

7 years agoFix short length detection.
Timothy B. Terriberry [Wed, 2 Feb 2011 19:42:33 +0000 (11:42 -0800)]
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.

7 years agoMore Opus build work
Jean-Marc Valin [Thu, 3 Feb 2011 05:43:37 +0000 (00:43 -0500)]
More Opus build work

7 years agoEnabling the post-filter and exporting the ec functions for Opus
Jean-Marc Valin [Thu, 3 Feb 2011 04:02:25 +0000 (23:02 -0500)]
Enabling the post-filter and exporting the ec functions for Opus

7 years agoAlso fixing the DoFs for intensity stereo
Jean-Marc Valin [Thu, 3 Feb 2011 02:23:21 +0000 (21:23 -0500)]
Also fixing the DoFs for intensity stereo

7 years agoGetting the right DoFs for dual stereo
Jean-Marc Valin [Thu, 3 Feb 2011 02:03:31 +0000 (21:03 -0500)]
Getting the right DoFs for dual stereo

7 years agoRemoving ancient allocation matrix
Jean-Marc Valin [Wed, 2 Feb 2011 03:03:26 +0000 (22:03 -0500)]
Removing ancient allocation matrix

7 years agoIncrease caps/allocation accuracy.
Timothy B. Terriberry [Wed, 2 Feb 2011 01:41:12 +0000 (17:41 -0800)]
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.

7 years agoOnly checking for a mismatch when RESYNTH is defined
Jean-Marc Valin [Wed, 2 Feb 2011 01:33:17 +0000 (20:33 -0500)]
Only checking for a mismatch when RESYNTH is defined

7 years agoLimit mode creation to supported modes.
Timothy B. Terriberry [Tue, 1 Feb 2011 23:36:59 +0000 (15:36 -0800)]
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.

7 years agoFixing the global stack -- and an overflow in collapse_mask
Jean-Marc Valin [Tue, 1 Feb 2011 23:00:29 +0000 (18:00 -0500)]
Fixing the global stack -- and an overflow in collapse_mask

7 years agoAdd assertions for band size restrictions.
Timothy B. Terriberry [Tue, 1 Feb 2011 20:53:05 +0000 (12:53 -0800)]
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.

7 years agoDon't allow empty eBands.
Timothy B. Terriberry [Tue, 1 Feb 2011 20:32:34 +0000 (12:32 -0800)]
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.

7 years agoAdds a generic CELT_SET_BITRATE() ctl() API for CBR and VBR
Jean-Marc Valin [Tue, 1 Feb 2011 22:04:27 +0000 (17:04 -0500)]
Adds a generic CELT_SET_BITRATE() ctl() API for CBR and VBR

7 years agoTuning the split threshold
Jean-Marc Valin [Tue, 1 Feb 2011 16:20:09 +0000 (11:20 -0500)]
Tuning the split threshold

7 years agoAdd a seprate qtheta offset for two-phase stereo.
Timothy B. Terriberry [Tue, 1 Feb 2011 09:55:01 +0000 (01:55 -0800)]
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.

7 years agoAdjust the splitting threshold.
Timothy B. Terriberry [Mon, 31 Jan 2011 18:44:03 +0000 (10:44 -0800)]
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.

7 years agoIncluding static_mode* files in the distribution
Jean-Marc Valin [Mon, 31 Jan 2011 22:34:46 +0000 (17:34 -0500)]
Including static_mode* files in the distribution

7 years agoStop collapsing the background noise channels when switching to mono
Jean-Marc Valin [Mon, 31 Jan 2011 22:30:15 +0000 (17:30 -0500)]
Stop collapsing the background noise channels when switching to mono

7 years agoDon't destroy stereo history when switching to mono.
Timothy B. Terriberry [Mon, 31 Jan 2011 21:34:54 +0000 (13:34 -0800)]
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).

7 years agoPropagate balance from compute_allocation() to quant_all_bands().
Timothy B. Terriberry [Mon, 31 Jan 2011 20:28:12 +0000 (12:28 -0800)]
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.

7 years agoFix sample type conversion when resampling
Jean-Marc Valin [Mon, 31 Jan 2011 18:41:01 +0000 (13:41 -0500)]
Fix sample type conversion when resampling

7 years agoNo longer extracting the frame size from the mode to build the header
Jean-Marc Valin [Mon, 31 Jan 2011 18:27:21 +0000 (13:27 -0500)]
No longer extracting the frame size from the mode to build the header

7 years agoMaking the stereo encoder capable of encoding in mono
Jean-Marc Valin [Mon, 31 Jan 2011 16:19:03 +0000 (11:19 -0500)]
Making the stereo encoder capable of encoding in mono

7 years agoMaking it possible for the stereo decoder to decode a mono stream
Jean-Marc Valin [Mon, 31 Jan 2011 15:51:30 +0000 (10:51 -0500)]
Making it possible for the stereo decoder to decode a mono stream

7 years agoApply band caps to the band allocation table.
Timothy B. Terriberry [Mon, 31 Jan 2011 06:27:13 +0000 (22:27 -0800)]
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.

7 years agoMore band caps updates.
Timothy B. Terriberry [Mon, 31 Jan 2011 06:18:12 +0000 (22:18 -0800)]
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.

7 years agoAdd generic fine-energy rebalancing.
Timothy B. Terriberry [Sun, 30 Jan 2011 08:12:31 +0000 (00:12 -0800)]
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.

7 years agoCustom and non-custom versions of the get_size() functions
Jean-Marc Valin [Mon, 31 Jan 2011 04:38:28 +0000 (23:38 -0500)]
Custom and non-custom versions of the get_size() functions

7 years agoMaking sure that itheta=0 or 16384 really cuts allocation to one band
Jean-Marc Valin [Mon, 31 Jan 2011 02:19:06 +0000 (21:19 -0500)]
Making sure that itheta=0 or 16384 really cuts allocation to one band

7 years agoMerge branch 'exp_api_change'
Jean-Marc Valin [Sun, 30 Jan 2011 17:15:12 +0000 (12:15 -0500)]
Merge branch 'exp_api_change'

7 years agoUse a smarter per-band bitrate cap.
Timothy B. Terriberry [Sat, 29 Jan 2011 20:57:18 +0000 (12:57 -0800)]
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).

7 years agoError handling in _create() functions exp_api_change
Jean-Marc Valin [Sun, 30 Jan 2011 15:23:40 +0000 (10:23 -0500)]
Error handling in _create() functions