Opus
IETF low-delay audio codec: API and operations manual
0.9.14
 All Files Functions Typedefs Macros Groups Pages
opus_defines.h
Go to the documentation of this file.
1 /* 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
18  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
19  OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  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 
33 #ifndef OPUS_DEFINES_H
34 #define OPUS_DEFINES_H
35 
36 #include "opus_types.h"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
46 #define OPUS_OK 0
47 
48 #define OPUS_BAD_ARG -1
49 
50 #define OPUS_BUFFER_TOO_SMALL -2
51 
52 #define OPUS_INTERNAL_ERROR -3
53 
54 #define OPUS_INVALID_PACKET -4
55 
56 #define OPUS_UNIMPLEMENTED -5
57 
58 #define OPUS_INVALID_STATE -6
59 
60 #define OPUS_ALLOC_FAIL -7
61 
66 #if defined(__GNUC__) && defined(OPUS_BUILD)
67 # define OPUS_EXPORT __attribute__ ((visibility ("default")))
68 #elif defined(WIN32) && !defined(__MINGW32__)
69 # ifdef OPUS_BUILD
70 # define OPUS_EXPORT __declspec(dllexport)
71 # else
72 # define OPUS_EXPORT
73 # endif
74 #else
75 # define OPUS_EXPORT
76 #endif
77 
78 # if !defined(OPUS_GNUC_PREREQ)
79 # if defined(__GNUC__)&&defined(__GNUC_MINOR__)
80 # define OPUS_GNUC_PREREQ(_maj,_min) \
81  ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min))
82 # else
83 # define OPUS_GNUC_PREREQ(_maj,_min) 0
84 # endif
85 # endif
86 
90 #if defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4)
91 # define OPUS_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__))
92 #else
93 # define OPUS_WARN_UNUSED_RESULT
94 #endif
95 #if !defined(OPUS_BUILD) && defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4)
96 # define OPUS_ARG_NONNULL(_x) __attribute__ ((__nonnull__(_x)))
97 #else
98 # define OPUS_ARG_NONNULL(_x)
99 #endif
100 
103 #define OPUS_SET_APPLICATION_REQUEST 4000
104 #define OPUS_GET_APPLICATION_REQUEST 4001
105 #define OPUS_SET_BITRATE_REQUEST 4002
106 #define OPUS_GET_BITRATE_REQUEST 4003
107 #define OPUS_SET_MAX_BANDWIDTH_REQUEST 4004
108 #define OPUS_GET_MAX_BANDWIDTH_REQUEST 4005
109 #define OPUS_SET_VBR_REQUEST 4006
110 #define OPUS_GET_VBR_REQUEST 4007
111 #define OPUS_SET_BANDWIDTH_REQUEST 4008
112 #define OPUS_GET_BANDWIDTH_REQUEST 4009
113 #define OPUS_SET_COMPLEXITY_REQUEST 4010
114 #define OPUS_GET_COMPLEXITY_REQUEST 4011
115 #define OPUS_SET_INBAND_FEC_REQUEST 4012
116 #define OPUS_GET_INBAND_FEC_REQUEST 4013
117 #define OPUS_SET_PACKET_LOSS_PERC_REQUEST 4014
118 #define OPUS_GET_PACKET_LOSS_PERC_REQUEST 4015
119 #define OPUS_SET_DTX_REQUEST 4016
120 #define OPUS_GET_DTX_REQUEST 4017
121 #define OPUS_SET_VBR_CONSTRAINT_REQUEST 4020
122 #define OPUS_GET_VBR_CONSTRAINT_REQUEST 4021
123 #define OPUS_SET_FORCE_CHANNELS_REQUEST 4022
124 #define OPUS_GET_FORCE_CHANNELS_REQUEST 4023
125 #define OPUS_SET_SIGNAL_REQUEST 4024
126 #define OPUS_GET_SIGNAL_REQUEST 4025
127 #define OPUS_GET_LOOKAHEAD_REQUEST 4027
128 /* #define OPUS_RESET_STATE 4028 */
129 #define OPUS_GET_FINAL_RANGE_REQUEST 4031
130 #define OPUS_GET_PITCH_REQUEST 4033
131 
132 /* Macros to trigger compilation errors when the wrong types are provided to a CTL */
133 #define __opus_check_int(x) (((void)((x) == (opus_int32)0)), (opus_int32)(x))
134 #define __opus_check_int_ptr(ptr) ((ptr) + ((ptr) - (opus_int32*)(ptr)))
135 #define __opus_check_uint_ptr(ptr) ((ptr) + ((ptr) - (opus_uint32*)(ptr)))
136 
142 /* Values for the various encoder CTLs */
143 #define OPUS_AUTO -1000
144 #define OPUS_BITRATE_MAX -1
148 #define OPUS_APPLICATION_VOIP 2048
149 
151 #define OPUS_APPLICATION_AUDIO 2049
152 
154 #define OPUS_APPLICATION_RESTRICTED_LOWDELAY 2051
155 
156 #define OPUS_SIGNAL_VOICE 3001
157 #define OPUS_SIGNAL_MUSIC 3002
158 #define OPUS_BANDWIDTH_NARROWBAND 1101
159 #define OPUS_BANDWIDTH_MEDIUMBAND 1102
160 #define OPUS_BANDWIDTH_WIDEBAND 1103
161 #define OPUS_BANDWIDTH_SUPERWIDEBAND 1104
162 #define OPUS_BANDWIDTH_FULLBAND 1105
196 #define OPUS_SET_COMPLEXITY(x) OPUS_SET_COMPLEXITY_REQUEST, __opus_check_int(x)
197 
200 #define OPUS_GET_COMPLEXITY(x) OPUS_GET_COMPLEXITY_REQUEST, __opus_check_int_ptr(x)
201 
210 #define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __opus_check_int(x)
211 
214 #define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __opus_check_int_ptr(x)
215 
225 #define OPUS_SET_VBR(x) OPUS_SET_VBR_REQUEST, __opus_check_int(x)
226 
229 #define OPUS_GET_VBR(x) OPUS_GET_VBR_REQUEST, __opus_check_int_ptr(x)
230 
242 #define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __opus_check_int(x)
243 
246 #define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __opus_check_int_ptr(x)
247 
253 #define OPUS_SET_FORCE_CHANNELS(x) OPUS_SET_FORCE_CHANNELS_REQUEST, __opus_check_int(x)
254 
257 #define OPUS_GET_FORCE_CHANNELS(x) OPUS_GET_FORCE_CHANNELS_REQUEST, __opus_check_int_ptr(x)
258 
268 #define OPUS_SET_MAX_BANDWIDTH(x) OPUS_SET_MAX_BANDWIDTH_REQUEST, __opus_check_int(x)
269 
273 #define OPUS_GET_MAX_BANDWIDTH(x) OPUS_GET_MAX_BANDWIDTH_REQUEST, __opus_check_int_ptr(x)
274 
285 #define OPUS_SET_BANDWIDTH(x) OPUS_SET_BANDWIDTH_REQUEST, __opus_check_int(x)
286 
295 #define OPUS_SET_SIGNAL(x) OPUS_SET_SIGNAL_REQUEST, __opus_check_int(x)
296 
300 #define OPUS_GET_SIGNAL(x) OPUS_GET_SIGNAL_REQUEST, __opus_check_int_ptr(x)
301 
302 
312 #define OPUS_SET_APPLICATION(x) OPUS_SET_APPLICATION_REQUEST, __opus_check_int(x)
313 
317 #define OPUS_GET_APPLICATION(x) OPUS_GET_APPLICATION_REQUEST, __opus_check_int_ptr(x)
318 
332 #define OPUS_GET_LOOKAHEAD(x) OPUS_GET_LOOKAHEAD_REQUEST, __opus_check_int_ptr(x)
333 
339 #define OPUS_SET_INBAND_FEC(x) OPUS_SET_INBAND_FEC_REQUEST, __opus_check_int(x)
340 
344 #define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_int_ptr(x)
345 
353 #define OPUS_SET_PACKET_LOSS_PERC(x) OPUS_SET_PACKET_LOSS_PERC_REQUEST, __opus_check_int(x)
354 
358 #define OPUS_GET_PACKET_LOSS_PERC(x) OPUS_GET_PACKET_LOSS_PERC_REQUEST, __opus_check_int_ptr(x)
359 
365 #define OPUS_SET_DTX(x) OPUS_SET_DTX_REQUEST, __opus_check_int(x)
366 
370 #define OPUS_GET_DTX(x) OPUS_GET_DTX_REQUEST, __opus_check_int_ptr(x)
371 
412 #define OPUS_RESET_STATE 4028
413 
422 #define OPUS_GET_FINAL_RANGE(x) OPUS_GET_FINAL_RANGE_REQUEST, __opus_check_uint_ptr(x)
423 
434 #define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x)
435 
439 #define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __opus_check_int_ptr(x)
440 
452 OPUS_EXPORT const char *opus_strerror(int error);
453 
458 OPUS_EXPORT const char *opus_get_version_string(void);
461 #ifdef __cplusplus
462 }
463 #endif
464 
465 #endif /* OPUS_DEFINES_H */
For more information visit the Opus Website.