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