Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Harris <mark.hsj@gmail.com>2016-11-02 16:16:50 +0300
committerMark Harris <mark.hsj@gmail.com>2016-11-02 17:19:32 +0300
commit1fd53f9a928a7c76d1a89c01f0e8466efaa071bf (patch)
tree78dcd3011eea6fbb0644236533ec42b871b9dc6b
parentd31f883c823b6ff09c84ab4e4263ae0868db9bba (diff)
Fix redundancy on SILK 80+ms bandwidth switch
With packets of 80 ms or more, a SILK bandwidth switch was missing the second half of the redundancy, because st->silk_bw_switch was cleared too early before any recursive calls.
-rw-r--r--src/opus_encoder.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/src/opus_encoder.c b/src/opus_encoder.c
index db4cdb16..974bd129 100644
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -1677,24 +1677,6 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
equiv_rate = compute_equiv_rate(st->bitrate_bps, st->stream_channels, st->Fs/frame_size,
st->use_vbr, st->mode, st->silk_mode.complexity, st->silk_mode.packetLossPercentage);
- /* For the first frame at a new SILK bandwidth */
- if (st->silk_bw_switch)
- {
- redundancy = 1;
- celt_to_silk = 1;
- st->silk_bw_switch = 0;
- prefill=1;
- }
-
- if (redundancy)
- {
- /* Fair share of the max size allowed */
- redundancy_bytes = IMIN(257, max_data_bytes*(opus_int32)(st->Fs/200)/(frame_size+st->Fs/200));
- /* For VBR, target the actual bitrate (subject to the limit above) */
- if (st->use_vbr)
- redundancy_bytes = IMIN(redundancy_bytes, st->bitrate_bps/1600);
- }
-
if (st->mode != MODE_CELT_ONLY && st->prev_mode == MODE_CELT_ONLY)
{
silk_EncControlStruct dummy;
@@ -1844,12 +1826,27 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
return ret;
}
+ /* For the first frame at a new SILK bandwidth */
+ if (st->silk_bw_switch)
+ {
+ redundancy = 1;
+ celt_to_silk = 1;
+ st->silk_bw_switch = 0;
+ prefill=1;
+ }
+
/* If we decided to go with CELT, make sure redundancy is off, no matter what
we decided earlier. */
if (st->mode == MODE_CELT_ONLY)
- {
redundancy = 0;
- redundancy_bytes = 0;
+
+ if (redundancy)
+ {
+ /* Fair share of the max size allowed */
+ redundancy_bytes = IMIN(257, max_data_bytes*(opus_int32)(st->Fs/200)/(frame_size+st->Fs/200));
+ /* For VBR, target the actual bitrate (subject to the limit above) */
+ if (st->use_vbr)
+ redundancy_bytes = IMIN(redundancy_bytes, st->bitrate_bps/1600);
}
/* printf("%d %d %d %d\n", st->bitrate_bps, st->stream_channels, st->mode, curr_bandwidth); */