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