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