This makes all remaining large stack allocations use the vararray
macros.
This continues the work of 6f2d9f50 to allow compiling with
NONTHREADSAFE_PSEUDOSTACK to move the memory for large buffers
off the stack for devices where it is very limited.
It also does this for some additional large buffers used by the
PLC in the decoder.
1) The memcpy's were using sizeof(opus_int32), but the type of the
local buffer was opus_int16.
2) Because the size was wrong, this potentially allowed the source
and destination regions of the memcpy overlap.
I _believe_ that nSamplesIn is at least fs_in_khZ, which is at
least 8.
Since RESAMPLER_ORDER_FIR_12 is only 8, I don't think that's a
problem once you fix the type size.
3) The size of the buffer used RESAMPLER_MAX_BATCH_SIZE_IN, but the
data stored in it was actually _twice_ the input batch size
(nSamplesIn<<1).
Because this never blew up in testing, I suspect that in practice
the batch sizes are reasonable enough that none of these things
was ever a problem, but proving that seems non-obvious.
This patch just converts the whole thing to use CELT's vararrays.
This fixes the buffer size problems (since we allocate a buffer
with the actual size we use) and gets these large buffers off the
stack on devices using the pseudo-stack.
It also fixes the memcpy problems by changing the sizeof to
opus_int16.
It turns out sFIR, which saved state between calls, was being used
elsewhere as opus_int32, so this converts it to a union to make
this sharing explicit.
Stereo now gets twice the "marginal allocation" compared to mono, but has
a 20 kb/s offset. This should be more realistic across a wide range of
bitrates.
Forces CELT-only mode for LFE (despite the rate) and "locks" most of the
CELT analysis:
- No transient or TF
- Band boost on first band
- Only first two bands get PVQ bits
- Forced energy decay after the first two bands
This left FEC disabled on the decoder side for all cases except concatenated
packets. Also fixes a FEC bug in opus_demo (wrong output buffer size
calculation).
- Properly apply the transient boost by counting all the bits in the cost
- Disable the post-filter for non-20-ms frames that follow a transient (applies
only to variable framesize)
The original code was causing parts of a sine sweep to be completely dropped
due to the 300 Hz margin and the hysteresis. Also, fixes scaling for the
analysis downmix when the input is 16-bit PCM.
opus_decode() and opus_multistream_decode() now apply soft clipping
before converting to 16-bit int. This should produce better a higher
quality result than hard clipping like we were doing before. The _float()
API isn't affected, but the clipping function is exported so users can
manually apply the soft clipping.
Variable duration option renamed to OPUS_SET_EXPERT_FRAME_DURATION,
with new API.
Also moves up the analysis to avoid having to do int->float conversion
on large buffers.
1) In cases where the SILK desired bandwidth went down, then quickly up, we
count get stuck in a mode with the LP variation going the wrong way.
2) Bandwidth detection can no longer force SILK to go below wideband to
avoid switches that require redundancy.
Detects a transient when the average band energy jumps by more than 6 dB
between two consecutive frames. This fixes some undetected transients on
Gainless' Muse_Breaks_Rmx sample.