shithub: opus

Download patch

ref: 69f44c5cea57aa2eae1edf231250ac01081d07b9
parent: 0fd8d675f8bf0f43fe25931c5f4b99bfa0db77fb
author: Jean-Marc Valin <[email protected]>
date: Tue Sep 6 22:43:23 EDT 2011

Making the encoder more robust against extreme bitrate requests

--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -848,6 +848,8 @@
     if (st->mode != MODE_SILK_ONLY)
     {
         ret = celt_encode_with_ec(celt_enc, pcm_buf, frame_size, NULL, nb_compr_bytes, &enc);
+        if (ret < 0)
+           return OPUS_INTERNAL_ERROR;
     }
 
     /* 5 ms redundant frame for SILK->CELT */
@@ -958,6 +960,8 @@
                     goto bad_arg;
                 else if (value <= 500)
                     value = 500;
+                else if (value > (opus_int32)300000*st->channels)
+                    value = (opus_int32)300000*st->channels;
             }
             st->user_bitrate_bps = value;
         }