diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2016-06-02 17:54:14 -0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2016-07-19 16:11:19 -0400 |
commit | f6c4f6464eb59c2d3e66ba3d0bb44ec7883c5ffb (patch) | |
tree | 6797e9646fc58dacac6e6c0406030f04c2aca767 | |
parent | de1f92c610ce69a8ccc3124b28a2fd5a5f1ff8cd (diff) | |
download | opus-f6c4f6464eb59c2d3e66ba3d0bb44ec7883c5ffb.tar.gz |
Improving CBR for hybrid mode
Hybrid CBR now simply forces the SILK CBR rate to the "target" value. Also,
we're getting rid of the -2 kb/s offset for CBR, which appeared to be harmful.
In the case of hybrid constrained VBR, the cap is computed in the same way
as the target.
-rw-r--r-- | src/opus_encoder.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/opus_encoder.c b/src/opus_encoder.c index c13b1da1..ef6fc590 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -1792,14 +1792,21 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ nBytes = IMIN(1275, max_data_bytes-1-redundancy_bytes); st->silk_mode.maxBits = nBytes*8; - /* Only allow up to 90% of the bits for hybrid mode*/ - if (st->mode == MODE_HYBRID) - st->silk_mode.maxBits = (opus_int32)st->silk_mode.maxBits*9/10; if (st->silk_mode.useCBR) { - st->silk_mode.maxBits = (st->silk_mode.bitRate * frame_size / (st->Fs * 8))*8; - /* Reduce the initial target to make it easier to reach the CBR rate */ - st->silk_mode.bitRate = IMAX(1, st->silk_mode.bitRate-2000); + if (st->mode == MODE_HYBRID) + { + st->silk_mode.maxBits = st->silk_mode.bitRate * frame_size / st->Fs; + } + } else { + /* Constrained VBR. */ + if (st->mode == MODE_HYBRID) + { + /* Compute SILK bitrate corresponding to the max total bits available */ + opus_int32 maxBitRate = compute_silk_rate_for_hybrid(nBytes*8*st->Fs / frame_size, + curr_bandwidth, st->Fs == 50 * frame_size, st->use_vbr); + st->silk_mode.maxBits = maxBitRate * frame_size / st->Fs; + } } if (prefill) |