CELT 0.11.1
|
00001 /* Copyright (c) 2007-2008 CSIRO 00002 Copyright (c) 2007-2009 Xiph.Org Foundation 00003 Copyright (c) 2008 Gregory Maxwell 00004 Written by Jean-Marc Valin and Gregory Maxwell */ 00010 /* 00011 Redistribution and use in source and binary forms, with or without 00012 modification, are permitted provided that the following conditions 00013 are met: 00014 00015 - Redistributions of source code must retain the above copyright 00016 notice, this list of conditions and the following disclaimer. 00017 00018 - Redistributions in binary form must reproduce the above copyright 00019 notice, this list of conditions and the following disclaimer in the 00020 documentation and/or other materials provided with the distribution. 00021 00022 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00025 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 00026 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00027 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00028 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00029 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00030 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00031 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00032 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 */ 00034 00035 #ifndef CELT_H 00036 #define CELT_H 00037 00038 #include "celt_types.h" 00039 00040 #ifdef __cplusplus 00041 extern "C" { 00042 #endif 00043 00044 #if defined(__GNUC__) && defined(CELT_BUILD) 00045 #define EXPORT __attribute__ ((visibility ("default"))) 00046 #elif defined(WIN32) 00047 #define EXPORT __declspec(dllexport) 00048 #else 00049 #define EXPORT 00050 #endif 00051 00052 #define _celt_check_int(x) (((void)((x) == (celt_int32)0)), (celt_int32)(x)) 00053 #define _celt_check_mode_ptr_ptr(ptr) ((ptr) + ((ptr) - (CELTMode**)(ptr))) 00054 00055 /* Error codes */ 00057 #define CELT_OK 0 00058 00059 #define CELT_BAD_ARG -1 00060 00061 #define CELT_INVALID_MODE -2 00062 00063 #define CELT_INTERNAL_ERROR -3 00064 00065 #define CELT_CORRUPTED_DATA -4 00066 00067 #define CELT_UNIMPLEMENTED -5 00068 00069 #define CELT_INVALID_STATE -6 00070 00071 #define CELT_ALLOC_FAIL -7 00072 00073 /* Requests */ 00074 #define CELT_GET_MODE_REQUEST 1 00075 00076 #define CELT_GET_MODE(x) CELT_GET_MODE_REQUEST, _celt_check_mode_ptr_ptr(x) 00077 00078 #define CELT_SET_COMPLEXITY_REQUEST 2 00079 00080 #define CELT_SET_COMPLEXITY(x) CELT_SET_COMPLEXITY_REQUEST, _celt_check_int(x) 00081 00082 #define CELT_SET_PREDICTION_REQUEST 4 00083 00088 #define CELT_SET_PREDICTION(x) CELT_SET_PREDICTION_REQUEST, _celt_check_int(x) 00089 00090 #define CELT_SET_BITRATE_REQUEST 6 00091 00092 #define CELT_SET_BITRATE(x) CELT_SET_BITRATE_REQUEST, _celt_check_int(x) 00093 00095 #define CELT_RESET_STATE_REQUEST 8 00096 #define CELT_RESET_STATE CELT_RESET_STATE_REQUEST 00097 00098 #define CELT_SET_VBR_CONSTRAINT_REQUEST 10 00099 #define CELT_SET_VBR_CONSTRAINT(x) CELT_SET_VBR_CONSTRAINT_REQUEST, _celt_check_int(x) 00100 00101 #define CELT_SET_VBR_REQUEST 12 00102 #define CELT_SET_VBR(x) CELT_SET_VBR_REQUEST, _celt_check_int(x) 00103 00104 #define CELT_SET_INPUT_CLIPPING_REQUEST 14 00105 #define CELT_SET_INPUT_CLIPPING(x) CELT_SET_INPUT_CLIPPING_REQUEST, _celt_check_int(x) 00106 00107 #define CELT_SET_START_BAND_REQUEST 10000 00108 #define CELT_SET_START_BAND(x) CELT_SET_START_BAND_REQUEST, _celt_check_int(x) 00109 00110 #define CELT_SET_END_BAND_REQUEST 10001 00111 #define CELT_SET_END_BAND(x) CELT_SET_END_BAND_REQUEST, _celt_check_int(x) 00112 00113 #define CELT_SET_CHANNELS_REQUEST 10002 00114 #define CELT_SET_CHANNELS(x) CELT_SET_CHANNELS_REQUEST, _celt_check_int(x) 00115 00117 #define CELT_GET_LOOKAHEAD 1001 00118 00119 #define CELT_GET_SAMPLE_RATE 1003 00120 00122 #define CELT_GET_BITSTREAM_VERSION 2000 00123 00124 00130 typedef struct CELTEncoder CELTEncoder; 00131 00135 typedef struct CELTDecoder CELTDecoder; 00136 00141 typedef struct CELTMode CELTMode; 00142 00143 00145 /* @{ */ 00146 00147 /* Mode calls */ 00148 00158 EXPORT CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error); 00159 00164 EXPORT void celt_mode_destroy(CELTMode *mode); 00165 00167 EXPORT int celt_mode_info(const CELTMode *mode, int request, celt_int32 *value); 00168 00169 /* Encoder stuff */ 00170 00171 EXPORT int celt_encoder_get_size(int channels); 00172 00173 EXPORT int celt_encoder_get_size_custom(const CELTMode *mode, int channels); 00174 00181 EXPORT CELTEncoder *celt_encoder_create(int sampling_rate, int channels, int *error); 00182 00192 EXPORT CELTEncoder *celt_encoder_create_custom(const CELTMode *mode, int channels, int *error); 00193 00194 EXPORT CELTEncoder *celt_encoder_init(CELTEncoder *st, int sampling_rate, int channels, int *error); 00195 00196 EXPORT CELTEncoder *celt_encoder_init_custom(CELTEncoder *st, const CELTMode *mode, int channels, int *error); 00197 00201 EXPORT void celt_encoder_destroy(CELTEncoder *st); 00202 00221 EXPORT int celt_encode_float(CELTEncoder *st, const float *pcm, int frame_size, unsigned char *compressed, int maxCompressedBytes); 00222 00237 EXPORT int celt_encode(CELTEncoder *st, const celt_int16 *pcm, int frame_size, unsigned char *compressed, int maxCompressedBytes); 00238 00245 EXPORT int celt_encoder_ctl(CELTEncoder * st, int request, ...); 00246 00247 /* Decoder stuff */ 00248 00249 EXPORT int celt_decoder_get_size(int channels); 00250 00251 EXPORT int celt_decoder_get_size_custom(const CELTMode *mode, int channels); 00252 00261 EXPORT CELTDecoder *celt_decoder_create(int sampling_rate, int channels, int *error); 00262 00271 EXPORT CELTDecoder *celt_decoder_create_custom(const CELTMode *mode, int channels, int *error); 00272 00273 EXPORT CELTDecoder *celt_decoder_init(CELTDecoder *st, int sampling_rate, int channels, int *error); 00274 00275 EXPORT CELTDecoder *celt_decoder_init_custom(CELTDecoder *st, const CELTMode *mode, int channels, int *error); 00276 00280 EXPORT void celt_decoder_destroy(CELTDecoder *st); 00281 00291 EXPORT int celt_decode_float(CELTDecoder *st, const unsigned char *data, int len, float *pcm, int frame_size); 00292 00302 EXPORT int celt_decode(CELTDecoder *st, const unsigned char *data, int len, celt_int16 *pcm, int frame_size); 00303 00310 EXPORT int celt_decoder_ctl(CELTDecoder * st, int request, ...); 00311 00312 00317 EXPORT const char *celt_strerror(int error); 00318 00319 /* @} */ 00320 00321 00322 #ifdef __cplusplus 00323 } 00324 #endif 00325 00326 #endif /*CELT_H */