Doing the overlap coying in the same OPUS_MOVE() as the rest of the synthesis
memory. Also, there was a missing OPUS_MOVE() in the PLC for the hybrid/CNG
case.
Use the output buffer directly for imdct output, avoiding use of an
intermediary buffer and copying from it. This works because the output
buffer is offset to always be continous with the overlap buffer in the
decoder. Adjust encoder resynth code to have the same buffer layout.
Signed-off-by: Jean-Marc Valin <jmvalin@jmvalin.ca>
This implements an API used in future encoders to avoid dynalloc doing silly things
on periodic LSB patterns and to reduce the bitrate on near-silence.
We now have rates for each possible threshold. This also adds some
histeresis but it's not that useful for now because the effective rate
doesn't changes from frame to frame (unless one changes the target rate).
This change also has the side effect of lowering the intensity stereo
point for 64 kb/s to band 15 (instead of 16).
This prevents rate reduction due to channel correlation from increasing
by more than 0.25 bit/sample between two frames. This issue was observed
on r.flac where the frame following a transient would lose nearly
1 bit/sample
This only increases the average rate by about 1.5 kb/s, but it
restores the high quality of transients from 1.0. Also it
ensures that dynalloc can never starve other bands when used
aggressively.
1) Stereo saving was being too aggressive because it only considered the LF
and because the savings were multiplied by coded_bins rather than by
just the number of "side bins" below the intensity threshold
2) In the case of bandlimited signals, dynalloc would allocate way too many
bits to the last non-zero band. We now explicitly check for the last
band with a meaningful signal.
These issues were really obvious when encoding the decoded test01.mp3
because of the strong inter-channel correlation and (especially) the 16 kHz
lowpass used by the mp3 encoder.
We had previously advised people to -Drestrict on
non-C99 compilers, but this creates problems for
some of the MSVC headers. Instead this just
uses a macro and defines it sanely.
tf_estimate was being initialized to zero and then never set because
transient_analysis() wasn't being called. This could also have affected
other frame sizes at lower complexity.
Tuned the tonality estimator to trigger on signals where only part of the
spectrum is tonal. Also tuned the pitch detector not to be confused
by short-term correlation.