1*a58d3d2aSXin Li /* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited 2*a58d3d2aSXin Li Written by Jean-Marc Valin and Koen Vos */ 3*a58d3d2aSXin Li /* 4*a58d3d2aSXin Li Redistribution and use in source and binary forms, with or without 5*a58d3d2aSXin Li modification, are permitted provided that the following conditions 6*a58d3d2aSXin Li are met: 7*a58d3d2aSXin Li 8*a58d3d2aSXin Li - Redistributions of source code must retain the above copyright 9*a58d3d2aSXin Li notice, this list of conditions and the following disclaimer. 10*a58d3d2aSXin Li 11*a58d3d2aSXin Li - Redistributions in binary form must reproduce the above copyright 12*a58d3d2aSXin Li notice, this list of conditions and the following disclaimer in the 13*a58d3d2aSXin Li documentation and/or other materials provided with the distribution. 14*a58d3d2aSXin Li 15*a58d3d2aSXin Li THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16*a58d3d2aSXin Li ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17*a58d3d2aSXin Li LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18*a58d3d2aSXin Li A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19*a58d3d2aSXin Li OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20*a58d3d2aSXin Li EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21*a58d3d2aSXin Li PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22*a58d3d2aSXin Li PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23*a58d3d2aSXin Li LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24*a58d3d2aSXin Li NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25*a58d3d2aSXin Li SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26*a58d3d2aSXin Li */ 27*a58d3d2aSXin Li 28*a58d3d2aSXin Li /** 29*a58d3d2aSXin Li * @file opus_defines.h 30*a58d3d2aSXin Li * @brief Opus reference implementation constants 31*a58d3d2aSXin Li */ 32*a58d3d2aSXin Li 33*a58d3d2aSXin Li #ifndef OPUS_DEFINES_H 34*a58d3d2aSXin Li #define OPUS_DEFINES_H 35*a58d3d2aSXin Li 36*a58d3d2aSXin Li #include "opus_types.h" 37*a58d3d2aSXin Li 38*a58d3d2aSXin Li #ifdef __cplusplus 39*a58d3d2aSXin Li extern "C" { 40*a58d3d2aSXin Li #endif 41*a58d3d2aSXin Li 42*a58d3d2aSXin Li /** @defgroup opus_errorcodes Error codes 43*a58d3d2aSXin Li * @{ 44*a58d3d2aSXin Li */ 45*a58d3d2aSXin Li /** No error @hideinitializer*/ 46*a58d3d2aSXin Li #define OPUS_OK 0 47*a58d3d2aSXin Li /** One or more invalid/out of range arguments @hideinitializer*/ 48*a58d3d2aSXin Li #define OPUS_BAD_ARG -1 49*a58d3d2aSXin Li /** Not enough bytes allocated in the buffer @hideinitializer*/ 50*a58d3d2aSXin Li #define OPUS_BUFFER_TOO_SMALL -2 51*a58d3d2aSXin Li /** An internal error was detected @hideinitializer*/ 52*a58d3d2aSXin Li #define OPUS_INTERNAL_ERROR -3 53*a58d3d2aSXin Li /** The compressed data passed is corrupted @hideinitializer*/ 54*a58d3d2aSXin Li #define OPUS_INVALID_PACKET -4 55*a58d3d2aSXin Li /** Invalid/unsupported request number @hideinitializer*/ 56*a58d3d2aSXin Li #define OPUS_UNIMPLEMENTED -5 57*a58d3d2aSXin Li /** An encoder or decoder structure is invalid or already freed @hideinitializer*/ 58*a58d3d2aSXin Li #define OPUS_INVALID_STATE -6 59*a58d3d2aSXin Li /** Memory allocation has failed @hideinitializer*/ 60*a58d3d2aSXin Li #define OPUS_ALLOC_FAIL -7 61*a58d3d2aSXin Li /**@}*/ 62*a58d3d2aSXin Li 63*a58d3d2aSXin Li /** @cond OPUS_INTERNAL_DOC */ 64*a58d3d2aSXin Li /**Export control for opus functions */ 65*a58d3d2aSXin Li 66*a58d3d2aSXin Li #ifndef OPUS_EXPORT 67*a58d3d2aSXin Li # if defined(_WIN32) 68*a58d3d2aSXin Li # if defined(OPUS_BUILD) && defined(DLL_EXPORT) 69*a58d3d2aSXin Li # define OPUS_EXPORT __declspec(dllexport) 70*a58d3d2aSXin Li # else 71*a58d3d2aSXin Li # define OPUS_EXPORT 72*a58d3d2aSXin Li # endif 73*a58d3d2aSXin Li # elif defined(__GNUC__) && defined(OPUS_BUILD) 74*a58d3d2aSXin Li # define OPUS_EXPORT __attribute__ ((visibility ("default"))) 75*a58d3d2aSXin Li # else 76*a58d3d2aSXin Li # define OPUS_EXPORT 77*a58d3d2aSXin Li # endif 78*a58d3d2aSXin Li #endif 79*a58d3d2aSXin Li 80*a58d3d2aSXin Li # if !defined(OPUS_GNUC_PREREQ) 81*a58d3d2aSXin Li # if defined(__GNUC__)&&defined(__GNUC_MINOR__) 82*a58d3d2aSXin Li # define OPUS_GNUC_PREREQ(_maj,_min) \ 83*a58d3d2aSXin Li ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min)) 84*a58d3d2aSXin Li # else 85*a58d3d2aSXin Li # define OPUS_GNUC_PREREQ(_maj,_min) 0 86*a58d3d2aSXin Li # endif 87*a58d3d2aSXin Li # endif 88*a58d3d2aSXin Li 89*a58d3d2aSXin Li #if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) 90*a58d3d2aSXin Li # if OPUS_GNUC_PREREQ(3,0) 91*a58d3d2aSXin Li # define OPUS_RESTRICT __restrict__ 92*a58d3d2aSXin Li # elif (defined(_MSC_VER) && _MSC_VER >= 1400) 93*a58d3d2aSXin Li # define OPUS_RESTRICT __restrict 94*a58d3d2aSXin Li # else 95*a58d3d2aSXin Li # define OPUS_RESTRICT 96*a58d3d2aSXin Li # endif 97*a58d3d2aSXin Li #else 98*a58d3d2aSXin Li # define OPUS_RESTRICT restrict 99*a58d3d2aSXin Li #endif 100*a58d3d2aSXin Li 101*a58d3d2aSXin Li #if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) 102*a58d3d2aSXin Li # if OPUS_GNUC_PREREQ(2,7) 103*a58d3d2aSXin Li # define OPUS_INLINE __inline__ 104*a58d3d2aSXin Li # elif (defined(_MSC_VER)) 105*a58d3d2aSXin Li # define OPUS_INLINE __inline 106*a58d3d2aSXin Li # else 107*a58d3d2aSXin Li # define OPUS_INLINE 108*a58d3d2aSXin Li # endif 109*a58d3d2aSXin Li #else 110*a58d3d2aSXin Li # define OPUS_INLINE inline 111*a58d3d2aSXin Li #endif 112*a58d3d2aSXin Li 113*a58d3d2aSXin Li /**Warning attributes for opus functions 114*a58d3d2aSXin Li * NONNULL is not used in OPUS_BUILD to avoid the compiler optimizing out 115*a58d3d2aSXin Li * some paranoid null checks. */ 116*a58d3d2aSXin Li #if defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4) 117*a58d3d2aSXin Li # define OPUS_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) 118*a58d3d2aSXin Li #else 119*a58d3d2aSXin Li # define OPUS_WARN_UNUSED_RESULT 120*a58d3d2aSXin Li #endif 121*a58d3d2aSXin Li #if !defined(OPUS_BUILD) && defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4) 122*a58d3d2aSXin Li # define OPUS_ARG_NONNULL(_x) __attribute__ ((__nonnull__(_x))) 123*a58d3d2aSXin Li #else 124*a58d3d2aSXin Li # define OPUS_ARG_NONNULL(_x) 125*a58d3d2aSXin Li #endif 126*a58d3d2aSXin Li 127*a58d3d2aSXin Li /** These are the actual Encoder CTL ID numbers. 128*a58d3d2aSXin Li * They should not be used directly by applications. 129*a58d3d2aSXin Li * In general, SETs should be even and GETs should be odd.*/ 130*a58d3d2aSXin Li #define OPUS_SET_APPLICATION_REQUEST 4000 131*a58d3d2aSXin Li #define OPUS_GET_APPLICATION_REQUEST 4001 132*a58d3d2aSXin Li #define OPUS_SET_BITRATE_REQUEST 4002 133*a58d3d2aSXin Li #define OPUS_GET_BITRATE_REQUEST 4003 134*a58d3d2aSXin Li #define OPUS_SET_MAX_BANDWIDTH_REQUEST 4004 135*a58d3d2aSXin Li #define OPUS_GET_MAX_BANDWIDTH_REQUEST 4005 136*a58d3d2aSXin Li #define OPUS_SET_VBR_REQUEST 4006 137*a58d3d2aSXin Li #define OPUS_GET_VBR_REQUEST 4007 138*a58d3d2aSXin Li #define OPUS_SET_BANDWIDTH_REQUEST 4008 139*a58d3d2aSXin Li #define OPUS_GET_BANDWIDTH_REQUEST 4009 140*a58d3d2aSXin Li #define OPUS_SET_COMPLEXITY_REQUEST 4010 141*a58d3d2aSXin Li #define OPUS_GET_COMPLEXITY_REQUEST 4011 142*a58d3d2aSXin Li #define OPUS_SET_INBAND_FEC_REQUEST 4012 143*a58d3d2aSXin Li #define OPUS_GET_INBAND_FEC_REQUEST 4013 144*a58d3d2aSXin Li #define OPUS_SET_PACKET_LOSS_PERC_REQUEST 4014 145*a58d3d2aSXin Li #define OPUS_GET_PACKET_LOSS_PERC_REQUEST 4015 146*a58d3d2aSXin Li #define OPUS_SET_DTX_REQUEST 4016 147*a58d3d2aSXin Li #define OPUS_GET_DTX_REQUEST 4017 148*a58d3d2aSXin Li #define OPUS_SET_VBR_CONSTRAINT_REQUEST 4020 149*a58d3d2aSXin Li #define OPUS_GET_VBR_CONSTRAINT_REQUEST 4021 150*a58d3d2aSXin Li #define OPUS_SET_FORCE_CHANNELS_REQUEST 4022 151*a58d3d2aSXin Li #define OPUS_GET_FORCE_CHANNELS_REQUEST 4023 152*a58d3d2aSXin Li #define OPUS_SET_SIGNAL_REQUEST 4024 153*a58d3d2aSXin Li #define OPUS_GET_SIGNAL_REQUEST 4025 154*a58d3d2aSXin Li #define OPUS_GET_LOOKAHEAD_REQUEST 4027 155*a58d3d2aSXin Li /* #define OPUS_RESET_STATE 4028 */ 156*a58d3d2aSXin Li #define OPUS_GET_SAMPLE_RATE_REQUEST 4029 157*a58d3d2aSXin Li #define OPUS_GET_FINAL_RANGE_REQUEST 4031 158*a58d3d2aSXin Li #define OPUS_GET_PITCH_REQUEST 4033 159*a58d3d2aSXin Li #define OPUS_SET_GAIN_REQUEST 4034 160*a58d3d2aSXin Li #define OPUS_GET_GAIN_REQUEST 4045 /* Should have been 4035 */ 161*a58d3d2aSXin Li #define OPUS_SET_LSB_DEPTH_REQUEST 4036 162*a58d3d2aSXin Li #define OPUS_GET_LSB_DEPTH_REQUEST 4037 163*a58d3d2aSXin Li #define OPUS_GET_LAST_PACKET_DURATION_REQUEST 4039 164*a58d3d2aSXin Li #define OPUS_SET_EXPERT_FRAME_DURATION_REQUEST 4040 165*a58d3d2aSXin Li #define OPUS_GET_EXPERT_FRAME_DURATION_REQUEST 4041 166*a58d3d2aSXin Li #define OPUS_SET_PREDICTION_DISABLED_REQUEST 4042 167*a58d3d2aSXin Li #define OPUS_GET_PREDICTION_DISABLED_REQUEST 4043 168*a58d3d2aSXin Li /* Don't use 4045, it's already taken by OPUS_GET_GAIN_REQUEST */ 169*a58d3d2aSXin Li #define OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST 4046 170*a58d3d2aSXin Li #define OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST 4047 171*a58d3d2aSXin Li #define OPUS_GET_IN_DTX_REQUEST 4049 172*a58d3d2aSXin Li #define OPUS_SET_DRED_DURATION_REQUEST 4050 173*a58d3d2aSXin Li #define OPUS_GET_DRED_DURATION_REQUEST 4051 174*a58d3d2aSXin Li #define OPUS_SET_DNN_BLOB_REQUEST 4052 175*a58d3d2aSXin Li /*#define OPUS_GET_DNN_BLOB_REQUEST 4053 */ 176*a58d3d2aSXin Li 177*a58d3d2aSXin Li /** Defines for the presence of extended APIs. */ 178*a58d3d2aSXin Li #define OPUS_HAVE_OPUS_PROJECTION_H 179*a58d3d2aSXin Li 180*a58d3d2aSXin Li /* Macros to trigger compilation errors when the wrong types are provided to a CTL */ 181*a58d3d2aSXin Li #define __opus_check_int(x) (((void)((x) == (opus_int32)0)), (opus_int32)(x)) 182*a58d3d2aSXin Li 183*a58d3d2aSXin Li #ifdef DISABLE_PTR_CHECK 184*a58d3d2aSXin Li /* Disable checks to prevent ubsan from complaining about NULL checks 185*a58d3d2aSXin Li in test_opus_api. */ 186*a58d3d2aSXin Li #define __opus_check_int_ptr(ptr) (ptr) 187*a58d3d2aSXin Li #define __opus_check_uint_ptr(ptr) (ptr) 188*a58d3d2aSXin Li #define __opus_check_uint8_ptr(ptr) (ptr) 189*a58d3d2aSXin Li #define __opus_check_val16_ptr(ptr) (ptr) 190*a58d3d2aSXin Li #define __opus_check_void_ptr(ptr) (ptr) 191*a58d3d2aSXin Li #else 192*a58d3d2aSXin Li #define __opus_check_int_ptr(ptr) ((ptr) + ((ptr) - (opus_int32*)(ptr))) 193*a58d3d2aSXin Li #define __opus_check_uint_ptr(ptr) ((ptr) + ((ptr) - (opus_uint32*)(ptr))) 194*a58d3d2aSXin Li #define __opus_check_uint8_ptr(ptr) ((ptr) + ((ptr) - (opus_uint8*)(ptr))) 195*a58d3d2aSXin Li #define __opus_check_val16_ptr(ptr) ((ptr) + ((ptr) - (opus_val16*)(ptr))) 196*a58d3d2aSXin Li #define __opus_check_void_ptr(x) ((void)((void *)0 == (x)), (x)) 197*a58d3d2aSXin Li #endif 198*a58d3d2aSXin Li /** @endcond */ 199*a58d3d2aSXin Li 200*a58d3d2aSXin Li /** @defgroup opus_ctlvalues Pre-defined values for CTL interface 201*a58d3d2aSXin Li * @see opus_genericctls, opus_encoderctls 202*a58d3d2aSXin Li * @{ 203*a58d3d2aSXin Li */ 204*a58d3d2aSXin Li /* Values for the various encoder CTLs */ 205*a58d3d2aSXin Li #define OPUS_AUTO -1000 /**<Auto/default setting @hideinitializer*/ 206*a58d3d2aSXin Li #define OPUS_BITRATE_MAX -1 /**<Maximum bitrate @hideinitializer*/ 207*a58d3d2aSXin Li 208*a58d3d2aSXin Li /** Best for most VoIP/videoconference applications where listening quality and intelligibility matter most 209*a58d3d2aSXin Li * @hideinitializer */ 210*a58d3d2aSXin Li #define OPUS_APPLICATION_VOIP 2048 211*a58d3d2aSXin Li /** Best for broadcast/high-fidelity application where the decoded audio should be as close as possible to the input 212*a58d3d2aSXin Li * @hideinitializer */ 213*a58d3d2aSXin Li #define OPUS_APPLICATION_AUDIO 2049 214*a58d3d2aSXin Li /** Only use when lowest-achievable latency is what matters most. Voice-optimized modes cannot be used. 215*a58d3d2aSXin Li * @hideinitializer */ 216*a58d3d2aSXin Li #define OPUS_APPLICATION_RESTRICTED_LOWDELAY 2051 217*a58d3d2aSXin Li 218*a58d3d2aSXin Li #define OPUS_SIGNAL_VOICE 3001 /**< Signal being encoded is voice */ 219*a58d3d2aSXin Li #define OPUS_SIGNAL_MUSIC 3002 /**< Signal being encoded is music */ 220*a58d3d2aSXin Li #define OPUS_BANDWIDTH_NARROWBAND 1101 /**< 4 kHz bandpass @hideinitializer*/ 221*a58d3d2aSXin Li #define OPUS_BANDWIDTH_MEDIUMBAND 1102 /**< 6 kHz bandpass @hideinitializer*/ 222*a58d3d2aSXin Li #define OPUS_BANDWIDTH_WIDEBAND 1103 /**< 8 kHz bandpass @hideinitializer*/ 223*a58d3d2aSXin Li #define OPUS_BANDWIDTH_SUPERWIDEBAND 1104 /**<12 kHz bandpass @hideinitializer*/ 224*a58d3d2aSXin Li #define OPUS_BANDWIDTH_FULLBAND 1105 /**<20 kHz bandpass @hideinitializer*/ 225*a58d3d2aSXin Li 226*a58d3d2aSXin Li #define OPUS_FRAMESIZE_ARG 5000 /**< Select frame size from the argument (default) */ 227*a58d3d2aSXin Li #define OPUS_FRAMESIZE_2_5_MS 5001 /**< Use 2.5 ms frames */ 228*a58d3d2aSXin Li #define OPUS_FRAMESIZE_5_MS 5002 /**< Use 5 ms frames */ 229*a58d3d2aSXin Li #define OPUS_FRAMESIZE_10_MS 5003 /**< Use 10 ms frames */ 230*a58d3d2aSXin Li #define OPUS_FRAMESIZE_20_MS 5004 /**< Use 20 ms frames */ 231*a58d3d2aSXin Li #define OPUS_FRAMESIZE_40_MS 5005 /**< Use 40 ms frames */ 232*a58d3d2aSXin Li #define OPUS_FRAMESIZE_60_MS 5006 /**< Use 60 ms frames */ 233*a58d3d2aSXin Li #define OPUS_FRAMESIZE_80_MS 5007 /**< Use 80 ms frames */ 234*a58d3d2aSXin Li #define OPUS_FRAMESIZE_100_MS 5008 /**< Use 100 ms frames */ 235*a58d3d2aSXin Li #define OPUS_FRAMESIZE_120_MS 5009 /**< Use 120 ms frames */ 236*a58d3d2aSXin Li 237*a58d3d2aSXin Li /**@}*/ 238*a58d3d2aSXin Li 239*a58d3d2aSXin Li 240*a58d3d2aSXin Li /** @defgroup opus_encoderctls Encoder related CTLs 241*a58d3d2aSXin Li * 242*a58d3d2aSXin Li * These are convenience macros for use with the \c opus_encode_ctl 243*a58d3d2aSXin Li * interface. They are used to generate the appropriate series of 244*a58d3d2aSXin Li * arguments for that call, passing the correct type, size and so 245*a58d3d2aSXin Li * on as expected for each particular request. 246*a58d3d2aSXin Li * 247*a58d3d2aSXin Li * Some usage examples: 248*a58d3d2aSXin Li * 249*a58d3d2aSXin Li * @code 250*a58d3d2aSXin Li * int ret; 251*a58d3d2aSXin Li * ret = opus_encoder_ctl(enc_ctx, OPUS_SET_BANDWIDTH(OPUS_AUTO)); 252*a58d3d2aSXin Li * if (ret != OPUS_OK) return ret; 253*a58d3d2aSXin Li * 254*a58d3d2aSXin Li * opus_int32 rate; 255*a58d3d2aSXin Li * opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&rate)); 256*a58d3d2aSXin Li * 257*a58d3d2aSXin Li * opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE); 258*a58d3d2aSXin Li * @endcode 259*a58d3d2aSXin Li * 260*a58d3d2aSXin Li * @see opus_genericctls, opus_encoder 261*a58d3d2aSXin Li * @{ 262*a58d3d2aSXin Li */ 263*a58d3d2aSXin Li 264*a58d3d2aSXin Li /** Configures the encoder's computational complexity. 265*a58d3d2aSXin Li * The supported range is 0-10 inclusive with 10 representing the highest complexity. 266*a58d3d2aSXin Li * @see OPUS_GET_COMPLEXITY 267*a58d3d2aSXin Li * @param[in] x <tt>opus_int32</tt>: Allowed values: 0-10, inclusive. 268*a58d3d2aSXin Li * 269*a58d3d2aSXin Li * @hideinitializer */ 270*a58d3d2aSXin Li #define OPUS_SET_COMPLEXITY(x) OPUS_SET_COMPLEXITY_REQUEST, __opus_check_int(x) 271*a58d3d2aSXin Li /** Gets the encoder's complexity configuration. 272*a58d3d2aSXin Li * @see OPUS_SET_COMPLEXITY 273*a58d3d2aSXin Li * @param[out] x <tt>opus_int32 *</tt>: Returns a value in the range 0-10, 274*a58d3d2aSXin Li * inclusive. 275*a58d3d2aSXin Li * @hideinitializer */ 276*a58d3d2aSXin Li #define OPUS_GET_COMPLEXITY(x) OPUS_GET_COMPLEXITY_REQUEST, __opus_check_int_ptr(x) 277*a58d3d2aSXin Li 278*a58d3d2aSXin Li /** Configures the bitrate in the encoder. 279*a58d3d2aSXin Li * Rates from 500 to 512000 bits per second are meaningful, as well as the 280*a58d3d2aSXin Li * special values #OPUS_AUTO and #OPUS_BITRATE_MAX. 281*a58d3d2aSXin Li * The value #OPUS_BITRATE_MAX can be used to cause the codec to use as much 282*a58d3d2aSXin Li * rate as it can, which is useful for controlling the rate by adjusting the 283*a58d3d2aSXin Li * output buffer size. 284*a58d3d2aSXin Li * @see OPUS_GET_BITRATE 285*a58d3d2aSXin Li * @param[in] x <tt>opus_int32</tt>: Bitrate in bits per second. The default 286*a58d3d2aSXin Li * is determined based on the number of 287*a58d3d2aSXin Li * channels and the input sampling rate. 288*a58d3d2aSXin Li * @hideinitializer */ 289*a58d3d2aSXin Li #define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __opus_check_int(x) 290*a58d3d2aSXin Li /** Gets the encoder's bitrate configuration. 291*a58d3d2aSXin Li * @see OPUS_SET_BITRATE 292*a58d3d2aSXin Li * @param[out] x <tt>opus_int32 *</tt>: Returns the bitrate in bits per second. 293*a58d3d2aSXin Li * The default is determined based on the 294*a58d3d2aSXin Li * number of channels and the input 295*a58d3d2aSXin Li * sampling rate. 296*a58d3d2aSXin Li * @hideinitializer */ 297*a58d3d2aSXin Li #define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __opus_check_int_ptr(x) 298*a58d3d2aSXin Li 299*a58d3d2aSXin Li /** Enables or disables variable bitrate (VBR) in the encoder. 300*a58d3d2aSXin Li * The configured bitrate may not be met exactly because frames must 301*a58d3d2aSXin Li * be an integer number of bytes in length. 302*a58d3d2aSXin Li * @see OPUS_GET_VBR 303*a58d3d2aSXin Li * @see OPUS_SET_VBR_CONSTRAINT 304*a58d3d2aSXin Li * @param[in] x <tt>opus_int32</tt>: Allowed values: 305*a58d3d2aSXin Li * <dl> 306*a58d3d2aSXin Li * <dt>0</dt><dd>Hard CBR. For LPC/hybrid modes at very low bit-rate, this can 307*a58d3d2aSXin Li * cause noticeable quality degradation.</dd> 308*a58d3d2aSXin Li * <dt>1</dt><dd>VBR (default). The exact type of VBR is controlled by 309*a58d3d2aSXin Li * #OPUS_SET_VBR_CONSTRAINT.</dd> 310*a58d3d2aSXin Li * </dl> 311*a58d3d2aSXin Li * @hideinitializer */ 312*a58d3d2aSXin Li #define OPUS_SET_VBR(x) OPUS_SET_VBR_REQUEST, __opus_check_int(x) 313*a58d3d2aSXin Li /** Determine if variable bitrate (VBR) is enabled in the encoder. 314*a58d3d2aSXin Li * @see OPUS_SET_VBR 315*a58d3d2aSXin Li * @see OPUS_GET_VBR_CONSTRAINT 316*a58d3d2aSXin Li * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: 317*a58d3d2aSXin Li * <dl> 318*a58d3d2aSXin Li * <dt>0</dt><dd>Hard CBR.</dd> 319*a58d3d2aSXin Li * <dt>1</dt><dd>VBR (default). The exact type of VBR may be retrieved via 320*a58d3d2aSXin Li * #OPUS_GET_VBR_CONSTRAINT.</dd> 321*a58d3d2aSXin Li * </dl> 322*a58d3d2aSXin Li * @hideinitializer */ 323*a58d3d2aSXin Li #define OPUS_GET_VBR(x) OPUS_GET_VBR_REQUEST, __opus_check_int_ptr(x) 324*a58d3d2aSXin Li 325*a58d3d2aSXin Li /** Enables or disables constrained VBR in the encoder. 326*a58d3d2aSXin Li * This setting is ignored when the encoder is in CBR mode. 327*a58d3d2aSXin Li * @warning Only the MDCT mode of Opus currently heeds the constraint. 328*a58d3d2aSXin Li * Speech mode ignores it completely, hybrid mode may fail to obey it 329*a58d3d2aSXin Li * if the LPC layer uses more bitrate than the constraint would have 330*a58d3d2aSXin Li * permitted. 331*a58d3d2aSXin Li * @see OPUS_GET_VBR_CONSTRAINT 332*a58d3d2aSXin Li * @see OPUS_SET_VBR 333*a58d3d2aSXin Li * @param[in] x <tt>opus_int32</tt>: Allowed values: 334*a58d3d2aSXin Li * <dl> 335*a58d3d2aSXin Li * <dt>0</dt><dd>Unconstrained VBR.</dd> 336*a58d3d2aSXin Li * <dt>1</dt><dd>Constrained VBR (default). This creates a maximum of one 337*a58d3d2aSXin Li * frame of buffering delay assuming a transport with a 338*a58d3d2aSXin Li * serialization speed of the nominal bitrate.</dd> 339*a58d3d2aSXin Li * </dl> 340*a58d3d2aSXin Li * @hideinitializer */ 341*a58d3d2aSXin Li #define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __opus_check_int(x) 342*a58d3d2aSXin Li /** Determine if constrained VBR is enabled in the encoder. 343*a58d3d2aSXin Li * @see OPUS_SET_VBR_CONSTRAINT 344*a58d3d2aSXin Li * @see OPUS_GET_VBR 345*a58d3d2aSXin Li * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: 346*a58d3d2aSXin Li * <dl> 347*a58d3d2aSXin Li * <dt>0</dt><dd>Unconstrained VBR.</dd> 348*a58d3d2aSXin Li * <dt>1</dt><dd>Constrained VBR (default).</dd> 349*a58d3d2aSXin Li * </dl> 350*a58d3d2aSXin Li * @hideinitializer */ 351*a58d3d2aSXin Li #define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __opus_check_int_ptr(x) 352*a58d3d2aSXin Li 353*a58d3d2aSXin Li /** Configures mono/stereo forcing in the encoder. 354*a58d3d2aSXin Li * This can force the encoder to produce packets encoded as either mono or 355*a58d3d2aSXin Li * stereo, regardless of the format of the input audio. This is useful when 356*a58d3d2aSXin Li * the caller knows that the input signal is currently a mono source embedded 357*a58d3d2aSXin Li * in a stereo stream. 358*a58d3d2aSXin Li * @see OPUS_GET_FORCE_CHANNELS 359*a58d3d2aSXin Li * @param[in] x <tt>opus_int32</tt>: Allowed values: 360*a58d3d2aSXin Li * <dl> 361*a58d3d2aSXin Li * <dt>#OPUS_AUTO</dt><dd>Not forced (default)</dd> 362*a58d3d2aSXin Li * <dt>1</dt> <dd>Forced mono</dd> 363*a58d3d2aSXin Li * <dt>2</dt> <dd>Forced stereo</dd> 364*a58d3d2aSXin Li * </dl> 365*a58d3d2aSXin Li * @hideinitializer */ 366*a58d3d2aSXin Li #define OPUS_SET_FORCE_CHANNELS(x) OPUS_SET_FORCE_CHANNELS_REQUEST, __opus_check_int(x) 367*a58d3d2aSXin Li /** Gets the encoder's forced channel configuration. 368*a58d3d2aSXin Li * @see OPUS_SET_FORCE_CHANNELS 369*a58d3d2aSXin Li * @param[out] x <tt>opus_int32 *</tt>: 370*a58d3d2aSXin Li * <dl> 371*a58d3d2aSXin Li * <dt>#OPUS_AUTO</dt><dd>Not forced (default)</dd> 372*a58d3d2aSXin Li * <dt>1</dt> <dd>Forced mono</dd> 373*a58d3d2aSXin Li * <dt>2</dt> <dd>Forced stereo</dd> 374*a58d3d2aSXin Li * </dl> 375*a58d3d2aSXin Li * @hideinitializer */ 376*a58d3d2aSXin Li #define OPUS_GET_FORCE_CHANNELS(x) OPUS_GET_FORCE_CHANNELS_REQUEST, __opus_check_int_ptr(x) 377*a58d3d2aSXin Li 378*a58d3d2aSXin Li /** Configures the maximum bandpass that the encoder will select automatically. 379*a58d3d2aSXin Li * Applications should normally use this instead of #OPUS_SET_BANDWIDTH 380*a58d3d2aSXin Li * (leaving that set to the default, #OPUS_AUTO). This allows the 381*a58d3d2aSXin Li * application to set an upper bound based on the type of input it is 382*a58d3d2aSXin Li * providing, but still gives the encoder the freedom to reduce the bandpass 383*a58d3d2aSXin Li * when the bitrate becomes too low, for better overall quality. 384*a58d3d2aSXin Li * @see OPUS_GET_MAX_BANDWIDTH 385*a58d3d2aSXin Li * @param[in] x <tt>opus_int32</tt>: Allowed values: 386*a58d3d2aSXin Li * <dl> 387*a58d3d2aSXin Li * <dt>OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> 388*a58d3d2aSXin Li * <dt>OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> 389*a58d3d2aSXin Li * <dt>OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> 390*a58d3d2aSXin Li * <dt>OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> 391*a58d3d2aSXin Li * <dt>OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband (default)</dd> 392*a58d3d2aSXin Li * </dl> 393*a58d3d2aSXin Li * @hideinitializer */ 394*a58d3d2aSXin Li #define OPUS_SET_MAX_BANDWIDTH(x) OPUS_SET_MAX_BANDWIDTH_REQUEST, __opus_check_int(x) 395*a58d3d2aSXin Li 396*a58d3d2aSXin Li /** Gets the encoder's configured maximum allowed bandpass. 397*a58d3d2aSXin Li * @see OPUS_SET_MAX_BANDWIDTH 398*a58d3d2aSXin Li * @param[out] x <tt>opus_int32 *</tt>: Allowed values: 399*a58d3d2aSXin Li * <dl> 400*a58d3d2aSXin Li * <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> 401*a58d3d2aSXin Li * <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> 402*a58d3d2aSXin Li * <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> 403*a58d3d2aSXin Li * <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> 404*a58d3d2aSXin Li * <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband (default)</dd> 405*a58d3d2aSXin Li * </dl> 406*a58d3d2aSXin Li * @hideinitializer */ 407*a58d3d2aSXin Li #define OPUS_GET_MAX_BANDWIDTH(x) OPUS_GET_MAX_BANDWIDTH_REQUEST, __opus_check_int_ptr(x) 408*a58d3d2aSXin Li 409*a58d3d2aSXin Li /** Sets the encoder's bandpass to a specific value. 410*a58d3d2aSXin Li * This prevents the encoder from automatically selecting the bandpass based 411*a58d3d2aSXin Li * on the available bitrate. If an application knows the bandpass of the input 412*a58d3d2aSXin Li * audio it is providing, it should normally use #OPUS_SET_MAX_BANDWIDTH 413*a58d3d2aSXin Li * instead, which still gives the encoder the freedom to reduce the bandpass 414*a58d3d2aSXin Li * when the bitrate becomes too low, for better overall quality. 415*a58d3d2aSXin Li * @see OPUS_GET_BANDWIDTH 416*a58d3d2aSXin Li * @param[in] x <tt>opus_int32</tt>: Allowed values: 417*a58d3d2aSXin Li * <dl> 418*a58d3d2aSXin Li * <dt>#OPUS_AUTO</dt> <dd>(default)</dd> 419*a58d3d2aSXin Li * <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> 420*a58d3d2aSXin Li * <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> 421*a58d3d2aSXin Li * <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> 422*a58d3d2aSXin Li * <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> 423*a58d3d2aSXin Li * <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband</dd> 424*a58d3d2aSXin Li * </dl> 425*a58d3d2aSXin Li * @hideinitializer */ 426*a58d3d2aSXin Li #define OPUS_SET_BANDWIDTH(x) OPUS_SET_BANDWIDTH_REQUEST, __opus_check_int(x) 427*a58d3d2aSXin Li 428*a58d3d2aSXin Li /** Configures the type of signal being encoded. 429*a58d3d2aSXin Li * This is a hint which helps the encoder's mode selection. 430*a58d3d2aSXin Li * @see OPUS_GET_SIGNAL 431*a58d3d2aSXin Li * @param[in] x <tt>opus_int32</tt>: Allowed values: 432*a58d3d2aSXin Li * <dl> 433*a58d3d2aSXin Li * <dt>#OPUS_AUTO</dt> <dd>(default)</dd> 434*a58d3d2aSXin Li * <dt>#OPUS_SIGNAL_VOICE</dt><dd>Bias thresholds towards choosing LPC or Hybrid modes.</dd> 435*a58d3d2aSXin Li * <dt>#OPUS_SIGNAL_MUSIC</dt><dd>Bias thresholds towards choosing MDCT modes.</dd> 436*a58d3d2aSXin Li * </dl> 437*a58d3d2aSXin Li * @hideinitializer */ 438*a58d3d2aSXin Li #define OPUS_SET_SIGNAL(x) OPUS_SET_SIGNAL_REQUEST, __opus_check_int(x) 439*a58d3d2aSXin Li /** Gets the encoder's configured signal type. 440*a58d3d2aSXin Li * @see OPUS_SET_SIGNAL 441*a58d3d2aSXin Li * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: 442*a58d3d2aSXin Li * <dl> 443*a58d3d2aSXin Li * <dt>#OPUS_AUTO</dt> <dd>(default)</dd> 444*a58d3d2aSXin Li * <dt>#OPUS_SIGNAL_VOICE</dt><dd>Bias thresholds towards choosing LPC or Hybrid modes.</dd> 445*a58d3d2aSXin Li * <dt>#OPUS_SIGNAL_MUSIC</dt><dd>Bias thresholds towards choosing MDCT modes.</dd> 446*a58d3d2aSXin Li * </dl> 447*a58d3d2aSXin Li * @hideinitializer */ 448*a58d3d2aSXin Li #define OPUS_GET_SIGNAL(x) OPUS_GET_SIGNAL_REQUEST, __opus_check_int_ptr(x) 449*a58d3d2aSXin Li 450*a58d3d2aSXin Li 451*a58d3d2aSXin Li /** Configures the encoder's intended application. 452*a58d3d2aSXin Li * The initial value is a mandatory argument to the encoder_create function. 453*a58d3d2aSXin Li * @see OPUS_GET_APPLICATION 454*a58d3d2aSXin Li * @param[in] x <tt>opus_int32</tt>: Returns one of the following values: 455*a58d3d2aSXin Li * <dl> 456*a58d3d2aSXin Li * <dt>#OPUS_APPLICATION_VOIP</dt> 457*a58d3d2aSXin Li * <dd>Process signal for improved speech intelligibility.</dd> 458*a58d3d2aSXin Li * <dt>#OPUS_APPLICATION_AUDIO</dt> 459*a58d3d2aSXin Li * <dd>Favor faithfulness to the original input.</dd> 460*a58d3d2aSXin Li * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> 461*a58d3d2aSXin Li * <dd>Configure the minimum possible coding delay by disabling certain modes 462*a58d3d2aSXin Li * of operation.</dd> 463*a58d3d2aSXin Li * </dl> 464*a58d3d2aSXin Li * @hideinitializer */ 465*a58d3d2aSXin Li #define OPUS_SET_APPLICATION(x) OPUS_SET_APPLICATION_REQUEST, __opus_check_int(x) 466*a58d3d2aSXin Li /** Gets the encoder's configured application. 467*a58d3d2aSXin Li * @see OPUS_SET_APPLICATION 468*a58d3d2aSXin Li * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: 469*a58d3d2aSXin Li * <dl> 470*a58d3d2aSXin Li * <dt>#OPUS_APPLICATION_VOIP</dt> 471*a58d3d2aSXin Li * <dd>Process signal for improved speech intelligibility.</dd> 472*a58d3d2aSXin Li * <dt>#OPUS_APPLICATION_AUDIO</dt> 473*a58d3d2aSXin Li * <dd>Favor faithfulness to the original input.</dd> 474*a58d3d2aSXin Li * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> 475*a58d3d2aSXin Li * <dd>Configure the minimum possible coding delay by disabling certain modes 476*a58d3d2aSXin Li * of operation.</dd> 477*a58d3d2aSXin Li * </dl> 478*a58d3d2aSXin Li * @hideinitializer */ 479*a58d3d2aSXin Li #define OPUS_GET_APPLICATION(x) OPUS_GET_APPLICATION_REQUEST, __opus_check_int_ptr(x) 480*a58d3d2aSXin Li 481*a58d3d2aSXin Li /** Gets the total samples of delay added by the entire codec. 482*a58d3d2aSXin Li * This can be queried by the encoder and then the provided number of samples can be 483*a58d3d2aSXin Li * skipped on from the start of the decoder's output to provide time aligned input 484*a58d3d2aSXin Li * and output. From the perspective of a decoding application the real data begins this many 485*a58d3d2aSXin Li * samples late. 486*a58d3d2aSXin Li * 487*a58d3d2aSXin Li * The decoder contribution to this delay is identical for all decoders, but the 488*a58d3d2aSXin Li * encoder portion of the delay may vary from implementation to implementation, 489*a58d3d2aSXin Li * version to version, or even depend on the encoder's initial configuration. 490*a58d3d2aSXin Li * Applications needing delay compensation should call this CTL rather than 491*a58d3d2aSXin Li * hard-coding a value. 492*a58d3d2aSXin Li * @param[out] x <tt>opus_int32 *</tt>: Number of lookahead samples 493*a58d3d2aSXin Li * @hideinitializer */ 494*a58d3d2aSXin Li #define OPUS_GET_LOOKAHEAD(x) OPUS_GET_LOOKAHEAD_REQUEST, __opus_check_int_ptr(x) 495*a58d3d2aSXin Li 496*a58d3d2aSXin Li /** Configures the encoder's use of inband forward error correction (FEC). 497*a58d3d2aSXin Li * @note This is only applicable to the LPC layer 498*a58d3d2aSXin Li * @see OPUS_GET_INBAND_FEC 499*a58d3d2aSXin Li * @param[in] x <tt>opus_int32</tt>: Allowed values: 500*a58d3d2aSXin Li * <dl> 501*a58d3d2aSXin Li * <dt>0</dt><dd>Disable inband FEC (default).</dd> 502*a58d3d2aSXin Li * <dt>1</dt><dd>Inband FEC enabled. If the packet loss rate is sufficiently high, Opus will automatically switch to SILK even at high rates to enable use of that FEC.</dd> 503*a58d3d2aSXin Li * <dt>2</dt><dd>Inband FEC enabled, but does not necessarily switch to SILK if we have music.</dd> 504*a58d3d2aSXin Li * </dl> 505*a58d3d2aSXin Li * @hideinitializer */ 506*a58d3d2aSXin Li #define OPUS_SET_INBAND_FEC(x) OPUS_SET_INBAND_FEC_REQUEST, __opus_check_int(x) 507*a58d3d2aSXin Li /** Gets encoder's configured use of inband forward error correction. 508*a58d3d2aSXin Li * @see OPUS_SET_INBAND_FEC 509*a58d3d2aSXin Li * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: 510*a58d3d2aSXin Li * <dl> 511*a58d3d2aSXin Li * <dt>0</dt><dd>Inband FEC disabled (default).</dd> 512*a58d3d2aSXin Li * <dt>1</dt><dd>Inband FEC enabled. If the packet loss rate is sufficiently high, Opus will automatically switch to SILK even at high rates to enable use of that FEC.</dd> 513*a58d3d2aSXin Li * <dt>2</dt><dd>Inband FEC enabled, but does not necessarily switch to SILK if we have music.</dd> 514*a58d3d2aSXin Li * </dl> 515*a58d3d2aSXin Li * @hideinitializer */ 516*a58d3d2aSXin Li #define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_int_ptr(x) 517*a58d3d2aSXin Li 518*a58d3d2aSXin Li /** Configures the encoder's expected packet loss percentage. 519*a58d3d2aSXin Li * Higher values trigger progressively more loss resistant behavior in the encoder 520*a58d3d2aSXin Li * at the expense of quality at a given bitrate in the absence of packet loss, but 521*a58d3d2aSXin Li * greater quality under loss. 522*a58d3d2aSXin Li * @see OPUS_GET_PACKET_LOSS_PERC 523*a58d3d2aSXin Li * @param[in] x <tt>opus_int32</tt>: Loss percentage in the range 0-100, inclusive (default: 0). 524*a58d3d2aSXin Li * @hideinitializer */ 525*a58d3d2aSXin Li #define OPUS_SET_PACKET_LOSS_PERC(x) OPUS_SET_PACKET_LOSS_PERC_REQUEST, __opus_check_int(x) 526*a58d3d2aSXin Li /** Gets the encoder's configured packet loss percentage. 527*a58d3d2aSXin Li * @see OPUS_SET_PACKET_LOSS_PERC 528*a58d3d2aSXin Li * @param[out] x <tt>opus_int32 *</tt>: Returns the configured loss percentage 529*a58d3d2aSXin Li * in the range 0-100, inclusive (default: 0). 530*a58d3d2aSXin Li * @hideinitializer */ 531*a58d3d2aSXin Li #define OPUS_GET_PACKET_LOSS_PERC(x) OPUS_GET_PACKET_LOSS_PERC_REQUEST, __opus_check_int_ptr(x) 532*a58d3d2aSXin Li 533*a58d3d2aSXin Li /** Configures the encoder's use of discontinuous transmission (DTX). 534*a58d3d2aSXin Li * @note This is only applicable to the LPC layer 535*a58d3d2aSXin Li * @see OPUS_GET_DTX 536*a58d3d2aSXin Li * @param[in] x <tt>opus_int32</tt>: Allowed values: 537*a58d3d2aSXin Li * <dl> 538*a58d3d2aSXin Li * <dt>0</dt><dd>Disable DTX (default).</dd> 539*a58d3d2aSXin Li * <dt>1</dt><dd>Enabled DTX.</dd> 540*a58d3d2aSXin Li * </dl> 541*a58d3d2aSXin Li * @hideinitializer */ 542*a58d3d2aSXin Li #define OPUS_SET_DTX(x) OPUS_SET_DTX_REQUEST, __opus_check_int(x) 543*a58d3d2aSXin Li /** Gets encoder's configured use of discontinuous transmission. 544*a58d3d2aSXin Li * @see OPUS_SET_DTX 545*a58d3d2aSXin Li * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: 546*a58d3d2aSXin Li * <dl> 547*a58d3d2aSXin Li * <dt>0</dt><dd>DTX disabled (default).</dd> 548*a58d3d2aSXin Li * <dt>1</dt><dd>DTX enabled.</dd> 549*a58d3d2aSXin Li * </dl> 550*a58d3d2aSXin Li * @hideinitializer */ 551*a58d3d2aSXin Li #define OPUS_GET_DTX(x) OPUS_GET_DTX_REQUEST, __opus_check_int_ptr(x) 552*a58d3d2aSXin Li /** Configures the depth of signal being encoded. 553*a58d3d2aSXin Li * 554*a58d3d2aSXin Li * This is a hint which helps the encoder identify silence and near-silence. 555*a58d3d2aSXin Li * It represents the number of significant bits of linear intensity below 556*a58d3d2aSXin Li * which the signal contains ignorable quantization or other noise. 557*a58d3d2aSXin Li * 558*a58d3d2aSXin Li * For example, OPUS_SET_LSB_DEPTH(14) would be an appropriate setting 559*a58d3d2aSXin Li * for G.711 u-law input. OPUS_SET_LSB_DEPTH(16) would be appropriate 560*a58d3d2aSXin Li * for 16-bit linear pcm input with opus_encode_float(). 561*a58d3d2aSXin Li * 562*a58d3d2aSXin Li * When using opus_encode() instead of opus_encode_float(), or when libopus 563*a58d3d2aSXin Li * is compiled for fixed-point, the encoder uses the minimum of the value 564*a58d3d2aSXin Li * set here and the value 16. 565*a58d3d2aSXin Li * 566*a58d3d2aSXin Li * @see OPUS_GET_LSB_DEPTH 567*a58d3d2aSXin Li * @param[in] x <tt>opus_int32</tt>: Input precision in bits, between 8 and 24 568*a58d3d2aSXin Li * (default: 24). 569*a58d3d2aSXin Li * @hideinitializer */ 570*a58d3d2aSXin Li #define OPUS_SET_LSB_DEPTH(x) OPUS_SET_LSB_DEPTH_REQUEST, __opus_check_int(x) 571*a58d3d2aSXin Li /** Gets the encoder's configured signal depth. 572*a58d3d2aSXin Li * @see OPUS_SET_LSB_DEPTH 573*a58d3d2aSXin Li * @param[out] x <tt>opus_int32 *</tt>: Input precision in bits, between 8 and 574*a58d3d2aSXin Li * 24 (default: 24). 575*a58d3d2aSXin Li * @hideinitializer */ 576*a58d3d2aSXin Li #define OPUS_GET_LSB_DEPTH(x) OPUS_GET_LSB_DEPTH_REQUEST, __opus_check_int_ptr(x) 577*a58d3d2aSXin Li 578*a58d3d2aSXin Li /** Configures the encoder's use of variable duration frames. 579*a58d3d2aSXin Li * When variable duration is enabled, the encoder is free to use a shorter frame 580*a58d3d2aSXin Li * size than the one requested in the opus_encode*() call. 581*a58d3d2aSXin Li * It is then the user's responsibility 582*a58d3d2aSXin Li * to verify how much audio was encoded by checking the ToC byte of the encoded 583*a58d3d2aSXin Li * packet. The part of the audio that was not encoded needs to be resent to the 584*a58d3d2aSXin Li * encoder for the next call. Do not use this option unless you <b>really</b> 585*a58d3d2aSXin Li * know what you are doing. 586*a58d3d2aSXin Li * @see OPUS_GET_EXPERT_FRAME_DURATION 587*a58d3d2aSXin Li * @param[in] x <tt>opus_int32</tt>: Allowed values: 588*a58d3d2aSXin Li * <dl> 589*a58d3d2aSXin Li * <dt>OPUS_FRAMESIZE_ARG</dt><dd>Select frame size from the argument (default).</dd> 590*a58d3d2aSXin Li * <dt>OPUS_FRAMESIZE_2_5_MS</dt><dd>Use 2.5 ms frames.</dd> 591*a58d3d2aSXin Li * <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 5 ms frames.</dd> 592*a58d3d2aSXin Li * <dt>OPUS_FRAMESIZE_10_MS</dt><dd>Use 10 ms frames.</dd> 593*a58d3d2aSXin Li * <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd> 594*a58d3d2aSXin Li * <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd> 595*a58d3d2aSXin Li * <dt>OPUS_FRAMESIZE_60_MS</dt><dd>Use 60 ms frames.</dd> 596*a58d3d2aSXin Li * <dt>OPUS_FRAMESIZE_80_MS</dt><dd>Use 80 ms frames.</dd> 597*a58d3d2aSXin Li * <dt>OPUS_FRAMESIZE_100_MS</dt><dd>Use 100 ms frames.</dd> 598*a58d3d2aSXin Li * <dt>OPUS_FRAMESIZE_120_MS</dt><dd>Use 120 ms frames.</dd> 599*a58d3d2aSXin Li * </dl> 600*a58d3d2aSXin Li * @hideinitializer */ 601*a58d3d2aSXin Li #define OPUS_SET_EXPERT_FRAME_DURATION(x) OPUS_SET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int(x) 602*a58d3d2aSXin Li /** Gets the encoder's configured use of variable duration frames. 603*a58d3d2aSXin Li * @see OPUS_SET_EXPERT_FRAME_DURATION 604*a58d3d2aSXin Li * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: 605*a58d3d2aSXin Li * <dl> 606*a58d3d2aSXin Li * <dt>OPUS_FRAMESIZE_ARG</dt><dd>Select frame size from the argument (default).</dd> 607*a58d3d2aSXin Li * <dt>OPUS_FRAMESIZE_2_5_MS</dt><dd>Use 2.5 ms frames.</dd> 608*a58d3d2aSXin Li * <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 5 ms frames.</dd> 609*a58d3d2aSXin Li * <dt>OPUS_FRAMESIZE_10_MS</dt><dd>Use 10 ms frames.</dd> 610*a58d3d2aSXin Li * <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd> 611*a58d3d2aSXin Li * <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd> 612*a58d3d2aSXin Li * <dt>OPUS_FRAMESIZE_60_MS</dt><dd>Use 60 ms frames.</dd> 613*a58d3d2aSXin Li * <dt>OPUS_FRAMESIZE_80_MS</dt><dd>Use 80 ms frames.</dd> 614*a58d3d2aSXin Li * <dt>OPUS_FRAMESIZE_100_MS</dt><dd>Use 100 ms frames.</dd> 615*a58d3d2aSXin Li * <dt>OPUS_FRAMESIZE_120_MS</dt><dd>Use 120 ms frames.</dd> 616*a58d3d2aSXin Li * </dl> 617*a58d3d2aSXin Li * @hideinitializer */ 618*a58d3d2aSXin Li #define OPUS_GET_EXPERT_FRAME_DURATION(x) OPUS_GET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int_ptr(x) 619*a58d3d2aSXin Li 620*a58d3d2aSXin Li /** If set to 1, disables almost all use of prediction, making frames almost 621*a58d3d2aSXin Li * completely independent. This reduces quality. 622*a58d3d2aSXin Li * @see OPUS_GET_PREDICTION_DISABLED 623*a58d3d2aSXin Li * @param[in] x <tt>opus_int32</tt>: Allowed values: 624*a58d3d2aSXin Li * <dl> 625*a58d3d2aSXin Li * <dt>0</dt><dd>Enable prediction (default).</dd> 626*a58d3d2aSXin Li * <dt>1</dt><dd>Disable prediction.</dd> 627*a58d3d2aSXin Li * </dl> 628*a58d3d2aSXin Li * @hideinitializer */ 629*a58d3d2aSXin Li #define OPUS_SET_PREDICTION_DISABLED(x) OPUS_SET_PREDICTION_DISABLED_REQUEST, __opus_check_int(x) 630*a58d3d2aSXin Li /** Gets the encoder's configured prediction status. 631*a58d3d2aSXin Li * @see OPUS_SET_PREDICTION_DISABLED 632*a58d3d2aSXin Li * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: 633*a58d3d2aSXin Li * <dl> 634*a58d3d2aSXin Li * <dt>0</dt><dd>Prediction enabled (default).</dd> 635*a58d3d2aSXin Li * <dt>1</dt><dd>Prediction disabled.</dd> 636*a58d3d2aSXin Li * </dl> 637*a58d3d2aSXin Li * @hideinitializer */ 638*a58d3d2aSXin Li #define OPUS_GET_PREDICTION_DISABLED(x) OPUS_GET_PREDICTION_DISABLED_REQUEST, __opus_check_int_ptr(x) 639*a58d3d2aSXin Li 640*a58d3d2aSXin Li /** If non-zero, enables Deep Redundancy (DRED) and use the specified maximum number of 10-ms redundant frames 641*a58d3d2aSXin Li * @hideinitializer */ 642*a58d3d2aSXin Li #define OPUS_SET_DRED_DURATION(x) OPUS_SET_DRED_DURATION_REQUEST, __opus_check_int(x) 643*a58d3d2aSXin Li /** Gets the encoder's configured Deep Redundancy (DRED) maximum number of frames. 644*a58d3d2aSXin Li * @hideinitializer */ 645*a58d3d2aSXin Li #define OPUS_GET_DRED_DURATION(x) OPUS_GET_DRED_DURATION_REQUEST, __opus_check_int_ptr(x) 646*a58d3d2aSXin Li 647*a58d3d2aSXin Li /** Provide external DNN weights from binary object (only when explicitly built without the weights) 648*a58d3d2aSXin Li * @hideinitializer */ 649*a58d3d2aSXin Li #define OPUS_SET_DNN_BLOB(data, len) OPUS_SET_DNN_BLOB_REQUEST, __opus_check_void_ptr(data), __opus_check_int(len) 650*a58d3d2aSXin Li 651*a58d3d2aSXin Li 652*a58d3d2aSXin Li /**@}*/ 653*a58d3d2aSXin Li 654*a58d3d2aSXin Li /** @defgroup opus_genericctls Generic CTLs 655*a58d3d2aSXin Li * 656*a58d3d2aSXin Li * These macros are used with the \c opus_decoder_ctl and 657*a58d3d2aSXin Li * \c opus_encoder_ctl calls to generate a particular 658*a58d3d2aSXin Li * request. 659*a58d3d2aSXin Li * 660*a58d3d2aSXin Li * When called on an \c OpusDecoder they apply to that 661*a58d3d2aSXin Li * particular decoder instance. When called on an 662*a58d3d2aSXin Li * \c OpusEncoder they apply to the corresponding setting 663*a58d3d2aSXin Li * on that encoder instance, if present. 664*a58d3d2aSXin Li * 665*a58d3d2aSXin Li * Some usage examples: 666*a58d3d2aSXin Li * 667*a58d3d2aSXin Li * @code 668*a58d3d2aSXin Li * int ret; 669*a58d3d2aSXin Li * opus_int32 pitch; 670*a58d3d2aSXin Li * ret = opus_decoder_ctl(dec_ctx, OPUS_GET_PITCH(&pitch)); 671*a58d3d2aSXin Li * if (ret == OPUS_OK) return ret; 672*a58d3d2aSXin Li * 673*a58d3d2aSXin Li * opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE); 674*a58d3d2aSXin Li * opus_decoder_ctl(dec_ctx, OPUS_RESET_STATE); 675*a58d3d2aSXin Li * 676*a58d3d2aSXin Li * opus_int32 enc_bw, dec_bw; 677*a58d3d2aSXin Li * opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&enc_bw)); 678*a58d3d2aSXin Li * opus_decoder_ctl(dec_ctx, OPUS_GET_BANDWIDTH(&dec_bw)); 679*a58d3d2aSXin Li * if (enc_bw != dec_bw) { 680*a58d3d2aSXin Li * printf("packet bandwidth mismatch!\n"); 681*a58d3d2aSXin Li * } 682*a58d3d2aSXin Li * @endcode 683*a58d3d2aSXin Li * 684*a58d3d2aSXin Li * @see opus_encoder, opus_decoder_ctl, opus_encoder_ctl, opus_decoderctls, opus_encoderctls 685*a58d3d2aSXin Li * @{ 686*a58d3d2aSXin Li */ 687*a58d3d2aSXin Li 688*a58d3d2aSXin Li /** Resets the codec state to be equivalent to a freshly initialized state. 689*a58d3d2aSXin Li * This should be called when switching streams in order to prevent 690*a58d3d2aSXin Li * the back to back decoding from giving different results from 691*a58d3d2aSXin Li * one at a time decoding. 692*a58d3d2aSXin Li * @hideinitializer */ 693*a58d3d2aSXin Li #define OPUS_RESET_STATE 4028 694*a58d3d2aSXin Li 695*a58d3d2aSXin Li /** Gets the final state of the codec's entropy coder. 696*a58d3d2aSXin Li * This is used for testing purposes, 697*a58d3d2aSXin Li * The encoder and decoder state should be identical after coding a payload 698*a58d3d2aSXin Li * (assuming no data corruption or software bugs) 699*a58d3d2aSXin Li * 700*a58d3d2aSXin Li * @param[out] x <tt>opus_uint32 *</tt>: Entropy coder state 701*a58d3d2aSXin Li * 702*a58d3d2aSXin Li * @hideinitializer */ 703*a58d3d2aSXin Li #define OPUS_GET_FINAL_RANGE(x) OPUS_GET_FINAL_RANGE_REQUEST, __opus_check_uint_ptr(x) 704*a58d3d2aSXin Li 705*a58d3d2aSXin Li /** Gets the encoder's configured bandpass or the decoder's last bandpass. 706*a58d3d2aSXin Li * @see OPUS_SET_BANDWIDTH 707*a58d3d2aSXin Li * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: 708*a58d3d2aSXin Li * <dl> 709*a58d3d2aSXin Li * <dt>#OPUS_AUTO</dt> <dd>(default)</dd> 710*a58d3d2aSXin Li * <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> 711*a58d3d2aSXin Li * <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> 712*a58d3d2aSXin Li * <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> 713*a58d3d2aSXin Li * <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> 714*a58d3d2aSXin Li * <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband</dd> 715*a58d3d2aSXin Li * </dl> 716*a58d3d2aSXin Li * @hideinitializer */ 717*a58d3d2aSXin Li #define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __opus_check_int_ptr(x) 718*a58d3d2aSXin Li 719*a58d3d2aSXin Li /** Gets the sampling rate the encoder or decoder was initialized with. 720*a58d3d2aSXin Li * This simply returns the <code>Fs</code> value passed to opus_encoder_init() 721*a58d3d2aSXin Li * or opus_decoder_init(). 722*a58d3d2aSXin Li * @param[out] x <tt>opus_int32 *</tt>: Sampling rate of encoder or decoder. 723*a58d3d2aSXin Li * @hideinitializer 724*a58d3d2aSXin Li */ 725*a58d3d2aSXin Li #define OPUS_GET_SAMPLE_RATE(x) OPUS_GET_SAMPLE_RATE_REQUEST, __opus_check_int_ptr(x) 726*a58d3d2aSXin Li 727*a58d3d2aSXin Li /** If set to 1, disables the use of phase inversion for intensity stereo, 728*a58d3d2aSXin Li * improving the quality of mono downmixes, but slightly reducing normal 729*a58d3d2aSXin Li * stereo quality. Disabling phase inversion in the decoder does not comply 730*a58d3d2aSXin Li * with RFC 6716, although it does not cause any interoperability issue and 731*a58d3d2aSXin Li * is expected to become part of the Opus standard once RFC 6716 is updated 732*a58d3d2aSXin Li * by draft-ietf-codec-opus-update. 733*a58d3d2aSXin Li * @see OPUS_GET_PHASE_INVERSION_DISABLED 734*a58d3d2aSXin Li * @param[in] x <tt>opus_int32</tt>: Allowed values: 735*a58d3d2aSXin Li * <dl> 736*a58d3d2aSXin Li * <dt>0</dt><dd>Enable phase inversion (default).</dd> 737*a58d3d2aSXin Li * <dt>1</dt><dd>Disable phase inversion.</dd> 738*a58d3d2aSXin Li * </dl> 739*a58d3d2aSXin Li * @hideinitializer */ 740*a58d3d2aSXin Li #define OPUS_SET_PHASE_INVERSION_DISABLED(x) OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST, __opus_check_int(x) 741*a58d3d2aSXin Li /** Gets the encoder's configured phase inversion status. 742*a58d3d2aSXin Li * @see OPUS_SET_PHASE_INVERSION_DISABLED 743*a58d3d2aSXin Li * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: 744*a58d3d2aSXin Li * <dl> 745*a58d3d2aSXin Li * <dt>0</dt><dd>Stereo phase inversion enabled (default).</dd> 746*a58d3d2aSXin Li * <dt>1</dt><dd>Stereo phase inversion disabled.</dd> 747*a58d3d2aSXin Li * </dl> 748*a58d3d2aSXin Li * @hideinitializer */ 749*a58d3d2aSXin Li #define OPUS_GET_PHASE_INVERSION_DISABLED(x) OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST, __opus_check_int_ptr(x) 750*a58d3d2aSXin Li /** Gets the DTX state of the encoder. 751*a58d3d2aSXin Li * Returns whether the last encoded frame was either a comfort noise update 752*a58d3d2aSXin Li * during DTX or not encoded because of DTX. 753*a58d3d2aSXin Li * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: 754*a58d3d2aSXin Li * <dl> 755*a58d3d2aSXin Li * <dt>0</dt><dd>The encoder is not in DTX.</dd> 756*a58d3d2aSXin Li * <dt>1</dt><dd>The encoder is in DTX.</dd> 757*a58d3d2aSXin Li * </dl> 758*a58d3d2aSXin Li * @hideinitializer */ 759*a58d3d2aSXin Li #define OPUS_GET_IN_DTX(x) OPUS_GET_IN_DTX_REQUEST, __opus_check_int_ptr(x) 760*a58d3d2aSXin Li 761*a58d3d2aSXin Li /**@}*/ 762*a58d3d2aSXin Li 763*a58d3d2aSXin Li /** @defgroup opus_decoderctls Decoder related CTLs 764*a58d3d2aSXin Li * @see opus_genericctls, opus_encoderctls, opus_decoder 765*a58d3d2aSXin Li * @{ 766*a58d3d2aSXin Li */ 767*a58d3d2aSXin Li 768*a58d3d2aSXin Li /** Configures decoder gain adjustment. 769*a58d3d2aSXin Li * Scales the decoded output by a factor specified in Q8 dB units. 770*a58d3d2aSXin Li * This has a maximum range of -32768 to 32767 inclusive, and returns 771*a58d3d2aSXin Li * OPUS_BAD_ARG otherwise. The default is zero indicating no adjustment. 772*a58d3d2aSXin Li * This setting survives decoder reset. 773*a58d3d2aSXin Li * 774*a58d3d2aSXin Li * gain = pow(10, x/(20.0*256)) 775*a58d3d2aSXin Li * 776*a58d3d2aSXin Li * @param[in] x <tt>opus_int32</tt>: Amount to scale PCM signal by in Q8 dB units. 777*a58d3d2aSXin Li * @hideinitializer */ 778*a58d3d2aSXin Li #define OPUS_SET_GAIN(x) OPUS_SET_GAIN_REQUEST, __opus_check_int(x) 779*a58d3d2aSXin Li /** Gets the decoder's configured gain adjustment. @see OPUS_SET_GAIN 780*a58d3d2aSXin Li * 781*a58d3d2aSXin Li * @param[out] x <tt>opus_int32 *</tt>: Amount to scale PCM signal by in Q8 dB units. 782*a58d3d2aSXin Li * @hideinitializer */ 783*a58d3d2aSXin Li #define OPUS_GET_GAIN(x) OPUS_GET_GAIN_REQUEST, __opus_check_int_ptr(x) 784*a58d3d2aSXin Li 785*a58d3d2aSXin Li /** Gets the duration (in samples) of the last packet successfully decoded or concealed. 786*a58d3d2aSXin Li * @param[out] x <tt>opus_int32 *</tt>: Number of samples (at current sampling rate). 787*a58d3d2aSXin Li * @hideinitializer */ 788*a58d3d2aSXin Li #define OPUS_GET_LAST_PACKET_DURATION(x) OPUS_GET_LAST_PACKET_DURATION_REQUEST, __opus_check_int_ptr(x) 789*a58d3d2aSXin Li 790*a58d3d2aSXin Li /** Gets the pitch of the last decoded frame, if available. 791*a58d3d2aSXin Li * This can be used for any post-processing algorithm requiring the use of pitch, 792*a58d3d2aSXin Li * e.g. time stretching/shortening. If the last frame was not voiced, or if the 793*a58d3d2aSXin Li * pitch was not coded in the frame, then zero is returned. 794*a58d3d2aSXin Li * 795*a58d3d2aSXin Li * This CTL is only implemented for decoder instances. 796*a58d3d2aSXin Li * 797*a58d3d2aSXin Li * @param[out] x <tt>opus_int32 *</tt>: pitch period at 48 kHz (or 0 if not available) 798*a58d3d2aSXin Li * 799*a58d3d2aSXin Li * @hideinitializer */ 800*a58d3d2aSXin Li #define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x) 801*a58d3d2aSXin Li 802*a58d3d2aSXin Li /**@}*/ 803*a58d3d2aSXin Li 804*a58d3d2aSXin Li /** @defgroup opus_libinfo Opus library information functions 805*a58d3d2aSXin Li * @{ 806*a58d3d2aSXin Li */ 807*a58d3d2aSXin Li 808*a58d3d2aSXin Li /** Converts an opus error code into a human readable string. 809*a58d3d2aSXin Li * 810*a58d3d2aSXin Li * @param[in] error <tt>int</tt>: Error number 811*a58d3d2aSXin Li * @returns Error string 812*a58d3d2aSXin Li */ 813*a58d3d2aSXin Li OPUS_EXPORT const char *opus_strerror(int error); 814*a58d3d2aSXin Li 815*a58d3d2aSXin Li /** Gets the libopus version string. 816*a58d3d2aSXin Li * 817*a58d3d2aSXin Li * Applications may look for the substring "-fixed" in the version string to 818*a58d3d2aSXin Li * determine whether they have a fixed-point or floating-point build at 819*a58d3d2aSXin Li * runtime. 820*a58d3d2aSXin Li * 821*a58d3d2aSXin Li * @returns Version string 822*a58d3d2aSXin Li */ 823*a58d3d2aSXin Li OPUS_EXPORT const char *opus_get_version_string(void); 824*a58d3d2aSXin Li /**@}*/ 825*a58d3d2aSXin Li 826*a58d3d2aSXin Li #ifdef __cplusplus 827*a58d3d2aSXin Li } 828*a58d3d2aSXin Li #endif 829*a58d3d2aSXin Li 830*a58d3d2aSXin Li #endif /* OPUS_DEFINES_H */ 831