Define CELT bitrate=-1 as "unlimited" (i.e. all bytes given)
authorJean-Marc Valin <jean-marc.valin@usherbrooke.ca>
Tue, 16 Aug 2011 02:37:11 +0000 (22:37 -0400)
committerJean-Marc Valin <jean-marc.valin@usherbrooke.ca>
Tue, 16 Aug 2011 02:37:11 +0000 (22:37 -0400)
libcelt/celt.c
src/opus_encoder.c

index 6a1689c..acb81ad 100644 (file)
@@ -997,7 +997,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i
    nbCompressedBytes = IMIN(nbCompressedBytes,1275);
    nbAvailableBytes = nbCompressedBytes - nbFilledBytes;
 
-   if (st->vbr)
+   if (st->vbr && st->bitrate!=-1)
    {
       opus_int32 den=st->mode->Fs>>BITRES;
       vbr_rate=(st->bitrate*frame_size+(den>>1))/den;
@@ -1010,8 +1010,9 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i
       tmp = st->bitrate*frame_size;
       if (tell>1)
          tmp += tell;
-      nbCompressedBytes = IMAX(2, IMIN(nbCompressedBytes,
-            (tmp+4*st->mode->Fs)/(8*st->mode->Fs)-!!st->signalling));
+      if (st->bitrate!=-1)
+         nbCompressedBytes = IMAX(2, IMIN(nbCompressedBytes,
+               (tmp+4*st->mode->Fs)/(8*st->mode->Fs)-!!st->signalling));
       effectiveBytes = nbCompressedBytes;
    }
 
@@ -1806,7 +1807,7 @@ int celt_encoder_ctl(CELTEncoder * restrict st, int request, ...)
       case CELT_SET_BITRATE_REQUEST:
       {
          opus_int32 value = va_arg(ap, opus_int32);
-         if (value<=500)
+         if (value<=500 && value!=-1)
             goto bad_arg;
          value = IMIN(value, 260000*st->channels);
          st->bitrate = value;
index d6a2d48..3e86c63 100644 (file)
@@ -479,7 +479,7 @@ int opus_encode(OpusEncoder *st, const opus_int16 *pcm, int frame_size,
     if (st->mode != MODE_SILK_ONLY)
     {
         celt_encoder_ctl(celt_enc, CELT_SET_VBR(0));
-        celt_encoder_ctl(celt_enc, CELT_SET_BITRATE(510000));
+        celt_encoder_ctl(celt_enc, CELT_SET_BITRATE(-1));
         if (st->prev_mode == MODE_SILK_ONLY)
         {
             unsigned char dummy[10];