38 #include "opus_types.h"
39 #include "opus_defines.h"
40 #include "opus_custom.h"
49 #define CELTEncoder OpusCustomEncoder
50 #define CELTDecoder OpusCustomDecoder
51 #define CELTMode OpusCustomMode
64 float activity_probability;
66 unsigned char leak_boost[LEAK_BANDS];
74 #define __celt_check_mode_ptr_ptr(ptr) ((ptr) + ((ptr) - (const CELTMode**)(ptr)))
76 #define __celt_check_analysis_ptr(ptr) ((ptr) + ((ptr) - (const AnalysisInfo*)(ptr)))
78 #define __celt_check_silkinfo_ptr(ptr) ((ptr) + ((ptr) - (const SILKInfo*)(ptr)))
83 #define CELT_SET_PREDICTION_REQUEST 10002
89 #define CELT_SET_PREDICTION(x) CELT_SET_PREDICTION_REQUEST, __opus_check_int(x)
91 #define CELT_SET_INPUT_CLIPPING_REQUEST 10004
92 #define CELT_SET_INPUT_CLIPPING(x) CELT_SET_INPUT_CLIPPING_REQUEST, __opus_check_int(x)
94 #define CELT_GET_AND_CLEAR_ERROR_REQUEST 10007
95 #define CELT_GET_AND_CLEAR_ERROR(x) CELT_GET_AND_CLEAR_ERROR_REQUEST, __opus_check_int_ptr(x)
97 #define CELT_SET_CHANNELS_REQUEST 10008
98 #define CELT_SET_CHANNELS(x) CELT_SET_CHANNELS_REQUEST, __opus_check_int(x)
102 #define CELT_SET_START_BAND_REQUEST 10010
103 #define CELT_SET_START_BAND(x) CELT_SET_START_BAND_REQUEST, __opus_check_int(x)
105 #define CELT_SET_END_BAND_REQUEST 10012
106 #define CELT_SET_END_BAND(x) CELT_SET_END_BAND_REQUEST, __opus_check_int(x)
108 #define CELT_GET_MODE_REQUEST 10015
110 #define CELT_GET_MODE(x) CELT_GET_MODE_REQUEST, __celt_check_mode_ptr_ptr(x)
112 #define CELT_SET_SIGNALLING_REQUEST 10016
113 #define CELT_SET_SIGNALLING(x) CELT_SET_SIGNALLING_REQUEST, __opus_check_int(x)
115 #define CELT_SET_TONALITY_REQUEST 10018
116 #define CELT_SET_TONALITY(x) CELT_SET_TONALITY_REQUEST, __opus_check_int(x)
117 #define CELT_SET_TONALITY_SLOPE_REQUEST 10020
118 #define CELT_SET_TONALITY_SLOPE(x) CELT_SET_TONALITY_SLOPE_REQUEST, __opus_check_int(x)
120 #define CELT_SET_ANALYSIS_REQUEST 10022
121 #define CELT_SET_ANALYSIS(x) CELT_SET_ANALYSIS_REQUEST, __celt_check_analysis_ptr(x)
123 #define OPUS_SET_LFE_REQUEST 10024
124 #define OPUS_SET_LFE(x) OPUS_SET_LFE_REQUEST, __opus_check_int(x)
126 #define OPUS_SET_ENERGY_MASK_REQUEST 10026
127 #define OPUS_SET_ENERGY_MASK(x) OPUS_SET_ENERGY_MASK_REQUEST, __opus_check_val16_ptr(x)
129 #define CELT_SET_SILK_INFO_REQUEST 10028
130 #define CELT_SET_SILK_INFO(x) CELT_SET_SILK_INFO_REQUEST, __celt_check_silkinfo_ptr(x)
134 int celt_encoder_get_size(
int channels);
136 int celt_encode_with_ec(
OpusCustomEncoder * OPUS_RESTRICT st,
const opus_val16 * pcm,
int frame_size,
unsigned char *compressed,
int nbCompressedBytes, ec_enc *enc);
138 int celt_encoder_init(CELTEncoder *st, opus_int32 sampling_rate,
int channels,
145 int celt_decoder_get_size(
int channels);
148 int celt_decoder_init(CELTDecoder *st, opus_int32 sampling_rate,
int channels);
150 int celt_decode_with_ec(
OpusCustomDecoder * OPUS_RESTRICT st,
const unsigned char *data,
151 int len, opus_val16 * OPUS_RESTRICT pcm,
int frame_size, ec_dec *dec,
int accum);
153 #define celt_encoder_ctl opus_custom_encoder_ctl
154 #define celt_decoder_ctl opus_custom_decoder_ctl
158 #define OPUS_CUSTOM_NOSTATIC
160 #define OPUS_CUSTOM_NOSTATIC static OPUS_INLINE
163 static const unsigned char trim_icdf[11] = {126, 124, 119, 109, 87, 41, 19, 9, 4, 2, 0};
165 static const unsigned char spread_icdf[4] = {25, 23, 2, 0};
167 static const unsigned char tapset_icdf[3]={2,1,0};
170 static const unsigned char toOpusTable[20] = {
171 0xE0, 0xE8, 0xF0, 0xF8,
172 0xC0, 0xC8, 0xD0, 0xD8,
173 0xA0, 0xA8, 0xB0, 0xB8,
174 0x00, 0x00, 0x00, 0x00,
175 0x80, 0x88, 0x90, 0x98,
178 static const unsigned char fromOpusTable[16] = {
179 0x80, 0x88, 0x90, 0x98,
180 0x40, 0x48, 0x50, 0x58,
181 0x20, 0x28, 0x30, 0x38,
182 0x00, 0x08, 0x10, 0x18
185 static OPUS_INLINE
int toOpus(
unsigned char c)
189 ret = toOpusTable[c>>3];
196 static OPUS_INLINE
int fromOpus(
unsigned char c)
201 return fromOpusTable[(c>>3)-16] | (c&0x7);
205 #define COMBFILTER_MAXPERIOD 1024
206 #define COMBFILTER_MINPERIOD 15
208 extern const signed char tf_select_table[4][8];
210 int resampling_factor(opus_int32 rate);
212 void celt_preemphasis(
const opus_val16 * OPUS_RESTRICT pcmp, celt_sig * OPUS_RESTRICT inp,
213 int N,
int CC,
int upsample,
const opus_val16 *coef, celt_sig *mem,
int clip);
215 void comb_filter(opus_val32 *y, opus_val32 *x,
int T0,
int T1,
int N,
216 opus_val16 g0, opus_val16 g1,
int tapset0,
int tapset1,
217 const opus_val16 *window,
int overlap,
int arch);
219 #ifdef NON_STATIC_COMB_FILTER_CONST_C
220 void comb_filter_const_c(opus_val32 *y, opus_val32 *x,
int T,
int N,
221 opus_val16 g10, opus_val16 g11, opus_val16 g12);
224 #ifndef OVERRIDE_COMB_FILTER_CONST
225 # define comb_filter_const(y, x, T, N, g10, g11, g12, arch) \
226 ((void)(arch),comb_filter_const_c(y, x, T, N, g10, g11, g12))
229 void init_caps(
const CELTMode *m,
int *cap,
int LM,
int C);
232 void deemphasis(celt_sig *in[], opus_val16 *pcm,
int N,
int C,
int downsample,
const opus_val16 *coef, celt_sig *mem);
233 void celt_synthesis(
const CELTMode *mode, celt_norm *X, celt_sig * out_syn[],
234 opus_val16 *oldBandE,
int start,
int effEnd,
int C,
int CC,
int isTransient,
235 int LM,
int downsample,
int silence);