shithub: opus

Download patch

ref: dd7b0dac3ba85cda7e314eaa867b4f0d716c9ac4
parent: 90a39039a46040faa944b4690c16452a088016e2
author: Gregory Maxwell <[email protected]>
date: Sat Jun 29 16:06:07 EDT 2013

Fixes some return without va_end in the api, adds tests.

Also makes the CTL bad argument handling more consistent to avoid mistakes
 like that in the future.  Also updates the variable duration docs.

--- a/include/opus_defines.h
+++ b/include/opus_defines.h
@@ -538,8 +538,9 @@
 #define OPUS_GET_LAST_PACKET_DURATION(x) OPUS_GET_LAST_PACKET_DURATION_REQUEST, __opus_check_int_ptr(x)
 
 /** Configures the encoder's use of variable duration frames.
-  * When enabled, the encoder is free to use a shorter frame size than the one
-  * requested in the opus_encode*() call. It is then the user's responsibility
+  * When variable duration is enabled, the encoder is free to use a shorter frame
+  * size than the one requested in the opus_encode*() call.
+  * It is then the user's responsibility
   * to verify how much audio was encoded by checking the ToC byte of the encoded
   * packet. The part of the audio that was not encoded needs to be resent to the
   * encoder for the next call. Do not use this option unless you <b>really</b>
@@ -547,8 +548,14 @@
   * @see OPUS_GET_EXPERT_VARIABLE_DURATION
   * @param[in] x <tt>opus_int32</tt>: Allowed values:
   * <dl>
-  * <dt>0</dt><dd>Disable variable duration (default).</dd>
-  * <dt>1</dt><dd>Enable variable duration.</dd>
+  * <dt>OPUS_FRAMESIZE_ARG</dt><dd>Select frame size from the argument (default).</dd>
+  * <dt>OPUS_FRAMESIZE_2_5_MS</dt><dd>Use 2.5 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 2.5 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_10_MS</dt><dd>Use 10 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_60_MS</dt><dd>Use 60 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_VARIABLE</dt><dd>Optimize the frame size dynamically.</dd>
   * </dl>
   * @hideinitializer */
 #define OPUS_SET_EXPERT_FRAME_DURATION(x) OPUS_SET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int(x)
@@ -556,8 +563,14 @@
   * @see OPUS_SET_EXPERT_VARIABLE_DURATION
   * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
   * <dl>
-  * <dt>0</dt><dd>variable duration disabled (default).</dd>
-  * <dt>1</dt><dd>variable duration enabled.</dd>
+  * <dt>OPUS_FRAMESIZE_ARG</dt><dd>Select frame size from the argument (default).</dd>
+  * <dt>OPUS_FRAMESIZE_2_5_MS</dt><dd>Use 2.5 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 2.5 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_10_MS</dt><dd>Use 10 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_60_MS</dt><dd>Use 60 ms frames.</dd>
+  * <dt>OPUS_FRAMESIZE_VARIABLE</dt><dd>Optimize the frame size dynamically.</dd>
   * </dl>
   * @hideinitializer */
 #define OPUS_GET_EXPERT_FRAME_DURATION(x) OPUS_GET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int_ptr(x)
--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -937,6 +937,7 @@
    case OPUS_GET_BANDWIDTH_REQUEST:
    {
       opus_int32 *value = va_arg(ap, opus_int32*);
+      if (!value) goto bad_arg;
       *value = st->bandwidth;
    }
    break;
@@ -943,6 +944,7 @@
    case OPUS_GET_FINAL_RANGE_REQUEST:
    {
       opus_uint32 *value = va_arg(ap, opus_uint32*);
+      if (!value) goto bad_arg;
       *value = st->rangeFinal;
    }
    break;
@@ -961,11 +963,7 @@
    case OPUS_GET_SAMPLE_RATE_REQUEST:
    {
       opus_int32 *value = va_arg(ap, opus_int32*);
-      if (value==NULL)
-      {
-         ret = OPUS_BAD_ARG;
-         break;
-      }
+      if (!value) goto bad_arg;
       *value = st->Fs;
    }
    break;
@@ -972,11 +970,7 @@
    case OPUS_GET_PITCH_REQUEST:
    {
       opus_int32 *value = va_arg(ap, opus_int32*);
-      if (value==NULL)
-      {
-         ret = OPUS_BAD_ARG;
-         break;
-      }
+      if (!value) goto bad_arg;
       if (st->prev_mode == MODE_CELT_ONLY)
          celt_decoder_ctl(celt_dec, OPUS_GET_PITCH(value));
       else
@@ -986,11 +980,7 @@
    case OPUS_GET_GAIN_REQUEST:
    {
       opus_int32 *value = va_arg(ap, opus_int32*);
-      if (value==NULL)
-      {
-         ret = OPUS_BAD_ARG;
-         break;
-      }
+      if (!value) goto bad_arg;
       *value = st->decode_gain;
    }
    break;
@@ -997,11 +987,7 @@
    case OPUS_SET_GAIN_REQUEST:
    {
        opus_int32 value = va_arg(ap, opus_int32);
-       if (value<-32768 || value>32767)
-       {
-          ret = OPUS_BAD_ARG;
-          break;
-       }
+       if (value<-32768 || value>32767) goto bad_arg;
        st->decode_gain = value;
    }
    break;
@@ -1008,6 +994,7 @@
    case OPUS_GET_LAST_PACKET_DURATION_REQUEST:
    {
       opus_uint32 *value = va_arg(ap, opus_uint32*);
+      if (!value) goto bad_arg;
       *value = st->last_packet_duration;
    }
    break;
@@ -1019,6 +1006,9 @@
 
    va_end(ap);
    return ret;
+bad_arg:
+   va_end(ap);
+   return OPUS_BAD_ARG;
 }
 
 void opus_decoder_destroy(OpusDecoder *st)
--- a/src/opus_demo.c
+++ b/src/opus_demo.c
@@ -272,7 +272,7 @@
     int curr_mode=0;
     int curr_mode_count=0;
     int mode_switch_time = 48000;
-    int nb_encoded;
+    int nb_encoded=0;
     int remaining=0;
     int variable_duration=OPUS_FRAMESIZE_ARG;
     int delayed_decision=0;
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -1966,6 +1966,7 @@
         case OPUS_GET_APPLICATION_REQUEST:
         {
             opus_int32 *value = va_arg(ap, opus_int32*);
+            if (!value) goto bad_arg;
             *value = st->application;
         }
         break;
@@ -1987,6 +1988,7 @@
         case OPUS_GET_BITRATE_REQUEST:
         {
             opus_int32 *value = va_arg(ap, opus_int32*);
+            if (!value) goto bad_arg;
             *value = user_bitrate_to_bitrate(st, st->prev_framesize, 1276);
         }
         break;
@@ -1993,8 +1995,7 @@
         case OPUS_SET_FORCE_CHANNELS_REQUEST:
         {
             opus_int32 value = va_arg(ap, opus_int32);
-            if((value<1 || value>st->channels) && value != OPUS_AUTO)
-                return OPUS_BAD_ARG;
+            if((value<1 || value>st->channels) && value != OPUS_AUTO) goto bad_arg;
             st->force_channels = value;
         }
         break;
@@ -2001,6 +2002,7 @@
         case OPUS_GET_FORCE_CHANNELS_REQUEST:
         {
             opus_int32 *value = va_arg(ap, opus_int32*);
+            if (!value) goto bad_arg;
             *value = st->force_channels;
         }
         break;
@@ -2007,8 +2009,7 @@
         case OPUS_SET_MAX_BANDWIDTH_REQUEST:
         {
             opus_int32 value = va_arg(ap, opus_int32);
-            if (value < OPUS_BANDWIDTH_NARROWBAND || value > OPUS_BANDWIDTH_FULLBAND)
-                return OPUS_BAD_ARG;
+            if (value < OPUS_BANDWIDTH_NARROWBAND || value > OPUS_BANDWIDTH_FULLBAND) goto bad_arg;
             st->max_bandwidth = value;
             if (st->max_bandwidth == OPUS_BANDWIDTH_NARROWBAND) {
                 st->silk_mode.maxInternalSampleRate = 8000;
@@ -2022,6 +2023,7 @@
         case OPUS_GET_MAX_BANDWIDTH_REQUEST:
         {
             opus_int32 *value = va_arg(ap, opus_int32*);
+            if (!value) goto bad_arg;
             *value = st->max_bandwidth;
         }
         break;
@@ -2028,8 +2030,7 @@
         case OPUS_SET_BANDWIDTH_REQUEST:
         {
             opus_int32 value = va_arg(ap, opus_int32);
-            if ((value < OPUS_BANDWIDTH_NARROWBAND || value > OPUS_BANDWIDTH_FULLBAND) && value != OPUS_AUTO)
-                return OPUS_BAD_ARG;
+            if ((value < OPUS_BANDWIDTH_NARROWBAND || value > OPUS_BANDWIDTH_FULLBAND) && value != OPUS_AUTO) goto bad_arg;
             st->user_bandwidth = value;
             if (st->user_bandwidth == OPUS_BANDWIDTH_NARROWBAND) {
                 st->silk_mode.maxInternalSampleRate = 8000;
@@ -2043,6 +2044,7 @@
         case OPUS_GET_BANDWIDTH_REQUEST:
         {
             opus_int32 *value = va_arg(ap, opus_int32*);
+            if (!value) goto bad_arg;
             *value = st->bandwidth;
         }
         break;
@@ -2049,8 +2051,7 @@
         case OPUS_SET_DTX_REQUEST:
         {
             opus_int32 value = va_arg(ap, opus_int32);
-            if(value<0 || value>1)
-                return OPUS_BAD_ARG;
+            if(value<0 || value>1) goto bad_arg;
             st->silk_mode.useDTX = value;
         }
         break;
@@ -2057,6 +2058,7 @@
         case OPUS_GET_DTX_REQUEST:
         {
             opus_int32 *value = va_arg(ap, opus_int32*);
+            if (!value) goto bad_arg;
             *value = st->silk_mode.useDTX;
         }
         break;
@@ -2063,8 +2065,7 @@
         case OPUS_SET_COMPLEXITY_REQUEST:
         {
             opus_int32 value = va_arg(ap, opus_int32);
-            if(value<0 || value>10)
-                return OPUS_BAD_ARG;
+            if(value<0 || value>10) goto bad_arg;
             st->silk_mode.complexity = value;
             celt_encoder_ctl(celt_enc, OPUS_SET_COMPLEXITY(value));
         }
@@ -2072,6 +2073,7 @@
         case OPUS_GET_COMPLEXITY_REQUEST:
         {
             opus_int32 *value = va_arg(ap, opus_int32*);
+            if (!value) goto bad_arg;
             *value = st->silk_mode.complexity;
         }
         break;
@@ -2078,8 +2080,7 @@
         case OPUS_SET_INBAND_FEC_REQUEST:
         {
             opus_int32 value = va_arg(ap, opus_int32);
-            if(value<0 || value>1)
-                return OPUS_BAD_ARG;
+            if(value<0 || value>1) goto bad_arg;
             st->silk_mode.useInBandFEC = value;
         }
         break;
@@ -2086,6 +2087,7 @@
         case OPUS_GET_INBAND_FEC_REQUEST:
         {
             opus_int32 *value = va_arg(ap, opus_int32*);
+            if (!value) goto bad_arg;
             *value = st->silk_mode.useInBandFEC;
         }
         break;
@@ -2092,8 +2094,7 @@
         case OPUS_SET_PACKET_LOSS_PERC_REQUEST:
         {
             opus_int32 value = va_arg(ap, opus_int32);
-            if (value < 0 || value > 100)
-                return OPUS_BAD_ARG;
+            if (value < 0 || value > 100) goto bad_arg;
             st->silk_mode.packetLossPercentage = value;
             celt_encoder_ctl(celt_enc, OPUS_SET_PACKET_LOSS_PERC(value));
         }
@@ -2101,6 +2102,7 @@
         case OPUS_GET_PACKET_LOSS_PERC_REQUEST:
         {
             opus_int32 *value = va_arg(ap, opus_int32*);
+            if (!value) goto bad_arg;
             *value = st->silk_mode.packetLossPercentage;
         }
         break;
@@ -2107,8 +2109,7 @@
         case OPUS_SET_VBR_REQUEST:
         {
             opus_int32 value = va_arg(ap, opus_int32);
-            if(value<0 || value>1)
-                return OPUS_BAD_ARG;
+            if(value<0 || value>1) goto bad_arg;
             st->use_vbr = value;
             st->silk_mode.useCBR = 1-value;
         }
@@ -2116,6 +2117,7 @@
         case OPUS_GET_VBR_REQUEST:
         {
             opus_int32 *value = va_arg(ap, opus_int32*);
+            if (!value) goto bad_arg;
             *value = st->use_vbr;
         }
         break;
@@ -2122,8 +2124,7 @@
         case OPUS_SET_VOICE_RATIO_REQUEST:
         {
             opus_int32 value = va_arg(ap, opus_int32);
-            if (value>100 || value<-1)
-                goto bad_arg;
+            if (value<-1 || value>100) goto bad_arg;
             st->voice_ratio = value;
         }
         break;
@@ -2130,6 +2131,7 @@
         case OPUS_GET_VOICE_RATIO_REQUEST:
         {
             opus_int32 *value = va_arg(ap, opus_int32*);
+            if (!value) goto bad_arg;
             *value = st->voice_ratio;
         }
         break;
@@ -2136,8 +2138,7 @@
         case OPUS_SET_VBR_CONSTRAINT_REQUEST:
         {
             opus_int32 value = va_arg(ap, opus_int32);
-            if(value<0 || value>1)
-                return OPUS_BAD_ARG;
+            if(value<0 || value>1) goto bad_arg;
             st->vbr_constraint = value;
         }
         break;
@@ -2144,6 +2145,7 @@
         case OPUS_GET_VBR_CONSTRAINT_REQUEST:
         {
             opus_int32 *value = va_arg(ap, opus_int32*);
+            if (!value) goto bad_arg;
             *value = st->vbr_constraint;
         }
         break;
@@ -2150,8 +2152,7 @@
         case OPUS_SET_SIGNAL_REQUEST:
         {
             opus_int32 value = va_arg(ap, opus_int32);
-            if(value!=OPUS_AUTO && value!=OPUS_SIGNAL_VOICE && value!=OPUS_SIGNAL_MUSIC)
-                return OPUS_BAD_ARG;
+            if(value!=OPUS_AUTO && value!=OPUS_SIGNAL_VOICE && value!=OPUS_SIGNAL_MUSIC) goto bad_arg;
             st->signal_type = value;
         }
         break;
@@ -2158,6 +2159,7 @@
         case OPUS_GET_SIGNAL_REQUEST:
         {
             opus_int32 *value = va_arg(ap, opus_int32*);
+            if (!value) goto bad_arg;
             *value = st->signal_type;
         }
         break;
@@ -2164,6 +2166,7 @@
         case OPUS_GET_LOOKAHEAD_REQUEST:
         {
             opus_int32 *value = va_arg(ap, opus_int32*);
+            if (!value) goto bad_arg;
             *value = st->Fs/400;
             if (st->application != OPUS_APPLICATION_RESTRICTED_LOWDELAY)
                 *value += st->delay_compensation;
@@ -2172,11 +2175,7 @@
         case OPUS_GET_SAMPLE_RATE_REQUEST:
         {
             opus_int32 *value = va_arg(ap, opus_int32*);
-            if (value==NULL)
-            {
-                ret = OPUS_BAD_ARG;
-                break;
-            }
+            if (!value) goto bad_arg;
             *value = st->Fs;
         }
         break;
@@ -2183,6 +2182,7 @@
         case OPUS_GET_FINAL_RANGE_REQUEST:
         {
             opus_uint32 *value = va_arg(ap, opus_uint32*);
+            if (!value) goto bad_arg;
             *value = st->rangeFinal;
         }
         break;
@@ -2189,8 +2189,7 @@
         case OPUS_SET_LSB_DEPTH_REQUEST:
         {
             opus_int32 value = va_arg(ap, opus_int32);
-            if (value<8 || value>24)
-               goto bad_arg;
+            if (value<8 || value>24) goto bad_arg;
             st->lsb_depth=value;
         }
         break;
@@ -2197,6 +2196,7 @@
         case OPUS_GET_LSB_DEPTH_REQUEST:
         {
             opus_int32 *value = va_arg(ap, opus_int32*);
+            if (!value) goto bad_arg;
             *value = st->lsb_depth;
         }
         break;
@@ -2203,6 +2203,12 @@
         case OPUS_SET_EXPERT_FRAME_DURATION_REQUEST:
         {
             opus_int32 value = va_arg(ap, opus_int32);
+            if (value != OPUS_FRAMESIZE_ARG   && value != OPUS_FRAMESIZE_2_5_MS &&
+                value != OPUS_FRAMESIZE_5_MS  && value != OPUS_FRAMESIZE_10_MS  &&
+                value != OPUS_FRAMESIZE_20_MS && value != OPUS_FRAMESIZE_40_MS  &&
+                value != OPUS_FRAMESIZE_60_MS && value != OPUS_FRAMESIZE_VARIABLE) {
+              goto bad_arg;
+            }
             st->variable_duration = value;
             celt_encoder_ctl(celt_enc, OPUS_SET_EXPERT_FRAME_DURATION(value));
         }
@@ -2210,6 +2216,7 @@
         case OPUS_GET_EXPERT_FRAME_DURATION_REQUEST:
         {
             opus_int32 *value = va_arg(ap, opus_int32*);
+            if (!value) goto bad_arg;
             *value = st->variable_duration;
         }
         break;
@@ -2237,8 +2244,7 @@
         case OPUS_SET_FORCE_MODE_REQUEST:
         {
             opus_int32 value = va_arg(ap, opus_int32);
-            if ((value < MODE_SILK_ONLY || value > MODE_CELT_ONLY) && value != OPUS_AUTO)
-               goto bad_arg;
+            if ((value < MODE_SILK_ONLY || value > MODE_CELT_ONLY) && value != OPUS_AUTO) goto bad_arg;
             st->user_forced_mode = value;
         }
         break;
@@ -2246,13 +2252,14 @@
         {
             opus_int32 value = va_arg(ap, opus_int32);
             st->lfe = value;
-            celt_encoder_ctl(celt_enc, OPUS_SET_LFE(value));
+            ret = celt_encoder_ctl(celt_enc, OPUS_SET_LFE(value));
         }
         break;
         case OPUS_SET_ENERGY_SAVE_REQUEST:
         {
             opus_val16 *value = va_arg(ap, opus_val16*);
-            celt_encoder_ctl(celt_enc, OPUS_SET_ENERGY_SAVE(value));
+            if (!value) goto bad_arg;
+            ret = celt_encoder_ctl(celt_enc, OPUS_SET_ENERGY_SAVE(value));
         }
         break;
         case OPUS_SET_ENERGY_MASK_REQUEST:
@@ -2259,7 +2266,7 @@
         {
             opus_val16 *value = va_arg(ap, opus_val16*);
             st->energy_masking = (value!=NULL);
-            celt_encoder_ctl(celt_enc, OPUS_SET_ENERGY_MASK(value));
+            ret = celt_encoder_ctl(celt_enc, OPUS_SET_ENERGY_MASK(value));
         }
         break;
 
@@ -2266,9 +2273,8 @@
         case CELT_GET_MODE_REQUEST:
         {
            const CELTMode ** value = va_arg(ap, const CELTMode**);
-           if (value==0)
-              goto bad_arg;
-           celt_encoder_ctl(celt_enc, CELT_GET_MODE(value));
+           if (!value) goto bad_arg;
+           ret = celt_encoder_ctl(celt_enc, CELT_GET_MODE(value));
         }
         break;
         default:
--- a/src/opus_multistream_decoder.c
+++ b/src/opus_multistream_decoder.c
@@ -400,6 +400,7 @@
           int s;
           opus_uint32 *value = va_arg(ap, opus_uint32*);
           opus_uint32 tmp;
+          if (!value) goto bad_arg;
           *value = 0;
           for (s=0;s<st->layout.nb_streams;s++)
           {
@@ -442,6 +443,7 @@
           if (stream_id<0 || stream_id >= st->layout.nb_streams)
              ret = OPUS_BAD_ARG;
           value = va_arg(ap, OpusDecoder**);
+          if (!value) goto bad_arg;
           for (s=0;s<stream_id;s++)
           {
              if (s < st->layout.nb_coupled_streams)
@@ -479,6 +481,9 @@
 
    va_end(ap);
    return ret;
+bad_arg:
+   va_end(ap);
+   return OPUS_BAD_ARG;
 }
 
 
--- a/src/opus_multistream_encoder.c
+++ b/src/opus_multistream_encoder.c
@@ -861,6 +861,7 @@
    {
       int s;
       opus_int32 *value = va_arg(ap, opus_int32*);
+      if (!value) goto bad_arg;
       *value = 0;
       for (s=0;s<st->layout.nb_streams;s++)
       {
@@ -903,6 +904,7 @@
       int s;
       opus_uint32 *value = va_arg(ap, opus_uint32*);
       opus_uint32 tmp;
+      if (!value) goto bad_arg;
       *value=0;
       for (s=0;s<st->layout.nb_streams;s++)
       {
@@ -958,6 +960,7 @@
       if (stream_id<0 || stream_id >= st->layout.nb_streams)
          ret = OPUS_BAD_ARG;
       value = va_arg(ap, OpusEncoder**);
+      if (!value) goto bad_arg;
       for (s=0;s<stream_id;s++)
       {
          if (s < st->layout.nb_coupled_streams)
@@ -977,6 +980,7 @@
    case OPUS_GET_EXPERT_FRAME_DURATION_REQUEST:
    {
        opus_int32 *value = va_arg(ap, opus_int32*);
+       if (!value) goto bad_arg;
        *value = st->variable_duration;
    }
    break;
@@ -996,5 +1000,3 @@
 {
     opus_free(st);
 }
-
-
--- a/tests/test_opus_api.c
+++ b/tests/test_opus_api.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 Xiph.Org Foundation
+/* Copyright (c) 2011-2013 Xiph.Org Foundation
    Written by Gregory Maxwell */
 /*
    Redistribution and use in source and binary forms, with or without
@@ -1120,8 +1120,8 @@
    cfgs++;
    err=opus_encoder_ctl(enc,OPUS_GET_LOOKAHEAD(&i));
    if(err!=OPUS_OK || i<0 || i>32766)test_failed();
-   opus_encoder_destroy(enc);
    cfgs++;
+   opus_encoder_destroy(enc);
 
    VG_UNDEF(&err,sizeof(err));
    enc = opus_encoder_create(48000, 2, OPUS_APPLICATION_AUDIO, &err);
@@ -1145,17 +1145,34 @@
    err=opus_encoder_ctl(enc,OPUS_GET_LOOKAHEAD(&i));
    if(err!=OPUS_OK || i<0 || i>32766)test_failed();
    cfgs++;
+   err=opus_encoder_ctl(enc,OPUS_GET_LOOKAHEAD((opus_int32 *)NULL));
+   if(err!=OPUS_BAD_ARG)test_failed();
+   cfgs++;
    fprintf(stdout,"    OPUS_GET_LOOKAHEAD ........................... OK.\n");
 
+   err=opus_encoder_ctl(enc,OPUS_GET_SAMPLE_RATE(&i));
+   if(err!=OPUS_OK || i!=48000)test_failed();
+   cfgs++;
+   err=opus_encoder_ctl(enc,OPUS_GET_SAMPLE_RATE((opus_int32 *)NULL));
+   if(err!=OPUS_BAD_ARG)test_failed();
+   cfgs++;
+   fprintf(stdout,"    OPUS_GET_SAMPLE_RATE ......................... OK.\n");
+
    if(opus_encoder_ctl(enc,OPUS_UNIMPLEMENTED)!=OPUS_UNIMPLEMENTED)test_failed();
    fprintf(stdout,"    OPUS_UNIMPLEMENTED ........................... OK.\n");
    cfgs++;
 
+   err=opus_encoder_ctl(enc,OPUS_GET_APPLICATION((opus_int32 *)NULL));
+   if(err!=OPUS_BAD_ARG)test_failed();
+   cfgs++;
    CHECK_SETGET(OPUS_SET_APPLICATION(i),OPUS_GET_APPLICATION(&i),-1,OPUS_AUTO,
      OPUS_APPLICATION_AUDIO,OPUS_APPLICATION_RESTRICTED_LOWDELAY,
      "    OPUS_SET_APPLICATION ......................... OK.\n",
      "    OPUS_GET_APPLICATION ......................... OK.\n")
 
+   err=opus_encoder_ctl(enc,OPUS_GET_BITRATE((opus_int32 *)NULL));
+   if(err!=OPUS_BAD_ARG)test_failed();
+   cfgs++;
    if(opus_encoder_ctl(enc,OPUS_SET_BITRATE(1073741832))!=OPUS_OK)test_failed();
    cfgs++;
    VG_UNDEF(&i,sizeof(i));
@@ -1167,6 +1184,9 @@
      "    OPUS_SET_BITRATE ............................. OK.\n",
      "    OPUS_GET_BITRATE ............................. OK.\n")
 
+   err=opus_encoder_ctl(enc,OPUS_GET_FORCE_CHANNELS((opus_int32 *)NULL));
+   if(err!=OPUS_BAD_ARG)test_failed();
+   cfgs++;
    CHECK_SETGET(OPUS_SET_FORCE_CHANNELS(i),OPUS_GET_FORCE_CHANNELS(&i),-1,3,
      1,OPUS_AUTO,
      "    OPUS_SET_FORCE_CHANNELS ...................... OK.\n",
@@ -1202,6 +1222,9 @@
    cfgs++;
    if(opus_encoder_ctl(enc,OPUS_SET_BANDWIDTH(OPUS_AUTO))!=OPUS_OK)test_failed();
    cfgs++;
+   err=opus_encoder_ctl(enc,OPUS_GET_BANDWIDTH((opus_int32 *)NULL));
+   if(err!=OPUS_BAD_ARG)test_failed();
+   cfgs++;
    fprintf(stdout,"    OPUS_GET_BANDWIDTH ........................... OK.\n");
 
    i=-2;
@@ -1232,55 +1255,113 @@
       i!=OPUS_BANDWIDTH_MEDIUMBAND&&i!=OPUS_BANDWIDTH_WIDEBAND&&
       i!=OPUS_BANDWIDTH_FULLBAND))test_failed();
    cfgs++;
+   err=opus_encoder_ctl(enc,OPUS_GET_MAX_BANDWIDTH((opus_int32 *)NULL));
+   if(err!=OPUS_BAD_ARG)test_failed();
+   cfgs++;
    fprintf(stdout,"    OPUS_GET_MAX_BANDWIDTH ....................... OK.\n");
 
+   err=opus_encoder_ctl(enc,OPUS_GET_DTX((opus_int32 *)NULL));
+   if(err!=OPUS_BAD_ARG)test_failed();
+   cfgs++;
    CHECK_SETGET(OPUS_SET_DTX(i),OPUS_GET_DTX(&i),-1,2,
      1,0,
      "    OPUS_SET_DTX ................................. OK.\n",
      "    OPUS_GET_DTX ................................. OK.\n")
 
+   err=opus_encoder_ctl(enc,OPUS_GET_COMPLEXITY((opus_int32 *)NULL));
+   if(err!=OPUS_BAD_ARG)test_failed();
+   cfgs++;
    CHECK_SETGET(OPUS_SET_COMPLEXITY(i),OPUS_GET_COMPLEXITY(&i),-1,11,
      0,10,
      "    OPUS_SET_COMPLEXITY .......................... OK.\n",
      "    OPUS_GET_COMPLEXITY .......................... OK.\n")
 
+   err=opus_encoder_ctl(enc,OPUS_GET_INBAND_FEC((opus_int32 *)NULL));
+   if(err!=OPUS_BAD_ARG)test_failed();
+   cfgs++;
    CHECK_SETGET(OPUS_SET_INBAND_FEC(i),OPUS_GET_INBAND_FEC(&i),-1,2,
      1,0,
      "    OPUS_SET_INBAND_FEC .......................... OK.\n",
      "    OPUS_GET_INBAND_FEC .......................... OK.\n")
 
+   err=opus_encoder_ctl(enc,OPUS_GET_PACKET_LOSS_PERC((opus_int32 *)NULL));
+   if(err!=OPUS_BAD_ARG)test_failed();
+   cfgs++;
    CHECK_SETGET(OPUS_SET_PACKET_LOSS_PERC(i),OPUS_GET_PACKET_LOSS_PERC(&i),-1,101,
      100,0,
      "    OPUS_SET_PACKET_LOSS_PERC .................... OK.\n",
      "    OPUS_GET_PACKET_LOSS_PERC .................... OK.\n")
 
+   err=opus_encoder_ctl(enc,OPUS_GET_VBR((opus_int32 *)NULL));
+   if(err!=OPUS_BAD_ARG)test_failed();
+   cfgs++;
    CHECK_SETGET(OPUS_SET_VBR(i),OPUS_GET_VBR(&i),-1,2,
      1,0,
      "    OPUS_SET_VBR ................................. OK.\n",
      "    OPUS_GET_VBR ................................. OK.\n")
 
-   /*CHECK_SETGET(OPUS_SET_VOICE_RATIO(i),OPUS_GET_VOICE_RATIO(&i),-2,101,
+/*   err=opus_encoder_ctl(enc,OPUS_GET_VOICE_RATIO((opus_int32 *)NULL));
+   if(err!=OPUS_BAD_ARG)test_failed();
+   cfgs++;
+   CHECK_SETGET(OPUS_SET_VOICE_RATIO(i),OPUS_GET_VOICE_RATIO(&i),-2,101,
      0,50,
      "    OPUS_SET_VOICE_RATIO ......................... OK.\n",
-     "    OPUS_GET_VOICE_RATIO ......................... OK.\n")
-   */
+     "    OPUS_GET_VOICE_RATIO ......................... OK.\n")*/
 
+   err=opus_encoder_ctl(enc,OPUS_GET_VBR_CONSTRAINT((opus_int32 *)NULL));
+   if(err!=OPUS_BAD_ARG)test_failed();
+   cfgs++;
    CHECK_SETGET(OPUS_SET_VBR_CONSTRAINT(i),OPUS_GET_VBR_CONSTRAINT(&i),-1,2,
      1,0,
      "    OPUS_SET_VBR_CONSTRAINT ...................... OK.\n",
      "    OPUS_GET_VBR_CONSTRAINT ...................... OK.\n")
 
+   err=opus_encoder_ctl(enc,OPUS_GET_SIGNAL((opus_int32 *)NULL));
+   if(err!=OPUS_BAD_ARG)test_failed();
+   cfgs++;
    CHECK_SETGET(OPUS_SET_SIGNAL(i),OPUS_GET_SIGNAL(&i),-12345,0x7FFFFFFF,
      OPUS_SIGNAL_MUSIC,OPUS_AUTO,
      "    OPUS_SET_SIGNAL .............................. OK.\n",
      "    OPUS_GET_SIGNAL .............................. OK.\n")
 
+   err=opus_encoder_ctl(enc,OPUS_GET_LSB_DEPTH((opus_int32 *)NULL));
+   if(err!=OPUS_BAD_ARG)test_failed();
+   cfgs++;
    CHECK_SETGET(OPUS_SET_LSB_DEPTH(i),OPUS_GET_LSB_DEPTH(&i),7,25,16,24,
      "    OPUS_SET_LSB_DEPTH ........................... OK.\n",
      "    OPUS_GET_LSB_DEPTH ........................... OK.\n")
 
+   err=opus_encoder_ctl(enc,OPUS_GET_EXPERT_FRAME_DURATION((opus_int32 *)NULL));
+   if(err!=OPUS_BAD_ARG)test_failed();
+   cfgs++;
+   err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_2_5_MS));
+   if(err!=OPUS_OK)test_failed();
+   cfgs++;
+   err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_5_MS));
+   if(err!=OPUS_OK)test_failed();
+   cfgs++;
+   err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_10_MS));
+   if(err!=OPUS_OK)test_failed();
+   cfgs++;
+   err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_20_MS));
+   if(err!=OPUS_OK)test_failed();
+   cfgs++;
+   err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_40_MS));
+   if(err!=OPUS_OK)test_failed();
+   cfgs++;
+   err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_60_MS));
+   if(err!=OPUS_OK)test_failed();
+   cfgs++;
+   CHECK_SETGET(OPUS_SET_EXPERT_FRAME_DURATION(i),OPUS_GET_EXPERT_FRAME_DURATION(&i),0,-1,
+     OPUS_FRAMESIZE_VARIABLE,OPUS_FRAMESIZE_ARG,
+     "    OPUS_SET_EXPERT_FRAME_DURATION ............... OK.\n",
+     "    OPUS_GET_EXPERT_FRAME_DURATION ............... OK.\n")
+
    /*OPUS_SET_FORCE_MODE is not tested here because it's not a public API, however the encoder tests use it*/
 
+   err=opus_encoder_ctl(enc,OPUS_GET_FINAL_RANGE((opus_uint32 *)NULL));
+   if(err!=OPUS_BAD_ARG)test_failed();
+   cfgs++;
    if(opus_encoder_ctl(enc,OPUS_GET_FINAL_RANGE(&enc_final_range))!=OPUS_OK)test_failed();
    cfgs++;
    fprintf(stdout,"    OPUS_GET_FINAL_RANGE ......................... OK.\n");