Commit graph

2979 commits

Author SHA1 Message Date
Timothy B. Terriberry
c152d602aa Use dynamic stack allocation in the SILK encoder.
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.
2013-05-08 10:37:17 -07:00
Timothy B. Terriberry
dc58579c2c Fix several memory errors in the SILK resampler.
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.
2013-05-08 10:37:10 -07:00
Timothy B. Terriberry
c41a81680c Remove trailing whitespace. 2013-05-07 20:05:56 -07:00
Timothy B. Terriberry
bfe52ceb74 Fix some warnings.
You can't use /* within a comment.
2013-05-07 20:05:53 -07:00
Ralph Giles
c973a5961e Update implementation status for Firefox 20 stable release.
Release date based on directory timestamps in
https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/20.0/
2013-05-06 16:38:40 -04:00
Jean-Marc Valin
d66bdc7343 Revisit surround rate allocation
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.
2013-05-06 16:03:39 -04:00
Jean-Marc Valin
d2c484b5e7 Adds spreading to the surround masking computation
This avoids a single low-energy band from changing the masking results.
2013-05-06 16:02:31 -04:00
Jean-Marc Valin
a4dccd3f65 Implements basic surround masking
The idea is that the rate of each stream is adjusted based on its
contribution to the total energy of a stereo downmix.
2013-05-05 02:44:54 -04:00
Jean-Marc Valin
7a8b1399d2 Adds support for all Vorbis mappings 2013-05-05 02:33:53 -04:00
Jean-Marc Valin
172f66a3ac More forced decisions in CELT LFE encoding 2013-05-05 02:32:00 -04:00
Jean-Marc Valin
b08c4ca3f5 Surround: Better LFE handling
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
2013-05-05 02:31:38 -04:00
Jean-Marc Valin
1b72386a7c Initial surround code with new API
Conflicts:
	src/opus_multistream_encoder.c
2013-05-05 02:31:09 -04:00
Jean-Marc Valin
b042935693 Fixes missing initialization in OpusMSEncoder
Problem found using valgrind.
2013-05-05 02:22:06 -04:00
Jean-Marc Valin
1bf32bb5ac Fixes FEC issues introduced in 7fcd66c
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).
2013-04-23 02:41:28 -04:00
Jean-Marc Valin
f77410deb6 VBR bitrate calibration for variable duration.
Also fixes uninitialized value in previous commit.
2013-04-19 22:44:03 -04:00
Jean-Marc Valin
3252bf2a68 Variable framesize improvements
- 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)
2013-04-19 03:20:40 -04:00
Jean-Marc Valin
a8783a15b4 Converts the analysis to ALLOC() 2013-04-15 15:49:40 -04:00
Jean-Marc Valin
c37834b27e Fixes a minor bug found by valgrind in the bandwidth detector
The energy calculation from the packed FFTs ended up reading out-of-bound
memory for frequency zero. The bug was exposed by c5e04e4.
2013-04-15 02:53:09 -04:00
Gregory Maxwell
2fb4f5c439 Random complexity in the encoder tests. 2013-04-05 19:16:58 -07:00
Timothy B. Terriberry
a8f04b23f9 Fix some 16-bit int issues in the multistream API.
With 120 ms frames and 6 or more channels, the total number of
 samples in the buffer could overflow.
2013-03-18 14:42:44 -07:00
Jean-Marc Valin
74d43f0a36 Minor soft clipping doc fix 2013-03-18 17:06:43 -04:00
Ralph Giles
99e8a9352b Remove -Wdeclaration-after-statement.
This causes warnings with the ALLOC() macro.
2013-03-12 22:57:00 -07:00
Jean-Marc Valin
c5e04e4aa4 Makes bandwidth detection less aggressive.
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.
2013-03-12 11:24:53 -04:00
Jean-Marc Valin
f982b84d1e Fixes a minor glitch on SILK bandwidth changes
We weren't doing the prefilling for SILK->SILK transitions.
2013-03-11 17:13:34 -04:00
Ralph Giles
42f39c547b Add -Wdeclaration-after-statement.
We keep accidentally adding these which break the -pedantic build,
so complain about it in the normal build.

Also de-duplicate the warning list.
2013-03-11 10:59:13 -07:00
Koen Vos
933a2754fc High-band attenuation tuning for hybrid mode
Signed-off-by: Jean-Marc Valin <jmvalin@jmvalin.ca>
2013-03-11 13:43:17 -04:00
Jean-Marc Valin
5a6e7c8b2f Fixes pseudo-stack 2013-03-11 13:41:11 -04:00
Taihei Momma
22345ef16e Fixes OPUS_SET_EXPERT_FRAME_DURATION_REQUEST for multi-stream
Signed-off-by: Jean-Marc Valin <jmvalin@jmvalin.ca>
2013-03-11 13:39:26 -04:00
Robert Meakins
097fd4b111 Fixes C90 issues for obsolete compilers
Signed-off-by: Jean-Marc Valin <jmvalin@jmvalin.ca>
2013-03-11 13:39:17 -04:00
Jean-Marc Valin
d865fe6187 Adds stereo width computation
Using this to change the encoder based on mono/stereo rather than looking
at the number of input channels.
2013-03-11 11:35:10 -04:00
Jean-Marc Valin
f96fc8cc83 Merge branch 'exp_analysis'
Conflicts:
	celt/celt_encoder.c
2013-03-08 12:29:53 -05:00
Jean-Marc Valin
fa43c770e0 Making CELT stereo<->mono transitions gradual
This not only avoids sudden changes in audio quality, but also increases
quality when we don't have enough bits to code a wide stereo image.
2013-03-08 11:35:15 -05:00
Jean-Marc Valin
f55b0eaca5 Documentation fixes
Improved version of:
f44b28ab56
2013-03-07 18:17:52 -05:00
James Zern
a41a585f35 test_opus_decode: force integer constants unsigned
Quiets:
warning: this decimal constant is unsigned only in ISO C90

when building with e.g., gcc -m32 -std=gnu90
2013-03-05 09:18:07 -08:00
Jean-Marc Valin
d9aa6e046b Oops, fixed API name from previous commit 2013-03-01 16:07:02 -05:00
Jean-Marc Valin
32c4a0c96e Applies soft-clipping to the int decoder API.
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.
2013-03-01 15:23:01 -05:00
Jean-Marc Valin
73142b100a Makes the speech/music probability estimation mode conservative
This is done using an adaptive beta and an estimate of the speech
and music detection confidence
2013-02-28 15:30:51 -05:00
Jean-Marc Valin
742aac1056 Adds silence probability to speech/music detector
Avoids biasing the decision when it's all silence/noise.
2013-02-22 16:44:56 -05:00
Jean-Marc Valin
74f36b56dd oops s/IMAX/IMIN/ 2013-02-20 22:32:19 -05:00
Jean-Marc Valin
51f4a32ec2 Adds support for delayed decision
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.
2013-02-20 04:08:34 -05:00
Jean-Marc Valin
69c3dcd105 Fixes a bug introduced in 851f803 2013-02-19 03:42:18 -05:00
Jean-Marc Valin
3ecd9c20cb Fixes two bandwidth decision issues
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.
2013-02-19 00:42:15 -05:00
Jean-Marc Valin
851f8033f6 Moves mono downmixing and upsampling to the compute_mdcts() 2013-02-18 01:43:43 -05:00
Jean-Marc Valin
541a472ff6 Adds code to revise the transient decision using the band energy
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.
2013-02-17 21:21:30 -05:00
Jean-Marc Valin
10a34a5dd6 Making multistream variable duration work for both the float and int API 2013-02-10 23:53:44 -05:00
Jean-Marc Valin
bb43b8b69d No need for extra_buffer anymore 2013-02-10 23:53:44 -05:00
Jean-Marc Valin
95561be6de Better handling of the multistream bitrate
Now supports OPUS_AUTO and OPUS_BITRATE_MAX
2013-02-10 23:53:43 -05:00
Jean-Marc Valin
7448366046 Multistream support for variable frame duration
Also fixes a bug with stereo streams where the initial memory was only
using the left channel.
2013-02-10 23:53:43 -05:00
Jean-Marc Valin
f548a5a35d Makes variable framesize less aggressive at lower rates 2013-02-10 23:53:43 -05:00
Jean-Marc Valin
8547964815 Re-enable analysis for 40- and 60-ms frames 2013-02-10 23:53:27 -05:00