Chris@69: /* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited Chris@69: Written by Jean-Marc Valin and Koen Vos */ Chris@69: /* Chris@69: Redistribution and use in source and binary forms, with or without Chris@69: modification, are permitted provided that the following conditions Chris@69: are met: Chris@69: Chris@69: - Redistributions of source code must retain the above copyright Chris@69: notice, this list of conditions and the following disclaimer. Chris@69: Chris@69: - Redistributions in binary form must reproduce the above copyright Chris@69: notice, this list of conditions and the following disclaimer in the Chris@69: documentation and/or other materials provided with the distribution. Chris@69: Chris@69: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS Chris@69: ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT Chris@69: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR Chris@69: A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER Chris@69: OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, Chris@69: EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, Chris@69: PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR Chris@69: PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF Chris@69: LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING Chris@69: NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS Chris@69: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Chris@69: */ Chris@69: Chris@69: /** Chris@69: * @file opus_defines.h Chris@69: * @brief Opus reference implementation constants Chris@69: */ Chris@69: Chris@69: #ifndef OPUS_DEFINES_H Chris@69: #define OPUS_DEFINES_H Chris@69: Chris@69: #include "opus_types.h" Chris@69: Chris@69: #ifdef __cplusplus Chris@69: extern "C" { Chris@69: #endif Chris@69: Chris@69: /** @defgroup opus_errorcodes Error codes Chris@69: * @{ Chris@69: */ Chris@69: /** No error @hideinitializer*/ Chris@69: #define OPUS_OK 0 Chris@69: /** One or more invalid/out of range arguments @hideinitializer*/ Chris@69: #define OPUS_BAD_ARG -1 Chris@69: /** Not enough bytes allocated in the buffer @hideinitializer*/ Chris@69: #define OPUS_BUFFER_TOO_SMALL -2 Chris@69: /** An internal error was detected @hideinitializer*/ Chris@69: #define OPUS_INTERNAL_ERROR -3 Chris@69: /** The compressed data passed is corrupted @hideinitializer*/ Chris@69: #define OPUS_INVALID_PACKET -4 Chris@69: /** Invalid/unsupported request number @hideinitializer*/ Chris@69: #define OPUS_UNIMPLEMENTED -5 Chris@69: /** An encoder or decoder structure is invalid or already freed @hideinitializer*/ Chris@69: #define OPUS_INVALID_STATE -6 Chris@69: /** Memory allocation has failed @hideinitializer*/ Chris@69: #define OPUS_ALLOC_FAIL -7 Chris@69: /**@}*/ Chris@69: Chris@69: /** @cond OPUS_INTERNAL_DOC */ Chris@69: /**Export control for opus functions */ Chris@69: Chris@69: #ifndef OPUS_EXPORT Chris@69: # if defined(WIN32) Chris@69: # if defined(OPUS_BUILD) && defined(DLL_EXPORT) Chris@69: # define OPUS_EXPORT __declspec(dllexport) Chris@69: # else Chris@69: # define OPUS_EXPORT Chris@69: # endif Chris@69: # elif defined(__GNUC__) && defined(OPUS_BUILD) Chris@69: # define OPUS_EXPORT __attribute__ ((visibility ("default"))) Chris@69: # else Chris@69: # define OPUS_EXPORT Chris@69: # endif Chris@69: #endif Chris@69: Chris@69: # if !defined(OPUS_GNUC_PREREQ) Chris@69: # if defined(__GNUC__)&&defined(__GNUC_MINOR__) Chris@69: # define OPUS_GNUC_PREREQ(_maj,_min) \ Chris@69: ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min)) Chris@69: # else Chris@69: # define OPUS_GNUC_PREREQ(_maj,_min) 0 Chris@69: # endif Chris@69: # endif Chris@69: Chris@69: #if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) Chris@69: # if OPUS_GNUC_PREREQ(3,0) Chris@69: # define OPUS_RESTRICT __restrict__ Chris@69: # elif (defined(_MSC_VER) && _MSC_VER >= 1400) Chris@69: # define OPUS_RESTRICT __restrict Chris@69: # else Chris@69: # define OPUS_RESTRICT Chris@69: # endif Chris@69: #else Chris@69: # define OPUS_RESTRICT restrict Chris@69: #endif Chris@69: Chris@69: #if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) Chris@69: # if OPUS_GNUC_PREREQ(2,7) Chris@69: # define OPUS_INLINE __inline__ Chris@69: # elif (defined(_MSC_VER)) Chris@69: # define OPUS_INLINE __inline Chris@69: # else Chris@69: # define OPUS_INLINE Chris@69: # endif Chris@69: #else Chris@69: # define OPUS_INLINE inline Chris@69: #endif Chris@69: Chris@69: /**Warning attributes for opus functions Chris@69: * NONNULL is not used in OPUS_BUILD to avoid the compiler optimizing out Chris@69: * some paranoid null checks. */ Chris@69: #if defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4) Chris@69: # define OPUS_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) Chris@69: #else Chris@69: # define OPUS_WARN_UNUSED_RESULT Chris@69: #endif Chris@69: #if !defined(OPUS_BUILD) && defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4) Chris@69: # define OPUS_ARG_NONNULL(_x) __attribute__ ((__nonnull__(_x))) Chris@69: #else Chris@69: # define OPUS_ARG_NONNULL(_x) Chris@69: #endif Chris@69: Chris@69: /** These are the actual Encoder CTL ID numbers. Chris@69: * They should not be used directly by applications. Chris@69: * In general, SETs should be even and GETs should be odd.*/ Chris@69: #define OPUS_SET_APPLICATION_REQUEST 4000 Chris@69: #define OPUS_GET_APPLICATION_REQUEST 4001 Chris@69: #define OPUS_SET_BITRATE_REQUEST 4002 Chris@69: #define OPUS_GET_BITRATE_REQUEST 4003 Chris@69: #define OPUS_SET_MAX_BANDWIDTH_REQUEST 4004 Chris@69: #define OPUS_GET_MAX_BANDWIDTH_REQUEST 4005 Chris@69: #define OPUS_SET_VBR_REQUEST 4006 Chris@69: #define OPUS_GET_VBR_REQUEST 4007 Chris@69: #define OPUS_SET_BANDWIDTH_REQUEST 4008 Chris@69: #define OPUS_GET_BANDWIDTH_REQUEST 4009 Chris@69: #define OPUS_SET_COMPLEXITY_REQUEST 4010 Chris@69: #define OPUS_GET_COMPLEXITY_REQUEST 4011 Chris@69: #define OPUS_SET_INBAND_FEC_REQUEST 4012 Chris@69: #define OPUS_GET_INBAND_FEC_REQUEST 4013 Chris@69: #define OPUS_SET_PACKET_LOSS_PERC_REQUEST 4014 Chris@69: #define OPUS_GET_PACKET_LOSS_PERC_REQUEST 4015 Chris@69: #define OPUS_SET_DTX_REQUEST 4016 Chris@69: #define OPUS_GET_DTX_REQUEST 4017 Chris@69: #define OPUS_SET_VBR_CONSTRAINT_REQUEST 4020 Chris@69: #define OPUS_GET_VBR_CONSTRAINT_REQUEST 4021 Chris@69: #define OPUS_SET_FORCE_CHANNELS_REQUEST 4022 Chris@69: #define OPUS_GET_FORCE_CHANNELS_REQUEST 4023 Chris@69: #define OPUS_SET_SIGNAL_REQUEST 4024 Chris@69: #define OPUS_GET_SIGNAL_REQUEST 4025 Chris@69: #define OPUS_GET_LOOKAHEAD_REQUEST 4027 Chris@69: /* #define OPUS_RESET_STATE 4028 */ Chris@69: #define OPUS_GET_SAMPLE_RATE_REQUEST 4029 Chris@69: #define OPUS_GET_FINAL_RANGE_REQUEST 4031 Chris@69: #define OPUS_GET_PITCH_REQUEST 4033 Chris@69: #define OPUS_SET_GAIN_REQUEST 4034 Chris@69: #define OPUS_GET_GAIN_REQUEST 4045 /* Should have been 4035 */ Chris@69: #define OPUS_SET_LSB_DEPTH_REQUEST 4036 Chris@69: #define OPUS_GET_LSB_DEPTH_REQUEST 4037 Chris@69: #define OPUS_GET_LAST_PACKET_DURATION_REQUEST 4039 Chris@69: #define OPUS_SET_EXPERT_FRAME_DURATION_REQUEST 4040 Chris@69: #define OPUS_GET_EXPERT_FRAME_DURATION_REQUEST 4041 Chris@69: #define OPUS_SET_PREDICTION_DISABLED_REQUEST 4042 Chris@69: #define OPUS_GET_PREDICTION_DISABLED_REQUEST 4043 Chris@69: /* Don't use 4045, it's already taken by OPUS_GET_GAIN_REQUEST */ Chris@69: #define OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST 4046 Chris@69: #define OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST 4047 Chris@69: Chris@69: /** Defines for the presence of extended APIs. */ Chris@69: #define OPUS_HAVE_OPUS_PROJECTION_H Chris@69: Chris@69: /* Macros to trigger compilation errors when the wrong types are provided to a CTL */ Chris@69: #define __opus_check_int(x) (((void)((x) == (opus_int32)0)), (opus_int32)(x)) Chris@69: #define __opus_check_int_ptr(ptr) ((ptr) + ((ptr) - (opus_int32*)(ptr))) Chris@69: #define __opus_check_uint_ptr(ptr) ((ptr) + ((ptr) - (opus_uint32*)(ptr))) Chris@69: #define __opus_check_val16_ptr(ptr) ((ptr) + ((ptr) - (opus_val16*)(ptr))) Chris@69: /** @endcond */ Chris@69: Chris@69: /** @defgroup opus_ctlvalues Pre-defined values for CTL interface Chris@69: * @see opus_genericctls, opus_encoderctls Chris@69: * @{ Chris@69: */ Chris@69: /* Values for the various encoder CTLs */ Chris@69: #define OPUS_AUTO -1000 /**opus_int32: Allowed values: 0-10, inclusive. Chris@69: * Chris@69: * @hideinitializer */ Chris@69: #define OPUS_SET_COMPLEXITY(x) OPUS_SET_COMPLEXITY_REQUEST, __opus_check_int(x) Chris@69: /** Gets the encoder's complexity configuration. Chris@69: * @see OPUS_SET_COMPLEXITY Chris@69: * @param[out] x opus_int32 *: Returns a value in the range 0-10, Chris@69: * inclusive. Chris@69: * @hideinitializer */ Chris@69: #define OPUS_GET_COMPLEXITY(x) OPUS_GET_COMPLEXITY_REQUEST, __opus_check_int_ptr(x) Chris@69: Chris@69: /** Configures the bitrate in the encoder. Chris@69: * Rates from 500 to 512000 bits per second are meaningful, as well as the Chris@69: * special values #OPUS_AUTO and #OPUS_BITRATE_MAX. Chris@69: * The value #OPUS_BITRATE_MAX can be used to cause the codec to use as much Chris@69: * rate as it can, which is useful for controlling the rate by adjusting the Chris@69: * output buffer size. Chris@69: * @see OPUS_GET_BITRATE Chris@69: * @param[in] x opus_int32: Bitrate in bits per second. The default Chris@69: * is determined based on the number of Chris@69: * channels and the input sampling rate. Chris@69: * @hideinitializer */ Chris@69: #define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __opus_check_int(x) Chris@69: /** Gets the encoder's bitrate configuration. Chris@69: * @see OPUS_SET_BITRATE Chris@69: * @param[out] x opus_int32 *: Returns the bitrate in bits per second. Chris@69: * The default is determined based on the Chris@69: * number of channels and the input Chris@69: * sampling rate. Chris@69: * @hideinitializer */ Chris@69: #define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __opus_check_int_ptr(x) Chris@69: Chris@69: /** Enables or disables variable bitrate (VBR) in the encoder. Chris@69: * The configured bitrate may not be met exactly because frames must Chris@69: * be an integer number of bytes in length. Chris@69: * @see OPUS_GET_VBR Chris@69: * @see OPUS_SET_VBR_CONSTRAINT Chris@69: * @param[in] x opus_int32: Allowed values: Chris@69: *
Chris@69: *
0
Hard CBR. For LPC/hybrid modes at very low bit-rate, this can Chris@69: * cause noticeable quality degradation.
Chris@69: *
1
VBR (default). The exact type of VBR is controlled by Chris@69: * #OPUS_SET_VBR_CONSTRAINT.
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_SET_VBR(x) OPUS_SET_VBR_REQUEST, __opus_check_int(x) Chris@69: /** Determine if variable bitrate (VBR) is enabled in the encoder. Chris@69: * @see OPUS_SET_VBR Chris@69: * @see OPUS_GET_VBR_CONSTRAINT Chris@69: * @param[out] x opus_int32 *: Returns one of the following values: Chris@69: *
Chris@69: *
0
Hard CBR.
Chris@69: *
1
VBR (default). The exact type of VBR may be retrieved via Chris@69: * #OPUS_GET_VBR_CONSTRAINT.
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_GET_VBR(x) OPUS_GET_VBR_REQUEST, __opus_check_int_ptr(x) Chris@69: Chris@69: /** Enables or disables constrained VBR in the encoder. Chris@69: * This setting is ignored when the encoder is in CBR mode. Chris@69: * @warning Only the MDCT mode of Opus currently heeds the constraint. Chris@69: * Speech mode ignores it completely, hybrid mode may fail to obey it Chris@69: * if the LPC layer uses more bitrate than the constraint would have Chris@69: * permitted. Chris@69: * @see OPUS_GET_VBR_CONSTRAINT Chris@69: * @see OPUS_SET_VBR Chris@69: * @param[in] x opus_int32: Allowed values: Chris@69: *
Chris@69: *
0
Unconstrained VBR.
Chris@69: *
1
Constrained VBR (default). This creates a maximum of one Chris@69: * frame of buffering delay assuming a transport with a Chris@69: * serialization speed of the nominal bitrate.
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __opus_check_int(x) Chris@69: /** Determine if constrained VBR is enabled in the encoder. Chris@69: * @see OPUS_SET_VBR_CONSTRAINT Chris@69: * @see OPUS_GET_VBR Chris@69: * @param[out] x opus_int32 *: Returns one of the following values: Chris@69: *
Chris@69: *
0
Unconstrained VBR.
Chris@69: *
1
Constrained VBR (default).
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __opus_check_int_ptr(x) Chris@69: Chris@69: /** Configures mono/stereo forcing in the encoder. Chris@69: * This can force the encoder to produce packets encoded as either mono or Chris@69: * stereo, regardless of the format of the input audio. This is useful when Chris@69: * the caller knows that the input signal is currently a mono source embedded Chris@69: * in a stereo stream. Chris@69: * @see OPUS_GET_FORCE_CHANNELS Chris@69: * @param[in] x opus_int32: Allowed values: Chris@69: *
Chris@69: *
#OPUS_AUTO
Not forced (default)
Chris@69: *
1
Forced mono
Chris@69: *
2
Forced stereo
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_SET_FORCE_CHANNELS(x) OPUS_SET_FORCE_CHANNELS_REQUEST, __opus_check_int(x) Chris@69: /** Gets the encoder's forced channel configuration. Chris@69: * @see OPUS_SET_FORCE_CHANNELS Chris@69: * @param[out] x opus_int32 *: Chris@69: *
Chris@69: *
#OPUS_AUTO
Not forced (default)
Chris@69: *
1
Forced mono
Chris@69: *
2
Forced stereo
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_GET_FORCE_CHANNELS(x) OPUS_GET_FORCE_CHANNELS_REQUEST, __opus_check_int_ptr(x) Chris@69: Chris@69: /** Configures the maximum bandpass that the encoder will select automatically. Chris@69: * Applications should normally use this instead of #OPUS_SET_BANDWIDTH Chris@69: * (leaving that set to the default, #OPUS_AUTO). This allows the Chris@69: * application to set an upper bound based on the type of input it is Chris@69: * providing, but still gives the encoder the freedom to reduce the bandpass Chris@69: * when the bitrate becomes too low, for better overall quality. Chris@69: * @see OPUS_GET_MAX_BANDWIDTH Chris@69: * @param[in] x opus_int32: Allowed values: Chris@69: *
Chris@69: *
OPUS_BANDWIDTH_NARROWBAND
4 kHz passband
Chris@69: *
OPUS_BANDWIDTH_MEDIUMBAND
6 kHz passband
Chris@69: *
OPUS_BANDWIDTH_WIDEBAND
8 kHz passband
Chris@69: *
OPUS_BANDWIDTH_SUPERWIDEBAND
12 kHz passband
Chris@69: *
OPUS_BANDWIDTH_FULLBAND
20 kHz passband (default)
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_SET_MAX_BANDWIDTH(x) OPUS_SET_MAX_BANDWIDTH_REQUEST, __opus_check_int(x) Chris@69: Chris@69: /** Gets the encoder's configured maximum allowed bandpass. Chris@69: * @see OPUS_SET_MAX_BANDWIDTH Chris@69: * @param[out] x opus_int32 *: Allowed values: Chris@69: *
Chris@69: *
#OPUS_BANDWIDTH_NARROWBAND
4 kHz passband
Chris@69: *
#OPUS_BANDWIDTH_MEDIUMBAND
6 kHz passband
Chris@69: *
#OPUS_BANDWIDTH_WIDEBAND
8 kHz passband
Chris@69: *
#OPUS_BANDWIDTH_SUPERWIDEBAND
12 kHz passband
Chris@69: *
#OPUS_BANDWIDTH_FULLBAND
20 kHz passband (default)
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_GET_MAX_BANDWIDTH(x) OPUS_GET_MAX_BANDWIDTH_REQUEST, __opus_check_int_ptr(x) Chris@69: Chris@69: /** Sets the encoder's bandpass to a specific value. Chris@69: * This prevents the encoder from automatically selecting the bandpass based Chris@69: * on the available bitrate. If an application knows the bandpass of the input Chris@69: * audio it is providing, it should normally use #OPUS_SET_MAX_BANDWIDTH Chris@69: * instead, which still gives the encoder the freedom to reduce the bandpass Chris@69: * when the bitrate becomes too low, for better overall quality. Chris@69: * @see OPUS_GET_BANDWIDTH Chris@69: * @param[in] x opus_int32: Allowed values: Chris@69: *
Chris@69: *
#OPUS_AUTO
(default)
Chris@69: *
#OPUS_BANDWIDTH_NARROWBAND
4 kHz passband
Chris@69: *
#OPUS_BANDWIDTH_MEDIUMBAND
6 kHz passband
Chris@69: *
#OPUS_BANDWIDTH_WIDEBAND
8 kHz passband
Chris@69: *
#OPUS_BANDWIDTH_SUPERWIDEBAND
12 kHz passband
Chris@69: *
#OPUS_BANDWIDTH_FULLBAND
20 kHz passband
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_SET_BANDWIDTH(x) OPUS_SET_BANDWIDTH_REQUEST, __opus_check_int(x) Chris@69: Chris@69: /** Configures the type of signal being encoded. Chris@69: * This is a hint which helps the encoder's mode selection. Chris@69: * @see OPUS_GET_SIGNAL Chris@69: * @param[in] x opus_int32: Allowed values: Chris@69: *
Chris@69: *
#OPUS_AUTO
(default)
Chris@69: *
#OPUS_SIGNAL_VOICE
Bias thresholds towards choosing LPC or Hybrid modes.
Chris@69: *
#OPUS_SIGNAL_MUSIC
Bias thresholds towards choosing MDCT modes.
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_SET_SIGNAL(x) OPUS_SET_SIGNAL_REQUEST, __opus_check_int(x) Chris@69: /** Gets the encoder's configured signal type. Chris@69: * @see OPUS_SET_SIGNAL Chris@69: * @param[out] x opus_int32 *: Returns one of the following values: Chris@69: *
Chris@69: *
#OPUS_AUTO
(default)
Chris@69: *
#OPUS_SIGNAL_VOICE
Bias thresholds towards choosing LPC or Hybrid modes.
Chris@69: *
#OPUS_SIGNAL_MUSIC
Bias thresholds towards choosing MDCT modes.
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_GET_SIGNAL(x) OPUS_GET_SIGNAL_REQUEST, __opus_check_int_ptr(x) Chris@69: Chris@69: Chris@69: /** Configures the encoder's intended application. Chris@69: * The initial value is a mandatory argument to the encoder_create function. Chris@69: * @see OPUS_GET_APPLICATION Chris@69: * @param[in] x opus_int32: Returns one of the following values: Chris@69: *
Chris@69: *
#OPUS_APPLICATION_VOIP
Chris@69: *
Process signal for improved speech intelligibility.
Chris@69: *
#OPUS_APPLICATION_AUDIO
Chris@69: *
Favor faithfulness to the original input.
Chris@69: *
#OPUS_APPLICATION_RESTRICTED_LOWDELAY
Chris@69: *
Configure the minimum possible coding delay by disabling certain modes Chris@69: * of operation.
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_SET_APPLICATION(x) OPUS_SET_APPLICATION_REQUEST, __opus_check_int(x) Chris@69: /** Gets the encoder's configured application. Chris@69: * @see OPUS_SET_APPLICATION Chris@69: * @param[out] x opus_int32 *: Returns one of the following values: Chris@69: *
Chris@69: *
#OPUS_APPLICATION_VOIP
Chris@69: *
Process signal for improved speech intelligibility.
Chris@69: *
#OPUS_APPLICATION_AUDIO
Chris@69: *
Favor faithfulness to the original input.
Chris@69: *
#OPUS_APPLICATION_RESTRICTED_LOWDELAY
Chris@69: *
Configure the minimum possible coding delay by disabling certain modes Chris@69: * of operation.
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_GET_APPLICATION(x) OPUS_GET_APPLICATION_REQUEST, __opus_check_int_ptr(x) Chris@69: Chris@69: /** Gets the total samples of delay added by the entire codec. Chris@69: * This can be queried by the encoder and then the provided number of samples can be Chris@69: * skipped on from the start of the decoder's output to provide time aligned input Chris@69: * and output. From the perspective of a decoding application the real data begins this many Chris@69: * samples late. Chris@69: * Chris@69: * The decoder contribution to this delay is identical for all decoders, but the Chris@69: * encoder portion of the delay may vary from implementation to implementation, Chris@69: * version to version, or even depend on the encoder's initial configuration. Chris@69: * Applications needing delay compensation should call this CTL rather than Chris@69: * hard-coding a value. Chris@69: * @param[out] x opus_int32 *: Number of lookahead samples Chris@69: * @hideinitializer */ Chris@69: #define OPUS_GET_LOOKAHEAD(x) OPUS_GET_LOOKAHEAD_REQUEST, __opus_check_int_ptr(x) Chris@69: Chris@69: /** Configures the encoder's use of inband forward error correction (FEC). Chris@69: * @note This is only applicable to the LPC layer Chris@69: * @see OPUS_GET_INBAND_FEC Chris@69: * @param[in] x opus_int32: Allowed values: Chris@69: *
Chris@69: *
0
Disable inband FEC (default).
Chris@69: *
1
Enable inband FEC.
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_SET_INBAND_FEC(x) OPUS_SET_INBAND_FEC_REQUEST, __opus_check_int(x) Chris@69: /** Gets encoder's configured use of inband forward error correction. Chris@69: * @see OPUS_SET_INBAND_FEC Chris@69: * @param[out] x opus_int32 *: Returns one of the following values: Chris@69: *
Chris@69: *
0
Inband FEC disabled (default).
Chris@69: *
1
Inband FEC enabled.
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_int_ptr(x) Chris@69: Chris@69: /** Configures the encoder's expected packet loss percentage. Chris@69: * Higher values trigger progressively more loss resistant behavior in the encoder Chris@69: * at the expense of quality at a given bitrate in the absence of packet loss, but Chris@69: * greater quality under loss. Chris@69: * @see OPUS_GET_PACKET_LOSS_PERC Chris@69: * @param[in] x opus_int32: Loss percentage in the range 0-100, inclusive (default: 0). Chris@69: * @hideinitializer */ Chris@69: #define OPUS_SET_PACKET_LOSS_PERC(x) OPUS_SET_PACKET_LOSS_PERC_REQUEST, __opus_check_int(x) Chris@69: /** Gets the encoder's configured packet loss percentage. Chris@69: * @see OPUS_SET_PACKET_LOSS_PERC Chris@69: * @param[out] x opus_int32 *: Returns the configured loss percentage Chris@69: * in the range 0-100, inclusive (default: 0). Chris@69: * @hideinitializer */ Chris@69: #define OPUS_GET_PACKET_LOSS_PERC(x) OPUS_GET_PACKET_LOSS_PERC_REQUEST, __opus_check_int_ptr(x) Chris@69: Chris@69: /** Configures the encoder's use of discontinuous transmission (DTX). Chris@69: * @note This is only applicable to the LPC layer Chris@69: * @see OPUS_GET_DTX Chris@69: * @param[in] x opus_int32: Allowed values: Chris@69: *
Chris@69: *
0
Disable DTX (default).
Chris@69: *
1
Enabled DTX.
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_SET_DTX(x) OPUS_SET_DTX_REQUEST, __opus_check_int(x) Chris@69: /** Gets encoder's configured use of discontinuous transmission. Chris@69: * @see OPUS_SET_DTX Chris@69: * @param[out] x opus_int32 *: Returns one of the following values: Chris@69: *
Chris@69: *
0
DTX disabled (default).
Chris@69: *
1
DTX enabled.
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_GET_DTX(x) OPUS_GET_DTX_REQUEST, __opus_check_int_ptr(x) Chris@69: /** Configures the depth of signal being encoded. Chris@69: * Chris@69: * This is a hint which helps the encoder identify silence and near-silence. Chris@69: * It represents the number of significant bits of linear intensity below Chris@69: * which the signal contains ignorable quantization or other noise. Chris@69: * Chris@69: * For example, OPUS_SET_LSB_DEPTH(14) would be an appropriate setting Chris@69: * for G.711 u-law input. OPUS_SET_LSB_DEPTH(16) would be appropriate Chris@69: * for 16-bit linear pcm input with opus_encode_float(). Chris@69: * Chris@69: * When using opus_encode() instead of opus_encode_float(), or when libopus Chris@69: * is compiled for fixed-point, the encoder uses the minimum of the value Chris@69: * set here and the value 16. Chris@69: * Chris@69: * @see OPUS_GET_LSB_DEPTH Chris@69: * @param[in] x opus_int32: Input precision in bits, between 8 and 24 Chris@69: * (default: 24). Chris@69: * @hideinitializer */ Chris@69: #define OPUS_SET_LSB_DEPTH(x) OPUS_SET_LSB_DEPTH_REQUEST, __opus_check_int(x) Chris@69: /** Gets the encoder's configured signal depth. Chris@69: * @see OPUS_SET_LSB_DEPTH Chris@69: * @param[out] x opus_int32 *: Input precision in bits, between 8 and Chris@69: * 24 (default: 24). Chris@69: * @hideinitializer */ Chris@69: #define OPUS_GET_LSB_DEPTH(x) OPUS_GET_LSB_DEPTH_REQUEST, __opus_check_int_ptr(x) Chris@69: Chris@69: /** Configures the encoder's use of variable duration frames. Chris@69: * When variable duration is enabled, the encoder is free to use a shorter frame Chris@69: * size than the one requested in the opus_encode*() call. Chris@69: * It is then the user's responsibility Chris@69: * to verify how much audio was encoded by checking the ToC byte of the encoded Chris@69: * packet. The part of the audio that was not encoded needs to be resent to the Chris@69: * encoder for the next call. Do not use this option unless you really Chris@69: * know what you are doing. Chris@69: * @see OPUS_GET_EXPERT_FRAME_DURATION Chris@69: * @param[in] x opus_int32: Allowed values: Chris@69: *
Chris@69: *
OPUS_FRAMESIZE_ARG
Select frame size from the argument (default).
Chris@69: *
OPUS_FRAMESIZE_2_5_MS
Use 2.5 ms frames.
Chris@69: *
OPUS_FRAMESIZE_5_MS
Use 5 ms frames.
Chris@69: *
OPUS_FRAMESIZE_10_MS
Use 10 ms frames.
Chris@69: *
OPUS_FRAMESIZE_20_MS
Use 20 ms frames.
Chris@69: *
OPUS_FRAMESIZE_40_MS
Use 40 ms frames.
Chris@69: *
OPUS_FRAMESIZE_60_MS
Use 60 ms frames.
Chris@69: *
OPUS_FRAMESIZE_80_MS
Use 80 ms frames.
Chris@69: *
OPUS_FRAMESIZE_100_MS
Use 100 ms frames.
Chris@69: *
OPUS_FRAMESIZE_120_MS
Use 120 ms frames.
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_SET_EXPERT_FRAME_DURATION(x) OPUS_SET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int(x) Chris@69: /** Gets the encoder's configured use of variable duration frames. Chris@69: * @see OPUS_SET_EXPERT_FRAME_DURATION Chris@69: * @param[out] x opus_int32 *: Returns one of the following values: Chris@69: *
Chris@69: *
OPUS_FRAMESIZE_ARG
Select frame size from the argument (default).
Chris@69: *
OPUS_FRAMESIZE_2_5_MS
Use 2.5 ms frames.
Chris@69: *
OPUS_FRAMESIZE_5_MS
Use 5 ms frames.
Chris@69: *
OPUS_FRAMESIZE_10_MS
Use 10 ms frames.
Chris@69: *
OPUS_FRAMESIZE_20_MS
Use 20 ms frames.
Chris@69: *
OPUS_FRAMESIZE_40_MS
Use 40 ms frames.
Chris@69: *
OPUS_FRAMESIZE_60_MS
Use 60 ms frames.
Chris@69: *
OPUS_FRAMESIZE_80_MS
Use 80 ms frames.
Chris@69: *
OPUS_FRAMESIZE_100_MS
Use 100 ms frames.
Chris@69: *
OPUS_FRAMESIZE_120_MS
Use 120 ms frames.
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_GET_EXPERT_FRAME_DURATION(x) OPUS_GET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int_ptr(x) Chris@69: Chris@69: /** If set to 1, disables almost all use of prediction, making frames almost Chris@69: * completely independent. This reduces quality. Chris@69: * @see OPUS_GET_PREDICTION_DISABLED Chris@69: * @param[in] x opus_int32: Allowed values: Chris@69: *
Chris@69: *
0
Enable prediction (default).
Chris@69: *
1
Disable prediction.
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_SET_PREDICTION_DISABLED(x) OPUS_SET_PREDICTION_DISABLED_REQUEST, __opus_check_int(x) Chris@69: /** Gets the encoder's configured prediction status. Chris@69: * @see OPUS_SET_PREDICTION_DISABLED Chris@69: * @param[out] x opus_int32 *: Returns one of the following values: Chris@69: *
Chris@69: *
0
Prediction enabled (default).
Chris@69: *
1
Prediction disabled.
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_GET_PREDICTION_DISABLED(x) OPUS_GET_PREDICTION_DISABLED_REQUEST, __opus_check_int_ptr(x) Chris@69: Chris@69: /**@}*/ Chris@69: Chris@69: /** @defgroup opus_genericctls Generic CTLs Chris@69: * Chris@69: * These macros are used with the \c opus_decoder_ctl and Chris@69: * \c opus_encoder_ctl calls to generate a particular Chris@69: * request. Chris@69: * Chris@69: * When called on an \c OpusDecoder they apply to that Chris@69: * particular decoder instance. When called on an Chris@69: * \c OpusEncoder they apply to the corresponding setting Chris@69: * on that encoder instance, if present. Chris@69: * Chris@69: * Some usage examples: Chris@69: * Chris@69: * @code Chris@69: * int ret; Chris@69: * opus_int32 pitch; Chris@69: * ret = opus_decoder_ctl(dec_ctx, OPUS_GET_PITCH(&pitch)); Chris@69: * if (ret == OPUS_OK) return ret; Chris@69: * Chris@69: * opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE); Chris@69: * opus_decoder_ctl(dec_ctx, OPUS_RESET_STATE); Chris@69: * Chris@69: * opus_int32 enc_bw, dec_bw; Chris@69: * opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&enc_bw)); Chris@69: * opus_decoder_ctl(dec_ctx, OPUS_GET_BANDWIDTH(&dec_bw)); Chris@69: * if (enc_bw != dec_bw) { Chris@69: * printf("packet bandwidth mismatch!\n"); Chris@69: * } Chris@69: * @endcode Chris@69: * Chris@69: * @see opus_encoder, opus_decoder_ctl, opus_encoder_ctl, opus_decoderctls, opus_encoderctls Chris@69: * @{ Chris@69: */ Chris@69: Chris@69: /** Resets the codec state to be equivalent to a freshly initialized state. Chris@69: * This should be called when switching streams in order to prevent Chris@69: * the back to back decoding from giving different results from Chris@69: * one at a time decoding. Chris@69: * @hideinitializer */ Chris@69: #define OPUS_RESET_STATE 4028 Chris@69: Chris@69: /** Gets the final state of the codec's entropy coder. Chris@69: * This is used for testing purposes, Chris@69: * The encoder and decoder state should be identical after coding a payload Chris@69: * (assuming no data corruption or software bugs) Chris@69: * Chris@69: * @param[out] x opus_uint32 *: Entropy coder state Chris@69: * Chris@69: * @hideinitializer */ Chris@69: #define OPUS_GET_FINAL_RANGE(x) OPUS_GET_FINAL_RANGE_REQUEST, __opus_check_uint_ptr(x) Chris@69: Chris@69: /** Gets the encoder's configured bandpass or the decoder's last bandpass. Chris@69: * @see OPUS_SET_BANDWIDTH Chris@69: * @param[out] x opus_int32 *: Returns one of the following values: Chris@69: *
Chris@69: *
#OPUS_AUTO
(default)
Chris@69: *
#OPUS_BANDWIDTH_NARROWBAND
4 kHz passband
Chris@69: *
#OPUS_BANDWIDTH_MEDIUMBAND
6 kHz passband
Chris@69: *
#OPUS_BANDWIDTH_WIDEBAND
8 kHz passband
Chris@69: *
#OPUS_BANDWIDTH_SUPERWIDEBAND
12 kHz passband
Chris@69: *
#OPUS_BANDWIDTH_FULLBAND
20 kHz passband
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __opus_check_int_ptr(x) Chris@69: Chris@69: /** Gets the sampling rate the encoder or decoder was initialized with. Chris@69: * This simply returns the Fs value passed to opus_encoder_init() Chris@69: * or opus_decoder_init(). Chris@69: * @param[out] x opus_int32 *: Sampling rate of encoder or decoder. Chris@69: * @hideinitializer Chris@69: */ Chris@69: #define OPUS_GET_SAMPLE_RATE(x) OPUS_GET_SAMPLE_RATE_REQUEST, __opus_check_int_ptr(x) Chris@69: Chris@69: /** If set to 1, disables the use of phase inversion for intensity stereo, Chris@69: * improving the quality of mono downmixes, but slightly reducing normal Chris@69: * stereo quality. Disabling phase inversion in the decoder does not comply Chris@69: * with RFC 6716, although it does not cause any interoperability issue and Chris@69: * is expected to become part of the Opus standard once RFC 6716 is updated Chris@69: * by draft-ietf-codec-opus-update. Chris@69: * @see OPUS_GET_PHASE_INVERSION_DISABLED Chris@69: * @param[in] x opus_int32: Allowed values: Chris@69: *
Chris@69: *
0
Enable phase inversion (default).
Chris@69: *
1
Disable phase inversion.
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_SET_PHASE_INVERSION_DISABLED(x) OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST, __opus_check_int(x) Chris@69: /** Gets the encoder's configured phase inversion status. Chris@69: * @see OPUS_SET_PHASE_INVERSION_DISABLED Chris@69: * @param[out] x opus_int32 *: Returns one of the following values: Chris@69: *
Chris@69: *
0
Stereo phase inversion enabled (default).
Chris@69: *
1
Stereo phase inversion disabled.
Chris@69: *
Chris@69: * @hideinitializer */ Chris@69: #define OPUS_GET_PHASE_INVERSION_DISABLED(x) OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST, __opus_check_int_ptr(x) Chris@69: Chris@69: /**@}*/ Chris@69: Chris@69: /** @defgroup opus_decoderctls Decoder related CTLs Chris@69: * @see opus_genericctls, opus_encoderctls, opus_decoder Chris@69: * @{ Chris@69: */ Chris@69: Chris@69: /** Configures decoder gain adjustment. Chris@69: * Scales the decoded output by a factor specified in Q8 dB units. Chris@69: * This has a maximum range of -32768 to 32767 inclusive, and returns Chris@69: * OPUS_BAD_ARG otherwise. The default is zero indicating no adjustment. Chris@69: * This setting survives decoder reset. Chris@69: * Chris@69: * gain = pow(10, x/(20.0*256)) Chris@69: * Chris@69: * @param[in] x opus_int32: Amount to scale PCM signal by in Q8 dB units. Chris@69: * @hideinitializer */ Chris@69: #define OPUS_SET_GAIN(x) OPUS_SET_GAIN_REQUEST, __opus_check_int(x) Chris@69: /** Gets the decoder's configured gain adjustment. @see OPUS_SET_GAIN Chris@69: * Chris@69: * @param[out] x opus_int32 *: Amount to scale PCM signal by in Q8 dB units. Chris@69: * @hideinitializer */ Chris@69: #define OPUS_GET_GAIN(x) OPUS_GET_GAIN_REQUEST, __opus_check_int_ptr(x) Chris@69: Chris@69: /** Gets the duration (in samples) of the last packet successfully decoded or concealed. Chris@69: * @param[out] x opus_int32 *: Number of samples (at current sampling rate). Chris@69: * @hideinitializer */ Chris@69: #define OPUS_GET_LAST_PACKET_DURATION(x) OPUS_GET_LAST_PACKET_DURATION_REQUEST, __opus_check_int_ptr(x) Chris@69: Chris@69: /** Gets the pitch of the last decoded frame, if available. Chris@69: * This can be used for any post-processing algorithm requiring the use of pitch, Chris@69: * e.g. time stretching/shortening. If the last frame was not voiced, or if the Chris@69: * pitch was not coded in the frame, then zero is returned. Chris@69: * Chris@69: * This CTL is only implemented for decoder instances. Chris@69: * Chris@69: * @param[out] x opus_int32 *: pitch period at 48 kHz (or 0 if not available) Chris@69: * Chris@69: * @hideinitializer */ Chris@69: #define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x) Chris@69: Chris@69: /**@}*/ Chris@69: Chris@69: /** @defgroup opus_libinfo Opus library information functions Chris@69: * @{ Chris@69: */ Chris@69: Chris@69: /** Converts an opus error code into a human readable string. Chris@69: * Chris@69: * @param[in] error int: Error number Chris@69: * @returns Error string Chris@69: */ Chris@69: OPUS_EXPORT const char *opus_strerror(int error); Chris@69: Chris@69: /** Gets the libopus version string. Chris@69: * Chris@69: * Applications may look for the substring "-fixed" in the version string to Chris@69: * determine whether they have a fixed-point or floating-point build at Chris@69: * runtime. Chris@69: * Chris@69: * @returns Version string Chris@69: */ Chris@69: OPUS_EXPORT const char *opus_get_version_string(void); Chris@69: /**@}*/ Chris@69: Chris@69: #ifdef __cplusplus Chris@69: } Chris@69: #endif Chris@69: Chris@69: #endif /* OPUS_DEFINES_H */