Loss rate adaptation for the CELT layer
authorJean-Marc Valin <jean-marc.valin@octasic.com>
Mon, 25 Apr 2011 17:36:14 +0000 (13:36 -0400)
committerJean-Marc Valin <jean-marc.valin@octasic.com>
Mon, 25 Apr 2011 17:36:14 +0000 (13:36 -0400)
celt
src/opus_encoder.c

diff --git a/celt b/celt
index d25dd2b..cb73e5c 160000 (submodule)
--- a/celt
+++ b/celt
@@ -1 +1 @@
-Subproject commit d25dd2bff9f111fcc8d2de802c1cca337db27873
+Subproject commit cb73e5ca62f93f530e65b244cf52f905a727d04d
index 1872fe9..cf0eee1 100644 (file)
@@ -583,7 +583,10 @@ int opus_encoder_ctl(OpusEncoder *st, int request, ...)
         case OPUS_SET_PACKET_LOSS_PERC_REQUEST:
         {
             int value = va_arg(ap, int);
+            if (value < 0 || value > 100)
+                return OPUS_BAD_ARG;
             st->silk_mode.packetLossPercentage = value;
+            celt_encoder_ctl(st->celt_enc, CELT_SET_LOSS_PERC(value));
         }
         break;
         case OPUS_GET_PACKET_LOSS_PERC_REQUEST:
@@ -609,7 +612,7 @@ int opus_encoder_ctl(OpusEncoder *st, int request, ...)
         {
             int value = va_arg(ap, int);
             if (value>100 || value<0)
-                return OPUS_BAD_ARG;
+                goto bad_arg;
             st->voice_ratio = value;
         }
         break;
@@ -635,9 +638,11 @@ int opus_encoder_ctl(OpusEncoder *st, int request, ...)
             fprintf(stderr, "unknown opus_encoder_ctl() request: %d", request);
             break;
     }
-
     va_end(ap);
     return OPUS_OK;
+bad_arg:
+    va_end(ap);
+    return OPUS_BAD_ARG;
 }
 
 void opus_encoder_destroy(OpusEncoder *st)