diff --git a/ilbc/decode.c b/ilbc/decode.c index 827532c568..e276353ab5 100644 --- a/ilbc/decode.c +++ b/ilbc/decode.c @@ -32,6 +32,9 @@ #include "swap_bytes.h" #endif +/* Export all functions defined in this file. */ +#pragma GCC visibility push(default) + /*----------------------------------------------------------------* * main decoder function *---------------------------------------------------------------*/ diff --git a/ilbc/defines.h b/ilbc/defines.h index bdeba0194a..a43774ea3f 100644 --- a/ilbc/defines.h +++ b/ilbc/defines.h @@ -19,39 +19,10 @@ #define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DEFINES_H_ #include "typedefs.h" +#include "ilbc.h" #include "signal_processing_library.h" #include -/* general codec settings */ - -#define FS 8000 -#define BLOCKL_20MS 160 -#define BLOCKL_30MS 240 -#define BLOCKL_MAX 240 -#define NSUB_20MS 4 -#define NSUB_30MS 6 -#define NSUB_MAX 6 -#define NASUB_20MS 2 -#define NASUB_30MS 4 -#define NASUB_MAX 4 -#define SUBL 40 -#define STATE_LEN 80 -#define STATE_SHORT_LEN_30MS 58 -#define STATE_SHORT_LEN_20MS 57 - -/* LPC settings */ - -#define LPC_FILTERORDER 10 -#define LPC_LOOKBACK 60 -#define LPC_N_20MS 1 -#define LPC_N_30MS 2 -#define LPC_N_MAX 2 -#define LPC_ASYMDIFF 20 -#define LSF_NSPLIT 3 -#define LSF_NUMBER_OF_STEPS 4 -#define LPC_HALFORDER 5 -#define COS_GRID_POINTS 60 - /* cb settings */ #define CB_NSTAGES 3 @@ -63,31 +34,6 @@ #define CB_MAXGAIN_FIXQ6 83 /* error = -0.24% */ #define CB_MAXGAIN_FIXQ14 21299 -/* enhancer */ - -#define ENH_BLOCKL 80 /* block length */ -#define ENH_BLOCKL_HALF (ENH_BLOCKL/2) -#define ENH_HL 3 /* 2*ENH_HL+1 is number blocks - in said second sequence */ -#define ENH_SLOP 2 /* max difference estimated and - correct pitch period */ -#define ENH_PLOCSL 8 /* pitch-estimates and - pitch-locations buffer length */ -#define ENH_OVERHANG 2 -#define ENH_UPS0 4 /* upsampling rate */ -#define ENH_FL0 3 /* 2*FLO+1 is the length of each filter */ -#define ENH_FLO_MULT2_PLUS1 7 -#define ENH_VECTL (ENH_BLOCKL+2*ENH_FL0) -#define ENH_CORRDIM (2*ENH_SLOP+1) -#define ENH_NBLOCKS (BLOCKL/ENH_BLOCKL) -#define ENH_NBLOCKS_EXTRA 5 -#define ENH_NBLOCKS_TOT 8 /* ENH_NBLOCKS+ENH_NBLOCKS_EXTRA */ -#define ENH_BUFL (ENH_NBLOCKS_TOT)*ENH_BLOCKL -#define ENH_BUFL_FILTEROVERHEAD 3 -#define ENH_A0 819 /* Q14 */ -#define ENH_A0_MINUS_A0A0DIV4 848256041 /* Q34 */ -#define ENH_A0DIV2 26843546 /* Q30 */ - /* PLC */ /* Down sampling */ @@ -128,92 +74,4 @@ typedef struct iLBC_bits_t_ { WebRtc_Word16 startIdx; } iLBC_bits; -/* type definition encoder instance */ -typedef struct iLBC_Enc_Inst_t_ { - - /* flag for frame size mode */ - WebRtc_Word16 mode; - - /* basic parameters for different frame sizes */ - WebRtc_Word16 blockl; - WebRtc_Word16 nsub; - WebRtc_Word16 nasub; - WebRtc_Word16 no_of_bytes, no_of_words; - WebRtc_Word16 lpc_n; - WebRtc_Word16 state_short_len; - - /* analysis filter state */ - WebRtc_Word16 anaMem[LPC_FILTERORDER]; - - /* Fix-point old lsf parameters for interpolation */ - WebRtc_Word16 lsfold[LPC_FILTERORDER]; - WebRtc_Word16 lsfdeqold[LPC_FILTERORDER]; - - /* signal buffer for LP analysis */ - WebRtc_Word16 lpc_buffer[LPC_LOOKBACK + BLOCKL_MAX]; - - /* state of input HP filter */ - WebRtc_Word16 hpimemx[2]; - WebRtc_Word16 hpimemy[4]; - -#ifdef SPLIT_10MS - WebRtc_Word16 weightdenumbuf[66]; - WebRtc_Word16 past_samples[160]; - WebRtc_UWord16 bytes[25]; - WebRtc_Word16 section; - WebRtc_Word16 Nfor_flag; - WebRtc_Word16 Nback_flag; - WebRtc_Word16 start_pos; - WebRtc_Word16 diff; -#endif - -} iLBC_Enc_Inst_t; - -/* type definition decoder instance */ -typedef struct iLBC_Dec_Inst_t_ { - - /* flag for frame size mode */ - WebRtc_Word16 mode; - - /* basic parameters for different frame sizes */ - WebRtc_Word16 blockl; - WebRtc_Word16 nsub; - WebRtc_Word16 nasub; - WebRtc_Word16 no_of_bytes, no_of_words; - WebRtc_Word16 lpc_n; - WebRtc_Word16 state_short_len; - - /* synthesis filter state */ - WebRtc_Word16 syntMem[LPC_FILTERORDER]; - - /* old LSF for interpolation */ - WebRtc_Word16 lsfdeqold[LPC_FILTERORDER]; - - /* pitch lag estimated in enhancer and used in PLC */ - int last_lag; - - /* PLC state information */ - int consPLICount, prev_enh_pl; - WebRtc_Word16 perSquare; - - WebRtc_Word16 prevScale, prevPLI; - WebRtc_Word16 prevLag, prevLpc[LPC_FILTERORDER+1]; - WebRtc_Word16 prevResidual[NSUB_MAX*SUBL]; - WebRtc_Word16 seed; - - /* previous synthesis filter parameters */ - - WebRtc_Word16 old_syntdenum[(LPC_FILTERORDER + 1)*NSUB_MAX]; - - /* state of output HP filter */ - WebRtc_Word16 hpimemx[2]; - WebRtc_Word16 hpimemy[4]; - - /* enhancer state information */ - int use_enhancer; - WebRtc_Word16 enh_buf[ENH_BUFL+ENH_BUFL_FILTEROVERHEAD]; - WebRtc_Word16 enh_period[ENH_NBLOCKS_TOT]; - -} iLBC_Dec_Inst_t; - #endif diff --git a/ilbc/encode.c b/ilbc/encode.c index 64e9eab3dc..fdd99b1146 100644 --- a/ilbc/encode.c +++ b/ilbc/encode.c @@ -36,6 +36,9 @@ #include "swap_bytes.h" #endif +/* Export all functions defined in this file. */ +#pragma GCC visibility push(default) + /*----------------------------------------------------------------* * main encoder function *---------------------------------------------------------------*/ diff --git a/ilbc/init_decode.c b/ilbc/init_decode.c index b654f1ec91..6035724260 100644 --- a/ilbc/init_decode.c +++ b/ilbc/init_decode.c @@ -19,6 +19,9 @@ #include "defines.h" #include "constants.h" +/* Export all functions defined in this file. */ +#pragma GCC visibility push(default) + /*----------------------------------------------------------------* * Initiation of decoder instance. *---------------------------------------------------------------*/ diff --git a/ilbc/init_encode.c b/ilbc/init_encode.c index e034bb0dd8..66ec5fa330 100644 --- a/ilbc/init_encode.c +++ b/ilbc/init_encode.c @@ -19,6 +19,9 @@ #include "defines.h" #include "constants.h" +/* Export all functions defined in this file. */ +#pragma GCC visibility push(default) + /*----------------------------------------------------------------* * Initiation of encoder instance. *---------------------------------------------------------------*/ diff --git a/ilbc/interface/ilbc.h b/ilbc/interface/ilbc.h index 919f722a2f..66ff064def 100644 --- a/ilbc/interface/ilbc.h +++ b/ilbc/interface/ilbc.h @@ -252,6 +252,172 @@ extern "C" { void WebRtcIlbcfix_version(WebRtc_Word8 *version); + + /**************************************************************************** + * Compatibility with the library code from RFC3951. + * + */ + + /* general codec settings */ + +#define FS 8000 +#define BLOCKL_20MS 160 +#define BLOCKL_30MS 240 +#define BLOCKL_MAX 240 +#define NSUB_20MS 4 +#define NSUB_30MS 6 +#define NSUB_MAX 6 +#define NASUB_20MS 2 +#define NASUB_30MS 4 +#define NASUB_MAX 4 +#define SUBL 40 +#define STATE_LEN 80 +#define STATE_SHORT_LEN_30MS 58 +#define STATE_SHORT_LEN_20MS 57 + + /* LPC settings */ + +#define LPC_FILTERORDER 10 +#define LPC_LOOKBACK 60 +#define LPC_N_20MS 1 +#define LPC_N_30MS 2 +#define LPC_N_MAX 2 +#define LPC_ASYMDIFF 20 +#define LSF_NSPLIT 3 +#define LSF_NUMBER_OF_STEPS 4 +#define LPC_HALFORDER 5 +#define COS_GRID_POINTS 60 + + /* enhancer */ + +#define ENH_BLOCKL 80 /* block length */ +#define ENH_BLOCKL_HALF (ENH_BLOCKL/2) +#define ENH_HL 3 /* 2*ENH_HL+1 is number blocks + in said second sequence */ +#define ENH_SLOP 2 /* max difference estimated and + correct pitch period */ +#define ENH_PLOCSL 8 /* pitch-estimates and + pitch-locations buffer length */ +#define ENH_OVERHANG 2 +#define ENH_UPS0 4 /* upsampling rate */ +#define ENH_FL0 3 /* 2*FLO+1 is the length of each filter */ +#define ENH_FLO_MULT2_PLUS1 7 +#define ENH_VECTL (ENH_BLOCKL+2*ENH_FL0) +#define ENH_CORRDIM (2*ENH_SLOP+1) +#define ENH_NBLOCKS (BLOCKL/ENH_BLOCKL) +#define ENH_NBLOCKS_EXTRA 5 +#define ENH_NBLOCKS_TOT 8 /* ENH_NBLOCKS+ENH_NBLOCKS_EXTRA */ +#define ENH_BUFL (ENH_NBLOCKS_TOT)*ENH_BLOCKL +#define ENH_BUFL_FILTEROVERHEAD 3 +#define ENH_A0 819 /* Q14 */ +#define ENH_A0_MINUS_A0A0DIV4 848256041 /* Q34 */ +#define ENH_A0DIV2 26843546 /* Q30 */ + + /* type definition encoder instance */ + typedef struct iLBC_Enc_Inst_t_ { + + /* flag for frame size mode */ + WebRtc_Word16 mode; + + /* basic parameters for different frame sizes */ + WebRtc_Word16 blockl; + WebRtc_Word16 nsub; + WebRtc_Word16 nasub; + WebRtc_Word16 no_of_bytes, no_of_words; + WebRtc_Word16 lpc_n; + WebRtc_Word16 state_short_len; + + /* analysis filter state */ + WebRtc_Word16 anaMem[LPC_FILTERORDER]; + + /* Fix-point old lsf parameters for interpolation */ + WebRtc_Word16 lsfold[LPC_FILTERORDER]; + WebRtc_Word16 lsfdeqold[LPC_FILTERORDER]; + + /* signal buffer for LP analysis */ + WebRtc_Word16 lpc_buffer[LPC_LOOKBACK + BLOCKL_MAX]; + + /* state of input HP filter */ + WebRtc_Word16 hpimemx[2]; + WebRtc_Word16 hpimemy[4]; + +#ifdef SPLIT_10MS + WebRtc_Word16 weightdenumbuf[66]; + WebRtc_Word16 past_samples[160]; + WebRtc_UWord16 bytes[25]; + WebRtc_Word16 section; + WebRtc_Word16 Nfor_flag; + WebRtc_Word16 Nback_flag; + WebRtc_Word16 start_pos; + WebRtc_Word16 diff; +#endif + + } iLBC_Enc_Inst_t; + + /* type definition decoder instance */ + typedef struct iLBC_Dec_Inst_t_ { + + /* flag for frame size mode */ + WebRtc_Word16 mode; + + /* basic parameters for different frame sizes */ + WebRtc_Word16 blockl; + WebRtc_Word16 nsub; + WebRtc_Word16 nasub; + WebRtc_Word16 no_of_bytes, no_of_words; + WebRtc_Word16 lpc_n; + WebRtc_Word16 state_short_len; + + /* synthesis filter state */ + WebRtc_Word16 syntMem[LPC_FILTERORDER]; + + /* old LSF for interpolation */ + WebRtc_Word16 lsfdeqold[LPC_FILTERORDER]; + + /* pitch lag estimated in enhancer and used in PLC */ + int last_lag; + + /* PLC state information */ + int consPLICount, prev_enh_pl; + WebRtc_Word16 perSquare; + + WebRtc_Word16 prevScale, prevPLI; + WebRtc_Word16 prevLag, prevLpc[LPC_FILTERORDER+1]; + WebRtc_Word16 prevResidual[NSUB_MAX*SUBL]; + WebRtc_Word16 seed; + + /* previous synthesis filter parameters */ + + WebRtc_Word16 old_syntdenum[(LPC_FILTERORDER + 1)*NSUB_MAX]; + + /* state of output HP filter */ + WebRtc_Word16 hpimemx[2]; + WebRtc_Word16 hpimemy[4]; + + /* enhancer state information */ + int use_enhancer; + WebRtc_Word16 enh_buf[ENH_BUFL+ENH_BUFL_FILTEROVERHEAD]; + WebRtc_Word16 enh_period[ENH_NBLOCKS_TOT]; + + } iLBC_Dec_Inst_t; + +#define initDecode WebRtcIlbcfix_InitDecode +#define initEncode WebRtcIlbcfix_InitEncode +#define iLBC_decode WebRtcIlbcfix_DecodeImpl +#define iLBC_encode WebRtcIlbcfix_EncodeImpl + WebRtc_Word16 WebRtcIlbcfix_InitDecode(iLBC_Dec_Inst_t *iLBCdec_inst, + WebRtc_Word16 mode, + int use_enhancer); + WebRtc_Word16 WebRtcIlbcfix_InitEncode(iLBC_Enc_Inst_t *iLBCenc_inst, + WebRtc_Word16 mode); + void WebRtcIlbcfix_DecodeImpl(WebRtc_Word16 *decblock, + WebRtc_UWord16 *bytes, + iLBC_Dec_Inst_t *iLBCdec_inst, + WebRtc_Word16 mode); + void WebRtcIlbcfix_EncodeImpl(WebRtc_UWord16 *bytes, + WebRtc_Word16 *block, + iLBC_Enc_Inst_t *iLBCenc_inst); + #ifdef __cplusplus } #endif