Opus
Opus audio codec (RFC 6716): API and operations manual
1.1
opus_defines.h
Go to the documentation of this file.
00001 /* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited
00002    Written by Jean-Marc Valin and Koen Vos */
00003 /*
00004    Redistribution and use in source and binary forms, with or without
00005    modification, are permitted provided that the following conditions
00006    are met:
00007 
00008    - Redistributions of source code must retain the above copyright
00009    notice, this list of conditions and the following disclaimer.
00010 
00011    - Redistributions in binary form must reproduce the above copyright
00012    notice, this list of conditions and the following disclaimer in the
00013    documentation and/or other materials provided with the distribution.
00014 
00015    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00016    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00017    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00018    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
00019    OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00020    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00021    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00022    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00023    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00024    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00025    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 */
00027 
00033 #ifndef OPUS_DEFINES_H
00034 #define OPUS_DEFINES_H
00035 
00036 #include "opus_types.h"
00037 
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041 
00046 #define OPUS_OK                0
00047 
00048 #define OPUS_BAD_ARG          -1
00049 
00050 #define OPUS_BUFFER_TOO_SMALL -2
00051 
00052 #define OPUS_INTERNAL_ERROR   -3
00053 
00054 #define OPUS_INVALID_PACKET   -4
00055 
00056 #define OPUS_UNIMPLEMENTED    -5
00057 
00058 #define OPUS_INVALID_STATE    -6
00059 
00060 #define OPUS_ALLOC_FAIL       -7
00061 
00066 #ifndef OPUS_EXPORT
00067 # if defined(WIN32)
00068 #  ifdef OPUS_BUILD
00069 #   define OPUS_EXPORT __declspec(dllexport)
00070 #  else
00071 #   define OPUS_EXPORT
00072 #  endif
00073 # elif defined(__GNUC__) && defined(OPUS_BUILD)
00074 #  define OPUS_EXPORT __attribute__ ((visibility ("default")))
00075 # else
00076 #  define OPUS_EXPORT
00077 # endif
00078 #endif
00079 
00080 # if !defined(OPUS_GNUC_PREREQ)
00081 #  if defined(__GNUC__)&&defined(__GNUC_MINOR__)
00082 #   define OPUS_GNUC_PREREQ(_maj,_min) \
00083  ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min))
00084 #  else
00085 #   define OPUS_GNUC_PREREQ(_maj,_min) 0
00086 #  endif
00087 # endif
00088 
00089 #if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) )
00090 # if OPUS_GNUC_PREREQ(3,0)
00091 #  define OPUS_RESTRICT __restrict__
00092 # elif (defined(_MSC_VER) && _MSC_VER >= 1400)
00093 #  define OPUS_RESTRICT __restrict
00094 # else
00095 #  define OPUS_RESTRICT
00096 # endif
00097 #else
00098 # define OPUS_RESTRICT restrict
00099 #endif
00100 
00101 #if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) )
00102 # if OPUS_GNUC_PREREQ(2,7)
00103 #  define OPUS_INLINE __inline__
00104 # elif (defined(_MSC_VER))
00105 #  define OPUS_INLINE __inline
00106 # else
00107 #  define OPUS_INLINE
00108 # endif
00109 #else
00110 # define OPUS_INLINE inline
00111 #endif
00112 
00116 #if defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4)
00117 # define OPUS_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__))
00118 #else
00119 # define OPUS_WARN_UNUSED_RESULT
00120 #endif
00121 #if !defined(OPUS_BUILD) && defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4)
00122 # define OPUS_ARG_NONNULL(_x)  __attribute__ ((__nonnull__(_x)))
00123 #else
00124 # define OPUS_ARG_NONNULL(_x)
00125 #endif
00126 
00130 #define OPUS_SET_APPLICATION_REQUEST         4000
00131 #define OPUS_GET_APPLICATION_REQUEST         4001
00132 #define OPUS_SET_BITRATE_REQUEST             4002
00133 #define OPUS_GET_BITRATE_REQUEST             4003
00134 #define OPUS_SET_MAX_BANDWIDTH_REQUEST       4004
00135 #define OPUS_GET_MAX_BANDWIDTH_REQUEST       4005
00136 #define OPUS_SET_VBR_REQUEST                 4006
00137 #define OPUS_GET_VBR_REQUEST                 4007
00138 #define OPUS_SET_BANDWIDTH_REQUEST           4008
00139 #define OPUS_GET_BANDWIDTH_REQUEST           4009
00140 #define OPUS_SET_COMPLEXITY_REQUEST          4010
00141 #define OPUS_GET_COMPLEXITY_REQUEST          4011
00142 #define OPUS_SET_INBAND_FEC_REQUEST          4012
00143 #define OPUS_GET_INBAND_FEC_REQUEST          4013
00144 #define OPUS_SET_PACKET_LOSS_PERC_REQUEST    4014
00145 #define OPUS_GET_PACKET_LOSS_PERC_REQUEST    4015
00146 #define OPUS_SET_DTX_REQUEST                 4016
00147 #define OPUS_GET_DTX_REQUEST                 4017
00148 #define OPUS_SET_VBR_CONSTRAINT_REQUEST      4020
00149 #define OPUS_GET_VBR_CONSTRAINT_REQUEST      4021
00150 #define OPUS_SET_FORCE_CHANNELS_REQUEST      4022
00151 #define OPUS_GET_FORCE_CHANNELS_REQUEST      4023
00152 #define OPUS_SET_SIGNAL_REQUEST              4024
00153 #define OPUS_GET_SIGNAL_REQUEST              4025
00154 #define OPUS_GET_LOOKAHEAD_REQUEST           4027
00155 /* #define OPUS_RESET_STATE 4028 */
00156 #define OPUS_GET_SAMPLE_RATE_REQUEST         4029
00157 #define OPUS_GET_FINAL_RANGE_REQUEST         4031
00158 #define OPUS_GET_PITCH_REQUEST               4033
00159 #define OPUS_SET_GAIN_REQUEST                4034
00160 #define OPUS_GET_GAIN_REQUEST                4045 /* Should have been 4035 */
00161 #define OPUS_SET_LSB_DEPTH_REQUEST           4036
00162 #define OPUS_GET_LSB_DEPTH_REQUEST           4037
00163 #define OPUS_GET_LAST_PACKET_DURATION_REQUEST 4039
00164 #define OPUS_SET_EXPERT_FRAME_DURATION_REQUEST 4040
00165 #define OPUS_GET_EXPERT_FRAME_DURATION_REQUEST 4041
00166 #define OPUS_SET_PREDICTION_DISABLED_REQUEST 4042
00167 #define OPUS_GET_PREDICTION_DISABLED_REQUEST 4043
00168 
00169 /* Don't use 4045, it's already taken by OPUS_GET_GAIN_REQUEST */
00170 
00171 /* Macros to trigger compilation errors when the wrong types are provided to a CTL */
00172 #define __opus_check_int(x) (((void)((x) == (opus_int32)0)), (opus_int32)(x))
00173 #define __opus_check_int_ptr(ptr) ((ptr) + ((ptr) - (opus_int32*)(ptr)))
00174 #define __opus_check_uint_ptr(ptr) ((ptr) + ((ptr) - (opus_uint32*)(ptr)))
00175 #define __opus_check_val16_ptr(ptr) ((ptr) + ((ptr) - (opus_val16*)(ptr)))
00176 
00182 /* Values for the various encoder CTLs */
00183 #define OPUS_AUTO                           -1000 
00184 #define OPUS_BITRATE_MAX                       -1 
00188 #define OPUS_APPLICATION_VOIP                2048
00189 
00191 #define OPUS_APPLICATION_AUDIO               2049
00192 
00194 #define OPUS_APPLICATION_RESTRICTED_LOWDELAY 2051
00195 
00196 #define OPUS_SIGNAL_VOICE                    3001 
00197 #define OPUS_SIGNAL_MUSIC                    3002 
00198 #define OPUS_BANDWIDTH_NARROWBAND            1101 
00199 #define OPUS_BANDWIDTH_MEDIUMBAND            1102 
00200 #define OPUS_BANDWIDTH_WIDEBAND              1103 
00201 #define OPUS_BANDWIDTH_SUPERWIDEBAND         1104 
00202 #define OPUS_BANDWIDTH_FULLBAND              1105 
00204 #define OPUS_FRAMESIZE_ARG                   5000 
00205 #define OPUS_FRAMESIZE_2_5_MS                5001 
00206 #define OPUS_FRAMESIZE_5_MS                  5002 
00207 #define OPUS_FRAMESIZE_10_MS                 5003 
00208 #define OPUS_FRAMESIZE_20_MS                 5004 
00209 #define OPUS_FRAMESIZE_40_MS                 5005 
00210 #define OPUS_FRAMESIZE_60_MS                 5006 
00245 #define OPUS_SET_COMPLEXITY(x) OPUS_SET_COMPLEXITY_REQUEST, __opus_check_int(x)
00246 
00251 #define OPUS_GET_COMPLEXITY(x) OPUS_GET_COMPLEXITY_REQUEST, __opus_check_int_ptr(x)
00252 
00264 #define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __opus_check_int(x)
00265 
00272 #define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __opus_check_int_ptr(x)
00273 
00288 #define OPUS_SET_VBR(x) OPUS_SET_VBR_REQUEST, __opus_check_int(x)
00289 
00299 #define OPUS_GET_VBR(x) OPUS_GET_VBR_REQUEST, __opus_check_int_ptr(x)
00300 
00317 #define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __opus_check_int(x)
00318 
00327 #define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __opus_check_int_ptr(x)
00328 
00342 #define OPUS_SET_FORCE_CHANNELS(x) OPUS_SET_FORCE_CHANNELS_REQUEST, __opus_check_int(x)
00343 
00352 #define OPUS_GET_FORCE_CHANNELS(x) OPUS_GET_FORCE_CHANNELS_REQUEST, __opus_check_int_ptr(x)
00353 
00370 #define OPUS_SET_MAX_BANDWIDTH(x) OPUS_SET_MAX_BANDWIDTH_REQUEST, __opus_check_int(x)
00371 
00383 #define OPUS_GET_MAX_BANDWIDTH(x) OPUS_GET_MAX_BANDWIDTH_REQUEST, __opus_check_int_ptr(x)
00384 
00402 #define OPUS_SET_BANDWIDTH(x) OPUS_SET_BANDWIDTH_REQUEST, __opus_check_int(x)
00403 
00414 #define OPUS_SET_SIGNAL(x) OPUS_SET_SIGNAL_REQUEST, __opus_check_int(x)
00415 
00424 #define OPUS_GET_SIGNAL(x) OPUS_GET_SIGNAL_REQUEST, __opus_check_int_ptr(x)
00425 
00426 
00441 #define OPUS_SET_APPLICATION(x) OPUS_SET_APPLICATION_REQUEST, __opus_check_int(x)
00442 
00455 #define OPUS_GET_APPLICATION(x) OPUS_GET_APPLICATION_REQUEST, __opus_check_int_ptr(x)
00456 
00463 #define OPUS_GET_SAMPLE_RATE(x) OPUS_GET_SAMPLE_RATE_REQUEST, __opus_check_int_ptr(x)
00464 
00478 #define OPUS_GET_LOOKAHEAD(x) OPUS_GET_LOOKAHEAD_REQUEST, __opus_check_int_ptr(x)
00479 
00489 #define OPUS_SET_INBAND_FEC(x) OPUS_SET_INBAND_FEC_REQUEST, __opus_check_int(x)
00490 
00498 #define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_int_ptr(x)
00499 
00507 #define OPUS_SET_PACKET_LOSS_PERC(x) OPUS_SET_PACKET_LOSS_PERC_REQUEST, __opus_check_int(x)
00508 
00513 #define OPUS_GET_PACKET_LOSS_PERC(x) OPUS_GET_PACKET_LOSS_PERC_REQUEST, __opus_check_int_ptr(x)
00514 
00524 #define OPUS_SET_DTX(x) OPUS_SET_DTX_REQUEST, __opus_check_int(x)
00525 
00533 #define OPUS_GET_DTX(x) OPUS_GET_DTX_REQUEST, __opus_check_int_ptr(x)
00534 
00540 #define OPUS_SET_LSB_DEPTH(x) OPUS_SET_LSB_DEPTH_REQUEST, __opus_check_int(x)
00541 
00546 #define OPUS_GET_LSB_DEPTH(x) OPUS_GET_LSB_DEPTH_REQUEST, __opus_check_int_ptr(x)
00547 
00551 #define OPUS_GET_LAST_PACKET_DURATION(x) OPUS_GET_LAST_PACKET_DURATION_REQUEST, __opus_check_int_ptr(x)
00552 
00574 #define OPUS_SET_EXPERT_FRAME_DURATION(x) OPUS_SET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int(x)
00575 
00589 #define OPUS_GET_EXPERT_FRAME_DURATION(x) OPUS_GET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int_ptr(x)
00590 
00594 #define OPUS_SET_PREDICTION_DISABLED(x) OPUS_SET_PREDICTION_DISABLED_REQUEST, __opus_check_int(x)
00595 
00597 #define OPUS_GET_PREDICTION_DISABLED(x) OPUS_GET_PREDICTION_DISABLED_REQUEST, __opus_check_int_ptr(x)
00598 
00640 #define OPUS_RESET_STATE 4028
00641 
00650 #define OPUS_GET_FINAL_RANGE(x) OPUS_GET_FINAL_RANGE_REQUEST, __opus_check_uint_ptr(x)
00651 
00662 #define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x)
00663 
00676 #define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __opus_check_int_ptr(x)
00677 
00695 #define OPUS_SET_GAIN(x) OPUS_SET_GAIN_REQUEST, __opus_check_int(x)
00696 
00700 #define OPUS_GET_GAIN(x) OPUS_GET_GAIN_REQUEST, __opus_check_int_ptr(x)
00701 
00713 OPUS_EXPORT const char *opus_strerror(int error);
00714 
00719 OPUS_EXPORT const char *opus_get_version_string(void);
00722 #ifdef __cplusplus
00723 }
00724 #endif
00725 
00726 #endif /* OPUS_DEFINES_H */
 All Files Functions Typedefs Defines
For more information visit the Opus Website.