shithub: opus

Download patch

ref: d7aadd808fd2d6f2d8f4a5daf8b3ec32a0968e8e
parent: c5635d284b489c7705c2357cc4f0601587416b78
author: Jean-Marc Valin <[email protected]>
date: Thu Nov 14 20:41:12 EST 2013

Fixes a bug where the encoder was trying to use redundancy in CELT mode

The problem was that forcing CELT-mode for low bitrate CBR was done too late,
after the encoder had decided to use SILK. This was causing redundancy
to be allocated because the encoder didn't realize it was going to keep
using CELT.

--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -1165,6 +1165,9 @@
        st->mode = MODE_CELT_ONLY;
     if (st->lfe)
        st->mode = MODE_CELT_ONLY;
+    /* If max_data_bytes represents less than 8 kb/s, switch to CELT-only mode */
+    if (max_data_bytes < (frame_rate > 50 ? 12000 : 8000)*frame_size / (st->Fs * 8))
+       st->mode = MODE_CELT_ONLY;
 
     if (st->stream_channels == 1 && st->prev_channels ==2 && st->silk_mode.toMono==0
           && st->mode != MODE_CELT_ONLY && st->prev_mode != MODE_CELT_ONLY)
@@ -1318,10 +1321,6 @@
     }
 #endif
     celt_encoder_ctl(celt_enc, OPUS_SET_LSB_DEPTH(lsb_depth));
-
-    /* If max_data_bytes represents less than 8 kb/s, switch to CELT-only mode */
-    if (max_data_bytes < (frame_rate > 50 ? 12000 : 8000)*frame_size / (st->Fs * 8))
-       st->mode = MODE_CELT_ONLY;
 
     /* CELT mode doesn't support mediumband, use wideband instead */
     if (st->mode == MODE_CELT_ONLY && st->bandwidth == OPUS_BANDWIDTH_MEDIUMBAND)