Opus
IETF low-delay audio codec: API and operations manual
1.0.1-rc2
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 #if defined(__GNUC__) && defined(OPUS_BUILD)
00067 # define OPUS_EXPORT __attribute__ ((visibility ("default")))
00068 #elif defined(WIN32) && !defined(__MINGW32__)
00069 # ifdef OPUS_BUILD
00070 #   define OPUS_EXPORT __declspec(dllexport)
00071 # else
00072 #   define OPUS_EXPORT
00073 # endif
00074 #else
00075 # define OPUS_EXPORT
00076 #endif
00077 
00078 # if !defined(OPUS_GNUC_PREREQ)
00079 #  if defined(__GNUC__)&&defined(__GNUC_MINOR__)
00080 #   define OPUS_GNUC_PREREQ(_maj,_min) \
00081  ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min))
00082 #  else
00083 #   define OPUS_GNUC_PREREQ(_maj,_min) 0
00084 #  endif
00085 # endif
00086 
00087 #if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) )
00088 # if OPUS_GNUC_PREREQ(3,0)
00089 #  define OPUS_RESTRICT __restrict__
00090 # elif (defined(_MSC_VER) && _MSC_VER >= 1400)
00091 #  define OPUS_RESTRICT __restrict
00092 # else
00093 #  define OPUS_RESTRICT
00094 # endif
00095 #else
00096 # define OPUS_RESTRICT restrict
00097 #endif
00098 
00102 #if defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4)
00103 # define OPUS_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__))
00104 #else
00105 # define OPUS_WARN_UNUSED_RESULT
00106 #endif
00107 #if !defined(OPUS_BUILD) && defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4)
00108 # define OPUS_ARG_NONNULL(_x)  __attribute__ ((__nonnull__(_x)))
00109 #else
00110 # define OPUS_ARG_NONNULL(_x)
00111 #endif
00112 
00115 #define OPUS_SET_APPLICATION_REQUEST         4000
00116 #define OPUS_GET_APPLICATION_REQUEST         4001
00117 #define OPUS_SET_BITRATE_REQUEST             4002
00118 #define OPUS_GET_BITRATE_REQUEST             4003
00119 #define OPUS_SET_MAX_BANDWIDTH_REQUEST       4004
00120 #define OPUS_GET_MAX_BANDWIDTH_REQUEST       4005
00121 #define OPUS_SET_VBR_REQUEST                 4006
00122 #define OPUS_GET_VBR_REQUEST                 4007
00123 #define OPUS_SET_BANDWIDTH_REQUEST           4008
00124 #define OPUS_GET_BANDWIDTH_REQUEST           4009
00125 #define OPUS_SET_COMPLEXITY_REQUEST          4010
00126 #define OPUS_GET_COMPLEXITY_REQUEST          4011
00127 #define OPUS_SET_INBAND_FEC_REQUEST          4012
00128 #define OPUS_GET_INBAND_FEC_REQUEST          4013
00129 #define OPUS_SET_PACKET_LOSS_PERC_REQUEST    4014
00130 #define OPUS_GET_PACKET_LOSS_PERC_REQUEST    4015
00131 #define OPUS_SET_DTX_REQUEST                 4016
00132 #define OPUS_GET_DTX_REQUEST                 4017
00133 #define OPUS_SET_VBR_CONSTRAINT_REQUEST      4020
00134 #define OPUS_GET_VBR_CONSTRAINT_REQUEST      4021
00135 #define OPUS_SET_FORCE_CHANNELS_REQUEST      4022
00136 #define OPUS_GET_FORCE_CHANNELS_REQUEST      4023
00137 #define OPUS_SET_SIGNAL_REQUEST              4024
00138 #define OPUS_GET_SIGNAL_REQUEST              4025
00139 #define OPUS_GET_LOOKAHEAD_REQUEST           4027
00140 /* #define OPUS_RESET_STATE 4028 */
00141 #define OPUS_GET_FINAL_RANGE_REQUEST         4031
00142 #define OPUS_GET_PITCH_REQUEST               4033
00143 #define OPUS_SET_GAIN_REQUEST                4034
00144 #define OPUS_GET_GAIN_REQUEST                4045
00145 #define OPUS_SET_LSB_DEPTH_REQUEST           4036
00146 #define OPUS_GET_LSB_DEPTH_REQUEST           4037
00147 
00148 /* Macros to trigger compilation errors when the wrong types are provided to a CTL */
00149 #define __opus_check_int(x) (((void)((x) == (opus_int32)0)), (opus_int32)(x))
00150 #define __opus_check_int_ptr(ptr) ((ptr) + ((ptr) - (opus_int32*)(ptr)))
00151 #define __opus_check_uint_ptr(ptr) ((ptr) + ((ptr) - (opus_uint32*)(ptr)))
00152 
00158 /* Values for the various encoder CTLs */
00159 #define OPUS_AUTO                           -1000 
00160 #define OPUS_BITRATE_MAX                       -1 
00164 #define OPUS_APPLICATION_VOIP                2048
00165 
00167 #define OPUS_APPLICATION_AUDIO               2049
00168 
00170 #define OPUS_APPLICATION_RESTRICTED_LOWDELAY 2051
00171 
00172 #define OPUS_SIGNAL_VOICE                    3001 
00173 #define OPUS_SIGNAL_MUSIC                    3002 
00174 #define OPUS_BANDWIDTH_NARROWBAND            1101 
00175 #define OPUS_BANDWIDTH_MEDIUMBAND            1102 
00176 #define OPUS_BANDWIDTH_WIDEBAND              1103 
00177 #define OPUS_BANDWIDTH_SUPERWIDEBAND         1104 
00178 #define OPUS_BANDWIDTH_FULLBAND              1105 
00213 #define OPUS_SET_COMPLEXITY(x) OPUS_SET_COMPLEXITY_REQUEST, __opus_check_int(x)
00214 
00219 #define OPUS_GET_COMPLEXITY(x) OPUS_GET_COMPLEXITY_REQUEST, __opus_check_int_ptr(x)
00220 
00232 #define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __opus_check_int(x)
00233 
00240 #define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __opus_check_int_ptr(x)
00241 
00256 #define OPUS_SET_VBR(x) OPUS_SET_VBR_REQUEST, __opus_check_int(x)
00257 
00267 #define OPUS_GET_VBR(x) OPUS_GET_VBR_REQUEST, __opus_check_int_ptr(x)
00268 
00285 #define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __opus_check_int(x)
00286 
00295 #define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __opus_check_int_ptr(x)
00296 
00310 #define OPUS_SET_FORCE_CHANNELS(x) OPUS_SET_FORCE_CHANNELS_REQUEST, __opus_check_int(x)
00311 
00320 #define OPUS_GET_FORCE_CHANNELS(x) OPUS_GET_FORCE_CHANNELS_REQUEST, __opus_check_int_ptr(x)
00321 
00338 #define OPUS_SET_MAX_BANDWIDTH(x) OPUS_SET_MAX_BANDWIDTH_REQUEST, __opus_check_int(x)
00339 
00351 #define OPUS_GET_MAX_BANDWIDTH(x) OPUS_GET_MAX_BANDWIDTH_REQUEST, __opus_check_int_ptr(x)
00352 
00370 #define OPUS_SET_BANDWIDTH(x) OPUS_SET_BANDWIDTH_REQUEST, __opus_check_int(x)
00371 
00382 #define OPUS_SET_SIGNAL(x) OPUS_SET_SIGNAL_REQUEST, __opus_check_int(x)
00383 
00392 #define OPUS_GET_SIGNAL(x) OPUS_GET_SIGNAL_REQUEST, __opus_check_int_ptr(x)
00393 
00394 
00409 #define OPUS_SET_APPLICATION(x) OPUS_SET_APPLICATION_REQUEST, __opus_check_int(x)
00410 
00423 #define OPUS_GET_APPLICATION(x) OPUS_GET_APPLICATION_REQUEST, __opus_check_int_ptr(x)
00424 
00438 #define OPUS_GET_LOOKAHEAD(x) OPUS_GET_LOOKAHEAD_REQUEST, __opus_check_int_ptr(x)
00439 
00449 #define OPUS_SET_INBAND_FEC(x) OPUS_SET_INBAND_FEC_REQUEST, __opus_check_int(x)
00450 
00458 #define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_int_ptr(x)
00459 
00467 #define OPUS_SET_PACKET_LOSS_PERC(x) OPUS_SET_PACKET_LOSS_PERC_REQUEST, __opus_check_int(x)
00468 
00473 #define OPUS_GET_PACKET_LOSS_PERC(x) OPUS_GET_PACKET_LOSS_PERC_REQUEST, __opus_check_int_ptr(x)
00474 
00484 #define OPUS_SET_DTX(x) OPUS_SET_DTX_REQUEST, __opus_check_int(x)
00485 
00493 #define OPUS_GET_DTX(x) OPUS_GET_DTX_REQUEST, __opus_check_int_ptr(x)
00494 
00535 #define OPUS_RESET_STATE 4028
00536 
00545 #define OPUS_GET_FINAL_RANGE(x) OPUS_GET_FINAL_RANGE_REQUEST, __opus_check_uint_ptr(x)
00546 
00557 #define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x)
00558 
00571 #define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __opus_check_int_ptr(x)
00572 
00579 #define OPUS_SET_LSB_DEPTH(x) OPUS_SET_LSB_DEPTH_REQUEST, __opus_check_int(x)
00580 
00585 #define OPUS_GET_LSB_DEPTH(x) OPUS_GET_LSB_DEPTH_REQUEST, __opus_check_int_ptr(x)
00586 
00603 #define OPUS_SET_GAIN(x) OPUS_SET_GAIN_REQUEST, __opus_check_int(x)
00604 
00608 #define OPUS_GET_GAIN(x) OPUS_GET_GAIN_REQUEST, __opus_check_int_ptr(x)
00609 
00621 OPUS_EXPORT const char *opus_strerror(int error);
00622 
00627 OPUS_EXPORT const char *opus_get_version_string(void);
00630 #ifdef __cplusplus
00631 }
00632 #endif
00633 
00634 #endif /* OPUS_DEFINES_H */
 All Files Functions Typedefs Defines
For more information visit the Opus Website.