| 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_Hcxx . . $ `external/opusfile/opus/celt/celt.h:36:9`! |
| 37 | |
| 38 | #include "opus_types.h"cxx . . $ `<file>/external/opusfile/opus/opus_types.h`/ |
| 39 | #include "opus_defines.h"cxx . . $ `<file>/external/opusfile/opus/opus_defines.h`/ |
| 40 | #include "opus_custom.h"cxx . . $ `<file>/external/opusfile/opus/opus_custom.h`/ |
| 41 | #include "entenc.h"cxx . . $ `<file>/external/opusfile/opus/celt/entenc.h`/ |
| 42 | #include "entdec.h"cxx . . $ `<file>/external/opusfile/opus/celt/entdec.h`/ |
| 43 | #include "arch.h"cxx . . $ `<file>/external/opusfile/opus/celt/arch.h`/ |
| 44 | |
| 45 | #ifdef __cplusplus |
| 46 | extern "C" { |
| 47 | #endif |
| 48 | |
| 49 | #define CELTEncodercxx . . $ `external/opusfile/opus/celt/celt.h:49:9`! OpusCustomEncoder |
| 50 | #define CELTDecodercxx . . $ `external/opusfile/opus/celt/celt.h:50:9`! OpusCustomDecoder |
| 51 | #define CELTModecxx . . $ `external/opusfile/opus/celt/celt.h:51:9`! OpusCustomMode |
| 52 | |
| 53 | #define LEAK_BANDScxx . . $ `external/opusfile/opus/celt/celt.h:53:9`! 19 |
| 54 | |
| 55 | typedef structcxx . . $ $anonymous_type_a73490e6e97f56b0_0# { |
| 56 | int validcxx . . $ $anonymous_type_a73490e6e97f56b0_0#valid.; |
| 57 | float tonalitycxx . . $ $anonymous_type_a73490e6e97f56b0_0#tonality.; |
| 58 | float tonality_slopecxx . . $ $anonymous_type_a73490e6e97f56b0_0#tonality_slope.; |
| 59 | float noisinesscxx . . $ $anonymous_type_a73490e6e97f56b0_0#noisiness.; |
| 60 | float activitycxx . . $ $anonymous_type_a73490e6e97f56b0_0#activity.; |
| 61 | float music_probcxx . . $ $anonymous_type_a73490e6e97f56b0_0#music_prob.; |
| 62 | float music_prob_mincxx . . $ $anonymous_type_a73490e6e97f56b0_0#music_prob_min.; |
| 63 | float music_prob_maxcxx . . $ $anonymous_type_a73490e6e97f56b0_0#music_prob_max.; |
| 64 | int bandwidthcxx . . $ $anonymous_type_a73490e6e97f56b0_0#bandwidth.; |
| 65 | float activity_probabilitycxx . . $ $anonymous_type_a73490e6e97f56b0_0#activity_probability.; |
| 66 | float max_pitch_ratiocxx . . $ $anonymous_type_a73490e6e97f56b0_0#max_pitch_ratio.; |
| 67 | /* Store as Q6 char to save space. */ |
| 68 | unsigned char leak_boostcxx . . $ $anonymous_type_a73490e6e97f56b0_0#leak_boost.[LEAK_BANDScxx . . $ `external/opusfile/opus/celt/celt.h:53:9`!]; |
| 69 | } AnalysisInfocxx . . $ AnalysisInfo#; |
| 70 | |
| 71 | typedef structcxx . . $ $anonymous_type_a73490e6e97f56b0_1# { |
| 72 | int signalTypecxx . . $ $anonymous_type_a73490e6e97f56b0_1#signalType.; |
| 73 | int offsetcxx . . $ $anonymous_type_a73490e6e97f56b0_1#offset.; |
| 74 | } SILKInfocxx . . $ SILKInfo#; |
| 75 | |
| 76 | #define __celt_check_mode_ptr_ptrcxx . . $ `external/opusfile/opus/celt/celt.h:76:9`!(ptr) ((ptr) + ((ptr) - (const CELTModecxx . . $ `external/opusfile/opus/celt/celt.h:51:9`!**)(ptr))) |
| 77 | |
| 78 | #define __celt_check_analysis_ptrcxx . . $ `external/opusfile/opus/celt/celt.h:78:9`!(ptr) ((ptr) + ((ptr) - (const AnalysisInfo*)(ptr))) |
| 79 | |
| 80 | #define __celt_check_silkinfo_ptrcxx . . $ `external/opusfile/opus/celt/celt.h:80:9`!(ptr) ((ptr) + ((ptr) - (const SILKInfo*)(ptr))) |
| 81 | |
| 82 | /* Encoder/decoder Requests */ |
| 83 | |
| 84 | |
| 85 | #define CELT_SET_PREDICTION_REQUESTcxx . . $ `external/opusfile/opus/celt/celt.h:85:9`! 10002 |
| 86 | /** Controls the use of interframe prediction. |
| 87 | 0=Independent frames |
| 88 | 1=Short term interframe prediction allowed |
| 89 | 2=Long term prediction allowed |
| 90 | */ |
| 91 | #define CELT_SET_PREDICTIONcxx . . $ `external/opusfile/opus/celt/celt.h:91:9`!(x) CELT_SET_PREDICTION_REQUEST, __opus_check_int(x) |
| 92 | |
| 93 | #define CELT_SET_INPUT_CLIPPING_REQUESTcxx . . $ `external/opusfile/opus/celt/celt.h:93:9`! 10004 |
| 94 | #define CELT_SET_INPUT_CLIPPINGcxx . . $ `external/opusfile/opus/celt/celt.h:94:9`!(x) CELT_SET_INPUT_CLIPPING_REQUEST, __opus_check_int(x) |
| 95 | |
| 96 | #define CELT_GET_AND_CLEAR_ERROR_REQUESTcxx . . $ `external/opusfile/opus/celt/celt.h:96:9`! 10007 |
| 97 | #define CELT_GET_AND_CLEAR_ERRORcxx . . $ `external/opusfile/opus/celt/celt.h:97:9`!(x) CELT_GET_AND_CLEAR_ERROR_REQUEST, __opus_check_int_ptr(x) |
| 98 | |
| 99 | #define CELT_SET_CHANNELS_REQUESTcxx . . $ `external/opusfile/opus/celt/celt.h:99:9`! 10008 |
| 100 | #define CELT_SET_CHANNELScxx . . $ `external/opusfile/opus/celt/celt.h:100:9`!(x) CELT_SET_CHANNELS_REQUESTcxx . . $ `external/opusfile/opus/celt/celt.h:99:9`!, __opus_check_intcxx . . $ `external/opusfile/opus/opus_defines.h:177:9`!(x) |
| 101 | |
| 102 | |
| 103 | /* Internal */ |
| 104 | #define CELT_SET_START_BAND_REQUESTcxx . . $ `external/opusfile/opus/celt/celt.h:104:9`! 10010 |
| 105 | #define CELT_SET_START_BANDcxx . . $ `external/opusfile/opus/celt/celt.h:105:9`!(x) CELT_SET_START_BAND_REQUESTcxx . . $ `external/opusfile/opus/celt/celt.h:104:9`!, __opus_check_intcxx . . $ `external/opusfile/opus/opus_defines.h:177:9`!(x) |
| 106 | |
| 107 | #define CELT_SET_END_BAND_REQUESTcxx . . $ `external/opusfile/opus/celt/celt.h:107:9`! 10012 |
| 108 | #define CELT_SET_END_BANDcxx . . $ `external/opusfile/opus/celt/celt.h:108:9`!(x) CELT_SET_END_BAND_REQUESTcxx . . $ `external/opusfile/opus/celt/celt.h:107:9`!, __opus_check_intcxx . . $ `external/opusfile/opus/opus_defines.h:177:9`!(x) |
| 109 | |
| 110 | #define CELT_GET_MODE_REQUESTcxx . . $ `external/opusfile/opus/celt/celt.h:110:9`! 10015 |
| 111 | /** Get the CELTMode used by an encoder or decoder */ |
| 112 | #define CELT_GET_MODEcxx . . $ `external/opusfile/opus/celt/celt.h:112:9`!(x) CELT_GET_MODE_REQUESTcxx . . $ `external/opusfile/opus/celt/celt.h:110:9`!, __celt_check_mode_ptr_ptrcxx . . $ `external/opusfile/opus/celt/celt.h:76:9`!(x) |
| 113 | |
| 114 | #define CELT_SET_SIGNALLING_REQUESTcxx . . $ `external/opusfile/opus/celt/celt.h:114:9`! 10016 |
| 115 | #define CELT_SET_SIGNALLINGcxx . . $ `external/opusfile/opus/celt/celt.h:115:9`!(x) CELT_SET_SIGNALLING_REQUESTcxx . . $ `external/opusfile/opus/celt/celt.h:114:9`!, __opus_check_intcxx . . $ `external/opusfile/opus/opus_defines.h:177:9`!(x) |
| 116 | |
| 117 | #define CELT_SET_TONALITY_REQUESTcxx . . $ `external/opusfile/opus/celt/celt.h:117:9`! 10018 |
| 118 | #define CELT_SET_TONALITYcxx . . $ `external/opusfile/opus/celt/celt.h:118:9`!(x) CELT_SET_TONALITY_REQUEST, __opus_check_int(x) |
| 119 | #define CELT_SET_TONALITY_SLOPE_REQUESTcxx . . $ `external/opusfile/opus/celt/celt.h:119:9`! 10020 |
| 120 | #define CELT_SET_TONALITY_SLOPEcxx . . $ `external/opusfile/opus/celt/celt.h:120:9`!(x) CELT_SET_TONALITY_SLOPE_REQUEST, __opus_check_int(x) |
| 121 | |
| 122 | #define CELT_SET_ANALYSIS_REQUESTcxx . . $ `external/opusfile/opus/celt/celt.h:122:9`! 10022 |
| 123 | #define CELT_SET_ANALYSIScxx . . $ `external/opusfile/opus/celt/celt.h:123:9`!(x) CELT_SET_ANALYSIS_REQUEST, __celt_check_analysis_ptr(x) |
| 124 | |
| 125 | #define OPUS_SET_LFE_REQUESTcxx . . $ `external/opusfile/opus/celt/celt.h:125:9`! 10024 |
| 126 | #define OPUS_SET_LFEcxx . . $ `external/opusfile/opus/celt/celt.h:126:9`!(x) OPUS_SET_LFE_REQUEST, __opus_check_int(x) |
| 127 | |
| 128 | #define OPUS_SET_ENERGY_MASK_REQUESTcxx . . $ `external/opusfile/opus/celt/celt.h:128:9`! 10026 |
| 129 | #define OPUS_SET_ENERGY_MASKcxx . . $ `external/opusfile/opus/celt/celt.h:129:9`!(x) OPUS_SET_ENERGY_MASK_REQUEST, __opus_check_val16_ptr(x) |
| 130 | |
| 131 | #define CELT_SET_SILK_INFO_REQUESTcxx . . $ `external/opusfile/opus/celt/celt.h:131:9`! 10028 |
| 132 | #define CELT_SET_SILK_INFOcxx . . $ `external/opusfile/opus/celt/celt.h:132:9`!(x) CELT_SET_SILK_INFO_REQUEST, __celt_check_silkinfo_ptr(x) |
| 133 | |
| 134 | /* Encoder stuff */ |
| 135 | |
| 136 | int celt_encoder_get_sizecxx . . $ celt_encoder_get_size(7864480464b09eea).(int channels); |
| 137 | |
| 138 | int celt_encode_with_eccxx . . $ celt_encode_with_ec(cbb5a56e18a81261).(OpusCustomEncodercxx . . $ OpusCustomEncoder# * OPUS_RESTRICTcxx . . $ `external/opusfile/opus/opus_defines.h:98:10`! st, const opus_val16cxx . . $ opus_val16# * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enccxx . . $ ec_enc# *enc); |
| 139 | |
| 140 | int celt_encoder_initcxx . . $ celt_encoder_init(cf1de4845c2e84fe).(CELTEncodercxx . . $ OpusCustomEncoder# *st, opus_int32cxx . . $ opus_int32# sampling_rate, int channels, |
| 141 | int arch); |
| 142 | |
| 143 | |
| 144 | |
| 145 | /* Decoder stuff */ |
| 146 | |
| 147 | int celt_decoder_get_sizecxx . . $ celt_decoder_get_size(7864480464b09eea).(int channels); |
| 148 | |
| 149 | |
| 150 | int celt_decoder_initcxx . . $ celt_decoder_init(27423e1ca630a3b0).(CELTDecodercxx . . $ `external/opusfile/opus/celt/celt.h:50:9`! *st, opus_int32cxx . . $ opus_int32# sampling_rate, int channels); |
| 151 | |
| 152 | int celt_decode_with_eccxx . . $ celt_decode_with_ec(f094f6999cb7947e).(OpusCustomDecodercxx . . $ OpusCustomDecoder# * OPUS_RESTRICTcxx . . $ `external/opusfile/opus/opus_defines.h:98:10`! st, const unsigned char *data, |
| 153 | int len, opus_val16cxx . . $ opus_val16# * OPUS_RESTRICTcxx . . $ `external/opusfile/opus/opus_defines.h:98:10`! pcm, int frame_size, ec_deccxx . . $ ec_dec# *dec, int accum); |
| 154 | |
| 155 | #define celt_encoder_ctlcxx . . $ `external/opusfile/opus/celt/celt.h:155:9`! opus_custom_encoder_ctl |
| 156 | #define celt_decoder_ctlcxx . . $ `external/opusfile/opus/celt/celt.h:156:9`! opus_custom_decoder_ctl |
| 157 | |
| 158 | |
| 159 | #ifdef CUSTOM_MODES |
| 160 | #define OPUS_CUSTOM_NOSTATIC |
| 161 | #else |
| 162 | #define OPUS_CUSTOM_NOSTATICcxx . . $ `external/opusfile/opus/celt/celt.h:162:9`! static OPUS_INLINE |
| 163 | #endif |
| 164 | |
| 165 | static const unsigned char trim_icdfcxx . . $ trim_icdf.[11] = {126, 124, 119, 109, 87, 41, 19, 9, 4, 2, 0}; |
| 166 | /* Probs: NONE: 21.875%, LIGHT: 6.25%, NORMAL: 65.625%, AGGRESSIVE: 6.25% */ |
| 167 | static const unsigned char spread_icdfcxx . . $ spread_icdf.[4] = {25, 23, 2, 0}; |
| 168 | |
| 169 | static const unsigned char tapset_icdfcxx . . $ tapset_icdf.[3]={2,1,0}; |
| 170 | |
| 171 | #ifdef CUSTOM_MODES |
| 172 | static const unsigned char toOpusTable[20] = { |
| 173 | 0xE0, 0xE8, 0xF0, 0xF8, |
| 174 | 0xC0, 0xC8, 0xD0, 0xD8, |
| 175 | 0xA0, 0xA8, 0xB0, 0xB8, |
| 176 | 0x00, 0x00, 0x00, 0x00, |
| 177 | 0x80, 0x88, 0x90, 0x98, |
| 178 | }; |
| 179 | |
| 180 | static const unsigned char fromOpusTable[16] = { |
| 181 | 0x80, 0x88, 0x90, 0x98, |
| 182 | 0x40, 0x48, 0x50, 0x58, |
| 183 | 0x20, 0x28, 0x30, 0x38, |
| 184 | 0x00, 0x08, 0x10, 0x18 |
| 185 | }; |
| 186 | |
| 187 | static OPUS_INLINE int toOpus(unsigned char c) |
| 188 | { |
| 189 | int ret=0; |
| 190 | if (c<0xA0) |
| 191 | ret = toOpusTable[c>>3]; |
| 192 | if (ret == 0) |
| 193 | return -1; |
| 194 | else |
| 195 | return ret|(c&0x7); |
| 196 | } |
| 197 | |
| 198 | static OPUS_INLINE int fromOpus(unsigned char c) |
| 199 | { |
| 200 | if (c<0x80) |
| 201 | return -1; |
| 202 | else |
| 203 | return fromOpusTable[(c>>3)-16] | (c&0x7); |
| 204 | } |
| 205 | #endif /* CUSTOM_MODES */ |
| 206 | |
| 207 | #define COMBFILTER_MAXPERIODcxx . . $ `external/opusfile/opus/celt/celt.h:207:9`! 1024 |
| 208 | #define COMBFILTER_MINPERIODcxx . . $ `external/opusfile/opus/celt/celt.h:208:9`! 15 |
| 209 | |
| 210 | extern const signed char tf_select_tablecxx . . $ tf_select_table.[4][8]; |
| 211 | |
| 212 | #if defined(ENABLE_HARDENINGcxx . . $ `external/opusfile/opus/opus__config.h:23:9`!) || defined(ENABLE_ASSERTIONS) |
| 213 | void validate_celt_decodercxx . . $ validate_celt_decoder(ebfe4033180b6457).(CELTDecodercxx . . $ OpusCustomDecoder# *st); |
| 214 | #define VALIDATE_CELT_DECODERcxx . . $ `external/opusfile/opus/celt/celt.h:214:9`!(st) validate_celt_decoder(st) |
| 215 | #else |
| 216 | #define VALIDATE_CELT_DECODER(st) |
| 217 | #endif |
| 218 | |
| 219 | int resampling_factorcxx . . $ resampling_factor(7864480464b09eea).(opus_int32cxx . . $ opus_int32# rate); |
| 220 | |
| 221 | void celt_preemphasiscxx . . $ celt_preemphasis(383154fc753de063).(const opus_val16cxx . . $ opus_val16# * OPUS_RESTRICTcxx . . $ `external/opusfile/opus/opus_defines.h:98:10`! pcmp, celt_sigcxx . . $ celt_sig# * OPUS_RESTRICTcxx . . $ `external/opusfile/opus/opus_defines.h:98:10`! inp, |
| 222 | int N, int CC, int upsample, const opus_val16cxx . . $ opus_val16# *coef, celt_sigcxx . . $ celt_sig# *mem, int clip); |
| 223 | |
| 224 | void comb_filtercxx . . $ comb_filter(4a0820a333c3cac3).(opus_val32cxx . . $ opus_val32# *y, opus_val32cxx . . $ opus_val32# *x, int T0, int T1, int N, |
| 225 | opus_val16cxx . . $ opus_val16# g0, opus_val16cxx . . $ opus_val16# g1, int tapset0, int tapset1, |
| 226 | const opus_val16cxx . . $ opus_val16# *window, int overlap, int arch); |
| 227 | |
| 228 | #ifdef NON_STATIC_COMB_FILTER_CONST_C |
| 229 | void comb_filter_const_c(opus_val32 *y, opus_val32 *x, int T, int N, |
| 230 | opus_val16 g10, opus_val16 g11, opus_val16 g12); |
| 231 | #endif |
| 232 | |
| 233 | #ifndef OVERRIDE_COMB_FILTER_CONST |
| 234 | # define comb_filter_constcxx . . $ `external/opusfile/opus/celt/celt.h:234:10`!(y, x, T, N, g10, g11, g12, arch) \ |
| 235 | ((void)(arch),comb_filter_const_c(y, x, T, N, g10, g11, g12)) |
| 236 | #endif |
| 237 | |
| 238 | void init_capscxx . . $ init_caps(54d4a0d7ae0b5d7e).(const CELTModecxx . . $ `external/opusfile/opus/celt/celt.h:51:9`! *m,int *cap,int LM,int C); |
| 239 | |
| 240 | #ifdef RESYNTH |
| 241 | void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsample, const opus_val16 *coef, celt_sig *mem); |
| 242 | void celt_synthesis(const CELTMode *mode, celt_norm *X, celt_sig * out_syn[], |
| 243 | opus_val16 *oldBandE, int start, int effEnd, int C, int CC, int isTransient, |
| 244 | int LM, int downsample, int silence); |
| 245 | #endif |
| 246 | |
| 247 | #ifdef __cplusplus |
| 248 | } |
| 249 | #endif |
| 250 | |
| 251 | #endif /* CELT_H */ |