| OLD | NEW |
| (Empty) | |
| 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 #if defined(__GNUC__) && defined(OPUS_BUILD) |
| 67 # define OPUS_EXPORT __attribute__ ((visibility ("default"))) |
| 68 #elif defined(WIN32) && !defined(__MINGW32__) |
| 69 # ifdef OPUS_BUILD |
| 70 # define OPUS_EXPORT __declspec(dllexport) |
| 71 # else |
| 72 # define OPUS_EXPORT |
| 73 # endif |
| 74 #else |
| 75 # define OPUS_EXPORT |
| 76 #endif |
| 77 |
| 78 # if !defined(OPUS_GNUC_PREREQ) |
| 79 # if defined(__GNUC__)&&defined(__GNUC_MINOR__) |
| 80 # define OPUS_GNUC_PREREQ(_maj,_min) \ |
| 81 ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min)) |
| 82 # else |
| 83 # define OPUS_GNUC_PREREQ(_maj,_min) 0 |
| 84 # endif |
| 85 # endif |
| 86 |
| 87 #if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) |
| 88 # if OPUS_GNUC_PREREQ(3,0) |
| 89 # define OPUS_RESTRICT __restrict__ |
| 90 # elif (defined(_MSC_VER) && _MSC_VER >= 1400) |
| 91 # define OPUS_RESTRICT __restrict |
| 92 # else |
| 93 # define OPUS_RESTRICT |
| 94 # endif |
| 95 #else |
| 96 # define OPUS_RESTRICT restrict |
| 97 #endif |
| 98 |
| 99 /**Warning attributes for opus functions |
| 100 * NONNULL is not used in OPUS_BUILD to avoid the compiler optimizing out |
| 101 * some paranoid null checks. */ |
| 102 #if defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4) |
| 103 # define OPUS_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) |
| 104 #else |
| 105 # define OPUS_WARN_UNUSED_RESULT |
| 106 #endif |
| 107 #if !defined(OPUS_BUILD) && defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4) |
| 108 # define OPUS_ARG_NONNULL(_x) __attribute__ ((__nonnull__(_x))) |
| 109 #else |
| 110 # define OPUS_ARG_NONNULL(_x) |
| 111 #endif |
| 112 |
| 113 /** These are the actual Encoder CTL ID numbers. |
| 114 * They should not be used directly by applications. */ |
| 115 #define OPUS_SET_APPLICATION_REQUEST 4000 |
| 116 #define OPUS_GET_APPLICATION_REQUEST 4001 |
| 117 #define OPUS_SET_BITRATE_REQUEST 4002 |
| 118 #define OPUS_GET_BITRATE_REQUEST 4003 |
| 119 #define OPUS_SET_MAX_BANDWIDTH_REQUEST 4004 |
| 120 #define OPUS_GET_MAX_BANDWIDTH_REQUEST 4005 |
| 121 #define OPUS_SET_VBR_REQUEST 4006 |
| 122 #define OPUS_GET_VBR_REQUEST 4007 |
| 123 #define OPUS_SET_BANDWIDTH_REQUEST 4008 |
| 124 #define OPUS_GET_BANDWIDTH_REQUEST 4009 |
| 125 #define OPUS_SET_COMPLEXITY_REQUEST 4010 |
| 126 #define OPUS_GET_COMPLEXITY_REQUEST 4011 |
| 127 #define OPUS_SET_INBAND_FEC_REQUEST 4012 |
| 128 #define OPUS_GET_INBAND_FEC_REQUEST 4013 |
| 129 #define OPUS_SET_PACKET_LOSS_PERC_REQUEST 4014 |
| 130 #define OPUS_GET_PACKET_LOSS_PERC_REQUEST 4015 |
| 131 #define OPUS_SET_DTX_REQUEST 4016 |
| 132 #define OPUS_GET_DTX_REQUEST 4017 |
| 133 #define OPUS_SET_VBR_CONSTRAINT_REQUEST 4020 |
| 134 #define OPUS_GET_VBR_CONSTRAINT_REQUEST 4021 |
| 135 #define OPUS_SET_FORCE_CHANNELS_REQUEST 4022 |
| 136 #define OPUS_GET_FORCE_CHANNELS_REQUEST 4023 |
| 137 #define OPUS_SET_SIGNAL_REQUEST 4024 |
| 138 #define OPUS_GET_SIGNAL_REQUEST 4025 |
| 139 #define OPUS_GET_LOOKAHEAD_REQUEST 4027 |
| 140 /* #define OPUS_RESET_STATE 4028 */ |
| 141 #define OPUS_GET_FINAL_RANGE_REQUEST 4031 |
| 142 #define OPUS_GET_PITCH_REQUEST 4033 |
| 143 #define OPUS_SET_GAIN_REQUEST 4034 |
| 144 #define OPUS_GET_GAIN_REQUEST 4045 |
| 145 #define OPUS_SET_LSB_DEPTH_REQUEST 4036 |
| 146 #define OPUS_GET_LSB_DEPTH_REQUEST 4037 |
| 147 |
| 148 /* Macros to trigger compilation errors when the wrong types are provided to a C
TL */ |
| 149 #define __opus_check_int(x) (((void)((x) == (opus_int32)0)), (opus_int32)(x)) |
| 150 #define __opus_check_int_ptr(ptr) ((ptr) + ((ptr) - (opus_int32*)(ptr))) |
| 151 #define __opus_check_uint_ptr(ptr) ((ptr) + ((ptr) - (opus_uint32*)(ptr))) |
| 152 /** @endcond */ |
| 153 |
| 154 /** @defgroup opus_ctlvalues Pre-defined values for CTL interface |
| 155 * @see opus_genericctls, opus_encoderctls |
| 156 * @{ |
| 157 */ |
| 158 /* Values for the various encoder CTLs */ |
| 159 #define OPUS_AUTO -1000 /**<Auto/default setting @hide
initializer*/ |
| 160 #define OPUS_BITRATE_MAX -1 /**<Maximum bitrate @hideiniti
alizer*/ |
| 161 |
| 162 /** Best for most VoIP/videoconference applications where listening quality and
intelligibility matter most |
| 163 * @hideinitializer */ |
| 164 #define OPUS_APPLICATION_VOIP 2048 |
| 165 /** Best for broadcast/high-fidelity application where the decoded audio should
be as close as possible to the input |
| 166 * @hideinitializer */ |
| 167 #define OPUS_APPLICATION_AUDIO 2049 |
| 168 /** Only use when lowest-achievable latency is what matters most. Voice-optimize
d modes cannot be used. |
| 169 * @hideinitializer */ |
| 170 #define OPUS_APPLICATION_RESTRICTED_LOWDELAY 2051 |
| 171 |
| 172 #define OPUS_SIGNAL_VOICE 3001 /**< Signal being encoded is v
oice */ |
| 173 #define OPUS_SIGNAL_MUSIC 3002 /**< Signal being encoded is m
usic */ |
| 174 #define OPUS_BANDWIDTH_NARROWBAND 1101 /**< 4 kHz bandpass @hideiniti
alizer*/ |
| 175 #define OPUS_BANDWIDTH_MEDIUMBAND 1102 /**< 6 kHz bandpass @hideiniti
alizer*/ |
| 176 #define OPUS_BANDWIDTH_WIDEBAND 1103 /**< 8 kHz bandpass @hideiniti
alizer*/ |
| 177 #define OPUS_BANDWIDTH_SUPERWIDEBAND 1104 /**<12 kHz bandpass @hideiniti
alizer*/ |
| 178 #define OPUS_BANDWIDTH_FULLBAND 1105 /**<20 kHz bandpass @hideiniti
alizer*/ |
| 179 |
| 180 /**@}*/ |
| 181 |
| 182 |
| 183 /** @defgroup opus_encoderctls Encoder related CTLs |
| 184 * |
| 185 * These are convenience macros for use with the \c opus_encode_ctl |
| 186 * interface. They are used to generate the appropriate series of |
| 187 * arguments for that call, passing the correct type, size and so |
| 188 * on as expected for each particular request. |
| 189 * |
| 190 * Some usage examples: |
| 191 * |
| 192 * @code |
| 193 * int ret; |
| 194 * ret = opus_encoder_ctl(enc_ctx, OPUS_SET_BANDWIDTH(OPUS_AUTO)); |
| 195 * if (ret != OPUS_OK) return ret; |
| 196 * |
| 197 * opus_int32 rate; |
| 198 * opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&rate)); |
| 199 * |
| 200 * opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE); |
| 201 * @endcode |
| 202 * |
| 203 * @see opus_genericctls, opus_encoder |
| 204 * @{ |
| 205 */ |
| 206 |
| 207 /** Configures the encoder's computational complexity. |
| 208 * The supported range is 0-10 inclusive with 10 representing the highest compl
exity. |
| 209 * @see OPUS_GET_COMPLEXITY |
| 210 * @param[in] x <tt>opus_int32</tt>: Allowed values: 0-10, inclusive. |
| 211 * |
| 212 * @hideinitializer */ |
| 213 #define OPUS_SET_COMPLEXITY(x) OPUS_SET_COMPLEXITY_REQUEST, __opus_check_int(x) |
| 214 /** Gets the encoder's complexity configuration. |
| 215 * @see OPUS_SET_COMPLEXITY |
| 216 * @param[out] x <tt>opus_int32 *</tt>: Returns a value in the range 0-10, |
| 217 * inclusive. |
| 218 * @hideinitializer */ |
| 219 #define OPUS_GET_COMPLEXITY(x) OPUS_GET_COMPLEXITY_REQUEST, __opus_check_int_ptr
(x) |
| 220 |
| 221 /** Configures the bitrate in the encoder. |
| 222 * Rates from 500 to 512000 bits per second are meaningful, as well as the |
| 223 * special values #OPUS_AUTO and #OPUS_BITRATE_MAX. |
| 224 * The value #OPUS_BITRATE_MAX can be used to cause the codec to use as much |
| 225 * rate as it can, which is useful for controlling the rate by adjusting the |
| 226 * output buffer size. |
| 227 * @see OPUS_GET_BITRATE |
| 228 * @param[in] x <tt>opus_int32</tt>: Bitrate in bits per second. The default |
| 229 * is determined based on the number of |
| 230 * channels and the input sampling rate. |
| 231 * @hideinitializer */ |
| 232 #define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __opus_check_int(x) |
| 233 /** Gets the encoder's bitrate configuration. |
| 234 * @see OPUS_SET_BITRATE |
| 235 * @param[out] x <tt>opus_int32 *</tt>: Returns the bitrate in bits per second. |
| 236 * The default is determined based on the |
| 237 * number of channels and the input |
| 238 * sampling rate. |
| 239 * @hideinitializer */ |
| 240 #define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __opus_check_int_ptr(x) |
| 241 |
| 242 /** Enables or disables variable bitrate (VBR) in the encoder. |
| 243 * The configured bitrate may not be met exactly because frames must |
| 244 * be an integer number of bytes in length. |
| 245 * @warning Only the MDCT mode of Opus can provide hard CBR behavior. |
| 246 * @see OPUS_GET_VBR |
| 247 * @see OPUS_SET_VBR_CONSTRAINT |
| 248 * @param[in] x <tt>opus_int32</tt>: Allowed values: |
| 249 * <dl> |
| 250 * <dt>0</dt><dd>Hard CBR. For LPC/hybrid modes at very low bit-rate, this can |
| 251 * cause noticeable quality degradation.</dd> |
| 252 * <dt>1</dt><dd>VBR (default). The exact type of VBR is controlled by |
| 253 * #OPUS_SET_VBR_CONSTRAINT.</dd> |
| 254 * </dl> |
| 255 * @hideinitializer */ |
| 256 #define OPUS_SET_VBR(x) OPUS_SET_VBR_REQUEST, __opus_check_int(x) |
| 257 /** Determine if variable bitrate (VBR) is enabled in the encoder. |
| 258 * @see OPUS_SET_VBR |
| 259 * @see OPUS_GET_VBR_CONSTRAINT |
| 260 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
| 261 * <dl> |
| 262 * <dt>0</dt><dd>Hard CBR.</dd> |
| 263 * <dt>1</dt><dd>VBR (default). The exact type of VBR may be retrieved via |
| 264 * #OPUS_GET_VBR_CONSTRAINT.</dd> |
| 265 * </dl> |
| 266 * @hideinitializer */ |
| 267 #define OPUS_GET_VBR(x) OPUS_GET_VBR_REQUEST, __opus_check_int_ptr(x) |
| 268 |
| 269 /** Enables or disables constrained VBR in the encoder. |
| 270 * This setting is ignored when the encoder is in CBR mode. |
| 271 * @warning Only the MDCT mode of Opus currently heeds the constraint. |
| 272 * Speech mode ignores it completely, hybrid mode may fail to obey it |
| 273 * if the LPC layer uses more bitrate than the constraint would have |
| 274 * permitted. |
| 275 * @see OPUS_GET_VBR_CONSTRAINT |
| 276 * @see OPUS_SET_VBR |
| 277 * @param[in] x <tt>opus_int32</tt>: Allowed values: |
| 278 * <dl> |
| 279 * <dt>0</dt><dd>Unconstrained VBR.</dd> |
| 280 * <dt>1</dt><dd>Constrained VBR (default). This creates a maximum of one |
| 281 * frame of buffering delay assuming a transport with a |
| 282 * serialization speed of the nominal bitrate.</dd> |
| 283 * </dl> |
| 284 * @hideinitializer */ |
| 285 #define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __opus_check
_int(x) |
| 286 /** Determine if constrained VBR is enabled in the encoder. |
| 287 * @see OPUS_SET_VBR_CONSTRAINT |
| 288 * @see OPUS_GET_VBR |
| 289 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
| 290 * <dl> |
| 291 * <dt>0</dt><dd>Unconstrained VBR.</dd> |
| 292 * <dt>1</dt><dd>Constrained VBR (default).</dd> |
| 293 * </dl> |
| 294 * @hideinitializer */ |
| 295 #define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __opus_check
_int_ptr(x) |
| 296 |
| 297 /** Configures mono/stereo forcing in the encoder. |
| 298 * This can force the encoder to produce packets encoded as either mono or |
| 299 * stereo, regardless of the format of the input audio. This is useful when |
| 300 * the caller knows that the input signal is currently a mono source embedded |
| 301 * in a stereo stream. |
| 302 * @see OPUS_GET_FORCE_CHANNELS |
| 303 * @param[in] x <tt>opus_int32</tt>: Allowed values: |
| 304 * <dl> |
| 305 * <dt>#OPUS_AUTO</dt><dd>Not forced (default)</dd> |
| 306 * <dt>1</dt> <dd>Forced mono</dd> |
| 307 * <dt>2</dt> <dd>Forced stereo</dd> |
| 308 * </dl> |
| 309 * @hideinitializer */ |
| 310 #define OPUS_SET_FORCE_CHANNELS(x) OPUS_SET_FORCE_CHANNELS_REQUEST, __opus_check
_int(x) |
| 311 /** Gets the encoder's forced channel configuration. |
| 312 * @see OPUS_SET_FORCE_CHANNELS |
| 313 * @param[out] x <tt>opus_int32 *</tt>: |
| 314 * <dl> |
| 315 * <dt>#OPUS_AUTO</dt><dd>Not forced (default)</dd> |
| 316 * <dt>1</dt> <dd>Forced mono</dd> |
| 317 * <dt>2</dt> <dd>Forced stereo</dd> |
| 318 * </dl> |
| 319 * @hideinitializer */ |
| 320 #define OPUS_GET_FORCE_CHANNELS(x) OPUS_GET_FORCE_CHANNELS_REQUEST, __opus_check
_int_ptr(x) |
| 321 |
| 322 /** Configures the maximum bandpass that the encoder will select automatically. |
| 323 * Applications should normally use this instead of #OPUS_SET_BANDWIDTH |
| 324 * (leaving that set to the default, #OPUS_AUTO). This allows the |
| 325 * application to set an upper bound based on the type of input it is |
| 326 * providing, but still gives the encoder the freedom to reduce the bandpass |
| 327 * when the bitrate becomes too low, for better overall quality. |
| 328 * @see OPUS_GET_MAX_BANDWIDTH |
| 329 * @param[in] x <tt>opus_int32</tt>: Allowed values: |
| 330 * <dl> |
| 331 * <dt>OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
| 332 * <dt>OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
| 333 * <dt>OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
| 334 * <dt>OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
| 335 * <dt>OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband (default)</dd> |
| 336 * </dl> |
| 337 * @hideinitializer */ |
| 338 #define OPUS_SET_MAX_BANDWIDTH(x) OPUS_SET_MAX_BANDWIDTH_REQUEST, __opus_check_i
nt(x) |
| 339 |
| 340 /** Gets the encoder's configured maximum allowed bandpass. |
| 341 * @see OPUS_SET_MAX_BANDWIDTH |
| 342 * @param[out] x <tt>opus_int32 *</tt>: Allowed values: |
| 343 * <dl> |
| 344 * <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
| 345 * <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
| 346 * <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
| 347 * <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
| 348 * <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband (default)</dd> |
| 349 * </dl> |
| 350 * @hideinitializer */ |
| 351 #define OPUS_GET_MAX_BANDWIDTH(x) OPUS_GET_MAX_BANDWIDTH_REQUEST, __opus_check_i
nt_ptr(x) |
| 352 |
| 353 /** Sets the encoder's bandpass to a specific value. |
| 354 * This prevents the encoder from automatically selecting the bandpass based |
| 355 * on the available bitrate. If an application knows the bandpass of the input |
| 356 * audio it is providing, it should normally use #OPUS_SET_MAX_BANDWIDTH |
| 357 * instead, which still gives the encoder the freedom to reduce the bandpass |
| 358 * when the bitrate becomes too low, for better overall quality. |
| 359 * @see OPUS_GET_BANDWIDTH |
| 360 * @param[in] x <tt>opus_int32</tt>: Allowed values: |
| 361 * <dl> |
| 362 * <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
| 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</dd> |
| 368 * </dl> |
| 369 * @hideinitializer */ |
| 370 #define OPUS_SET_BANDWIDTH(x) OPUS_SET_BANDWIDTH_REQUEST, __opus_check_int(x) |
| 371 |
| 372 /** Configures the type of signal being encoded. |
| 373 * This is a hint which helps the encoder's mode selection. |
| 374 * @see OPUS_GET_SIGNAL |
| 375 * @param[in] x <tt>opus_int32</tt>: Allowed values: |
| 376 * <dl> |
| 377 * <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
| 378 * <dt>#OPUS_SIGNAL_VOICE</dt><dd>Bias thresholds towards choosing LPC or Hybri
d modes.</dd> |
| 379 * <dt>#OPUS_SIGNAL_MUSIC</dt><dd>Bias thresholds towards choosing MDCT modes.<
/dd> |
| 380 * </dl> |
| 381 * @hideinitializer */ |
| 382 #define OPUS_SET_SIGNAL(x) OPUS_SET_SIGNAL_REQUEST, __opus_check_int(x) |
| 383 /** Gets the encoder's configured signal type. |
| 384 * @see OPUS_SET_SIGNAL |
| 385 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
| 386 * <dl> |
| 387 * <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
| 388 * <dt>#OPUS_SIGNAL_VOICE</dt><dd>Bias thresholds towards choosing LPC or Hybri
d modes.</dd> |
| 389 * <dt>#OPUS_SIGNAL_MUSIC</dt><dd>Bias thresholds towards choosing MDCT modes.<
/dd> |
| 390 * </dl> |
| 391 * @hideinitializer */ |
| 392 #define OPUS_GET_SIGNAL(x) OPUS_GET_SIGNAL_REQUEST, __opus_check_int_ptr(x) |
| 393 |
| 394 |
| 395 /** Configures the encoder's intended application. |
| 396 * The initial value is a mandatory argument to the encoder_create function. |
| 397 * @see OPUS_GET_APPLICATION |
| 398 * @param[in] x <tt>opus_int32</tt>: Returns one of the following values: |
| 399 * <dl> |
| 400 * <dt>#OPUS_APPLICATION_VOIP</dt> |
| 401 * <dd>Process signal for improved speech intelligibility.</dd> |
| 402 * <dt>#OPUS_APPLICATION_AUDIO</dt> |
| 403 * <dd>Favor faithfulness to the original input.</dd> |
| 404 * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> |
| 405 * <dd>Configure the minimum possible coding delay by disabling certain modes |
| 406 * of operation.</dd> |
| 407 * </dl> |
| 408 * @hideinitializer */ |
| 409 #define OPUS_SET_APPLICATION(x) OPUS_SET_APPLICATION_REQUEST, __opus_check_int(x
) |
| 410 /** Gets the encoder's configured application. |
| 411 * @see OPUS_SET_APPLICATION |
| 412 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
| 413 * <dl> |
| 414 * <dt>#OPUS_APPLICATION_VOIP</dt> |
| 415 * <dd>Process signal for improved speech intelligibility.</dd> |
| 416 * <dt>#OPUS_APPLICATION_AUDIO</dt> |
| 417 * <dd>Favor faithfulness to the original input.</dd> |
| 418 * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> |
| 419 * <dd>Configure the minimum possible coding delay by disabling certain modes |
| 420 * of operation.</dd> |
| 421 * </dl> |
| 422 * @hideinitializer */ |
| 423 #define OPUS_GET_APPLICATION(x) OPUS_GET_APPLICATION_REQUEST, __opus_check_int_p
tr(x) |
| 424 |
| 425 /** Gets the total samples of delay added by the entire codec. |
| 426 * This can be queried by the encoder and then the provided number of samples c
an be |
| 427 * skipped on from the start of the decoder's output to provide time aligned in
put |
| 428 * and output. From the perspective of a decoding application the real data beg
ins this many |
| 429 * samples late. |
| 430 * |
| 431 * The decoder contribution to this delay is identical for all decoders, but th
e |
| 432 * encoder portion of the delay may vary from implementation to implementation, |
| 433 * version to version, or even depend on the encoder's initial configuration. |
| 434 * Applications needing delay compensation should call this CTL rather than |
| 435 * hard-coding a value. |
| 436 * @param[out] x <tt>opus_int32 *</tt>: Number of lookahead samples |
| 437 * @hideinitializer */ |
| 438 #define OPUS_GET_LOOKAHEAD(x) OPUS_GET_LOOKAHEAD_REQUEST, __opus_check_int_ptr(x
) |
| 439 |
| 440 /** Configures the encoder's use of inband forward error correction (FEC). |
| 441 * @note This is only applicable to the LPC layer |
| 442 * @see OPUS_GET_INBAND_FEC |
| 443 * @param[in] x <tt>opus_int32</tt>: Allowed values: |
| 444 * <dl> |
| 445 * <dt>0</dt><dd>Disable inband FEC (default).</dd> |
| 446 * <dt>1</dt><dd>Enable inband FEC.</dd> |
| 447 * </dl> |
| 448 * @hideinitializer */ |
| 449 #define OPUS_SET_INBAND_FEC(x) OPUS_SET_INBAND_FEC_REQUEST, __opus_check_int(x) |
| 450 /** Gets encoder's configured use of inband forward error correction. |
| 451 * @see OPUS_SET_INBAND_FEC |
| 452 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
| 453 * <dl> |
| 454 * <dt>0</dt><dd>Inband FEC disabled (default).</dd> |
| 455 * <dt>1</dt><dd>Inband FEC enabled.</dd> |
| 456 * </dl> |
| 457 * @hideinitializer */ |
| 458 #define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_int_ptr
(x) |
| 459 |
| 460 /** Configures the encoder's expected packet loss percentage. |
| 461 * Higher values with trigger progressively more loss resistant behavior in the
encoder |
| 462 * at the expense of quality at a given bitrate in the lossless case, but great
er quality |
| 463 * under loss. |
| 464 * @see OPUS_GET_PACKET_LOSS_PERC |
| 465 * @param[in] x <tt>opus_int32</tt>: Loss percentage in the range 0-100, incl
usive (default: 0). |
| 466 * @hideinitializer */ |
| 467 #define OPUS_SET_PACKET_LOSS_PERC(x) OPUS_SET_PACKET_LOSS_PERC_REQUEST, __opus_c
heck_int(x) |
| 468 /** Gets the encoder's configured packet loss percentage. |
| 469 * @see OPUS_SET_PACKET_LOSS_PERC |
| 470 * @param[out] x <tt>opus_int32 *</tt>: Returns the configured loss percentage |
| 471 * in the range 0-100, inclusive (default:
0). |
| 472 * @hideinitializer */ |
| 473 #define OPUS_GET_PACKET_LOSS_PERC(x) OPUS_GET_PACKET_LOSS_PERC_REQUEST, __opus_c
heck_int_ptr(x) |
| 474 |
| 475 /** Configures the encoder's use of discontinuous transmission (DTX). |
| 476 * @note This is only applicable to the LPC layer |
| 477 * @see OPUS_GET_DTX |
| 478 * @param[in] x <tt>opus_int32</tt>: Allowed values: |
| 479 * <dl> |
| 480 * <dt>0</dt><dd>Disable DTX (default).</dd> |
| 481 * <dt>1</dt><dd>Enabled DTX.</dd> |
| 482 * </dl> |
| 483 * @hideinitializer */ |
| 484 #define OPUS_SET_DTX(x) OPUS_SET_DTX_REQUEST, __opus_check_int(x) |
| 485 /** Gets encoder's configured use of discontinuous transmission. |
| 486 * @see OPUS_SET_DTX |
| 487 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
| 488 * <dl> |
| 489 * <dt>0</dt><dd>DTX disabled (default).</dd> |
| 490 * <dt>1</dt><dd>DTX enabled.</dd> |
| 491 * </dl> |
| 492 * @hideinitializer */ |
| 493 #define OPUS_GET_DTX(x) OPUS_GET_DTX_REQUEST, __opus_check_int_ptr(x) |
| 494 /**@}*/ |
| 495 |
| 496 /** @defgroup opus_genericctls Generic CTLs |
| 497 * |
| 498 * These macros are used with the \c opus_decoder_ctl and |
| 499 * \c opus_encoder_ctl calls to generate a particular |
| 500 * request. |
| 501 * |
| 502 * When called on an \c OpusDecoder they apply to that |
| 503 * particular decoder instance. When called on an |
| 504 * \c OpusEncoder they apply to the corresponding setting |
| 505 * on that encoder instance, if present. |
| 506 * |
| 507 * Some usage examples: |
| 508 * |
| 509 * @code |
| 510 * int ret; |
| 511 * opus_int32 pitch; |
| 512 * ret = opus_decoder_ctl(dec_ctx, OPUS_GET_PITCH(&pitch)); |
| 513 * if (ret == OPUS_OK) return ret; |
| 514 * |
| 515 * opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE); |
| 516 * opus_decoder_ctl(dec_ctx, OPUS_RESET_STATE); |
| 517 * |
| 518 * opus_int32 enc_bw, dec_bw; |
| 519 * opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&enc_bw)); |
| 520 * opus_decoder_ctl(dec_ctx, OPUS_GET_BANDWIDTH(&dec_bw)); |
| 521 * if (enc_bw != dec_bw) { |
| 522 * printf("packet bandwidth mismatch!\n"); |
| 523 * } |
| 524 * @endcode |
| 525 * |
| 526 * @see opus_encoder, opus_decoder_ctl, opus_encoder_ctl, opus_decoderctls, opu
s_encoderctls |
| 527 * @{ |
| 528 */ |
| 529 |
| 530 /** Resets the codec state to be equivalent to a freshly initialized state. |
| 531 * This should be called when switching streams in order to prevent |
| 532 * the back to back decoding from giving different results from |
| 533 * one at a time decoding. |
| 534 * @hideinitializer */ |
| 535 #define OPUS_RESET_STATE 4028 |
| 536 |
| 537 /** Gets the final state of the codec's entropy coder. |
| 538 * This is used for testing purposes, |
| 539 * The encoder and decoder state should be identical after coding a payload |
| 540 * (assuming no data corruption or software bugs) |
| 541 * |
| 542 * @param[out] x <tt>opus_uint32 *</tt>: Entropy coder state |
| 543 * |
| 544 * @hideinitializer */ |
| 545 #define OPUS_GET_FINAL_RANGE(x) OPUS_GET_FINAL_RANGE_REQUEST, __opus_check_uint_
ptr(x) |
| 546 |
| 547 /** Gets the pitch of the last decoded frame, if available. |
| 548 * This can be used for any post-processing algorithm requiring the use of pitc
h, |
| 549 * e.g. time stretching/shortening. If the last frame was not voiced, or if the |
| 550 * pitch was not coded in the frame, then zero is returned. |
| 551 * |
| 552 * This CTL is only implemented for decoder instances. |
| 553 * |
| 554 * @param[out] x <tt>opus_int32 *</tt>: pitch period at 48 kHz (or 0 if not ava
ilable) |
| 555 * |
| 556 * @hideinitializer */ |
| 557 #define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x) |
| 558 |
| 559 /** Gets the encoder's configured bandpass or the decoder's last bandpass. |
| 560 * @see OPUS_SET_BANDWIDTH |
| 561 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
| 562 * <dl> |
| 563 * <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
| 564 * <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
| 565 * <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
| 566 * <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
| 567 * <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
| 568 * <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband</dd> |
| 569 * </dl> |
| 570 * @hideinitializer */ |
| 571 #define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __opus_check_int_ptr(x
) |
| 572 |
| 573 /** Configures the depth of signal being encoded. |
| 574 * This is a hint which helps the encoder identify silence and near-silence. |
| 575 * @see OPUS_GET_LSB_DEPTH |
| 576 * @param[in] x <tt>opus_int32</tt>: Input precision in bits, between 8 and 24 |
| 577 * (default: 24). |
| 578 * @hideinitializer */ |
| 579 #define OPUS_SET_LSB_DEPTH(x) OPUS_SET_LSB_DEPTH_REQUEST, __opus_check_int(x) |
| 580 /** Gets the encoder's configured signal depth. |
| 581 * @see OPUS_SET_LSB_DEPTH |
| 582 * @param[out] x <tt>opus_int32 *</tt>: Input precision in bits, between 8 and |
| 583 * 24 (default: 24). |
| 584 * @hideinitializer */ |
| 585 #define OPUS_GET_LSB_DEPTH(x) OPUS_GET_LSB_DEPTH_REQUEST, __opus_check_int_ptr(x
) |
| 586 /**@}*/ |
| 587 |
| 588 /** @defgroup opus_decoderctls Decoder related CTLs |
| 589 * @see opus_genericctls, opus_encoderctls, opus_decoder |
| 590 * @{ |
| 591 */ |
| 592 |
| 593 /** Configures decoder gain adjustment. |
| 594 * Scales the decoded output by a factor specified in Q8 dB units. |
| 595 * This has a maximum range of -32768 to 32767 inclusive, and returns |
| 596 * OPUS_BAD_ARG otherwise. The default is zero indicating no adjustment. |
| 597 * This setting survives decoder reset. |
| 598 * |
| 599 * gain = pow(10, x/(20.0*256)) |
| 600 * |
| 601 * @param[in] x <tt>opus_int32</tt>: Amount to scale PCM signal by in Q8 dB u
nits. |
| 602 * @hideinitializer */ |
| 603 #define OPUS_SET_GAIN(x) OPUS_SET_GAIN_REQUEST, __opus_check_int(x) |
| 604 /** Gets the decoder's configured gain adjustment. @see OPUS_SET_GAIN |
| 605 * |
| 606 * @param[out] x <tt>opus_int32 *</tt>: Amount to scale PCM signal by in Q8 dB
units. |
| 607 * @hideinitializer */ |
| 608 #define OPUS_GET_GAIN(x) OPUS_GET_GAIN_REQUEST, __opus_check_int_ptr(x) |
| 609 |
| 610 /**@}*/ |
| 611 |
| 612 /** @defgroup opus_libinfo Opus library information functions |
| 613 * @{ |
| 614 */ |
| 615 |
| 616 /** Converts an opus error code into a human readable string. |
| 617 * |
| 618 * @param[in] error <tt>int</tt>: Error number |
| 619 * @returns Error string |
| 620 */ |
| 621 OPUS_EXPORT const char *opus_strerror(int error); |
| 622 |
| 623 /** Gets the libopus version string. |
| 624 * |
| 625 * @returns Version string |
| 626 */ |
| 627 OPUS_EXPORT const char *opus_get_version_string(void); |
| 628 /**@}*/ |
| 629 |
| 630 #ifdef __cplusplus |
| 631 } |
| 632 #endif |
| 633 |
| 634 #endif /* OPUS_DEFINES_H */ |
| OLD | NEW |