Alexandre Lision | 744f742 | 2013-09-25 11:39:37 -0400 | [diff] [blame] | 1 | /* Copyright (c) 2007-2008 CSIRO |
| 2 | Copyright (c) 2007-2009 Xiph.Org Foundation |
| 3 | Copyright (c) 2008 Gregory Maxwell |
| 4 | Written by Jean-Marc Valin and Gregory Maxwell */ |
| 5 | /** |
| 6 | @file celt.h |
| 7 | @brief Contains all the functions for encoding and decoding audio |
| 8 | */ |
| 9 | |
| 10 | /* |
| 11 | Redistribution and use in source and binary forms, with or without |
| 12 | modification, are permitted provided that the following conditions |
| 13 | are met: |
| 14 | |
| 15 | - Redistributions of source code must retain the above copyright |
| 16 | notice, this list of conditions and the following disclaimer. |
| 17 | |
| 18 | - Redistributions in binary form must reproduce the above copyright |
| 19 | notice, this list of conditions and the following disclaimer in the |
| 20 | documentation and/or other materials provided with the distribution. |
| 21 | |
| 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER |
| 26 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 33 | */ |
| 34 | |
| 35 | #ifndef CELT_H |
| 36 | #define CELT_H |
| 37 | |
| 38 | #include "opus_types.h" |
| 39 | #include "opus_defines.h" |
| 40 | #include "opus_custom.h" |
| 41 | #include "entenc.h" |
| 42 | #include "entdec.h" |
| 43 | #include "arch.h" |
| 44 | |
| 45 | #ifdef __cplusplus |
| 46 | extern "C" { |
| 47 | #endif |
| 48 | |
| 49 | #define CELTEncoder OpusCustomEncoder |
| 50 | #define CELTDecoder OpusCustomDecoder |
| 51 | #define CELTMode OpusCustomMode |
| 52 | |
| 53 | #define _celt_check_mode_ptr_ptr(ptr) ((ptr) + ((ptr) - (const CELTMode**)(ptr))) |
| 54 | |
| 55 | /* Encoder/decoder Requests */ |
| 56 | |
| 57 | #define CELT_SET_PREDICTION_REQUEST 10002 |
| 58 | /** Controls the use of interframe prediction. |
| 59 | 0=Independent frames |
| 60 | 1=Short term interframe prediction allowed |
| 61 | 2=Long term prediction allowed |
| 62 | */ |
| 63 | #define CELT_SET_PREDICTION(x) CELT_SET_PREDICTION_REQUEST, __opus_check_int(x) |
| 64 | |
| 65 | #define CELT_SET_INPUT_CLIPPING_REQUEST 10004 |
| 66 | #define CELT_SET_INPUT_CLIPPING(x) CELT_SET_INPUT_CLIPPING_REQUEST, __opus_check_int(x) |
| 67 | |
| 68 | #define CELT_GET_AND_CLEAR_ERROR_REQUEST 10007 |
| 69 | #define CELT_GET_AND_CLEAR_ERROR(x) CELT_GET_AND_CLEAR_ERROR_REQUEST, __opus_check_int_ptr(x) |
| 70 | |
| 71 | #define CELT_SET_CHANNELS_REQUEST 10008 |
| 72 | #define CELT_SET_CHANNELS(x) CELT_SET_CHANNELS_REQUEST, __opus_check_int(x) |
| 73 | |
| 74 | |
| 75 | /* Internal */ |
| 76 | #define CELT_SET_START_BAND_REQUEST 10010 |
| 77 | #define CELT_SET_START_BAND(x) CELT_SET_START_BAND_REQUEST, __opus_check_int(x) |
| 78 | |
| 79 | #define CELT_SET_END_BAND_REQUEST 10012 |
| 80 | #define CELT_SET_END_BAND(x) CELT_SET_END_BAND_REQUEST, __opus_check_int(x) |
| 81 | |
| 82 | #define CELT_GET_MODE_REQUEST 10015 |
| 83 | /** Get the CELTMode used by an encoder or decoder */ |
| 84 | #define CELT_GET_MODE(x) CELT_GET_MODE_REQUEST, _celt_check_mode_ptr_ptr(x) |
| 85 | |
| 86 | #define CELT_SET_SIGNALLING_REQUEST 10016 |
| 87 | #define CELT_SET_SIGNALLING(x) CELT_SET_SIGNALLING_REQUEST, __opus_check_int(x) |
| 88 | |
| 89 | |
| 90 | |
| 91 | /* Encoder stuff */ |
| 92 | |
| 93 | int celt_encoder_get_size(int channels); |
| 94 | |
| 95 | int celt_encode_with_ec(OpusCustomEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc); |
| 96 | |
| 97 | int celt_encoder_init(CELTEncoder *st, opus_int32 sampling_rate, int channels); |
| 98 | |
| 99 | |
| 100 | |
| 101 | /* Decoder stuff */ |
| 102 | |
| 103 | int celt_decoder_get_size(int channels); |
| 104 | |
| 105 | |
| 106 | int celt_decoder_init(CELTDecoder *st, opus_int32 sampling_rate, int channels); |
| 107 | |
| 108 | int celt_decode_with_ec(OpusCustomDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, opus_val16 * OPUS_RESTRICT pcm, int frame_size, ec_dec *dec); |
| 109 | |
| 110 | #define celt_encoder_ctl opus_custom_encoder_ctl |
| 111 | #define celt_decoder_ctl opus_custom_decoder_ctl |
| 112 | |
| 113 | #ifdef __cplusplus |
| 114 | } |
| 115 | #endif |
| 116 | |
| 117 | #endif /* CELT_H */ |