| OLD | NEW | 
|---|
| 1 /* Copyright (c) 2007-2008 CSIRO | 1 /* Copyright (c) 2007-2008 CSIRO | 
| 2    Copyright (c) 2007-2009 Xiph.Org Foundation | 2    Copyright (c) 2007-2009 Xiph.Org Foundation | 
| 3    Copyright (c) 2008 Gregory Maxwell | 3    Copyright (c) 2008 Gregory Maxwell | 
| 4    Written by Jean-Marc Valin and Gregory Maxwell */ | 4    Written by Jean-Marc Valin and Gregory Maxwell */ | 
| 5 /** | 5 /** | 
| 6   @file celt.h | 6   @file celt.h | 
| 7   @brief Contains all the functions for encoding and decoding audio | 7   @brief Contains all the functions for encoding and decoding audio | 
| 8  */ | 8  */ | 
| 9 | 9 | 
| 10 /* | 10 /* | 
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 59    float music_prob; | 59    float music_prob; | 
| 60    int        bandwidth; | 60    int        bandwidth; | 
| 61 }AnalysisInfo; | 61 }AnalysisInfo; | 
| 62 | 62 | 
| 63 #define __celt_check_mode_ptr_ptr(ptr) ((ptr) + ((ptr) - (const CELTMode**)(ptr)
     )) | 63 #define __celt_check_mode_ptr_ptr(ptr) ((ptr) + ((ptr) - (const CELTMode**)(ptr)
     )) | 
| 64 | 64 | 
| 65 #define __celt_check_analysis_ptr(ptr) ((ptr) + ((ptr) - (const AnalysisInfo*)(p
     tr))) | 65 #define __celt_check_analysis_ptr(ptr) ((ptr) + ((ptr) - (const AnalysisInfo*)(p
     tr))) | 
| 66 | 66 | 
| 67 /* Encoder/decoder Requests */ | 67 /* Encoder/decoder Requests */ | 
| 68 | 68 | 
|  | 69 /* Expose this option again when variable framesize actually works */ | 
|  | 70 #define OPUS_FRAMESIZE_VARIABLE              5010 /**< Optimize the frame size d
     ynamically */ | 
|  | 71 | 
|  | 72 | 
| 69 #define CELT_SET_PREDICTION_REQUEST    10002 | 73 #define CELT_SET_PREDICTION_REQUEST    10002 | 
| 70 /** Controls the use of interframe prediction. | 74 /** Controls the use of interframe prediction. | 
| 71     0=Independent frames | 75     0=Independent frames | 
| 72     1=Short term interframe prediction allowed | 76     1=Short term interframe prediction allowed | 
| 73     2=Long term prediction allowed | 77     2=Long term prediction allowed | 
| 74  */ | 78  */ | 
| 75 #define CELT_SET_PREDICTION(x) CELT_SET_PREDICTION_REQUEST, __opus_check_int(x) | 79 #define CELT_SET_PREDICTION(x) CELT_SET_PREDICTION_REQUEST, __opus_check_int(x) | 
| 76 | 80 | 
| 77 #define CELT_SET_INPUT_CLIPPING_REQUEST    10004 | 81 #define CELT_SET_INPUT_CLIPPING_REQUEST    10004 | 
| 78 #define CELT_SET_INPUT_CLIPPING(x) CELT_SET_INPUT_CLIPPING_REQUEST, __opus_check
     _int(x) | 82 #define CELT_SET_INPUT_CLIPPING(x) CELT_SET_INPUT_CLIPPING_REQUEST, __opus_check
     _int(x) | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 111 | 115 | 
| 112 #define OPUS_SET_ENERGY_MASK_REQUEST    10026 | 116 #define OPUS_SET_ENERGY_MASK_REQUEST    10026 | 
| 113 #define OPUS_SET_ENERGY_MASK(x) OPUS_SET_ENERGY_MASK_REQUEST, __opus_check_val16
     _ptr(x) | 117 #define OPUS_SET_ENERGY_MASK(x) OPUS_SET_ENERGY_MASK_REQUEST, __opus_check_val16
     _ptr(x) | 
| 114 | 118 | 
| 115 /* Encoder stuff */ | 119 /* Encoder stuff */ | 
| 116 | 120 | 
| 117 int celt_encoder_get_size(int channels); | 121 int celt_encoder_get_size(int channels); | 
| 118 | 122 | 
| 119 int celt_encode_with_ec(OpusCustomEncoder * OPUS_RESTRICT st, const opus_val16 *
      pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *
     enc); | 123 int celt_encode_with_ec(OpusCustomEncoder * OPUS_RESTRICT st, const opus_val16 *
      pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *
     enc); | 
| 120 | 124 | 
| 121 int celt_encoder_init(CELTEncoder *st, opus_int32 sampling_rate, int channels); | 125 int celt_encoder_init(CELTEncoder *st, opus_int32 sampling_rate, int channels, | 
|  | 126                       int arch); | 
| 122 | 127 | 
| 123 | 128 | 
| 124 | 129 | 
| 125 /* Decoder stuff */ | 130 /* Decoder stuff */ | 
| 126 | 131 | 
| 127 int celt_decoder_get_size(int channels); | 132 int celt_decoder_get_size(int channels); | 
| 128 | 133 | 
| 129 | 134 | 
| 130 int celt_decoder_init(CELTDecoder *st, opus_int32 sampling_rate, int channels); | 135 int celt_decoder_init(CELTDecoder *st, opus_int32 sampling_rate, int channels); | 
| 131 | 136 | 
| 132 int celt_decode_with_ec(OpusCustomDecoder * OPUS_RESTRICT st, const unsigned cha
     r *data, int len, opus_val16 * OPUS_RESTRICT pcm, int frame_size, ec_dec *dec); | 137 int celt_decode_with_ec(OpusCustomDecoder * OPUS_RESTRICT st, const unsigned cha
     r *data, int len, opus_val16 * OPUS_RESTRICT pcm, int frame_size, ec_dec *dec); | 
| 133 | 138 | 
| 134 #define celt_encoder_ctl opus_custom_encoder_ctl | 139 #define celt_encoder_ctl opus_custom_encoder_ctl | 
| 135 #define celt_decoder_ctl opus_custom_decoder_ctl | 140 #define celt_decoder_ctl opus_custom_decoder_ctl | 
| 136 | 141 | 
| 137 | 142 | 
| 138 #ifdef CUSTOM_MODES | 143 #ifdef CUSTOM_MODES | 
| 139 #define OPUS_CUSTOM_NOSTATIC | 144 #define OPUS_CUSTOM_NOSTATIC | 
| 140 #else | 145 #else | 
| 141 #define OPUS_CUSTOM_NOSTATIC static inline | 146 #define OPUS_CUSTOM_NOSTATIC static OPUS_INLINE | 
| 142 #endif | 147 #endif | 
| 143 | 148 | 
| 144 static const unsigned char trim_icdf[11] = {126, 124, 119, 109, 87, 41, 19, 9, 4
     , 2, 0}; | 149 static const unsigned char trim_icdf[11] = {126, 124, 119, 109, 87, 41, 19, 9, 4
     , 2, 0}; | 
| 145 /* Probs: NONE: 21.875%, LIGHT: 6.25%, NORMAL: 65.625%, AGGRESSIVE: 6.25% */ | 150 /* Probs: NONE: 21.875%, LIGHT: 6.25%, NORMAL: 65.625%, AGGRESSIVE: 6.25% */ | 
| 146 static const unsigned char spread_icdf[4] = {25, 23, 2, 0}; | 151 static const unsigned char spread_icdf[4] = {25, 23, 2, 0}; | 
| 147 | 152 | 
| 148 static const unsigned char tapset_icdf[3]={2,1,0}; | 153 static const unsigned char tapset_icdf[3]={2,1,0}; | 
| 149 | 154 | 
| 150 #ifdef CUSTOM_MODES | 155 #ifdef CUSTOM_MODES | 
| 151 static const unsigned char toOpusTable[20] = { | 156 static const unsigned char toOpusTable[20] = { | 
| 152       0xE0, 0xE8, 0xF0, 0xF8, | 157       0xE0, 0xE8, 0xF0, 0xF8, | 
| 153       0xC0, 0xC8, 0xD0, 0xD8, | 158       0xC0, 0xC8, 0xD0, 0xD8, | 
| 154       0xA0, 0xA8, 0xB0, 0xB8, | 159       0xA0, 0xA8, 0xB0, 0xB8, | 
| 155       0x00, 0x00, 0x00, 0x00, | 160       0x00, 0x00, 0x00, 0x00, | 
| 156       0x80, 0x88, 0x90, 0x98, | 161       0x80, 0x88, 0x90, 0x98, | 
| 157 }; | 162 }; | 
| 158 | 163 | 
| 159 static const unsigned char fromOpusTable[16] = { | 164 static const unsigned char fromOpusTable[16] = { | 
| 160       0x80, 0x88, 0x90, 0x98, | 165       0x80, 0x88, 0x90, 0x98, | 
| 161       0x40, 0x48, 0x50, 0x58, | 166       0x40, 0x48, 0x50, 0x58, | 
| 162       0x20, 0x28, 0x30, 0x38, | 167       0x20, 0x28, 0x30, 0x38, | 
| 163       0x00, 0x08, 0x10, 0x18 | 168       0x00, 0x08, 0x10, 0x18 | 
| 164 }; | 169 }; | 
| 165 | 170 | 
| 166 static inline int toOpus(unsigned char c) | 171 static OPUS_INLINE int toOpus(unsigned char c) | 
| 167 { | 172 { | 
| 168    int ret=0; | 173    int ret=0; | 
| 169    if (c<0xA0) | 174    if (c<0xA0) | 
| 170       ret = toOpusTable[c>>3]; | 175       ret = toOpusTable[c>>3]; | 
| 171    if (ret == 0) | 176    if (ret == 0) | 
| 172       return -1; | 177       return -1; | 
| 173    else | 178    else | 
| 174       return ret|(c&0x7); | 179       return ret|(c&0x7); | 
| 175 } | 180 } | 
| 176 | 181 | 
| 177 static inline int fromOpus(unsigned char c) | 182 static OPUS_INLINE int fromOpus(unsigned char c) | 
| 178 { | 183 { | 
| 179    if (c<0x80) | 184    if (c<0x80) | 
| 180       return -1; | 185       return -1; | 
| 181    else | 186    else | 
| 182       return fromOpusTable[(c>>3)-16] | (c&0x7); | 187       return fromOpusTable[(c>>3)-16] | (c&0x7); | 
| 183 } | 188 } | 
| 184 #endif /* CUSTOM_MODES */ | 189 #endif /* CUSTOM_MODES */ | 
| 185 | 190 | 
| 186 #define COMBFILTER_MAXPERIOD 1024 | 191 #define COMBFILTER_MAXPERIOD 1024 | 
| 187 #define COMBFILTER_MINPERIOD 15 | 192 #define COMBFILTER_MINPERIOD 15 | 
| 188 | 193 | 
| 189 extern const signed char tf_select_table[4][8]; | 194 extern const signed char tf_select_table[4][8]; | 
| 190 | 195 | 
| 191 int resampling_factor(opus_int32 rate); | 196 int resampling_factor(opus_int32 rate); | 
| 192 | 197 | 
| 193 void preemphasis(const opus_val16 * OPUS_RESTRICT pcmp, celt_sig * OPUS_RESTRICT
      inp, | 198 void celt_preemphasis(const opus_val16 * OPUS_RESTRICT pcmp, celt_sig * OPUS_RES
     TRICT inp, | 
| 194                         int N, int CC, int upsample, const opus_val16 *coef, cel
     t_sig *mem, int clip); | 199                         int N, int CC, int upsample, const opus_val16 *coef, cel
     t_sig *mem, int clip); | 
| 195 | 200 | 
| 196 void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, | 201 void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, | 
| 197       opus_val16 g0, opus_val16 g1, int tapset0, int tapset1, | 202       opus_val16 g0, opus_val16 g1, int tapset0, int tapset1, | 
| 198       const opus_val16 *window, int overlap); | 203       const opus_val16 *window, int overlap); | 
| 199 | 204 | 
| 200 void init_caps(const CELTMode *m,int *cap,int LM,int C); | 205 void init_caps(const CELTMode *m,int *cap,int LM,int C); | 
| 201 | 206 | 
| 202 #ifdef RESYNTH | 207 #ifdef RESYNTH | 
| 203 void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsample, c
     onst opus_val16 *coef, celt_sig *mem, celt_sig * OPUS_RESTRICT scratch); | 208 void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsample, c
     onst opus_val16 *coef, celt_sig *mem, celt_sig * OPUS_RESTRICT scratch); | 
| 204 | 209 | 
| 205 void compute_inv_mdcts(const CELTMode *mode, int shortBlocks, celt_sig *X, | 210 void compute_inv_mdcts(const CELTMode *mode, int shortBlocks, celt_sig *X, | 
| 206       celt_sig * OPUS_RESTRICT out_mem[], int C, int LM); | 211       celt_sig * OPUS_RESTRICT out_mem[], int C, int LM); | 
| 207 #endif | 212 #endif | 
| 208 | 213 | 
| 209 #ifdef __cplusplus | 214 #ifdef __cplusplus | 
| 210 } | 215 } | 
| 211 #endif | 216 #endif | 
| 212 | 217 | 
| 213 #endif /* CELT_H */ | 218 #endif /* CELT_H */ | 
| OLD | NEW | 
|---|