Smart Remote 3 nRF52 v1.2
opus_defines.h
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 
47 #define OPUS_OK 0
48 
49 #define OPUS_BAD_ARG -1
50 
51 #define OPUS_BUFFER_TOO_SMALL -2
52 
53 #define OPUS_INTERNAL_ERROR -3
54 
55 #define OPUS_INVALID_PACKET -4
56 
57 #define OPUS_UNIMPLEMENTED -5
58 
59 #define OPUS_INVALID_STATE -6
60 
61 #define OPUS_ALLOC_FAIL -7
62 
67 #ifndef OPUS_EXPORT
68 # if defined(WIN32)
69 # if defined(OPUS_BUILD) && defined(DLL_EXPORT)
70 # define OPUS_EXPORT __declspec(dllexport)
71 # else
72 # define OPUS_EXPORT
73 # endif
74 # elif defined(__GNUC__) && defined(OPUS_BUILD)
75 # define OPUS_EXPORT __attribute__ ((visibility ("default")))
76 # else
77 # define OPUS_EXPORT
78 # endif
79 #endif
80 
81 # if !defined(OPUS_GNUC_PREREQ)
82 # if defined(__GNUC__)&&defined(__GNUC_MINOR__)
83 # define OPUS_GNUC_PREREQ(_maj,_min) \
84  ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min))
85 # else
86 # define OPUS_GNUC_PREREQ(_maj,_min) 0
87 # endif
88 # endif
89 
90 #if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) )
91 # if OPUS_GNUC_PREREQ(3,0)
92 # define OPUS_RESTRICT __restrict__
93 # elif (defined(_MSC_VER) && _MSC_VER >= 1400)
94 # define OPUS_RESTRICT __restrict
95 # else
96 # define OPUS_RESTRICT
97 # endif
98 #else
99 # define OPUS_RESTRICT restrict
100 #endif
101 
102 #if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) )
103 # if OPUS_GNUC_PREREQ(2,7)
104 # define OPUS_INLINE __inline__
105 # elif (defined(_MSC_VER))
106 # define OPUS_INLINE __inline
107 # else
108 # define OPUS_INLINE
109 # endif
110 #else
111 # define OPUS_INLINE inline
112 #endif
113 
117 #if defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4)
118 # define OPUS_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__))
119 #else
120 # define OPUS_WARN_UNUSED_RESULT
121 #endif
122 #if !defined(OPUS_BUILD) && defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4)
123 # define OPUS_ARG_NONNULL(_x) __attribute__ ((__nonnull__(_x)))
124 #else
125 # define OPUS_ARG_NONNULL(_x)
126 #endif
127 
131 #define OPUS_SET_APPLICATION_REQUEST 4000
132 #define OPUS_GET_APPLICATION_REQUEST 4001
133 #define OPUS_SET_BITRATE_REQUEST 4002
134 #define OPUS_GET_BITRATE_REQUEST 4003
135 #define OPUS_SET_MAX_BANDWIDTH_REQUEST 4004
136 #define OPUS_GET_MAX_BANDWIDTH_REQUEST 4005
137 #define OPUS_SET_VBR_REQUEST 4006
138 #define OPUS_GET_VBR_REQUEST 4007
139 #define OPUS_SET_BANDWIDTH_REQUEST 4008
140 #define OPUS_GET_BANDWIDTH_REQUEST 4009
141 #define OPUS_SET_COMPLEXITY_REQUEST 4010
142 #define OPUS_GET_COMPLEXITY_REQUEST 4011
143 #define OPUS_SET_INBAND_FEC_REQUEST 4012
144 #define OPUS_GET_INBAND_FEC_REQUEST 4013
145 #define OPUS_SET_PACKET_LOSS_PERC_REQUEST 4014
146 #define OPUS_GET_PACKET_LOSS_PERC_REQUEST 4015
147 #define OPUS_SET_DTX_REQUEST 4016
148 #define OPUS_GET_DTX_REQUEST 4017
149 #define OPUS_SET_VBR_CONSTRAINT_REQUEST 4020
150 #define OPUS_GET_VBR_CONSTRAINT_REQUEST 4021
151 #define OPUS_SET_FORCE_CHANNELS_REQUEST 4022
152 #define OPUS_GET_FORCE_CHANNELS_REQUEST 4023
153 #define OPUS_SET_SIGNAL_REQUEST 4024
154 #define OPUS_GET_SIGNAL_REQUEST 4025
155 #define OPUS_GET_LOOKAHEAD_REQUEST 4027
156 /* #define OPUS_RESET_STATE 4028 */
157 #define OPUS_GET_SAMPLE_RATE_REQUEST 4029
158 #define OPUS_GET_FINAL_RANGE_REQUEST 4031
159 #define OPUS_GET_PITCH_REQUEST 4033
160 #define OPUS_SET_GAIN_REQUEST 4034
161 #define OPUS_GET_GAIN_REQUEST 4045 /* Should have been 4035 */
162 #define OPUS_SET_LSB_DEPTH_REQUEST 4036
163 #define OPUS_GET_LSB_DEPTH_REQUEST 4037
164 #define OPUS_GET_LAST_PACKET_DURATION_REQUEST 4039
165 #define OPUS_SET_EXPERT_FRAME_DURATION_REQUEST 4040
166 #define OPUS_GET_EXPERT_FRAME_DURATION_REQUEST 4041
167 #define OPUS_SET_PREDICTION_DISABLED_REQUEST 4042
168 #define OPUS_GET_PREDICTION_DISABLED_REQUEST 4043
169 /* Don't use 4045, it's already taken by OPUS_GET_GAIN_REQUEST */
170 #define OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST 4046
171 #define OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST 4047
172 
173 /* Macros to trigger compilation errors when the wrong types are provided to a CTL */
174 #ifdef __GNUC__
175  #define __opus_check_int(x) (((void)((x) == (opus_int32)0)), (opus_int32)(x))
176  #define __opus_check_int_ptr(ptr) ((ptr) + ((ptr) - (opus_int32*)(ptr)))
177  #define __opus_check_uint_ptr(ptr) ((ptr) + ((ptr) - (opus_uint32*)(ptr)))
178  #define __opus_check_val16_ptr(ptr) ((ptr) + ((ptr) - (opus_val16*)(ptr)))
179 #else
180  #define __opus_check_int(x) ((opus_int32)(x))
181  #define __opus_check_int_ptr(ptr) ((opus_int32*)(ptr))
182  #define __opus_check_uint_ptr(ptr) ((opus_uint32*)(ptr))
183  #define __opus_check_val16_ptr(ptr) ((opus_val16*)(ptr))
184 #endif
185 
192 /* Values for the various encoder CTLs */
193 #define OPUS_AUTO -1000
194 #define OPUS_BITRATE_MAX -1
198 #define OPUS_APPLICATION_VOIP 2048
199 
201 #define OPUS_APPLICATION_AUDIO 2049
202 
204 #define OPUS_APPLICATION_RESTRICTED_LOWDELAY 2051
205 
206 #define OPUS_SIGNAL_VOICE 3001
207 #define OPUS_SIGNAL_MUSIC 3002
208 #define OPUS_BANDWIDTH_NARROWBAND 1101
209 #define OPUS_BANDWIDTH_MEDIUMBAND 1102
210 #define OPUS_BANDWIDTH_WIDEBAND 1103
211 #define OPUS_BANDWIDTH_SUPERWIDEBAND 1104
212 #define OPUS_BANDWIDTH_FULLBAND 1105
214 #define OPUS_FRAMESIZE_ARG 5000
215 #define OPUS_FRAMESIZE_2_5_MS 5001
216 #define OPUS_FRAMESIZE_5_MS 5002
217 #define OPUS_FRAMESIZE_10_MS 5003
218 #define OPUS_FRAMESIZE_20_MS 5004
219 #define OPUS_FRAMESIZE_40_MS 5005
220 #define OPUS_FRAMESIZE_60_MS 5006
221 #define OPUS_FRAMESIZE_80_MS 5007
222 #define OPUS_FRAMESIZE_100_MS 5008
223 #define OPUS_FRAMESIZE_120_MS 5009
259 #define OPUS_SET_COMPLEXITY(x) OPUS_SET_COMPLEXITY_REQUEST, __opus_check_int(x)
260 
265 #define OPUS_GET_COMPLEXITY(x) OPUS_GET_COMPLEXITY_REQUEST, __opus_check_int_ptr(x)
266 
278 #define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __opus_check_int(x)
279 
286 #define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __opus_check_int_ptr(x)
287 
301 #define OPUS_SET_VBR(x) OPUS_SET_VBR_REQUEST, __opus_check_int(x)
302 
312 #define OPUS_GET_VBR(x) OPUS_GET_VBR_REQUEST, __opus_check_int_ptr(x)
313 
330 #define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __opus_check_int(x)
331 
340 #define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __opus_check_int_ptr(x)
341 
355 #define OPUS_SET_FORCE_CHANNELS(x) OPUS_SET_FORCE_CHANNELS_REQUEST, __opus_check_int(x)
356 
365 #define OPUS_GET_FORCE_CHANNELS(x) OPUS_GET_FORCE_CHANNELS_REQUEST, __opus_check_int_ptr(x)
366 
383 #define OPUS_SET_MAX_BANDWIDTH(x) OPUS_SET_MAX_BANDWIDTH_REQUEST, __opus_check_int(x)
384 
396 #define OPUS_GET_MAX_BANDWIDTH(x) OPUS_GET_MAX_BANDWIDTH_REQUEST, __opus_check_int_ptr(x)
397 
415 #define OPUS_SET_BANDWIDTH(x) OPUS_SET_BANDWIDTH_REQUEST, __opus_check_int(x)
416 
427 #define OPUS_SET_SIGNAL(x) OPUS_SET_SIGNAL_REQUEST, __opus_check_int(x)
428 
437 #define OPUS_GET_SIGNAL(x) OPUS_GET_SIGNAL_REQUEST, __opus_check_int_ptr(x)
438 
439 
454 #define OPUS_SET_APPLICATION(x) OPUS_SET_APPLICATION_REQUEST, __opus_check_int(x)
455 
468 #define OPUS_GET_APPLICATION(x) OPUS_GET_APPLICATION_REQUEST, __opus_check_int_ptr(x)
469 
483 #define OPUS_GET_LOOKAHEAD(x) OPUS_GET_LOOKAHEAD_REQUEST, __opus_check_int_ptr(x)
484 
494 #define OPUS_SET_INBAND_FEC(x) OPUS_SET_INBAND_FEC_REQUEST, __opus_check_int(x)
495 
503 #define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_int_ptr(x)
504 
512 #define OPUS_SET_PACKET_LOSS_PERC(x) OPUS_SET_PACKET_LOSS_PERC_REQUEST, __opus_check_int(x)
513 
518 #define OPUS_GET_PACKET_LOSS_PERC(x) OPUS_GET_PACKET_LOSS_PERC_REQUEST, __opus_check_int_ptr(x)
519 
529 #define OPUS_SET_DTX(x) OPUS_SET_DTX_REQUEST, __opus_check_int(x)
530 
538 #define OPUS_GET_DTX(x) OPUS_GET_DTX_REQUEST, __opus_check_int_ptr(x)
539 
557 #define OPUS_SET_LSB_DEPTH(x) OPUS_SET_LSB_DEPTH_REQUEST, __opus_check_int(x)
558 
563 #define OPUS_GET_LSB_DEPTH(x) OPUS_GET_LSB_DEPTH_REQUEST, __opus_check_int_ptr(x)
564 
588 #define OPUS_SET_EXPERT_FRAME_DURATION(x) OPUS_SET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int(x)
589 
605 #define OPUS_GET_EXPERT_FRAME_DURATION(x) OPUS_GET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int_ptr(x)
606 
616 #define OPUS_SET_PREDICTION_DISABLED(x) OPUS_SET_PREDICTION_DISABLED_REQUEST, __opus_check_int(x)
617 
625 #define OPUS_GET_PREDICTION_DISABLED(x) OPUS_GET_PREDICTION_DISABLED_REQUEST, __opus_check_int_ptr(x)
626 
669 #define OPUS_RESET_STATE 4028
670 
679 #define OPUS_GET_FINAL_RANGE(x) OPUS_GET_FINAL_RANGE_REQUEST, __opus_check_uint_ptr(x)
680 
693 #define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __opus_check_int_ptr(x)
694 
701 #define OPUS_GET_SAMPLE_RATE(x) OPUS_GET_SAMPLE_RATE_REQUEST, __opus_check_int_ptr(x)
702 
716 #define OPUS_SET_PHASE_INVERSION_DISABLED(x) OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST, __opus_check_int(x)
717 
725 #define OPUS_GET_PHASE_INVERSION_DISABLED(x) OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST, __opus_check_int_ptr(x)
726 
745 #define OPUS_SET_GAIN(x) OPUS_SET_GAIN_REQUEST, __opus_check_int(x)
746 
750 #define OPUS_GET_GAIN(x) OPUS_GET_GAIN_REQUEST, __opus_check_int_ptr(x)
751 
755 #define OPUS_GET_LAST_PACKET_DURATION(x) OPUS_GET_LAST_PACKET_DURATION_REQUEST, __opus_check_int_ptr(x)
756 
767 #define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x)
768 
781 OPUS_EXPORT const char *opus_strerror(int error);
782 
791 OPUS_EXPORT const char *opus_get_version_string(void);
794 #ifdef __cplusplus
795 }
796 #endif
797 
798 #endif /* OPUS_DEFINES_H */

Documentation feedback | Developer Zone | Subscribe | Updated