blob: 647ed5d6f2e399fd29c113ff023d8b08d5403898 [file] [log] [blame]
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -04001/* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited
2 Written by Jean-Marc Valin and Koen Vos */
3/*
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
6 are met:
7
8 - Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10
11 - Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution.
14
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Jean-Marc Valincb05e7c2012-04-20 16:40:24 -040018 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
19 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -040020 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
Ralph Giles1b951962011-09-07 10:40:25 -070028/**
29 * @file opus_defines.h
30 * @brief Opus reference implementation constants
31 */
32
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -040033#ifndef OPUS_DEFINES_H
34#define OPUS_DEFINES_H
35
36#include "opus_types.h"
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
Gregory Maxwelld445f022012-05-20 19:28:45 -040042/** @defgroup opus_errorcodes Error codes
Gregory Maxwell75ff53c2011-09-08 08:13:16 -040043 * @{
44 */
45/** No error @hideinitializer*/
46#define OPUS_OK 0
47/** One or more invalid/out of range arguments @hideinitializer*/
48#define OPUS_BAD_ARG -1
Jean-Marc Valine1326fe2014-09-04 01:48:46 -040049/** Not enough bytes allocated in the buffer @hideinitializer*/
Gregory Maxwell75ff53c2011-09-08 08:13:16 -040050#define OPUS_BUFFER_TOO_SMALL -2
51/** An internal error was detected @hideinitializer*/
52#define OPUS_INTERNAL_ERROR -3
53/** The compressed data passed is corrupted @hideinitializer*/
54#define OPUS_INVALID_PACKET -4
55/** Invalid/unsupported request number @hideinitializer*/
56#define OPUS_UNIMPLEMENTED -5
57/** An encoder or decoder structure is invalid or already freed @hideinitializer*/
58#define OPUS_INVALID_STATE -6
59/** Memory allocation has failed @hideinitializer*/
60#define OPUS_ALLOC_FAIL -7
61/**@}*/
62
Gregory Maxwell29095372011-09-09 14:24:49 -040063/** @cond OPUS_INTERNAL_DOC */
Gregory Maxwell75ff53c2011-09-08 08:13:16 -040064/**Export control for opus functions */
65
Ralph Giles265b6b12012-11-29 11:01:27 -080066#ifndef OPUS_EXPORT
Jacek Caban1f26ee22013-06-17 10:09:57 -070067# if defined(WIN32)
Ralph Giles265b6b12012-11-29 11:01:27 -080068# ifdef OPUS_BUILD
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -040069# define OPUS_EXPORT __declspec(dllexport)
Ralph Giles265b6b12012-11-29 11:01:27 -080070# else
Jean-Marc Valinbc1683d2012-05-31 11:50:33 -040071# define OPUS_EXPORT
Ralph Giles265b6b12012-11-29 11:01:27 -080072# endif
Jacek Caban1f26ee22013-06-17 10:09:57 -070073# elif defined(__GNUC__) && defined(OPUS_BUILD)
74# define OPUS_EXPORT __attribute__ ((visibility ("default")))
Ralph Giles265b6b12012-11-29 11:01:27 -080075# else
76# define OPUS_EXPORT
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -040077# endif
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -040078#endif
79
Gregory Maxwellc64f4a42012-06-01 02:21:53 -040080# if !defined(OPUS_GNUC_PREREQ)
81# if defined(__GNUC__)&&defined(__GNUC_MINOR__)
82# define OPUS_GNUC_PREREQ(_maj,_min) \
83 ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min))
84# else
85# define OPUS_GNUC_PREREQ(_maj,_min) 0
86# endif
87# endif
88
Gregory Maxwellde0b5322012-07-18 12:12:35 -040089#if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) )
90# if OPUS_GNUC_PREREQ(3,0)
91# define OPUS_RESTRICT __restrict__
Rafaël Carré7909d8a2012-07-26 14:24:25 -040092# elif (defined(_MSC_VER) && _MSC_VER >= 1400)
Gregory Maxwellde0b5322012-07-18 12:12:35 -040093# define OPUS_RESTRICT __restrict
94# else
95# define OPUS_RESTRICT
96# endif
97#else
98# define OPUS_RESTRICT restrict
99#endif
100
Gregory Maxwell7830cf12013-10-17 15:56:52 -0700101#if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) )
102# if OPUS_GNUC_PREREQ(2,7)
103# define OPUS_INLINE __inline__
104# elif (defined(_MSC_VER))
105# define OPUS_INLINE __inline
106# else
107# define OPUS_INLINE
108# endif
109#else
110# define OPUS_INLINE inline
111#endif
112
Gregory Maxwellc64f4a42012-06-01 02:21:53 -0400113/**Warning attributes for opus functions
114 * NONNULL is not used in OPUS_BUILD to avoid the compiler optimizing out
115 * some paranoid null checks. */
116#if defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4)
117# define OPUS_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__))
118#else
119# define OPUS_WARN_UNUSED_RESULT
120#endif
121#if !defined(OPUS_BUILD) && defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4)
122# define OPUS_ARG_NONNULL(_x) __attribute__ ((__nonnull__(_x)))
123#else
124# define OPUS_ARG_NONNULL(_x)
125#endif
126
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400127/** These are the actual Encoder CTL ID numbers.
Timothy B. Terriberrya40689e2012-09-07 06:01:53 -0700128 * They should not be used directly by applications.
129 * In general, SETs should be even and GETs should be odd.*/
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400130#define OPUS_SET_APPLICATION_REQUEST 4000
131#define OPUS_GET_APPLICATION_REQUEST 4001
Jean-Marc Valin9ba17432011-10-24 22:41:18 -0400132#define OPUS_SET_BITRATE_REQUEST 4002
133#define OPUS_GET_BITRATE_REQUEST 4003
134#define OPUS_SET_MAX_BANDWIDTH_REQUEST 4004
135#define OPUS_GET_MAX_BANDWIDTH_REQUEST 4005
136#define OPUS_SET_VBR_REQUEST 4006
137#define OPUS_GET_VBR_REQUEST 4007
138#define OPUS_SET_BANDWIDTH_REQUEST 4008
139#define OPUS_GET_BANDWIDTH_REQUEST 4009
140#define OPUS_SET_COMPLEXITY_REQUEST 4010
141#define OPUS_GET_COMPLEXITY_REQUEST 4011
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400142#define OPUS_SET_INBAND_FEC_REQUEST 4012
143#define OPUS_GET_INBAND_FEC_REQUEST 4013
144#define OPUS_SET_PACKET_LOSS_PERC_REQUEST 4014
145#define OPUS_GET_PACKET_LOSS_PERC_REQUEST 4015
146#define OPUS_SET_DTX_REQUEST 4016
147#define OPUS_GET_DTX_REQUEST 4017
Jean-Marc Valin9ba17432011-10-24 22:41:18 -0400148#define OPUS_SET_VBR_CONSTRAINT_REQUEST 4020
149#define OPUS_GET_VBR_CONSTRAINT_REQUEST 4021
150#define OPUS_SET_FORCE_CHANNELS_REQUEST 4022
151#define OPUS_GET_FORCE_CHANNELS_REQUEST 4023
152#define OPUS_SET_SIGNAL_REQUEST 4024
153#define OPUS_GET_SIGNAL_REQUEST 4025
154#define OPUS_GET_LOOKAHEAD_REQUEST 4027
155/* #define OPUS_RESET_STATE 4028 */
Timothy B. Terriberrya40689e2012-09-07 06:01:53 -0700156#define OPUS_GET_SAMPLE_RATE_REQUEST 4029
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400157#define OPUS_GET_FINAL_RANGE_REQUEST 4031
Jean-Marc Valin25f7f352011-09-14 09:50:06 -0700158#define OPUS_GET_PITCH_REQUEST 4033
Gregory Maxwell28b41ae2012-07-11 00:04:24 -0400159#define OPUS_SET_GAIN_REQUEST 4034
Jean-Marc Valin512d8492012-12-04 14:13:46 -0500160#define OPUS_GET_GAIN_REQUEST 4045 /* Should have been 4035 */
Jean-Marc Valin1cd5d952012-07-11 02:54:47 -0400161#define OPUS_SET_LSB_DEPTH_REQUEST 4036
162#define OPUS_GET_LSB_DEPTH_REQUEST 4037
Jean-Marc Valin512d8492012-12-04 14:13:46 -0500163#define OPUS_GET_LAST_PACKET_DURATION_REQUEST 4039
Jean-Marc Valin51f4a322013-02-20 04:08:04 -0500164#define OPUS_SET_EXPERT_FRAME_DURATION_REQUEST 4040
165#define OPUS_GET_EXPERT_FRAME_DURATION_REQUEST 4041
Jean-Marc Valincbe93e22013-11-15 13:50:38 -0500166#define OPUS_SET_PREDICTION_DISABLED_REQUEST 4042
167#define OPUS_GET_PREDICTION_DISABLED_REQUEST 4043
Jean-Marc Valin512d8492012-12-04 14:13:46 -0500168
169/* Don't use 4045, it's already taken by OPUS_GET_GAIN_REQUEST */
170
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400171/* Macros to trigger compilation errors when the wrong types are provided to a CTL */
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -0400172#define __opus_check_int(x) (((void)((x) == (opus_int32)0)), (opus_int32)(x))
173#define __opus_check_int_ptr(ptr) ((ptr) + ((ptr) - (opus_int32*)(ptr)))
174#define __opus_check_uint_ptr(ptr) ((ptr) + ((ptr) - (opus_uint32*)(ptr)))
Jean-Marc Valina4dccd32013-05-04 23:54:20 -0400175#define __opus_check_val16_ptr(ptr) ((ptr) + ((ptr) - (opus_val16*)(ptr)))
Gregory Maxwell29095372011-09-09 14:24:49 -0400176/** @endcond */
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -0400177
Gregory Maxwelld445f022012-05-20 19:28:45 -0400178/** @defgroup opus_ctlvalues Pre-defined values for CTL interface
179 * @see opus_genericctls, opus_encoderctls
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400180 * @{
181 */
Gregory Maxwell29095372011-09-09 14:24:49 -0400182/* Values for the various encoder CTLs */
Jean-Marc Valin25577502011-09-22 22:13:46 -0400183#define OPUS_AUTO -1000 /**<Auto/default setting @hideinitializer*/
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400184#define OPUS_BITRATE_MAX -1 /**<Maximum bitrate @hideinitializer*/
Jean-Marc Valin68bc8c02011-09-09 11:10:48 -0400185
Jean-Marc Valin72273002012-04-20 10:26:08 -0400186/** Best for most VoIP/videoconference applications where listening quality and intelligibility matter most
Jean-Marc Valin25577502011-09-22 22:13:46 -0400187 * @hideinitializer */
Jean-Marc Valin68bc8c02011-09-09 11:10:48 -0400188#define OPUS_APPLICATION_VOIP 2048
Jean-Marc Valin25577502011-09-22 22:13:46 -0400189/** Best for broadcast/high-fidelity application where the decoded audio should be as close as possible to the input
190 * @hideinitializer */
Jean-Marc Valin68bc8c02011-09-09 11:10:48 -0400191#define OPUS_APPLICATION_AUDIO 2049
Jean-Marc Valin25577502011-09-22 22:13:46 -0400192/** Only use when lowest-achievable latency is what matters most. Voice-optimized modes cannot be used.
193 * @hideinitializer */
Jean-Marc Valin68bc8c02011-09-09 11:10:48 -0400194#define OPUS_APPLICATION_RESTRICTED_LOWDELAY 2051
195
Jean-Marc Valin25577502011-09-22 22:13:46 -0400196#define OPUS_SIGNAL_VOICE 3001 /**< Signal being encoded is voice */
197#define OPUS_SIGNAL_MUSIC 3002 /**< Signal being encoded is music */
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700198#define OPUS_BANDWIDTH_NARROWBAND 1101 /**< 4 kHz bandpass @hideinitializer*/
199#define OPUS_BANDWIDTH_MEDIUMBAND 1102 /**< 6 kHz bandpass @hideinitializer*/
200#define OPUS_BANDWIDTH_WIDEBAND 1103 /**< 8 kHz bandpass @hideinitializer*/
201#define OPUS_BANDWIDTH_SUPERWIDEBAND 1104 /**<12 kHz bandpass @hideinitializer*/
202#define OPUS_BANDWIDTH_FULLBAND 1105 /**<20 kHz bandpass @hideinitializer*/
Jean-Marc Valin25577502011-09-22 22:13:46 -0400203
Jean-Marc Valin51f4a322013-02-20 04:08:04 -0500204#define OPUS_FRAMESIZE_ARG 5000 /**< Select frame size from the argument (default) */
205#define OPUS_FRAMESIZE_2_5_MS 5001 /**< Use 2.5 ms frames */
206#define OPUS_FRAMESIZE_5_MS 5002 /**< Use 5 ms frames */
207#define OPUS_FRAMESIZE_10_MS 5003 /**< Use 10 ms frames */
208#define OPUS_FRAMESIZE_20_MS 5004 /**< Use 20 ms frames */
209#define OPUS_FRAMESIZE_40_MS 5005 /**< Use 40 ms frames */
210#define OPUS_FRAMESIZE_60_MS 5006 /**< Use 60 ms frames */
Jean-Marc Valin51f4a322013-02-20 04:08:04 -0500211
Jean-Marc Valin25577502011-09-22 22:13:46 -0400212/**@}*/
213
214
Gregory Maxwelld445f022012-05-20 19:28:45 -0400215/** @defgroup opus_encoderctls Encoder related CTLs
Ralph Giles10ebc022011-11-25 23:25:38 -0500216 *
217 * These are convenience macros for use with the \c opus_encode_ctl
218 * interface. They are used to generate the appropriate series of
219 * arguments for that call, passing the correct type, size and so
220 * on as expected for each particular request.
221 *
222 * Some usage examples:
223 *
224 * @code
225 * int ret;
226 * ret = opus_encoder_ctl(enc_ctx, OPUS_SET_BANDWIDTH(OPUS_AUTO));
227 * if (ret != OPUS_OK) return ret;
228 *
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700229 * opus_int32 rate;
Ralph Giles10ebc022011-11-25 23:25:38 -0500230 * opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&rate));
231 *
232 * opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE);
233 * @endcode
234 *
Gregory Maxwelld445f022012-05-20 19:28:45 -0400235 * @see opus_genericctls, opus_encoder
Jean-Marc Valin25577502011-09-22 22:13:46 -0400236 * @{
237 */
Ralph Giles1b951962011-09-07 10:40:25 -0700238
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400239/** Configures the encoder's computational complexity.
240 * The supported range is 0-10 inclusive with 10 representing the highest complexity.
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700241 * @see OPUS_GET_COMPLEXITY
Gregory Maxwell31cf4e12012-08-12 14:50:29 -0400242 * @param[in] x <tt>opus_int32</tt>: Allowed values: 0-10, inclusive.
243 *
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400244 * @hideinitializer */
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -0400245#define OPUS_SET_COMPLEXITY(x) OPUS_SET_COMPLEXITY_REQUEST, __opus_check_int(x)
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700246/** Gets the encoder's complexity configuration.
247 * @see OPUS_SET_COMPLEXITY
248 * @param[out] x <tt>opus_int32 *</tt>: Returns a value in the range 0-10,
Gregory Maxwell31cf4e12012-08-12 14:50:29 -0400249 * inclusive.
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400250 * @hideinitializer */
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -0400251#define OPUS_GET_COMPLEXITY(x) OPUS_GET_COMPLEXITY_REQUEST, __opus_check_int_ptr(x)
252
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400253/** Configures the bitrate in the encoder.
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700254 * Rates from 500 to 512000 bits per second are meaningful, as well as the
Gregory Maxwell31cf4e12012-08-12 14:50:29 -0400255 * special values #OPUS_AUTO and #OPUS_BITRATE_MAX.
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700256 * The value #OPUS_BITRATE_MAX can be used to cause the codec to use as much
257 * rate as it can, which is useful for controlling the rate by adjusting the
258 * output buffer size.
259 * @see OPUS_GET_BITRATE
260 * @param[in] x <tt>opus_int32</tt>: Bitrate in bits per second. The default
261 * is determined based on the number of
262 * channels and the input sampling rate.
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400263 * @hideinitializer */
264#define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __opus_check_int(x)
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700265/** Gets the encoder's bitrate configuration.
266 * @see OPUS_SET_BITRATE
267 * @param[out] x <tt>opus_int32 *</tt>: Returns the bitrate in bits per second.
268 * The default is determined based on the
269 * number of channels and the input
270 * sampling rate.
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400271 * @hideinitializer */
272#define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __opus_check_int_ptr(x)
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -0400273
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700274/** Enables or disables variable bitrate (VBR) in the encoder.
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400275 * The configured bitrate may not be met exactly because frames must
276 * be an integer number of bytes in length.
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700277 * @see OPUS_GET_VBR
278 * @see OPUS_SET_VBR_CONSTRAINT
279 * @param[in] x <tt>opus_int32</tt>: Allowed values:
280 * <dl>
Gregory Maxwell31cf4e12012-08-12 14:50:29 -0400281 * <dt>0</dt><dd>Hard CBR. For LPC/hybrid modes at very low bit-rate, this can
282 * cause noticeable quality degradation.</dd>
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700283 * <dt>1</dt><dd>VBR (default). The exact type of VBR is controlled by
284 * #OPUS_SET_VBR_CONSTRAINT.</dd>
285 * </dl>
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400286 * @hideinitializer */
287#define OPUS_SET_VBR(x) OPUS_SET_VBR_REQUEST, __opus_check_int(x)
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700288/** Determine if variable bitrate (VBR) is enabled in the encoder.
289 * @see OPUS_SET_VBR
290 * @see OPUS_GET_VBR_CONSTRAINT
291 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
292 * <dl>
293 * <dt>0</dt><dd>Hard CBR.</dd>
294 * <dt>1</dt><dd>VBR (default). The exact type of VBR may be retrieved via
295 * #OPUS_GET_VBR_CONSTRAINT.</dd>
296 * </dl>
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400297 * @hideinitializer */
298#define OPUS_GET_VBR(x) OPUS_GET_VBR_REQUEST, __opus_check_int_ptr(x)
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -0400299
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700300/** Enables or disables constrained VBR in the encoder.
301 * This setting is ignored when the encoder is in CBR mode.
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400302 * @warning Only the MDCT mode of Opus currently heeds the constraint.
303 * Speech mode ignores it completely, hybrid mode may fail to obey it
304 * if the LPC layer uses more bitrate than the constraint would have
305 * permitted.
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700306 * @see OPUS_GET_VBR_CONSTRAINT
307 * @see OPUS_SET_VBR
308 * @param[in] x <tt>opus_int32</tt>: Allowed values:
309 * <dl>
310 * <dt>0</dt><dd>Unconstrained VBR.</dd>
311 * <dt>1</dt><dd>Constrained VBR (default). This creates a maximum of one
312 * frame of buffering delay assuming a transport with a
313 * serialization speed of the nominal bitrate.</dd>
314 * </dl>
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400315 * @hideinitializer */
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -0400316#define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __opus_check_int(x)
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700317/** Determine if constrained VBR is enabled in the encoder.
318 * @see OPUS_SET_VBR_CONSTRAINT
319 * @see OPUS_GET_VBR
320 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
321 * <dl>
322 * <dt>0</dt><dd>Unconstrained VBR.</dd>
323 * <dt>1</dt><dd>Constrained VBR (default).</dd>
324 * </dl>
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400325 * @hideinitializer */
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -0400326#define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __opus_check_int_ptr(x)
327
Jean-Marc Valind186c912011-09-08 15:13:46 -0400328/** Configures mono/stereo forcing in the encoder.
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700329 * This can force the encoder to produce packets encoded as either mono or
330 * stereo, regardless of the format of the input audio. This is useful when
331 * the caller knows that the input signal is currently a mono source embedded
332 * in a stereo stream.
333 * @see OPUS_GET_FORCE_CHANNELS
334 * @param[in] x <tt>opus_int32</tt>: Allowed values:
335 * <dl>
336 * <dt>#OPUS_AUTO</dt><dd>Not forced (default)</dd>
337 * <dt>1</dt> <dd>Forced mono</dd>
338 * <dt>2</dt> <dd>Forced stereo</dd>
339 * </dl>
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400340 * @hideinitializer */
Jean-Marc Valin07dceb72011-09-08 13:53:20 -0400341#define OPUS_SET_FORCE_CHANNELS(x) OPUS_SET_FORCE_CHANNELS_REQUEST, __opus_check_int(x)
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700342/** Gets the encoder's forced channel configuration.
343 * @see OPUS_SET_FORCE_CHANNELS
344 * @param[out] x <tt>opus_int32 *</tt>:
345 * <dl>
346 * <dt>#OPUS_AUTO</dt><dd>Not forced (default)</dd>
347 * <dt>1</dt> <dd>Forced mono</dd>
348 * <dt>2</dt> <dd>Forced stereo</dd>
349 * </dl>
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400350 * @hideinitializer */
Jean-Marc Valin07dceb72011-09-08 13:53:20 -0400351#define OPUS_GET_FORCE_CHANNELS(x) OPUS_GET_FORCE_CHANNELS_REQUEST, __opus_check_int_ptr(x)
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -0400352
Timothy B. Terriberryf5b2d782012-07-17 11:49:45 -0700353/** Configures the maximum bandpass that the encoder will select automatically.
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700354 * Applications should normally use this instead of #OPUS_SET_BANDWIDTH
355 * (leaving that set to the default, #OPUS_AUTO). This allows the
Timothy B. Terriberryf5b2d782012-07-17 11:49:45 -0700356 * application to set an upper bound based on the type of input it is
357 * providing, but still gives the encoder the freedom to reduce the bandpass
358 * when the bitrate becomes too low, for better overall quality.
359 * @see OPUS_GET_MAX_BANDWIDTH
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700360 * @param[in] x <tt>opus_int32</tt>: Allowed values:
361 * <dl>
362 * <dt>OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd>
363 * <dt>OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd>
364 * <dt>OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd>
365 * <dt>OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd>
366 * <dt>OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband (default)</dd>
367 * </dl>
Jean-Marc Valin97cefdd2011-10-25 12:10:45 -0400368 * @hideinitializer */
369#define OPUS_SET_MAX_BANDWIDTH(x) OPUS_SET_MAX_BANDWIDTH_REQUEST, __opus_check_int(x)
370
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700371/** Gets the encoder's configured maximum allowed bandpass.
372 * @see OPUS_SET_MAX_BANDWIDTH
373 * @param[out] x <tt>opus_int32 *</tt>: Allowed values:
374 * <dl>
375 * <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd>
376 * <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd>
377 * <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd>
378 * <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd>
379 * <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband (default)</dd>
380 * </dl>
Jean-Marc Valin97cefdd2011-10-25 12:10:45 -0400381 * @hideinitializer */
382#define OPUS_GET_MAX_BANDWIDTH(x) OPUS_GET_MAX_BANDWIDTH_REQUEST, __opus_check_int_ptr(x)
383
Timothy B. Terriberryf5b2d782012-07-17 11:49:45 -0700384/** Sets the encoder's bandpass to a specific value.
385 * This prevents the encoder from automatically selecting the bandpass based
386 * on the available bitrate. If an application knows the bandpass of the input
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700387 * audio it is providing, it should normally use #OPUS_SET_MAX_BANDWIDTH
Timothy B. Terriberryf5b2d782012-07-17 11:49:45 -0700388 * instead, which still gives the encoder the freedom to reduce the bandpass
389 * when the bitrate becomes too low, for better overall quality.
390 * @see OPUS_GET_BANDWIDTH
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700391 * @param[in] x <tt>opus_int32</tt>: Allowed values:
392 * <dl>
393 * <dt>#OPUS_AUTO</dt> <dd>(default)</dd>
394 * <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd>
395 * <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd>
396 * <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd>
397 * <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd>
398 * <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband</dd>
399 * </dl>
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400400 * @hideinitializer */
401#define OPUS_SET_BANDWIDTH(x) OPUS_SET_BANDWIDTH_REQUEST, __opus_check_int(x)
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400402
403/** Configures the type of signal being encoded.
404 * This is a hint which helps the encoder's mode selection.
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700405 * @see OPUS_GET_SIGNAL
406 * @param[in] x <tt>opus_int32</tt>: Allowed values:
407 * <dl>
408 * <dt>#OPUS_AUTO</dt> <dd>(default)</dd>
409 * <dt>#OPUS_SIGNAL_VOICE</dt><dd>Bias thresholds towards choosing LPC or Hybrid modes.</dd>
410 * <dt>#OPUS_SIGNAL_MUSIC</dt><dd>Bias thresholds towards choosing MDCT modes.</dd>
411 * </dl>
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400412 * @hideinitializer */
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -0400413#define OPUS_SET_SIGNAL(x) OPUS_SET_SIGNAL_REQUEST, __opus_check_int(x)
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700414/** Gets the encoder's configured signal type.
415 * @see OPUS_SET_SIGNAL
416 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
417 * <dl>
418 * <dt>#OPUS_AUTO</dt> <dd>(default)</dd>
419 * <dt>#OPUS_SIGNAL_VOICE</dt><dd>Bias thresholds towards choosing LPC or Hybrid modes.</dd>
420 * <dt>#OPUS_SIGNAL_MUSIC</dt><dd>Bias thresholds towards choosing MDCT modes.</dd>
421 * </dl>
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400422 * @hideinitializer */
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -0400423#define OPUS_GET_SIGNAL(x) OPUS_GET_SIGNAL_REQUEST, __opus_check_int_ptr(x)
424
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400425
426/** Configures the encoder's intended application.
427 * The initial value is a mandatory argument to the encoder_create function.
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700428 * @see OPUS_GET_APPLICATION
429 * @param[in] x <tt>opus_int32</tt>: Returns one of the following values:
430 * <dl>
431 * <dt>#OPUS_APPLICATION_VOIP</dt>
432 * <dd>Process signal for improved speech intelligibility.</dd>
433 * <dt>#OPUS_APPLICATION_AUDIO</dt>
434 * <dd>Favor faithfulness to the original input.</dd>
435 * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt>
436 * <dd>Configure the minimum possible coding delay by disabling certain modes
437 * of operation.</dd>
438 * </dl>
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400439 * @hideinitializer */
440#define OPUS_SET_APPLICATION(x) OPUS_SET_APPLICATION_REQUEST, __opus_check_int(x)
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700441/** Gets the encoder's configured application.
442 * @see OPUS_SET_APPLICATION
443 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
444 * <dl>
445 * <dt>#OPUS_APPLICATION_VOIP</dt>
446 * <dd>Process signal for improved speech intelligibility.</dd>
447 * <dt>#OPUS_APPLICATION_AUDIO</dt>
448 * <dd>Favor faithfulness to the original input.</dd>
449 * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt>
450 * <dd>Configure the minimum possible coding delay by disabling certain modes
451 * of operation.</dd>
452 * </dl>
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400453 * @hideinitializer */
454#define OPUS_GET_APPLICATION(x) OPUS_GET_APPLICATION_REQUEST, __opus_check_int_ptr(x)
455
456/** Gets the total samples of delay added by the entire codec.
457 * This can be queried by the encoder and then the provided number of samples can be
458 * skipped on from the start of the decoder's output to provide time aligned input
459 * and output. From the perspective of a decoding application the real data begins this many
460 * samples late.
461 *
462 * The decoder contribution to this delay is identical for all decoders, but the
463 * encoder portion of the delay may vary from implementation to implementation,
464 * version to version, or even depend on the encoder's initial configuration.
465 * Applications needing delay compensation should call this CTL rather than
466 * hard-coding a value.
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700467 * @param[out] x <tt>opus_int32 *</tt>: Number of lookahead samples
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400468 * @hideinitializer */
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -0400469#define OPUS_GET_LOOKAHEAD(x) OPUS_GET_LOOKAHEAD_REQUEST, __opus_check_int_ptr(x)
470
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700471/** Configures the encoder's use of inband forward error correction (FEC).
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400472 * @note This is only applicable to the LPC layer
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700473 * @see OPUS_GET_INBAND_FEC
474 * @param[in] x <tt>opus_int32</tt>: Allowed values:
475 * <dl>
476 * <dt>0</dt><dd>Disable inband FEC (default).</dd>
477 * <dt>1</dt><dd>Enable inband FEC.</dd>
478 * </dl>
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400479 * @hideinitializer */
480#define OPUS_SET_INBAND_FEC(x) OPUS_SET_INBAND_FEC_REQUEST, __opus_check_int(x)
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700481/** Gets encoder's configured use of inband forward error correction.
482 * @see OPUS_SET_INBAND_FEC
483 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
484 * <dl>
485 * <dt>0</dt><dd>Inband FEC disabled (default).</dd>
486 * <dt>1</dt><dd>Inband FEC enabled.</dd>
487 * </dl>
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400488 * @hideinitializer */
489#define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_int_ptr(x)
490
491/** Configures the encoder's expected packet loss percentage.
Mark Harrisd70b8ed2015-10-23 13:18:08 -0400492 * Higher values trigger progressively more loss resistant behavior in the encoder
493 * at the expense of quality at a given bitrate in the absence of packet loss, but
494 * greater quality under loss.
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700495 * @see OPUS_GET_PACKET_LOSS_PERC
496 * @param[in] x <tt>opus_int32</tt>: Loss percentage in the range 0-100, inclusive (default: 0).
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400497 * @hideinitializer */
498#define OPUS_SET_PACKET_LOSS_PERC(x) OPUS_SET_PACKET_LOSS_PERC_REQUEST, __opus_check_int(x)
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700499/** Gets the encoder's configured packet loss percentage.
500 * @see OPUS_SET_PACKET_LOSS_PERC
501 * @param[out] x <tt>opus_int32 *</tt>: Returns the configured loss percentage
502 * in the range 0-100, inclusive (default: 0).
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400503 * @hideinitializer */
504#define OPUS_GET_PACKET_LOSS_PERC(x) OPUS_GET_PACKET_LOSS_PERC_REQUEST, __opus_check_int_ptr(x)
505
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700506/** Configures the encoder's use of discontinuous transmission (DTX).
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400507 * @note This is only applicable to the LPC layer
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700508 * @see OPUS_GET_DTX
509 * @param[in] x <tt>opus_int32</tt>: Allowed values:
510 * <dl>
511 * <dt>0</dt><dd>Disable DTX (default).</dd>
512 * <dt>1</dt><dd>Enabled DTX.</dd>
513 * </dl>
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400514 * @hideinitializer */
515#define OPUS_SET_DTX(x) OPUS_SET_DTX_REQUEST, __opus_check_int(x)
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700516/** Gets encoder's configured use of discontinuous transmission.
517 * @see OPUS_SET_DTX
518 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
519 * <dl>
520 * <dt>0</dt><dd>DTX disabled (default).</dd>
521 * <dt>1</dt><dd>DTX enabled.</dd>
522 * </dl>
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400523 * @hideinitializer */
524#define OPUS_GET_DTX(x) OPUS_GET_DTX_REQUEST, __opus_check_int_ptr(x)
Gregory Maxwell06d44322012-10-31 18:42:27 -0400525/** Configures the depth of signal being encoded.
Ralph Giles811dc742016-01-07 11:43:47 -0800526 *
Gregory Maxwell06d44322012-10-31 18:42:27 -0400527 * This is a hint which helps the encoder identify silence and near-silence.
Ralph Giles811dc742016-01-07 11:43:47 -0800528 * It represents the number of significant bits of linear intensity below
529 * which the signal contains ignorable quantization or other noise.
530 *
531 * For example, OPUS_SET_LSB_DEPTH(14) would be an appropriate setting
532 * for G.711 u-law input. OPUS_SET_LSB_DEPTH(16) would be appropriate
533 * for 16-bit linear pcm input with opus_encode_float().
534 *
Mark Harrisd70b8ed2015-10-23 13:18:08 -0400535 * When using opus_encode() instead of opus_encode_float(), or when libopus
Timothy B. Terriberry25c2f622015-06-23 11:41:11 -0700536 * is compiled for fixed-point, the encoder uses the minimum of the value
537 * set here and the value 16.
Ralph Giles811dc742016-01-07 11:43:47 -0800538 *
Gregory Maxwell06d44322012-10-31 18:42:27 -0400539 * @see OPUS_GET_LSB_DEPTH
540 * @param[in] x <tt>opus_int32</tt>: Input precision in bits, between 8 and 24
541 * (default: 24).
542 * @hideinitializer */
543#define OPUS_SET_LSB_DEPTH(x) OPUS_SET_LSB_DEPTH_REQUEST, __opus_check_int(x)
544/** Gets the encoder's configured signal depth.
545 * @see OPUS_SET_LSB_DEPTH
546 * @param[out] x <tt>opus_int32 *</tt>: Input precision in bits, between 8 and
547 * 24 (default: 24).
548 * @hideinitializer */
549#define OPUS_GET_LSB_DEPTH(x) OPUS_GET_LSB_DEPTH_REQUEST, __opus_check_int_ptr(x)
Jean-Marc Valin512d8492012-12-04 14:13:46 -0500550
Jean-Marc Valin49583ed2012-11-22 13:11:43 -0500551/** Configures the encoder's use of variable duration frames.
Gregory Maxwelldd7b0da2013-06-29 20:06:07 -0700552 * When variable duration is enabled, the encoder is free to use a shorter frame
553 * size than the one requested in the opus_encode*() call.
554 * It is then the user's responsibility
Jean-Marc Valin49583ed2012-11-22 13:11:43 -0500555 * to verify how much audio was encoded by checking the ToC byte of the encoded
556 * packet. The part of the audio that was not encoded needs to be resent to the
557 * encoder for the next call. Do not use this option unless you <b>really</b>
558 * know what you are doing.
Mark Harrisd70b8ed2015-10-23 13:18:08 -0400559 * @see OPUS_GET_EXPERT_FRAME_DURATION
Jean-Marc Valin49583ed2012-11-22 13:11:43 -0500560 * @param[in] x <tt>opus_int32</tt>: Allowed values:
561 * <dl>
Gregory Maxwelldd7b0da2013-06-29 20:06:07 -0700562 * <dt>OPUS_FRAMESIZE_ARG</dt><dd>Select frame size from the argument (default).</dd>
563 * <dt>OPUS_FRAMESIZE_2_5_MS</dt><dd>Use 2.5 ms frames.</dd>
Mark Harrisd70b8ed2015-10-23 13:18:08 -0400564 * <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 5 ms frames.</dd>
Gregory Maxwelldd7b0da2013-06-29 20:06:07 -0700565 * <dt>OPUS_FRAMESIZE_10_MS</dt><dd>Use 10 ms frames.</dd>
566 * <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd>
567 * <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd>
568 * <dt>OPUS_FRAMESIZE_60_MS</dt><dd>Use 60 ms frames.</dd>
569 * <dt>OPUS_FRAMESIZE_VARIABLE</dt><dd>Optimize the frame size dynamically.</dd>
Jean-Marc Valin49583ed2012-11-22 13:11:43 -0500570 * </dl>
571 * @hideinitializer */
Jean-Marc Valin51f4a322013-02-20 04:08:04 -0500572#define OPUS_SET_EXPERT_FRAME_DURATION(x) OPUS_SET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int(x)
Jean-Marc Valin49583ed2012-11-22 13:11:43 -0500573/** Gets the encoder's configured use of variable duration frames.
Mark Harrisd70b8ed2015-10-23 13:18:08 -0400574 * @see OPUS_SET_EXPERT_FRAME_DURATION
Jean-Marc Valin49583ed2012-11-22 13:11:43 -0500575 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
576 * <dl>
Gregory Maxwelldd7b0da2013-06-29 20:06:07 -0700577 * <dt>OPUS_FRAMESIZE_ARG</dt><dd>Select frame size from the argument (default).</dd>
578 * <dt>OPUS_FRAMESIZE_2_5_MS</dt><dd>Use 2.5 ms frames.</dd>
Mark Harrisd70b8ed2015-10-23 13:18:08 -0400579 * <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 5 ms frames.</dd>
Gregory Maxwelldd7b0da2013-06-29 20:06:07 -0700580 * <dt>OPUS_FRAMESIZE_10_MS</dt><dd>Use 10 ms frames.</dd>
581 * <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd>
582 * <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd>
583 * <dt>OPUS_FRAMESIZE_60_MS</dt><dd>Use 60 ms frames.</dd>
584 * <dt>OPUS_FRAMESIZE_VARIABLE</dt><dd>Optimize the frame size dynamically.</dd>
Jean-Marc Valin49583ed2012-11-22 13:11:43 -0500585 * </dl>
586 * @hideinitializer */
Jean-Marc Valin51f4a322013-02-20 04:08:04 -0500587#define OPUS_GET_EXPERT_FRAME_DURATION(x) OPUS_GET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int_ptr(x)
Jean-Marc Valin49583ed2012-11-22 13:11:43 -0500588
Jean-Marc Valincbe93e22013-11-15 13:50:38 -0500589/** If set to 1, disables almost all use of prediction, making frames almost
Mark Harrisd70b8ed2015-10-23 13:18:08 -0400590 * completely independent. This reduces quality.
591 * @see OPUS_GET_PREDICTION_DISABLED
592 * @param[in] x <tt>opus_int32</tt>: Allowed values:
593 * <dl>
594 * <dt>0</dt><dd>Enable prediction (default).</dd>
595 * <dt>1</dt><dd>Disable prediction.</dd>
596 * </dl>
Jean-Marc Valincbe93e22013-11-15 13:50:38 -0500597 * @hideinitializer */
598#define OPUS_SET_PREDICTION_DISABLED(x) OPUS_SET_PREDICTION_DISABLED_REQUEST, __opus_check_int(x)
599/** Gets the encoder's configured prediction status.
Mark Harrisd70b8ed2015-10-23 13:18:08 -0400600 * @see OPUS_SET_PREDICTION_DISABLED
601 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
602 * <dl>
603 * <dt>0</dt><dd>Prediction enabled (default).</dd>
604 * <dt>1</dt><dd>Prediction disabled.</dd>
605 * </dl>
Jean-Marc Valincbe93e22013-11-15 13:50:38 -0500606 * @hideinitializer */
607#define OPUS_GET_PREDICTION_DISABLED(x) OPUS_GET_PREDICTION_DISABLED_REQUEST, __opus_check_int_ptr(x)
608
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400609/**@}*/
610
Gregory Maxwelld445f022012-05-20 19:28:45 -0400611/** @defgroup opus_genericctls Generic CTLs
Ralph Giles10ebc022011-11-25 23:25:38 -0500612 *
613 * These macros are used with the \c opus_decoder_ctl and
614 * \c opus_encoder_ctl calls to generate a particular
615 * request.
616 *
617 * When called on an \c OpusDecoder they apply to that
618 * particular decoder instance. When called on an
619 * \c OpusEncoder they apply to the corresponding setting
620 * on that encoder instance, if present.
621 *
622 * Some usage examples:
623 *
624 * @code
625 * int ret;
626 * opus_int32 pitch;
627 * ret = opus_decoder_ctl(dec_ctx, OPUS_GET_PITCH(&pitch));
628 * if (ret == OPUS_OK) return ret;
629 *
630 * opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE);
631 * opus_decoder_ctl(dec_ctx, OPUS_RESET_STATE);
632 *
633 * opus_int32 enc_bw, dec_bw;
634 * opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&enc_bw));
635 * opus_decoder_ctl(dec_ctx, OPUS_GET_BANDWIDTH(&dec_bw));
636 * if (enc_bw != dec_bw) {
637 * printf("packet bandwidth mismatch!\n");
638 * }
639 * @endcode
640 *
Gregory Maxwell28b41ae2012-07-11 00:04:24 -0400641 * @see opus_encoder, opus_decoder_ctl, opus_encoder_ctl, opus_decoderctls, opus_encoderctls
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400642 * @{
643 */
644
645/** Resets the codec state to be equivalent to a freshly initialized state.
646 * This should be called when switching streams in order to prevent
647 * the back to back decoding from giving different results from
648 * one at a time decoding.
649 * @hideinitializer */
Jean-Marc Valinfbbd9bf2011-09-05 21:13:53 -0400650#define OPUS_RESET_STATE 4028
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -0400651
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400652/** Gets the final state of the codec's entropy coder.
653 * This is used for testing purposes,
654 * The encoder and decoder state should be identical after coding a payload
655 * (assuming no data corruption or software bugs)
656 *
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700657 * @param[out] x <tt>opus_uint32 *</tt>: Entropy coder state
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400658 *
659 * @hideinitializer */
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -0400660#define OPUS_GET_FINAL_RANGE(x) OPUS_GET_FINAL_RANGE_REQUEST, __opus_check_uint_ptr(x)
Jean-Marc Valind186c912011-09-08 15:13:46 -0400661
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700662/** Gets the encoder's configured bandpass or the decoder's last bandpass.
663 * @see OPUS_SET_BANDWIDTH
664 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
665 * <dl>
666 * <dt>#OPUS_AUTO</dt> <dd>(default)</dd>
667 * <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd>
668 * <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd>
669 * <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd>
670 * <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd>
671 * <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband</dd>
672 * </dl>
Gregory Maxwell48069bf2011-09-15 11:33:18 -0400673 * @hideinitializer */
674#define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __opus_check_int_ptr(x)
675
Bruno Randolff5a351a2014-02-24 16:08:08 -0500676/** Gets the sampling rate the encoder or decoder was initialized with.
677 * This simply returns the <code>Fs</code> value passed to opus_encoder_init()
678 * or opus_decoder_init().
679 * @param[out] x <tt>opus_int32 *</tt>: Sampling rate of encoder or decoder.
680 * @hideinitializer
681 */
682#define OPUS_GET_SAMPLE_RATE(x) OPUS_GET_SAMPLE_RATE_REQUEST, __opus_check_int_ptr(x)
683
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400684/**@}*/
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -0400685
Gregory Maxwell28b41ae2012-07-11 00:04:24 -0400686/** @defgroup opus_decoderctls Decoder related CTLs
687 * @see opus_genericctls, opus_encoderctls, opus_decoder
688 * @{
689 */
690
691/** Configures decoder gain adjustment.
692 * Scales the decoded output by a factor specified in Q8 dB units.
693 * This has a maximum range of -32768 to 32767 inclusive, and returns
Gregory Maxwell03105f52012-07-11 02:33:55 -0400694 * OPUS_BAD_ARG otherwise. The default is zero indicating no adjustment.
695 * This setting survives decoder reset.
Gregory Maxwell28b41ae2012-07-11 00:04:24 -0400696 *
697 * gain = pow(10, x/(20.0*256))
698 *
699 * @param[in] x <tt>opus_int32</tt>: Amount to scale PCM signal by in Q8 dB units.
700 * @hideinitializer */
701#define OPUS_SET_GAIN(x) OPUS_SET_GAIN_REQUEST, __opus_check_int(x)
702/** Gets the decoder's configured gain adjustment. @see OPUS_SET_GAIN
703 *
Timothy B. Terriberry07b8e612012-08-08 15:13:17 -0700704 * @param[out] x <tt>opus_int32 *</tt>: Amount to scale PCM signal by in Q8 dB units.
Gregory Maxwell28b41ae2012-07-11 00:04:24 -0400705 * @hideinitializer */
706#define OPUS_GET_GAIN(x) OPUS_GET_GAIN_REQUEST, __opus_check_int_ptr(x)
707
Bruno Randolff5a351a2014-02-24 16:08:08 -0500708/** Gets the duration (in samples) of the last packet successfully decoded or concealed.
709 * @param[out] x <tt>opus_int32 *</tt>: Number of samples (at current sampling rate).
710 * @hideinitializer */
711#define OPUS_GET_LAST_PACKET_DURATION(x) OPUS_GET_LAST_PACKET_DURATION_REQUEST, __opus_check_int_ptr(x)
712
713/** Gets the pitch of the last decoded frame, if available.
714 * This can be used for any post-processing algorithm requiring the use of pitch,
715 * e.g. time stretching/shortening. If the last frame was not voiced, or if the
716 * pitch was not coded in the frame, then zero is returned.
717 *
718 * This CTL is only implemented for decoder instances.
719 *
720 * @param[out] x <tt>opus_int32 *</tt>: pitch period at 48 kHz (or 0 if not available)
721 *
722 * @hideinitializer */
723#define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x)
724
Gregory Maxwell28b41ae2012-07-11 00:04:24 -0400725/**@}*/
726
Gregory Maxwelld445f022012-05-20 19:28:45 -0400727/** @defgroup opus_libinfo Opus library information functions
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400728 * @{
729 */
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -0400730
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400731/** Converts an opus error code into a human readable string.
732 *
Gregory Maxwell29095372011-09-09 14:24:49 -0400733 * @param[in] error <tt>int</tt>: Error number
Gregory Maxwell3bcf3672011-09-09 17:11:43 -0400734 * @returns Error string
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400735 */
Jean-Marc Valin06237d72011-09-01 13:20:40 -0400736OPUS_EXPORT const char *opus_strerror(int error);
737
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400738/** Gets the libopus version string.
739 *
Timothy B. Terriberry75d81f52015-02-20 12:44:10 -0800740 * Applications may look for the substring "-fixed" in the version string to
741 * determine whether they have a fixed-point or floating-point build at
742 * runtime.
743 *
Gregory Maxwell3bcf3672011-09-09 17:11:43 -0400744 * @returns Version string
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400745 */
Jean-Marc Valin06237d72011-09-01 13:20:40 -0400746OPUS_EXPORT const char *opus_get_version_string(void);
Gregory Maxwell75ff53c2011-09-08 08:13:16 -0400747/**@}*/
Jean-Marc Valin06237d72011-09-01 13:20:40 -0400748
Jean-Marc Valinf9e701a2011-08-31 17:47:48 -0400749#ifdef __cplusplus
750}
751#endif
752
Ralph Giles1b951962011-09-07 10:40:25 -0700753#endif /* OPUS_DEFINES_H */