diff --git a/modules/audio_coding/codecs/isac/fix/include/isacfix.h b/modules/audio_coding/codecs/isac/fix/include/isacfix.h index afbacd0235..339c8060c5 100644 --- a/modules/audio_coding/codecs/isac/fix/include/isacfix.h +++ b/modules/audio_coding/codecs/isac/fix/include/isacfix.h @@ -98,36 +98,6 @@ int WebRtcIsacfix_Encode(ISACFIX_MainStruct* ISAC_main_inst, const int16_t* speechIn, uint8_t* encoded); -/**************************************************************************** - * WebRtcIsacfix_EncodeNb(...) - * - * This function encodes 10ms narrow band (8 kHz sampling) frame(s) and inserts - * it into a package. Input speech length has to be 80 samples (10ms). The - * encoder interpolates into wide-band (16 kHz sampling) buffers those 10ms - * frames until it reaches the chosen Framesize (480 or 960 wide-band samples - * corresponding to 30 or 60 ms frames), and then proceeds to the encoding. - * - * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - speechIn : input speech vector. - * - * Output: - * - encoded : the encoded data vector - * - * Return value : >0 - Length (in bytes) of coded data - * 0 - The buffer didn't reach the chosen framesize - * so it keeps buffering speech samples. - * -1 - Error - */ - -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED -int16_t WebRtcIsacfix_EncodeNb(ISACFIX_MainStruct* ISAC_main_inst, - const int16_t* speechIn, - int16_t* encoded); -#endif // WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - /**************************************************************************** * WebRtcIsacfix_DecoderInit(...) * @@ -213,61 +183,6 @@ int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst, int16_t* decoded, int16_t* speechType); -/**************************************************************************** - * WebRtcIsacfix_DecodeNb(...) - * - * This function decodes a ISAC frame in narrow-band (8 kHz sampling). - * Output speech length will be a multiple of 240 samples: 240 or 480 samples, - * depending on the framesize (30 or 60 ms). - * - * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC frame(s) - * - len : bytes in encoded vector - * - * Output: - * - decoded : The decoded vector - * - * Return value : >0 - number of samples in decoded vector - * -1 - Error - */ - -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED -int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct* ISAC_main_inst, - const uint16_t* encoded, - size_t len, - int16_t* decoded, - int16_t* speechType); -#endif // WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - -/**************************************************************************** - * WebRtcIsacfix_DecodePlcNb(...) - * - * This function conducts PLC for ISAC frame(s) in narrow-band (8kHz sampling). - * Output speech length will be "240*noOfLostFrames" samples - * that equevalent of "30*noOfLostFrames" millisecond. - * - * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - noOfLostFrames : Number of PLC frames (240 sample=30ms) to produce - * NOTE! Maximum number is 2 (480 samples = 60ms) - * - * Output: - * - decoded : The decoded vector - * - * Return value : Number of samples in decoded PLC vector - */ - -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED -size_t WebRtcIsacfix_DecodePlcNb(ISACFIX_MainStruct* ISAC_main_inst, - int16_t* decoded, - size_t noOfLostFrames); -#endif // WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - /**************************************************************************** * WebRtcIsacfix_DecodePlc(...) * diff --git a/modules/audio_coding/codecs/isac/fix/source/codec.h b/modules/audio_coding/codecs/isac/fix/source/codec.h index c95b53ff64..01d6fb907e 100644 --- a/modules/audio_coding/codecs/isac/fix/source/codec.h +++ b/modules/audio_coding/codecs/isac/fix/source/codec.h @@ -123,21 +123,6 @@ void WebRtcIsacfix_FilterAndCombine1(int16_t* tempin_ch1, int16_t* out16, PostFiltBankstr* postfiltdata); -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - -void WebRtcIsacfix_SplitAndFilter2(int16_t* in, - int16_t* LP16, - int16_t* HP16, - PreFiltBankstr* prefiltdata); - -void WebRtcIsacfix_FilterAndCombine2(int16_t* tempin_ch1, - int16_t* tempin_ch2, - int16_t* out16, - PostFiltBankstr* postfiltdata, - int16_t len); - -#endif - /* normalized lattice filters */ void WebRtcIsacfix_NormLatticeFilterMa(size_t orderCoef, diff --git a/modules/audio_coding/codecs/isac/fix/source/filterbanks.c b/modules/audio_coding/codecs/isac/fix/source/filterbanks.c index 6aba8b6a54..57b3e70b89 100644 --- a/modules/audio_coding/codecs/isac/fix/source/filterbanks.c +++ b/modules/audio_coding/codecs/isac/fix/source/filterbanks.c @@ -235,67 +235,6 @@ void WebRtcIsacfix_SplitAndFilter1(int16_t *pin, }/*end of WebRtcIsacfix_SplitAndFilter */ -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - -/* Without lookahead */ -void WebRtcIsacfix_SplitAndFilter2(int16_t *pin, - int16_t *LP16, - int16_t *HP16, - PreFiltBankstr *prefiltdata) -{ - /* Function WebRtcIsacfix_SplitAndFilter2 */ - /* This function creates low-pass and high-pass decimated versions of part of - the input signal. */ - - int k; - - int16_t tempin_ch1[FRAMESAMPLES/2]; - int16_t tempin_ch2[FRAMESAMPLES/2]; - - - /* High pass filter */ - WebRtcIsacfix_HighpassFilterFixDec32(pin, FRAMESAMPLES, WebRtcIsacfix_kHpStCoeffInQ30, prefiltdata->HPstates_fix); - - - /* First Channel */ - for (k=0;kINSTAT1_fix, - prefiltdata->INSTAT2_fix); - - /* Now Construct low-pass and high-pass signals as combinations of polyphase components */ - for (k=0; k Q0 - tmp2 = (int32_t)tempin_ch2[k]; // Q0 -> Q0 - tmp3 = (tmp1 + tmp2) >> 1; /* Low pass signal. */ - LP16[k] = (int16_t)WebRtcSpl_SatW32ToW16(tmp3); /*low pass */ - tmp3 = (tmp1 - tmp2) >> 1; /* High pass signal. */ - HP16[k] = (int16_t)WebRtcSpl_SatW32ToW16(tmp3); /*high pass */ - } - -}/*end of WebRtcIsacfix_SplitAndFilter */ - -#endif - - ////////////////////////////////////////////////////////// ////////// Combining @@ -356,66 +295,3 @@ void WebRtcIsacfix_FilterAndCombine1(int16_t *tempin_ch1, out16[k] = in[k]; } } - - -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED -/* Function WebRtcIsacfix_FilterAndCombine */ -/* This is a decoder function that takes the decimated - length len/2 input low-pass and - high-pass signals and creates a reconstructed fullband - output signal of length len. WebRtcIsacfix_FilterAndCombine - is the sibling function of WebRtcIsacfix_SplitAndFilter */ -/* INPUTS: - inLP: a length len/2 array of input low-pass - samples. - inHP: a length len/2 array of input high-pass - samples. - postfiltdata: input data structure containing the filterbank - states from the previous decoding iteration. - OUTPUTS: - Out: a length len array of output reconstructed - samples (fullband) based on the input low-pass and - high-pass signals. - postfiltdata: the input data structure containing the filterbank - states is updated for the next decoding iteration */ -void WebRtcIsacfix_FilterAndCombine2(int16_t *tempin_ch1, - int16_t *tempin_ch2, - int16_t *out16, - PostFiltBankstr *postfiltdata, - int16_t len) -{ - int k; - int16_t in[FRAMESAMPLES]; - - /* all-pass filter the new upper and lower channel signal. - For upper channel, use the all-pass filter factors that were used as a - lower channel at the encoding side. So at the decoder, the corresponding - all-pass filter factors for each channel are swapped. - For lower channel signal, since all-pass filter factors at the decoder are - swapped from the ones at the encoder, the 'upper' channel all-pass filter - factors (kUpperApFactors) are used to filter this new lower channel signal. - */ - WebRtcIsacfix_AllpassFilter2FixDec16(tempin_ch1, - tempin_ch2, - WebRtcIsacfix_kLowerApFactorsQ15, - WebRtcIsacfix_kUpperApFactorsQ15, - len / 2, - postfiltdata->STATE_0_UPPER_fix, - postfiltdata->STATE_0_LOWER_fix); - - /* Merge outputs to form the full length output signal.*/ - for (k=0;kHPstates1_fix); - WebRtcIsacfix_HighpassFilterFixDec32(in, len, WebRtcIsacfix_kHPStCoeffOut2Q30, postfiltdata->HPstates2_fix); - - for (k=0;kISACenc_obj.bitstr_obj.stream[k] = 0; } -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - WebRtcIsacfix_InitPostFilterbank(&ISAC_inst->ISACenc_obj.interpolatorstr_obj); -#endif - InitFunctionPointers(); return statusInit; @@ -383,85 +379,6 @@ int WebRtcIsacfix_Encode(ISACFIX_MainStruct *ISAC_main_inst, } - - -/**************************************************************************** - * WebRtcIsacfix_EncodeNb(...) - * - * This function encodes 10ms narrow band (8 kHz sampling) frame(s) and inserts - * it into a package. Input speech length has to be 80 samples (10ms). The encoder - * interpolates into wide-band (16 kHz sampling) buffers those - * 10ms frames until it reaches the chosen Framesize (480 or 960 wide-band samples - * corresponding to 30 or 60 ms frames), and then proceeds to the encoding. - * - * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - speechIn : input speech vector. - * - * Output: - * - encoded : the encoded data vector - * - * Return value: - * : >0 - Length (in bytes) of coded data - * : 0 - The buffer didn't reach the chosen framesize - * so it keeps buffering speech samples. - * : -1 - Error - */ -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED -int16_t WebRtcIsacfix_EncodeNb(ISACFIX_MainStruct *ISAC_main_inst, - const int16_t *speechIn, - int16_t *encoded) -{ - ISACFIX_SubStruct *ISAC_inst; - int16_t stream_len; - int16_t speechInWB[FRAMESAMPLES_10ms]; - int16_t Vector_Word16_1[FRAMESAMPLES_10ms/2]; - int16_t Vector_Word16_2[FRAMESAMPLES_10ms/2]; - - int k; - - - /* typecast pointer to rela structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - - /* check if encoder initiated */ - if ((ISAC_inst->initflag & 2) != 2) { - ISAC_inst->errorcode = ISAC_ENCODER_NOT_INITIATED; - return (-1); - } - - - /* Oversample to WB */ - - /* Form polyphase signals, and compensate for DC offset */ - for (k=0;kISACenc_obj.interpolatorstr_obj, FRAMESAMPLES_10ms); - - - /* Encode WB signal */ - stream_len = WebRtcIsacfix_EncodeImpl((int16_t*)speechInWB, - &ISAC_inst->ISACenc_obj, - &ISAC_inst->bwestimator_obj, - ISAC_inst->CodingMode); - if (stream_len<0) { - ISAC_inst->errorcode = - stream_len; - return -1; - } - - write_be16(ISAC_inst->ISACenc_obj.bitstr_obj.stream, - stream_len, - (uint8_t*)encoded); - return stream_len; -} -#endif /* WEBRTC_ISAC_FIX_NB_CALLS_ENABLED */ - - /**************************************************************************** * WebRtcIsacfix_GetNewBitStream(...) * @@ -540,11 +457,6 @@ void WebRtcIsacfix_DecoderInit(ISACFIX_MainStruct *ISAC_main_inst) /* TS */ WebRtcIsacfix_InitPlc( &ISAC_inst->ISACdec_obj.plcstr_obj ); - - -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - WebRtcIsacfix_InitPreFilterbank(&ISAC_inst->ISACdec_obj.decimatorstr_obj); -#endif } @@ -788,180 +700,6 @@ int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst, } - - - -/**************************************************************************** - * WebRtcIsacfix_DecodeNb(...) - * - * This function decodes a ISAC frame in narrow-band (8 kHz sampling). - * Output speech length will be a multiple of 240 samples: 240 or 480 samples, - * depending on the framesize (30 or 60 ms). - * - * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC frame(s) - * - len : bytes in encoded vector - * - * Output: - * - decoded : The decoded vector - * - * Return value : >0 - number of samples in decoded vector - * -1 - Error - */ - -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED -int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct* ISAC_main_inst, - const uint16_t* encoded, - size_t len, - int16_t* decoded, - int16_t* speechType) -{ - ISACFIX_SubStruct *ISAC_inst; - /* twice the number of samples (480 or 960), output from decoder */ - /* that were actually used in the encoder/decoder (determined on the fly) */ - size_t number_of_samples; - int declen_int = 0; - size_t declen; - int16_t dummy[FRAMESAMPLES/2]; - - - /* typecast pointer to real structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - /* check if decoder initiated */ - if ((ISAC_inst->initflag & 1) != 1) { - ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED; - return (-1); - } - - if (len == 0) { - /* return error code if the packet length is null or less */ - ISAC_inst->errorcode = ISAC_EMPTY_PACKET; - return -1; - } else if (len > (STREAM_MAXW16<<1)) { - /* return error code if length of stream is too long */ - ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; - return -1; - } - - InitializeDecoderBitstream(len, &ISAC_inst->ISACdec_obj.bitstr_obj); - - read_be16(encoded, len, ISAC_inst->ISACdec_obj.bitstr_obj.stream); - - /* added for NetEq purposes (VAD/DTX related) */ - *speechType=1; - - declen_int = WebRtcIsacfix_DecodeImpl(decoded, &ISAC_inst->ISACdec_obj, - &number_of_samples); - if (declen_int < 0) { - /* Some error inside the decoder */ - ISAC_inst->errorcode = -(int16_t)declen_int; - memset(decoded, 0, sizeof(int16_t) * FRAMESAMPLES); - return -1; - } - declen = (size_t)declen_int; - - /* error check */ - - if (declen & 1) { - if (len != declen && - len != declen + - ((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >> 1]) & 0xFF)) { - ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; - memset(decoded, 0, sizeof(int16_t) * number_of_samples); - return -1; - } - } else { - if (len != declen && - len != declen + - ((ISAC_inst->ISACdec_obj.bitstr_obj.stream[declen >>1]) >> 8)) { - ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; - memset(decoded, 0, sizeof(int16_t) * number_of_samples); - return -1; - } - } - - WebRtcIsacfix_SplitAndFilter2(decoded, decoded, dummy, &ISAC_inst->ISACdec_obj.decimatorstr_obj); - - if (number_of_samples>FRAMESAMPLES) { - WebRtcIsacfix_SplitAndFilter2(decoded + FRAMESAMPLES, decoded + FRAMESAMPLES/2, - dummy, &ISAC_inst->ISACdec_obj.decimatorstr_obj); - } - - return (int)(number_of_samples / 2); -} -#endif /* WEBRTC_ISAC_FIX_NB_CALLS_ENABLED */ - - -/**************************************************************************** - * WebRtcIsacfix_DecodePlcNb(...) - * - * This function conducts PLC for ISAC frame(s) in narrow-band (8kHz sampling). - * Output speech length will be "240*noOfLostFrames" samples - * that is equevalent of "30*noOfLostFrames" millisecond. - * - * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - noOfLostFrames : Number of PLC frames (240 sample=30ms) to produce - * - * Output: - * - decoded : The decoded vector - * - * Return value : Number of samples in decoded PLC vector - */ - -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED -size_t WebRtcIsacfix_DecodePlcNb(ISACFIX_MainStruct* ISAC_main_inst, - int16_t* decoded, - size_t noOfLostFrames ) -{ - size_t no_of_samples, declen, k; - int16_t outframeNB[FRAMESAMPLES]; - int16_t outframeWB[FRAMESAMPLES]; - int16_t dummy[FRAMESAMPLES/2]; - - - ISACFIX_SubStruct *ISAC_inst; - /* typecast pointer to real structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - /* Limit number of frames to two = 60 msec. Otherwise we exceed data vectors */ - if (noOfLostFrames > 2){ - noOfLostFrames = 2; - } - - k = 0; - declen = 0; - while( noOfLostFrames > 0 ) - { - WebRtcIsacfix_DecodePlcImpl(outframeWB, &ISAC_inst->ISACdec_obj, - &no_of_samples); - - WebRtcIsacfix_SplitAndFilter2(outframeWB, &(outframeNB[k*240]), dummy, &ISAC_inst->ISACdec_obj.decimatorstr_obj); - - declen += no_of_samples; - noOfLostFrames--; - k++; - } - - declen>>=1; - - for (k=0;k( WebRtcIsacfix_DecodePlc(ISAC_main_inst, decoded, prevFrameSize)); } else { -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - declen = static_cast(WebRtcIsacfix_DecodePlcNb( - ISAC_main_inst, decoded, prevFrameSize)); -#else declen = -1; -#endif } lostPackets++; } else { @@ -815,12 +805,7 @@ TEST(IsacFixTest, Kenny) { prevFrameSize = static_cast(declen / 480); } else { -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - declen = WebRtcIsacfix_DecodeNb(ISAC_main_inst, streamdata, - stream_len, decoded, speechType); -#else declen = -1; -#endif prevFrameSize = static_cast(declen / 240); } }