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