shithub: opus

Download patch

ref: e564cc509d74ef284fec5f5104249e594a8ca3d4
parent: 33698ee159ab6ab1de5ae86c62249d0c2ae4d8f7
author: Felicia Lim <[email protected]>
date: Fri Oct 28 05:34:51 EDT 2016

Fix CBR packet sizes for 80 ms

Also clean up comments from the last patches

Signed-off-by: Jean-Marc Valin <[email protected]>

--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -1285,7 +1285,6 @@
       }
    }
 
-   /* If encoding multiframes recursively, the true number of frames is rp->nb_frames. */
    ret = opus_repacketizer_out_range_impl(rp, 0, nb_frames, data, repacketize_len, 0, !st->use_vbr);
 
    if (ret<0)
@@ -1447,11 +1446,11 @@
     if (!st->use_vbr)
     {
        int cbrBytes;
-       /* Multiply by 3 to make sure the division is exact. */
-       int frame_rate6 = 6*st->Fs/frame_size;
+       /* Multiply by 12 to make sure the division is exact. */
+       int frame_rate12 = 12*st->Fs/frame_size;
        /* We need to make sure that "int" values always fit in 16 bits. */
-       cbrBytes = IMIN( (6*st->bitrate_bps/8 + frame_rate6/2)/frame_rate6, max_data_bytes);
-       st->bitrate_bps = cbrBytes*(opus_int32)frame_rate6*8/6;
+       cbrBytes = IMIN( (12*st->bitrate_bps/8 + frame_rate12/2)/frame_rate12, max_data_bytes);
+       st->bitrate_bps = cbrBytes*(opus_int32)frame_rate12*8/12;
        /* Make sure we provide at least one byte to avoid failing. */
        max_data_bytes = IMAX(1, cbrBytes);
     }