Reformat the WebRTC code base

Running clang-format with chromium's style guide.

The goal is n-fold:
 * providing consistency and readability (that's what code guidelines are for)
 * preventing noise with presubmit checks and git cl format
 * building on the previous point: making it easier to automatically fix format issues
 * you name it

Please consider using git-hyper-blame to ignore this commit.

Bug: webrtc:9340
Change-Id: I694567c4cdf8cee2860958cfe82bfaf25848bb87
Reviewed-on: https://webrtc-review.googlesource.com/81185
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23660}
This commit is contained in:
Yves Gerey
2018-06-19 15:03:05 +02:00
parent b602123a5a
commit 665174fdbb
1569 changed files with 30495 additions and 30309 deletions

View File

@ -90,9 +90,8 @@ size_t AudioEncoderIsacT<T>::NumChannels() const {
template <typename T>
size_t AudioEncoderIsacT<T>::Num10MsFramesInNextPacket() const {
const int samples_in_next_packet = T::GetNewFrameLen(isac_state_);
return static_cast<size_t>(
rtc::CheckedDivExact(samples_in_next_packet,
rtc::CheckedDivExact(SampleRateHz(), 100)));
return static_cast<size_t>(rtc::CheckedDivExact(
samples_in_next_packet, rtc::CheckedDivExact(SampleRateHz(), 100)));
}
template <typename T>
@ -123,8 +122,7 @@ AudioEncoder::EncodedInfo AudioEncoderIsacT<T>::EncodeImpl(
}
size_t encoded_bytes = encoded->AppendData(
kSufficientEncodeBufferSizeBytes,
[&] (rtc::ArrayView<uint8_t> encoded) {
kSufficientEncodeBufferSizeBytes, [&](rtc::ArrayView<uint8_t> encoded) {
int r = T::Encode(isac_state_, audio.data(), encoded.data());
RTC_CHECK_GE(r, 0) << "Encode failed (error code "

File diff suppressed because it is too large Load Diff

View File

@ -35,12 +35,10 @@
* Return value : 0 if ok,
* <0 otherwise.
*/
int WebRtcIsacfix_EncLogisticMulti2(
Bitstr_enc *streamData,
int16_t *dataQ7,
const uint16_t *env,
const int16_t lenData);
int WebRtcIsacfix_EncLogisticMulti2(Bitstr_enc* streamData,
int16_t* dataQ7,
const uint16_t* env,
const int16_t lenData);
/****************************************************************************
* WebRtcIsacfix_EncTerminate(...)
@ -53,8 +51,7 @@ int WebRtcIsacfix_EncLogisticMulti2(
*
* Return value : number of bytes in the stream
*/
int16_t WebRtcIsacfix_EncTerminate(Bitstr_enc *streamData);
int16_t WebRtcIsacfix_EncTerminate(Bitstr_enc* streamData);
/****************************************************************************
* WebRtcIsacfix_DecLogisticMulti2(...)
@ -73,12 +70,10 @@ int16_t WebRtcIsacfix_EncTerminate(Bitstr_enc *streamData);
* Return value : number of bytes in the stream so far
* <0 if error detected
*/
int WebRtcIsacfix_DecLogisticMulti2(
int16_t *data,
Bitstr_dec *streamData,
const int32_t *env,
const int16_t lenData);
int WebRtcIsacfix_DecLogisticMulti2(int16_t* data,
Bitstr_dec* streamData,
const int32_t* env,
const int16_t lenData);
/****************************************************************************
* WebRtcIsacfix_EncHistMulti(...)
@ -94,12 +89,10 @@ int WebRtcIsacfix_DecLogisticMulti2(
* Return value : 0 if ok
* <0 if error detected
*/
int WebRtcIsacfix_EncHistMulti(
Bitstr_enc *streamData,
const int16_t *data,
const uint16_t *const *cdf,
const int16_t lenData);
int WebRtcIsacfix_EncHistMulti(Bitstr_enc* streamData,
const int16_t* data,
const uint16_t* const* cdf,
const int16_t lenData);
/****************************************************************************
* WebRtcIsacfix_DecHistBisectMulti(...)
@ -121,13 +114,11 @@ int WebRtcIsacfix_EncHistMulti(
* Return value : number of bytes in the stream
* <0 if error detected
*/
int16_t WebRtcIsacfix_DecHistBisectMulti(
int16_t *data,
Bitstr_dec *streamData,
const uint16_t *const *cdf,
const uint16_t *cdfSize,
const int16_t lenData);
int16_t WebRtcIsacfix_DecHistBisectMulti(int16_t* data,
Bitstr_dec* streamData,
const uint16_t* const* cdf,
const uint16_t* cdfSize,
const int16_t lenData);
/****************************************************************************
* WebRtcIsacfix_DecHistOneStepMulti(...)
@ -149,11 +140,10 @@ int16_t WebRtcIsacfix_DecHistBisectMulti(
* Return value : number of bytes in original stream
* <0 if error detected
*/
int16_t WebRtcIsacfix_DecHistOneStepMulti(
int16_t *data,
Bitstr_dec *streamData,
const uint16_t *const *cdf,
const uint16_t *initIndex,
const int16_t lenData);
int16_t WebRtcIsacfix_DecHistOneStepMulti(int16_t* data,
Bitstr_dec* streamData,
const uint16_t* const* cdf,
const uint16_t* initIndex,
const int16_t lenData);
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ARITH_ROUTINS_H_ */

View File

@ -32,8 +32,7 @@
* Return value : 0
*/
int32_t WebRtcIsacfix_InitBandwidthEstimator(BwEstimatorstr *bwest_str);
int32_t WebRtcIsacfix_InitBandwidthEstimator(BwEstimatorstr* bwest_str);
/****************************************************************************
* WebRtcIsacfix_UpdateUplinkBwImpl(...)
@ -56,16 +55,17 @@ int32_t WebRtcIsacfix_InitBandwidthEstimator(BwEstimatorstr *bwest_str);
* -1 otherwise
*/
int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bwest_str,
const uint16_t rtp_number,
const int16_t frameSize,
const uint32_t send_ts,
const uint32_t arr_ts,
const size_t pksize,
const uint16_t Index);
int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr* bwest_str,
const uint16_t rtp_number,
const int16_t frameSize,
const uint32_t send_ts,
const uint32_t arr_ts,
const size_t pksize,
const uint16_t Index);
/* Update receiving estimates. Used when we only receive BWE index, no iSAC data packet. */
int16_t WebRtcIsacfix_UpdateUplinkBwRec(BwEstimatorstr *bwest_str,
/* Update receiving estimates. Used when we only receive BWE index, no iSAC data
* packet. */
int16_t WebRtcIsacfix_UpdateUplinkBwRec(BwEstimatorstr* bwest_str,
const int16_t Index);
/****************************************************************************
@ -80,19 +80,19 @@ int16_t WebRtcIsacfix_UpdateUplinkBwRec(BwEstimatorstr *bwest_str,
* Return:
* bandwith and jitter index (0..23)
*/
uint16_t WebRtcIsacfix_GetDownlinkBwIndexImpl(BwEstimatorstr *bwest_str);
uint16_t WebRtcIsacfix_GetDownlinkBwIndexImpl(BwEstimatorstr* bwest_str);
/* Returns the bandwidth estimation (in bps) */
uint16_t WebRtcIsacfix_GetDownlinkBandwidth(const BwEstimatorstr *bwest_str);
uint16_t WebRtcIsacfix_GetDownlinkBandwidth(const BwEstimatorstr* bwest_str);
/* Returns the bandwidth that iSAC should send with in bps */
int16_t WebRtcIsacfix_GetUplinkBandwidth(const BwEstimatorstr *bwest_str);
int16_t WebRtcIsacfix_GetUplinkBandwidth(const BwEstimatorstr* bwest_str);
/* Returns the max delay (in ms) */
int16_t WebRtcIsacfix_GetDownlinkMaxDelay(const BwEstimatorstr *bwest_str);
int16_t WebRtcIsacfix_GetDownlinkMaxDelay(const BwEstimatorstr* bwest_str);
/* Returns the max delay value from the other side in ms */
int16_t WebRtcIsacfix_GetUplinkMaxDelay(const BwEstimatorstr *bwest_str);
int16_t WebRtcIsacfix_GetUplinkMaxDelay(const BwEstimatorstr* bwest_str);
/* Fills in an IsacExternalBandwidthInfo struct. */
void WebRtcIsacfixBw_GetBandwidthInfo(BwEstimatorstr* bwest_str,
@ -106,29 +106,31 @@ void WebRtcIsacfixBw_SetBandwidthInfo(BwEstimatorstr* bwest_str,
* update amount of data in bottle neck buffer and burst handling
* returns minimum payload size (bytes)
*/
uint16_t WebRtcIsacfix_GetMinBytes(RateModel *State,
int16_t StreamSize, /* bytes in bitstream */
const int16_t FrameLen, /* ms per frame */
const int16_t BottleNeck, /* bottle neck rate; excl headers (bps) */
const int16_t DelayBuildUp); /* max delay from bottle neck buffering (ms) */
uint16_t WebRtcIsacfix_GetMinBytes(
RateModel* State,
int16_t StreamSize, /* bytes in bitstream */
const int16_t FrameLen, /* ms per frame */
const int16_t BottleNeck, /* bottle neck rate; excl headers (bps) */
const int16_t DelayBuildUp); /* max delay from bottle neck buffering (ms) */
/*
* update long-term average bitrate and amount of data in buffer
*/
void WebRtcIsacfix_UpdateRateModel(RateModel *State,
int16_t StreamSize, /* bytes in bitstream */
const int16_t FrameSamples, /* samples per frame */
const int16_t BottleNeck); /* bottle neck rate; excl headers (bps) */
void WebRtcIsacfix_UpdateRateModel(
RateModel* State,
int16_t StreamSize, /* bytes in bitstream */
const int16_t FrameSamples, /* samples per frame */
const int16_t BottleNeck); /* bottle neck rate; excl headers (bps) */
void WebRtcIsacfix_InitRateModel(RateModel *State);
void WebRtcIsacfix_InitRateModel(RateModel* State);
/* Returns the new framelength value (input argument: bottle_neck) */
int16_t WebRtcIsacfix_GetNewFrameLength(int16_t bottle_neck, int16_t current_framelength);
int16_t WebRtcIsacfix_GetNewFrameLength(int16_t bottle_neck,
int16_t current_framelength);
/* Returns the new SNR value (input argument: bottle_neck) */
//returns snr in Q10
// returns snr in Q10
int16_t WebRtcIsacfix_GetSnr(int16_t bottle_neck, int16_t framesamples);
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_BANDWIDTH_ESTIMATOR_H_ */
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_BANDWIDTH_ESTIMATOR_H_ \
*/

View File

@ -38,7 +38,7 @@ int WebRtcIsacfix_DecodeImpl(int16_t* signal_out16,
void WebRtcIsacfix_DecodePlcImpl(int16_t* decoded,
IsacFixDecoderInstance* ISACdec_obj,
size_t* current_framesample );
size_t* current_framesample);
int WebRtcIsacfix_EncodeImpl(int16_t* in,
IsacFixEncoderInstance* ISACenc_obj,
@ -64,7 +64,6 @@ void WebRtcIsacfix_InitPitchAnalysis(PitchAnalysisStruct* State);
void WebRtcIsacfix_InitPlc(PLCstr* State);
/* transform functions */
void WebRtcIsacfix_InitTransform(void);

View File

@ -22,91 +22,79 @@
#include "modules/audio_coding/codecs/isac/fix/source/structs.h"
/* decode complex spectrum (return number of bytes in stream) */
int WebRtcIsacfix_DecodeSpec(Bitstr_dec *streamdata,
int16_t *frQ7,
int16_t *fiQ7,
int WebRtcIsacfix_DecodeSpec(Bitstr_dec* streamdata,
int16_t* frQ7,
int16_t* fiQ7,
int16_t AvgPitchGain_Q12);
/* encode complex spectrum */
int WebRtcIsacfix_EncodeSpec(const int16_t *fr,
const int16_t *fi,
Bitstr_enc *streamdata,
int WebRtcIsacfix_EncodeSpec(const int16_t* fr,
const int16_t* fi,
Bitstr_enc* streamdata,
int16_t AvgPitchGain_Q12);
/* decode & dequantize LPC Coef */
int WebRtcIsacfix_DecodeLpcCoef(Bitstr_dec *streamdata,
int32_t *LPCCoefQ17,
int32_t *gain_lo_hiQ17,
int16_t *outmodel);
int WebRtcIsacfix_DecodeLpcCoef(Bitstr_dec* streamdata,
int32_t* LPCCoefQ17,
int32_t* gain_lo_hiQ17,
int16_t* outmodel);
int WebRtcIsacfix_DecodeLpc(int32_t *gain_lo_hiQ17,
int16_t *LPCCoef_loQ15,
int16_t *LPCCoef_hiQ15,
Bitstr_dec *streamdata,
int16_t *outmodel);
int WebRtcIsacfix_DecodeLpc(int32_t* gain_lo_hiQ17,
int16_t* LPCCoef_loQ15,
int16_t* LPCCoef_hiQ15,
Bitstr_dec* streamdata,
int16_t* outmodel);
/* quantize & code LPC Coef */
int WebRtcIsacfix_EncodeLpc(int32_t *gain_lo_hiQ17,
int16_t *LPCCoef_loQ15,
int16_t *LPCCoef_hiQ15,
int16_t *model,
int32_t *sizeQ11,
Bitstr_enc *streamdata,
int WebRtcIsacfix_EncodeLpc(int32_t* gain_lo_hiQ17,
int16_t* LPCCoef_loQ15,
int16_t* LPCCoef_hiQ15,
int16_t* model,
int32_t* sizeQ11,
Bitstr_enc* streamdata,
IsacSaveEncoderData* encData,
transcode_obj *transcodeParam);
transcode_obj* transcodeParam);
int WebRtcIsacfix_EstCodeLpcGain(int32_t *gain_lo_hiQ17,
Bitstr_enc *streamdata,
int WebRtcIsacfix_EstCodeLpcGain(int32_t* gain_lo_hiQ17,
Bitstr_enc* streamdata,
IsacSaveEncoderData* encData);
/* decode & dequantize RC */
int WebRtcIsacfix_DecodeRcCoef(Bitstr_dec *streamdata,
int16_t *RCQ15);
int WebRtcIsacfix_DecodeRcCoef(Bitstr_dec* streamdata, int16_t* RCQ15);
/* quantize & code RC */
int WebRtcIsacfix_EncodeRcCoef(int16_t *RCQ15,
Bitstr_enc *streamdata);
int WebRtcIsacfix_EncodeRcCoef(int16_t* RCQ15, Bitstr_enc* streamdata);
/* decode & dequantize squared Gain */
int WebRtcIsacfix_DecodeGain2(Bitstr_dec *streamdata,
int32_t *Gain2);
int WebRtcIsacfix_DecodeGain2(Bitstr_dec* streamdata, int32_t* Gain2);
/* quantize & code squared Gain (input is squared gain) */
int WebRtcIsacfix_EncodeGain2(int32_t *gain2,
Bitstr_enc *streamdata);
int WebRtcIsacfix_EncodeGain2(int32_t* gain2, Bitstr_enc* streamdata);
int WebRtcIsacfix_EncodePitchGain(int16_t *PitchGains_Q12,
Bitstr_enc *streamdata,
int WebRtcIsacfix_EncodePitchGain(int16_t* PitchGains_Q12,
Bitstr_enc* streamdata,
IsacSaveEncoderData* encData);
int WebRtcIsacfix_EncodePitchLag(int16_t *PitchLagQ7,
int16_t *PitchGain_Q12,
Bitstr_enc *streamdata,
int WebRtcIsacfix_EncodePitchLag(int16_t* PitchLagQ7,
int16_t* PitchGain_Q12,
Bitstr_enc* streamdata,
IsacSaveEncoderData* encData);
int WebRtcIsacfix_DecodePitchGain(Bitstr_dec *streamdata,
int16_t *PitchGain_Q12);
int WebRtcIsacfix_DecodePitchGain(Bitstr_dec* streamdata,
int16_t* PitchGain_Q12);
int WebRtcIsacfix_DecodePitchLag(Bitstr_dec *streamdata,
int16_t *PitchGain_Q12,
int16_t *PitchLagQ7);
int WebRtcIsacfix_DecodePitchLag(Bitstr_dec* streamdata,
int16_t* PitchGain_Q12,
int16_t* PitchLagQ7);
int WebRtcIsacfix_DecodeFrameLen(Bitstr_dec *streamdata,
size_t *framelength);
int WebRtcIsacfix_DecodeFrameLen(Bitstr_dec* streamdata, size_t* framelength);
int WebRtcIsacfix_EncodeFrameLen(int16_t framelength, Bitstr_enc* streamdata);
int WebRtcIsacfix_EncodeFrameLen(int16_t framelength,
Bitstr_enc *streamdata);
int WebRtcIsacfix_DecodeSendBandwidth(Bitstr_dec* streamdata, int16_t* BWno);
int WebRtcIsacfix_DecodeSendBandwidth(Bitstr_dec *streamdata,
int16_t *BWno);
int WebRtcIsacfix_EncodeReceiveBandwidth(int16_t* BWno, Bitstr_enc* streamdata);
int WebRtcIsacfix_EncodeReceiveBandwidth(int16_t *BWno,
Bitstr_enc *streamdata);
void WebRtcIsacfix_TranscodeLpcCoef(int32_t *tmpcoeffs_gQ6,
int16_t *index_gQQ);
void WebRtcIsacfix_TranscodeLpcCoef(int32_t* tmpcoeffs_gQ6, int16_t* index_gQQ);
// Pointer functions for LPC transforms.

View File

@ -32,8 +32,8 @@
#include "modules/audio_coding/codecs/isac/fix/source/structs.h"
int16_t WebRtcIsacfix_FftRadix16Fastest(int16_t RexQx[], int16_t ImxQx[], int16_t iSign);
int16_t WebRtcIsacfix_FftRadix16Fastest(int16_t RexQx[],
int16_t ImxQx[],
int16_t iSign);
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_FFT_H_ */

View File

@ -42,44 +42,41 @@ void WebRtcIsacfix_HighpassFilterFixDec32MIPS(int16_t* io,
#endif
typedef void (*AllpassFilter2FixDec16)(
int16_t *data_ch1, // Input and output in channel 1, in Q0
int16_t *data_ch2, // Input and output in channel 2, in Q0
const int16_t *factor_ch1, // Scaling factor for channel 1, in Q15
const int16_t *factor_ch2, // Scaling factor for channel 2, in Q15
int16_t* data_ch1, // Input and output in channel 1, in Q0
int16_t* data_ch2, // Input and output in channel 2, in Q0
const int16_t* factor_ch1, // Scaling factor for channel 1, in Q15
const int16_t* factor_ch2, // Scaling factor for channel 2, in Q15
const int length, // Length of the data buffers
int32_t *filter_state_ch1, // Filter state for channel 1, in Q16
int32_t *filter_state_ch2); // Filter state for channel 2, in Q16
int32_t* filter_state_ch1, // Filter state for channel 1, in Q16
int32_t* filter_state_ch2); // Filter state for channel 2, in Q16
extern AllpassFilter2FixDec16 WebRtcIsacfix_AllpassFilter2FixDec16;
void WebRtcIsacfix_AllpassFilter2FixDec16C(
int16_t *data_ch1,
int16_t *data_ch2,
const int16_t *factor_ch1,
const int16_t *factor_ch2,
const int length,
int32_t *filter_state_ch1,
int32_t *filter_state_ch2);
void WebRtcIsacfix_AllpassFilter2FixDec16C(int16_t* data_ch1,
int16_t* data_ch2,
const int16_t* factor_ch1,
const int16_t* factor_ch2,
const int length,
int32_t* filter_state_ch1,
int32_t* filter_state_ch2);
#if defined(WEBRTC_HAS_NEON)
void WebRtcIsacfix_AllpassFilter2FixDec16Neon(
int16_t *data_ch1,
int16_t *data_ch2,
const int16_t *factor_ch1,
const int16_t *factor_ch2,
const int length,
int32_t *filter_state_ch1,
int32_t *filter_state_ch2);
void WebRtcIsacfix_AllpassFilter2FixDec16Neon(int16_t* data_ch1,
int16_t* data_ch2,
const int16_t* factor_ch1,
const int16_t* factor_ch2,
const int length,
int32_t* filter_state_ch1,
int32_t* filter_state_ch2);
#endif
#if defined(MIPS_DSP_R1_LE)
void WebRtcIsacfix_AllpassFilter2FixDec16MIPS(
int16_t *data_ch1,
int16_t *data_ch2,
const int16_t *factor_ch1,
const int16_t *factor_ch2,
const int length,
int32_t *filter_state_ch1,
int32_t *filter_state_ch2);
void WebRtcIsacfix_AllpassFilter2FixDec16MIPS(int16_t* data_ch1,
int16_t* data_ch2,
const int16_t* factor_ch1,
const int16_t* factor_ch2,
const int length,
int32_t* filter_state_ch1,
int32_t* filter_state_ch2);
#endif
#if defined(__cplusplus) || defined(c_plusplus)

View File

@ -21,8 +21,8 @@ class FilterBanksTest : public testing::Test {
protected:
// Pass a function pointer to the Tester function.
void RTC_NO_SANITIZE("signed-integer-overflow") // bugs.webrtc.org/5513
CalculateResidualEnergyTester(AllpassFilter2FixDec16
AllpassFilter2FixDec16Function) {
CalculateResidualEnergyTester(
AllpassFilter2FixDec16 AllpassFilter2FixDec16Function) {
const int kSamples = QLOOKAHEAD;
const int kState = 2;
int16_t data_ch1[kSamples] = {0};
@ -31,12 +31,14 @@ class FilterBanksTest : public testing::Test {
int32_t state_ch2[kState] = {0};
const int32_t out_state_ch1[kState] = {-809122714, 1645972152};
const int32_t out_state_ch2[kState] = {428019288, 1057309936};
const int32_t out_data_ch1[kSamples] = {0, 0, 347, 10618, 16718, -7089,
32767, 16913, 27042, 8377, -22973, -28372, -27603, -14804, 398, -25332,
-11200, 18044, 25223, -6839, 1116, -23984, 32717, 7364};
const int32_t out_data_ch2[kSamples] = {0, 0, 3010, 22351, 21106, 16969,
-2095, -664, 3513, -30980, 32767, -23839, 13335, 20289, -6831, 339,
-17207, 32767, 4959, 6177, 32767, 16599, -4747, 20504};
const int32_t out_data_ch1[kSamples] = {
0, 0, 347, 10618, 16718, -7089, 32767, 16913,
27042, 8377, -22973, -28372, -27603, -14804, 398, -25332,
-11200, 18044, 25223, -6839, 1116, -23984, 32717, 7364};
const int32_t out_data_ch2[kSamples] = {
0, 0, 3010, 22351, 21106, 16969, -2095, -664,
3513, -30980, 32767, -23839, 13335, 20289, -6831, 339,
-17207, 32767, 4959, 6177, 32767, 16599, -4747, 20504};
int sign = 1;
for (int i = 0; i < kSamples; i++) {
@ -46,13 +48,9 @@ class FilterBanksTest : public testing::Test {
// UBSan: -1 * -2147483648 cannot be represented in type 'int'
};
AllpassFilter2FixDec16Function(data_ch1,
data_ch2,
WebRtcIsacfix_kUpperApFactorsQ15,
WebRtcIsacfix_kLowerApFactorsQ15,
kSamples,
state_ch1,
state_ch2);
AllpassFilter2FixDec16Function(
data_ch1, data_ch2, WebRtcIsacfix_kUpperApFactorsQ15,
WebRtcIsacfix_kLowerApFactorsQ15, kSamples, state_ch1, state_ch2);
for (int i = 0; i < kSamples; i++) {
EXPECT_EQ(out_data_ch1[i], data_ch1[i]);
@ -77,13 +75,13 @@ TEST_F(FilterBanksTest, HighpassFilterFixDec32Test) {
int16_t in[kSamples];
int32_t state[2] = {12345, 987654};
#ifdef WEBRTC_ARCH_ARM_V7
int32_t out[kSamples] = {-1040, -1035, -22875, -1397, -27604, 20018, 7917,
-1279, -8552, -14494, -7558, -23537, -27258, -30554, -32768, -3432, -32768,
25215, -27536, 22436};
int32_t out[kSamples] = {-1040, -1035, -22875, -1397, -27604, 20018, 7917,
-1279, -8552, -14494, -7558, -23537, -27258, -30554,
-32768, -3432, -32768, 25215, -27536, 22436};
#else
int32_t out[kSamples] = {-1040, -1035, -22875, -1397, -27604, 20017, 7915,
-1280, -8554, -14496, -7561, -23541, -27263, -30560, -32768, -3441, -32768,
25203, -27550, 22419};
int32_t out[kSamples] = {-1040, -1035, -22875, -1397, -27604, 20017, 7915,
-1280, -8554, -14496, -7561, -23541, -27263, -30560,
-32768, -3441, -32768, 25203, -27550, 22419};
#endif
HighpassFilterFixDec32 WebRtcIsacfix_HighpassFilterFixDec32;
#if defined(MIPS_DSP_R1_LE)
@ -98,7 +96,7 @@ TEST_F(FilterBanksTest, HighpassFilterFixDec32Test) {
}
WebRtcIsacfix_HighpassFilterFixDec32(in, kSamples,
WebRtcIsacfix_kHPStCoeffOut1Q30, state);
WebRtcIsacfix_kHPStCoeffOut1Q30, state);
for (int i = 0; i < kSamples; i++) {
EXPECT_EQ(out[i], in[i]);

View File

@ -23,34 +23,37 @@ class FiltersTest : public testing::Test {
int32_t r_buffer[kOrder + 2] = {0};
// Test an overflow case.
const int16_t x_buffer_0[kBuffer] = {0, 0, 3010, 22351, 21106, 16969, -2095,
-664, 3513, -30980, 32767, -23839, 13335, 20289, -6831, 339, -17207,
32767, 4959, 6177, 32767, 16599, -4747, 20504, 3513, -30980, 32767,
-23839, 13335, 20289, 0, -16969, -2095, -664, 3513, 31981, 32767,
-13839, 23336, 30281};
const int32_t r_expected_0[kOrder + 2] = {1872498461, -224288754, 203789985,
483400487, -208272635, 2436500, 137785322, 266600814, -208486262,
329510080, 137949184, -161738972, -26894267, 237630192};
const int16_t x_buffer_0[kBuffer] = {
0, 0, 3010, 22351, 21106, 16969, -2095, -664,
3513, -30980, 32767, -23839, 13335, 20289, -6831, 339,
-17207, 32767, 4959, 6177, 32767, 16599, -4747, 20504,
3513, -30980, 32767, -23839, 13335, 20289, 0, -16969,
-2095, -664, 3513, 31981, 32767, -13839, 23336, 30281};
const int32_t r_expected_0[kOrder + 2] = {
1872498461, -224288754, 203789985, 483400487, -208272635,
2436500, 137785322, 266600814, -208486262, 329510080,
137949184, -161738972, -26894267, 237630192};
WebRtcIsacfix_AutocorrFixFunction(r_buffer, x_buffer_0,
kBuffer, kOrder + 1, &scale);
WebRtcIsacfix_AutocorrFixFunction(r_buffer, x_buffer_0, kBuffer, kOrder + 1,
&scale);
for (int i = 0; i < kOrder + 2; i++) {
EXPECT_EQ(r_expected_0[i], r_buffer[i]);
}
EXPECT_EQ(3, scale);
// Test a no-overflow case.
const int16_t x_buffer_1[kBuffer] = {0, 0, 300, 21, 206, 169, -295,
-664, 3513, -300, 327, -29, 15, 289, -6831, 339, -107,
37, 59, 6177, 327, 169, -4747, 204, 313, -980, 767,
-9, 135, 289, 0, -6969, -2095, -664, 0, 1, 7,
-39, 236, 281};
const int32_t r_expected_1[kOrder + 2] = {176253864, 8126617, 1983287,
-26196788, -3487363, -42839676, -24644043, 3469813, 30559879, 31905045,
5101567, 29328896, -55787438, -13163978};
const int16_t x_buffer_1[kBuffer] = {
0, 0, 300, 21, 206, 169, -295, -664, 3513, -300,
327, -29, 15, 289, -6831, 339, -107, 37, 59, 6177,
327, 169, -4747, 204, 313, -980, 767, -9, 135, 289,
0, -6969, -2095, -664, 0, 1, 7, -39, 236, 281};
const int32_t r_expected_1[kOrder + 2] = {
176253864, 8126617, 1983287, -26196788, -3487363,
-42839676, -24644043, 3469813, 30559879, 31905045,
5101567, 29328896, -55787438, -13163978};
WebRtcIsacfix_AutocorrFixFunction(r_buffer, x_buffer_1,
kBuffer, kOrder + 1, &scale);
WebRtcIsacfix_AutocorrFixFunction(r_buffer, x_buffer_1, kBuffer, kOrder + 1,
&scale);
for (int i = 0; i < kOrder + 2; i++) {
EXPECT_EQ(r_expected_1[i], r_buffer[i]);
}

View File

@ -24,19 +24,19 @@ extern "C" {
#include "modules/audio_coding/codecs/isac/fix/source/structs.h"
void WebRtcIsacfix_GetVars(const int16_t *input,
const int16_t *pitchGains_Q12,
uint32_t *oldEnergy,
int16_t *varscale);
void WebRtcIsacfix_GetVars(const int16_t* input,
const int16_t* pitchGains_Q12,
uint32_t* oldEnergy,
int16_t* varscale);
void WebRtcIsacfix_GetLpcCoef(int16_t *inLoQ0,
int16_t *inHiQ0,
MaskFiltstr_enc *maskdata,
void WebRtcIsacfix_GetLpcCoef(int16_t* inLoQ0,
int16_t* inHiQ0,
MaskFiltstr_enc* maskdata,
int16_t snrQ10,
const int16_t *pitchGains_Q12,
int32_t *gain_lo_hiQ17,
int16_t *lo_coeffQ15,
int16_t *hi_coeffQ15);
const int16_t* pitchGains_Q12,
int32_t* gain_lo_hiQ17,
int16_t* lo_coeffQ15,
int16_t* hi_coeffQ15);
typedef int32_t (*CalculateResidualEnergy)(int lpc_order,
int32_t q_val_corr,

View File

@ -16,21 +16,21 @@
class LpcMaskingModelTest : public testing::Test {
protected:
// Pass a function pointer to the Tester function.
void CalculateResidualEnergyTester(CalculateResidualEnergy
CalculateResidualEnergyFunction) {
void CalculateResidualEnergyTester(
CalculateResidualEnergy CalculateResidualEnergyFunction) {
const int kIntOrder = 10;
const int32_t kInt32QDomain = 5;
const int kIntShift = 11;
int16_t a[kIntOrder + 1] = {32760, 122, 7, 0, -32760, -3958,
-48, 18745, 498, 9, 23456};
int32_t corr[kIntOrder + 1] = {11443647, -27495, 0,
98745, -11443600, 1, 1, 498, 9, 888, 23456};
int16_t a[kIntOrder + 1] = {32760, 122, 7, 0, -32760, -3958,
-48, 18745, 498, 9, 23456};
int32_t corr[kIntOrder + 1] = {11443647, -27495, 0, 98745, -11443600, 1,
1, 498, 9, 888, 23456};
int q_shift_residual = 0;
int32_t residual_energy = 0;
// Test the code path where (residual_energy >= 0x10000).
residual_energy = CalculateResidualEnergyFunction(kIntOrder,
kInt32QDomain, kIntShift, a, corr, &q_shift_residual);
residual_energy = CalculateResidualEnergyFunction(
kIntOrder, kInt32QDomain, kIntShift, a, corr, &q_shift_residual);
EXPECT_EQ(1789023310, residual_energy);
EXPECT_EQ(2, q_shift_residual);
@ -40,8 +40,8 @@ class LpcMaskingModelTest : public testing::Test {
a[i] = 24575 >> i;
corr[i] = i;
}
residual_energy = CalculateResidualEnergyFunction(kIntOrder,
kInt32QDomain, kIntShift, a, corr, &q_shift_residual);
residual_energy = CalculateResidualEnergyFunction(
kIntOrder, kInt32QDomain, kIntShift, a, corr, &q_shift_residual);
EXPECT_EQ(1595279092, residual_energy);
EXPECT_EQ(26, q_shift_residual);
@ -49,8 +49,8 @@ class LpcMaskingModelTest : public testing::Test {
for (int i = 0; i < kIntOrder + 1; i++) {
a[i] = 2457 >> i;
}
residual_energy = CalculateResidualEnergyFunction(kIntOrder,
kInt32QDomain, kIntShift, a, corr, &q_shift_residual);
residual_energy = CalculateResidualEnergyFunction(
kIntOrder, kInt32QDomain, kIntShift, a, corr, &q_shift_residual);
EXPECT_EQ(2029266944, residual_energy);
EXPECT_EQ(33, q_shift_residual);
}

View File

@ -26,10 +26,10 @@ extern const uint16_t WebRtcIsacfix_kSelIndGain[12];
extern const uint16_t WebRtcIsacfix_kSelIndShape[108];
/* cdf array for model indicator */
extern const uint16_t WebRtcIsacfix_kModelCdf[KLT_NUM_MODELS+1];
extern const uint16_t WebRtcIsacfix_kModelCdf[KLT_NUM_MODELS + 1];
/* pointer to cdf array for model indicator */
extern const uint16_t *WebRtcIsacfix_kModelCdfPtr[1];
extern const uint16_t* WebRtcIsacfix_kModelCdfPtr[1];
/* initial cdf index for decoder of model indicator */
extern const uint16_t WebRtcIsacfix_kModelInitIndex[1];
@ -70,9 +70,9 @@ extern const uint16_t WebRtcIsacfix_kCdfGain[1212];
extern const uint16_t WebRtcIsacfix_kCdfShape[2059];
/* pointers to cdf tables for quantizer indices */
extern const uint16_t *WebRtcIsacfix_kCdfGainPtr[KLT_NUM_MODELS][12];
extern const uint16_t* WebRtcIsacfix_kCdfGainPtr[KLT_NUM_MODELS][12];
extern const uint16_t *WebRtcIsacfix_kCdfShapePtr[KLT_NUM_MODELS][108];
extern const uint16_t* WebRtcIsacfix_kCdfShapePtr[KLT_NUM_MODELS][108];
/* code length for all coefficients using different models */
extern const int16_t WebRtcIsacfix_kCodeLenGainQ11[392];

View File

@ -20,21 +20,22 @@
#include "modules/audio_coding/codecs/isac/fix/source/structs.h"
void WebRtcIsacfix_PitchAnalysis(const int16_t *in, /* PITCH_FRAME_LEN samples */
int16_t *outQ0, /* PITCH_FRAME_LEN+QLOOKAHEAD samples */
PitchAnalysisStruct *State,
int16_t *lagsQ7,
int16_t *PitchGains_Q12);
void WebRtcIsacfix_PitchAnalysis(
const int16_t* in, /* PITCH_FRAME_LEN samples */
int16_t* outQ0, /* PITCH_FRAME_LEN+QLOOKAHEAD samples */
PitchAnalysisStruct* State,
int16_t* lagsQ7,
int16_t* PitchGains_Q12);
void WebRtcIsacfix_InitialPitch(const int16_t *in,
PitchAnalysisStruct *State,
int16_t *qlags);
void WebRtcIsacfix_InitialPitch(const int16_t* in,
PitchAnalysisStruct* State,
int16_t* qlags);
void WebRtcIsacfix_PitchFilter(int16_t *indatFix,
int16_t *outdatQQ,
PitchFiltstr *pfp,
int16_t *lagsQ7,
int16_t *gainsQ12,
void WebRtcIsacfix_PitchFilter(int16_t* indatFix,
int16_t* outdatQQ,
PitchFiltstr* pfp,
int16_t* lagsQ7,
int16_t* gainsQ12,
int16_t type);
void WebRtcIsacfix_PitchFilterCore(int loopNumber,
@ -48,17 +49,18 @@ void WebRtcIsacfix_PitchFilterCore(int loopNumber,
int16_t* outputBuf,
int* index2);
void WebRtcIsacfix_PitchFilterGains(const int16_t *indatQ0,
PitchFiltstr *pfp,
int16_t *lagsQ7,
int16_t *gainsQ12);
void WebRtcIsacfix_PitchFilterGains(const int16_t* indatQ0,
PitchFiltstr* pfp,
int16_t* lagsQ7,
int16_t* gainsQ12);
void WebRtcIsacfix_DecimateAllpass32(const int16_t *in,
int32_t *state_in, /* array of size: 2*ALLPASSSECTIONS+1 */
int16_t N, /* number of input samples */
int16_t *out); /* array of size N/2 */
void WebRtcIsacfix_DecimateAllpass32(
const int16_t* in,
int32_t* state_in, /* array of size: 2*ALLPASSSECTIONS+1 */
int16_t N, /* number of input samples */
int16_t* out); /* array of size N/2 */
int32_t WebRtcIsacfix_Log2Q8( uint32_t x );
int32_t WebRtcIsacfix_Log2Q8(uint32_t x);
void WebRtcIsacfix_PCorr2Q32(const int16_t* in, int32_t* logcorQ8);

View File

@ -11,7 +11,8 @@
/*
* pitch_gain_tables.h
*
* This file contains tables for the pitch filter side-info in the entropy coder.
* This file contains tables for the pitch filter side-info in the entropy
* coder.
*
*/
@ -20,7 +21,8 @@
#include "typedefs.h" // NOLINT(build/include)
/********************* Pitch Filter Gain Coefficient Tables ************************/
/********************* Pitch Filter Gain Coefficient Tables
* ************************/
/* cdf for quantized pitch filter gains */
extern const uint16_t WebRtcIsacfix_kPitchGainCdf[255];

View File

@ -11,7 +11,8 @@
/*
* pitch_lag_tables.h
*
* This file contains tables for the pitch filter side-info in the entropy coder.
* This file contains tables for the pitch filter side-info in the entropy
* coder.
*
*/
@ -20,7 +21,8 @@
#include "typedefs.h" // NOLINT(build/include)
/********************* Pitch Filter Lag Coefficient Tables ************************/
/********************* Pitch Filter Lag Coefficient Tables
* ************************/
/* tables for use with small pitch gain */
@ -30,7 +32,7 @@ extern const uint16_t WebRtcIsacfix_kPitchLagCdf2Lo[20];
extern const uint16_t WebRtcIsacfix_kPitchLagCdf3Lo[2];
extern const uint16_t WebRtcIsacfix_kPitchLagCdf4Lo[10];
extern const uint16_t *WebRtcIsacfix_kPitchLagPtrLo[4];
extern const uint16_t* WebRtcIsacfix_kPitchLagPtrLo[4];
/* size of first cdf table */
extern const uint16_t WebRtcIsacfix_kPitchLagSizeLo[1];
@ -46,8 +48,6 @@ extern const uint16_t WebRtcIsacfix_kInitIndLo[3];
extern const int16_t WebRtcIsacfix_kMeanLag2Lo[19];
extern const int16_t WebRtcIsacfix_kMeanLag4Lo[9];
/* tables for use with medium pitch gain */
/* cdfs for quantized pitch lags */
@ -56,7 +56,7 @@ extern const uint16_t WebRtcIsacfix_kPitchLagCdf2Mid[36];
extern const uint16_t WebRtcIsacfix_kPitchLagCdf3Mid[2];
extern const uint16_t WebRtcIsacfix_kPitchLagCdf4Mid[20];
extern const uint16_t *WebRtcIsacfix_kPitchLagPtrMid[4];
extern const uint16_t* WebRtcIsacfix_kPitchLagPtrMid[4];
/* size of first cdf table */
extern const uint16_t WebRtcIsacfix_kPitchLagSizeMid[1];
@ -72,7 +72,6 @@ extern const uint16_t WebRtcIsacfix_kInitIndMid[3];
extern const int16_t WebRtcIsacfix_kMeanLag2Mid[35];
extern const int16_t WebRtcIsacfix_kMeanLag4Mid[19];
/* tables for use with large pitch gain */
/* cdfs for quantized pitch lags */
@ -81,7 +80,7 @@ extern const uint16_t WebRtcIsacfix_kPitchLagCdf2Hi[68];
extern const uint16_t WebRtcIsacfix_kPitchLagCdf3Hi[2];
extern const uint16_t WebRtcIsacfix_kPitchLagCdf4Hi[35];
extern const uint16_t *WebRtcIsacfix_kPitchLagPtrHi[4];
extern const uint16_t* WebRtcIsacfix_kPitchLagPtrHi[4];
/* size of first cdf table */
extern const uint16_t WebRtcIsacfix_kPitchLagSizeHi[1];
@ -97,5 +96,4 @@ extern const uint16_t WebRtcIsacfix_kInitIndHi[3];
extern const int16_t WebRtcIsacfix_kMeanLag2Hi[67];
extern const int16_t WebRtcIsacfix_kMeanLag4Hi[34];
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_PITCH_LAG_TABLES_H_ */

View File

@ -18,84 +18,82 @@
#ifndef MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SETTINGS_H_
#define MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SETTINGS_H_
/* sampling frequency (Hz) */
#define FS 16000
#define FS 16000
/* 1.5 times Sampling frequency */
#define FS_1_HALF (uint32_t) 24000
#define FS_1_HALF (uint32_t)24000
/* Three times Sampling frequency */
#define FS3 (uint32_t) 48000
#define FS3 (uint32_t)48000
/* Eight times Sampling frequency */
#define FS8 (uint32_t) 128000
#define FS8 (uint32_t)128000
/* number of samples per frame (either 480 (30ms) or 960 (60ms)) */
#define INITIAL_FRAMESAMPLES 960
#define INITIAL_FRAMESAMPLES 960
/* miliseconds */
#define FRAMESIZE 30
#define FRAMESIZE 30
/* number of samples per frame processed in the encoder (30ms) */
#define FRAMESAMPLES 480 /* ((FRAMESIZE*FS)/1000) */
#define FRAMESAMPLES_HALF 240
#define FRAMESAMPLES 480 /* ((FRAMESIZE*FS)/1000) */
#define FRAMESAMPLES_HALF 240
/* max number of samples per frame (= 60 ms frame) */
#define MAX_FRAMESAMPLES 960
#define MAX_FRAMESAMPLES 960
/* number of samples per 10ms frame */
#define FRAMESAMPLES_10ms 160 /* ((10*FS)/1000) */
#define FRAMESAMPLES_10ms 160 /* ((10*FS)/1000) */
/* Number of samples per 1 ms */
#define SAMPLES_PER_MSEC 16
#define SAMPLES_PER_MSEC 16
/* number of subframes */
#define SUBFRAMES 6
#define SUBFRAMES 6
/* length of a subframe */
#define UPDATE 80
#define UPDATE 80
/* length of half a subframe (low/high band) */
#define HALF_SUBFRAMELEN 40 /* (UPDATE/2) */
/* samples of look ahead (in a half-band, so actually half the samples of look ahead @ FS) */
#define QLOOKAHEAD 24 /* 3 ms */
#define HALF_SUBFRAMELEN 40 /* (UPDATE/2) */
/* samples of look ahead (in a half-band, so actually half the samples of look
* ahead @ FS) */
#define QLOOKAHEAD 24 /* 3 ms */
/* order of AR model in spectral entropy coder */
#define AR_ORDER 6
#define MAX_ORDER 13
#define LEVINSON_MAX_ORDER 12
#define AR_ORDER 6
#define MAX_ORDER 13
#define LEVINSON_MAX_ORDER 12
/* window length (masking analysis) */
#define WINLEN 256
#define WINLEN 256
/* order of low-band pole filter used to approximate masking curve */
#define ORDERLO 12
#define ORDERLO 12
/* order of hi-band pole filter used to approximate masking curve */
#define ORDERHI 6
#define KLT_NUM_AVG_GAIN 0
#define KLT_NUM_AVG_SHAPE 0
#define KLT_NUM_MODELS 3
#define LPC_SHAPE_ORDER 18 /* (ORDERLO + ORDERHI) */
#define KLT_ORDER_GAIN 12 /* (2 * SUBFRAMES) */
#define KLT_ORDER_SHAPE 108 /* (LPC_SHAPE_ORDER * SUBFRAMES) */
#define ORDERHI 6
#define KLT_NUM_AVG_GAIN 0
#define KLT_NUM_AVG_SHAPE 0
#define KLT_NUM_MODELS 3
#define LPC_SHAPE_ORDER 18 /* (ORDERLO + ORDERHI) */
#define KLT_ORDER_GAIN 12 /* (2 * SUBFRAMES) */
#define KLT_ORDER_SHAPE 108 /* (LPC_SHAPE_ORDER * SUBFRAMES) */
/* order for post_filter_bank */
#define POSTQORDER 3
#define POSTQORDER 3
/* order for pre-filterbank */
#define QORDER 3
#define QORDER 3
/* for decimator */
#define ALLPASSSECTIONS 2
#define ALLPASSSECTIONS 2
/* The number of composite all-pass filter factors */
#define NUMBEROFCOMPOSITEAPSECTIONS 4
#define NUMBEROFCOMPOSITEAPSECTIONS 4
/* The number of all-pass filter factors in an upper or lower channel*/
#define NUMBEROFCHANNELAPSECTIONS 2
#define DPMIN_Q10 -10240 /* -10.00 in Q10 */
#define DPMAX_Q10 10240 /* 10.00 in Q10 */
#define MINBITS_Q10 10240 /* 10.0 in Q10 */
#define NUMBEROFCHANNELAPSECTIONS 2
#define DPMIN_Q10 -10240 /* -10.00 in Q10 */
#define DPMAX_Q10 10240 /* 10.00 in Q10 */
#define MINBITS_Q10 10240 /* 10.0 in Q10 */
/* array size for byte stream in number of Word16. */
#define STREAM_MAXW16 300 /* The old maximum size still needed for the decoding */
#define STREAM_MAXW16_30MS 100 /* 100 Word16 = 200 bytes = 53.4 kbit/s @ 30 ms.framelength */
#define STREAM_MAXW16_60MS 200 /* 200 Word16 = 400 bytes = 53.4 kbit/s @ 60 ms.framelength */
#define STREAM_MAXW16 \
300 /* The old maximum size still needed for the decoding */
#define STREAM_MAXW16_30MS \
100 /* 100 Word16 = 200 bytes = 53.4 kbit/s @ 30 ms.framelength */
#define STREAM_MAXW16_60MS \
200 /* 200 Word16 = 400 bytes = 53.4 kbit/s @ 60 ms.framelength */
/* This is used only at the decoder bit-stream struct.
* - The encoder and decoder bitstream containers are of different size because
* old iSAC limited the encoded bitstream to 600 bytes. But newer versions
@ -110,106 +108,104 @@
/* storage size for bit counts */
//#define BIT_COUNTER_SIZE 30
/* maximum order of any AR model or filter */
#define MAX_AR_MODEL_ORDER 12
#define MAX_AR_MODEL_ORDER 12
/* Maximum number of iterations allowed to limit payload size */
#define MAX_PAYLOAD_LIMIT_ITERATION 1
#define MAX_PAYLOAD_LIMIT_ITERATION 1
/* Bandwidth estimator */
#define MIN_ISAC_BW 10000 /* Minimum bandwidth in bits per sec */
#define MAX_ISAC_BW 32000 /* Maxmum bandwidth in bits per sec */
#define MIN_ISAC_MD 5 /* Minimum Max Delay in ?? */
#define MAX_ISAC_MD 25 /* Maxmum Max Delay in ?? */
#define DELAY_CORRECTION_MAX 717
#define DELAY_CORRECTION_MED 819
#define Thld_30_60 18000
#define Thld_60_30 27000
#define MIN_ISAC_BW 10000 /* Minimum bandwidth in bits per sec */
#define MAX_ISAC_BW 32000 /* Maxmum bandwidth in bits per sec */
#define MIN_ISAC_MD 5 /* Minimum Max Delay in ?? */
#define MAX_ISAC_MD 25 /* Maxmum Max Delay in ?? */
#define DELAY_CORRECTION_MAX 717
#define DELAY_CORRECTION_MED 819
#define Thld_30_60 18000
#define Thld_60_30 27000
/* assumed header size; we don't know the exact number (header compression may be used) */
#define HEADER_SIZE 35 /* bytes */
#define INIT_FRAME_LEN 60
#define INIT_BN_EST 20000
#define INIT_BN_EST_Q7 2560000 /* 20 kbps in Q7 */
#define INIT_REC_BN_EST_Q5 789312 /* INIT_BN_EST + INIT_HDR_RATE in Q5 */
/* assumed header size; we don't know the exact number (header compression may
* be used) */
#define HEADER_SIZE 35 /* bytes */
#define INIT_FRAME_LEN 60
#define INIT_BN_EST 20000
#define INIT_BN_EST_Q7 2560000 /* 20 kbps in Q7 */
#define INIT_REC_BN_EST_Q5 789312 /* INIT_BN_EST + INIT_HDR_RATE in Q5 */
/* 8738 in Q18 is ~ 1/30 */
/* #define INIT_HDR_RATE (((HEADER_SIZE * 8 * 1000) * 8738) >> NUM_BITS_TO_SHIFT (INIT_FRAME_LEN)) */
#define INIT_HDR_RATE 4666
/* #define INIT_HDR_RATE (((HEADER_SIZE * 8 * 1000) * 8738) >> NUM_BITS_TO_SHIFT
* (INIT_FRAME_LEN)) */
#define INIT_HDR_RATE 4666
/* number of packets in a row for a high rate burst */
#define BURST_LEN 3
#define BURST_LEN 3
/* ms, max time between two full bursts */
#define BURST_INTERVAL 800
#define BURST_INTERVAL 800
/* number of packets in a row for initial high rate burst */
#define INIT_BURST_LEN 5
#define INIT_BURST_LEN 5
/* bits/s, rate for the first BURST_LEN packets */
#define INIT_RATE 10240000 /* INIT_BN_EST in Q9 */
#define INIT_RATE 10240000 /* INIT_BN_EST in Q9 */
/* For pitch analysis */
#define PITCH_FRAME_LEN 240 /* (FRAMESAMPLES/2) 30 ms */
#define PITCH_MAX_LAG 140 /* 57 Hz */
#define PITCH_MIN_LAG 20 /* 400 Hz */
#define PITCH_MIN_LAG_Q8 5120 /* 256 * PITCH_MIN_LAG */
#define OFFSET_Q8 768 /* 256 * 3 */
#define PITCH_FRAME_LEN 240 /* (FRAMESAMPLES/2) 30 ms */
#define PITCH_MAX_LAG 140 /* 57 Hz */
#define PITCH_MIN_LAG 20 /* 400 Hz */
#define PITCH_MIN_LAG_Q8 5120 /* 256 * PITCH_MIN_LAG */
#define OFFSET_Q8 768 /* 256 * 3 */
#define PITCH_MAX_GAIN_Q12 1843 /* 0.45 */
#define PITCH_LAG_SPAN2 65 /* (PITCH_MAX_LAG/2-PITCH_MIN_LAG/2+5) */
#define PITCH_CORR_LEN2 60 /* 15 ms */
#define PITCH_CORR_STEP2 60 /* (PITCH_FRAME_LEN/4) */
#define PITCH_SUBFRAMES 4
#define PITCH_SUBFRAME_LEN 60 /* (PITCH_FRAME_LEN/PITCH_SUBFRAMES) */
#define PITCH_MAX_GAIN_Q12 1843 /* 0.45 */
#define PITCH_LAG_SPAN2 65 /* (PITCH_MAX_LAG/2-PITCH_MIN_LAG/2+5) */
#define PITCH_CORR_LEN2 60 /* 15 ms */
#define PITCH_CORR_STEP2 60 /* (PITCH_FRAME_LEN/4) */
#define PITCH_SUBFRAMES 4
#define PITCH_SUBFRAME_LEN 60 /* (PITCH_FRAME_LEN/PITCH_SUBFRAMES) */
/* For pitch filter */
#define PITCH_BUFFSIZE 190 /* (PITCH_MAX_LAG + 50) Extra 50 for fraction and LP filters */
#define PITCH_INTBUFFSIZE 430 /* (PITCH_FRAME_LEN+PITCH_BUFFSIZE) */
#define PITCH_FRACS 8
#define PITCH_FRACORDER 9
#define PITCH_DAMPORDER 5
#define PITCH_BUFFSIZE \
190 /* (PITCH_MAX_LAG + 50) Extra 50 for fraction and LP filters */
#define PITCH_INTBUFFSIZE 430 /* (PITCH_FRAME_LEN+PITCH_BUFFSIZE) */
#define PITCH_FRACS 8
#define PITCH_FRACORDER 9
#define PITCH_DAMPORDER 5
/* Order of high pass filter */
#define HPORDER 2
#define HPORDER 2
/* PLC */
#define DECAY_RATE 10 /* Q15, 20% of decay every lost frame apllied linearly sample by sample*/
#define PLC_WAS_USED 1
#define PLC_NOT_USED 3
#define RECOVERY_OVERLAP 80
#define RESAMP_RES 256
#define RESAMP_RES_BIT 8
#define DECAY_RATE \
10 /* Q15, 20% of decay every lost frame apllied linearly sample by sample*/
#define PLC_WAS_USED 1
#define PLC_NOT_USED 3
#define RECOVERY_OVERLAP 80
#define RESAMP_RES 256
#define RESAMP_RES_BIT 8
/* Define Error codes */
/* 6000 General */
#define ISAC_MEMORY_ALLOCATION_FAILED 6010
#define ISAC_MODE_MISMATCH 6020
#define ISAC_DISALLOWED_BOTTLENECK 6030
#define ISAC_DISALLOWED_FRAME_LENGTH 6040
#define ISAC_MEMORY_ALLOCATION_FAILED 6010
#define ISAC_MODE_MISMATCH 6020
#define ISAC_DISALLOWED_BOTTLENECK 6030
#define ISAC_DISALLOWED_FRAME_LENGTH 6040
/* 6200 Bandwidth estimator */
#define ISAC_RANGE_ERROR_BW_ESTIMATOR 6240
#define ISAC_RANGE_ERROR_BW_ESTIMATOR 6240
/* 6400 Encoder */
#define ISAC_ENCODER_NOT_INITIATED 6410
#define ISAC_DISALLOWED_CODING_MODE 6420
#define ISAC_DISALLOWED_FRAME_MODE_ENCODER 6430
#define ISAC_DISALLOWED_BITSTREAM_LENGTH 6440
#define ISAC_PAYLOAD_LARGER_THAN_LIMIT 6450
#define ISAC_ENCODER_NOT_INITIATED 6410
#define ISAC_DISALLOWED_CODING_MODE 6420
#define ISAC_DISALLOWED_FRAME_MODE_ENCODER 6430
#define ISAC_DISALLOWED_BITSTREAM_LENGTH 6440
#define ISAC_PAYLOAD_LARGER_THAN_LIMIT 6450
/* 6600 Decoder */
#define ISAC_DECODER_NOT_INITIATED 6610
#define ISAC_EMPTY_PACKET 6620
#define ISAC_DECODER_NOT_INITIATED 6610
#define ISAC_EMPTY_PACKET 6620
#define ISAC_PACKET_TOO_SHORT 6625
#define ISAC_DISALLOWED_FRAME_MODE_DECODER 6630
#define ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH 6640
#define ISAC_RANGE_ERROR_DECODE_BANDWIDTH 6650
#define ISAC_RANGE_ERROR_DECODE_PITCH_GAIN 6660
#define ISAC_RANGE_ERROR_DECODE_PITCH_LAG 6670
#define ISAC_RANGE_ERROR_DECODE_LPC 6680
#define ISAC_RANGE_ERROR_DECODE_SPECTRUM 6690
#define ISAC_LENGTH_MISMATCH 6730
#define ISAC_DISALLOWED_FRAME_MODE_DECODER 6630
#define ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH 6640
#define ISAC_RANGE_ERROR_DECODE_BANDWIDTH 6650
#define ISAC_RANGE_ERROR_DECODE_PITCH_GAIN 6660
#define ISAC_RANGE_ERROR_DECODE_PITCH_LAG 6670
#define ISAC_RANGE_ERROR_DECODE_LPC 6680
#define ISAC_RANGE_ERROR_DECODE_SPECTRUM 6690
#define ISAC_LENGTH_MISMATCH 6730
/* 6800 Call setup formats */
#define ISAC_INCOMPATIBLE_FORMATS 6810
#define ISAC_INCOMPATIBLE_FORMATS 6810
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SETTINGS_H_ */

View File

@ -62,15 +62,15 @@ extern const int16_t WebRtcIsacfix_kRc6Levels[11];
/* quantization boundary levels for reflection coefficients */
extern const int16_t WebRtcIsacfix_kRcBound[12];
/* initial indices for AR reflection coefficient quantizer and cdf table search */
/* initial indices for AR reflection coefficient quantizer and cdf table search
*/
extern const uint16_t WebRtcIsacfix_kRcInitInd[AR_ORDER];
/* pointers to AR cdf tables */
extern const uint16_t *WebRtcIsacfix_kRcCdfPtr[AR_ORDER];
extern const uint16_t* WebRtcIsacfix_kRcCdfPtr[AR_ORDER];
/* pointers to AR representation levels tables */
extern const int16_t *WebRtcIsacfix_kRcLevPtr[AR_ORDER];
extern const int16_t* WebRtcIsacfix_kRcLevPtr[AR_ORDER];
/******************** GAIN Coefficient Tables ***********************/
/* cdf for Gain coefficient */
@ -83,7 +83,7 @@ extern const int32_t WebRtcIsacfix_kGain2Lev[18];
extern const int32_t WebRtcIsacfix_kGain2Bound[19];
/* pointer to Gain cdf table */
extern const uint16_t *WebRtcIsacfix_kGainPtr[1];
extern const uint16_t* WebRtcIsacfix_kGainPtr[1];
/* Gain initial index for gain quantizer and cdf table search */
extern const uint16_t WebRtcIsacfix_kGainInitInd[1];
@ -92,4 +92,5 @@ extern const uint16_t WebRtcIsacfix_kGainInitInd[1];
/* Cosine table */
extern const int16_t WebRtcIsacfix_kCos[6][60];
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SPECTRUM_AR_MODEL_TABLES_H_ */
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SPECTRUM_AR_MODEL_TABLES_H_ \
*/

View File

@ -18,7 +18,6 @@
#ifndef MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_STRUCTS_H_
#define MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_STRUCTS_H_
#include "common_audio/signal_processing/include/signal_processing_library.h"
#include "modules/audio_coding/codecs/isac/bandwidth_info.h"
#include "modules/audio_coding/codecs/isac/fix/source/settings.h"
@ -26,72 +25,58 @@
/* Bitstream struct for decoder */
typedef struct Bitstreamstruct_dec {
uint16_t stream[INTERNAL_STREAM_SIZE_W16]; /* Array bytestream to decode */
uint32_t W_upper; /* Upper boundary of interval W */
uint32_t streamval;
uint16_t stream_index; /* Index to the current position in bytestream */
int16_t full; /* 0 - first byte in memory filled, second empty*/
uint16_t stream[INTERNAL_STREAM_SIZE_W16]; /* Array bytestream to decode */
uint32_t W_upper; /* Upper boundary of interval W */
uint32_t streamval;
uint16_t stream_index; /* Index to the current position in bytestream */
int16_t full; /* 0 - first byte in memory filled, second empty*/
/* 1 - both bytes are empty (we just filled the previous memory */
size_t stream_size; /* The size of stream in bytes. */
size_t stream_size; /* The size of stream in bytes. */
} Bitstr_dec;
/* Bitstream struct for encoder */
typedef struct Bitstreamstruct_enc {
uint16_t stream[STREAM_MAXW16_60MS]; /* Vector for adding encoded bytestream */
uint32_t W_upper; /* Upper boundary of interval W */
uint32_t streamval;
uint16_t stream_index; /* Index to the current position in bytestream */
int16_t full; /* 0 - first byte in memory filled, second empty*/
uint16_t
stream[STREAM_MAXW16_60MS]; /* Vector for adding encoded bytestream */
uint32_t W_upper; /* Upper boundary of interval W */
uint32_t streamval;
uint16_t stream_index; /* Index to the current position in bytestream */
int16_t full; /* 0 - first byte in memory filled, second empty*/
/* 1 - both bytes are empty (we just filled the previous memory */
} Bitstr_enc;
typedef struct {
int16_t DataBufferLoQ0[WINLEN];
int16_t DataBufferHiQ0[WINLEN];
int32_t CorrBufLoQQ[ORDERLO+1];
int32_t CorrBufHiQQ[ORDERHI+1];
int32_t CorrBufLoQQ[ORDERLO + 1];
int32_t CorrBufHiQQ[ORDERHI + 1];
int16_t CorrBufLoQdom[ORDERLO+1];
int16_t CorrBufHiQdom[ORDERHI+1];
int16_t CorrBufLoQdom[ORDERLO + 1];
int16_t CorrBufHiQdom[ORDERHI + 1];
int32_t PreStateLoGQ15[ORDERLO+1];
int32_t PreStateHiGQ15[ORDERHI+1];
int32_t PreStateLoGQ15[ORDERLO + 1];
int32_t PreStateHiGQ15[ORDERHI + 1];
uint32_t OldEnergy;
} MaskFiltstr_enc;
typedef struct {
int16_t PostStateLoGQ0[ORDERLO+1];
int16_t PostStateHiGQ0[ORDERHI+1];
int16_t PostStateLoGQ0[ORDERLO + 1];
int16_t PostStateHiGQ0[ORDERHI + 1];
uint32_t OldEnergy;
} MaskFiltstr_dec;
typedef struct {
// state vectors for each of the two analysis filters
//state vectors for each of the two analysis filters
int32_t INSTAT1_fix[2*(QORDER-1)];
int32_t INSTAT2_fix[2*(QORDER-1)];
int32_t INSTAT1_fix[2 * (QORDER - 1)];
int32_t INSTAT2_fix[2 * (QORDER - 1)];
int16_t INLABUF1_fix[QLOOKAHEAD];
int16_t INLABUF2_fix[QLOOKAHEAD];
@ -100,12 +85,10 @@ typedef struct {
} PreFiltBankstr;
typedef struct {
//state vectors for each of the two analysis filters
int32_t STATE_0_LOWER_fix[2*POSTQORDER];
int32_t STATE_0_UPPER_fix[2*POSTQORDER];
// state vectors for each of the two analysis filters
int32_t STATE_0_LOWER_fix[2 * POSTQORDER];
int32_t STATE_0_UPPER_fix[2 * POSTQORDER];
/* High pass filter */
@ -115,8 +98,6 @@ typedef struct {
} PostFiltBankstr;
typedef struct {
/* data buffer for pitch filter */
int16_t ubufQQ[PITCH_BUFFSIZE];
@ -129,42 +110,35 @@ typedef struct {
} PitchFiltstr;
typedef struct {
// for inital estimator
int16_t dec_buffer16[PITCH_CORR_LEN2 + PITCH_CORR_STEP2 + PITCH_MAX_LAG / 2 -
PITCH_FRAME_LEN / 2 + 2];
int32_t decimator_state32[2 * ALLPASSSECTIONS + 1];
int16_t inbuf[QLOOKAHEAD];
//for inital estimator
int16_t dec_buffer16[PITCH_CORR_LEN2+PITCH_CORR_STEP2+PITCH_MAX_LAG/2-PITCH_FRAME_LEN/2+2];
int32_t decimator_state32[2*ALLPASSSECTIONS+1];
int16_t inbuf[QLOOKAHEAD];
PitchFiltstr PFstr_wght;
PitchFiltstr PFstr;
PitchFiltstr PFstr_wght;
PitchFiltstr PFstr;
} PitchAnalysisStruct;
typedef struct {
/* Parameters used in PLC to avoid re-computation */
/* --- residual signals --- */
int16_t prevPitchInvIn[FRAMESAMPLES/2];
int16_t prevPitchInvOut[PITCH_MAX_LAG + 10]; // [FRAMESAMPLES/2]; save 90
int32_t prevHP[PITCH_MAX_LAG + 10]; // [FRAMESAMPLES/2]; save 90
int16_t prevPitchInvIn[FRAMESAMPLES / 2];
int16_t prevPitchInvOut[PITCH_MAX_LAG + 10]; // [FRAMESAMPLES/2]; save 90
int32_t prevHP[PITCH_MAX_LAG + 10]; // [FRAMESAMPLES/2]; save 90
int16_t decayCoeffPriodic; /* how much to supress a sample */
int16_t decayCoeffNoise;
int16_t used; /* if PLC is used */
int16_t *lastPitchLP; // [FRAMESAMPLES/2]; saved 240;
int16_t used; /* if PLC is used */
int16_t* lastPitchLP; // [FRAMESAMPLES/2]; saved 240;
/* --- LPC side info --- */
int16_t lofilt_coefQ15[ ORDERLO ];
int16_t hifilt_coefQ15[ ORDERHI ];
int16_t lofilt_coefQ15[ORDERLO];
int16_t hifilt_coefQ15[ORDERHI];
int32_t gain_lo_hiQ17[2];
/* --- LTP side info --- */
@ -173,95 +147,101 @@ typedef struct {
int16_t lastPitchLag_Q7;
/* --- Add-overlap in recovery packet --- */
int16_t overlapLP[ RECOVERY_OVERLAP ]; // [FRAMESAMPLES/2]; saved 160
int16_t overlapLP[RECOVERY_OVERLAP]; // [FRAMESAMPLES/2]; saved 160
int16_t pitchCycles;
int16_t A;
int16_t B;
size_t pitchIndex;
size_t stretchLag;
int16_t *prevPitchLP; // [ FRAMESAMPLES/2 ]; saved 240
int16_t* prevPitchLP; // [ FRAMESAMPLES/2 ]; saved 240
int16_t seed;
int16_t std;
} PLCstr;
/* Have instance of struct together with other iSAC structs */
typedef struct {
int16_t prevFrameSizeMs; /* Previous frame size (in ms) */
uint16_t prevRtpNumber; /* Previous RTP timestamp from received packet */
int16_t prevFrameSizeMs; /* Previous frame size (in ms) */
uint16_t prevRtpNumber; /* Previous RTP timestamp from received packet */
/* (in samples relative beginning) */
uint32_t prevSendTime; /* Send time for previous packet, from RTP header */
uint32_t prevArrivalTime; /* Arrival time for previous packet (in ms using timeGetTime()) */
uint16_t prevRtpRate; /* rate of previous packet, derived from RTP timestamps (in bits/s) */
uint32_t lastUpdate; /* Time since the last update of the Bottle Neck estimate (in samples) */
uint32_t lastReduction; /* Time sinse the last reduction (in samples) */
int32_t countUpdates; /* How many times the estimate was update in the beginning */
uint32_t prevSendTime; /* Send time for previous packet, from RTP header */
uint32_t prevArrivalTime; /* Arrival time for previous packet (in ms using
timeGetTime()) */
uint16_t
prevRtpRate; /* rate of previous packet, derived from RTP timestamps (in
bits/s) */
uint32_t
lastUpdate; /* Time since the last update of the Bottle Neck estimate (in
samples) */
uint32_t lastReduction; /* Time sinse the last reduction (in samples) */
int32_t countUpdates; /* How many times the estimate was update in the
beginning */
/* The estimated bottle neck rate from there to here (in bits/s) */
uint32_t recBw;
uint32_t recBwInv;
uint32_t recBwAvg;
uint32_t recBwAvgQ;
/* The estimated bottle neck rate from there to here (in bits/s) */
uint32_t recBw;
uint32_t recBwInv;
uint32_t recBwAvg;
uint32_t recBwAvgQ;
uint32_t minBwInv;
uint32_t maxBwInv;
uint32_t minBwInv;
uint32_t maxBwInv;
/* The estimated mean absolute jitter value, as seen on this side (in ms) */
int32_t recJitter;
int32_t recJitterShortTerm;
int32_t recJitterShortTermAbs;
int32_t recMaxDelay;
int32_t recMaxDelayAvgQ;
/* The estimated mean absolute jitter value, as seen on this side (in ms) */
int32_t recJitter;
int32_t recJitterShortTerm;
int32_t recJitterShortTermAbs;
int32_t recMaxDelay;
int32_t recMaxDelayAvgQ;
int16_t recHeaderRate; /* (assumed) bitrate for headers (bps) */
int16_t recHeaderRate; /* (assumed) bitrate for headers (bps) */
uint32_t sendBwAvg; /* The estimated bottle neck rate from here to there (in
bits/s) */
int32_t
sendMaxDelayAvg; /* The estimated mean absolute jitter value, as seen on
the other siee (in ms) */
uint32_t sendBwAvg; /* The estimated bottle neck rate from here to there (in bits/s) */
int32_t sendMaxDelayAvg; /* The estimated mean absolute jitter value, as seen on the other siee (in ms) */
int16_t countRecPkts; /* number of packets received since last update */
int16_t highSpeedRec; /* flag for marking that a high speed network has been detected downstream */
int16_t countRecPkts; /* number of packets received since last update */
int16_t highSpeedRec; /* flag for marking that a high speed network has been
detected downstream */
/* number of consecutive pkts sent during which the bwe estimate has
remained at a value greater than the downstream threshold for determining highspeed network */
int16_t countHighSpeedRec;
remained at a value greater than the downstream threshold for determining
highspeed network */
int16_t countHighSpeedRec;
/* flag indicating bwe should not adjust down immediately for very late pckts */
int16_t inWaitPeriod;
/* flag indicating bwe should not adjust down immediately for very late pckts
*/
int16_t inWaitPeriod;
/* variable holding the time of the start of a window of time when
bwe should not adjust down immediately for very late pckts */
uint32_t startWaitPeriod;
uint32_t startWaitPeriod;
/* number of consecutive pkts sent during which the bwe estimate has
remained at a value greater than the upstream threshold for determining highspeed network */
int16_t countHighSpeedSent;
remained at a value greater than the upstream threshold for determining
highspeed network */
int16_t countHighSpeedSent;
/* flag indicated the desired number of packets over threshold rate have been sent and
bwe will assume the connection is over broadband network */
int16_t highSpeedSend;
/* flag indicated the desired number of packets over threshold rate have been
sent and bwe will assume the connection is over broadband network */
int16_t highSpeedSend;
IsacBandwidthInfo external_bw_info;
} BwEstimatorstr;
typedef struct {
/* boolean, flags if previous packet exceeded B.N. */
int16_t PrevExceed;
int16_t PrevExceed;
/* ms */
int16_t ExceedAgo;
int16_t ExceedAgo;
/* packets left to send in current burst */
int16_t BurstCounter;
int16_t BurstCounter;
/* packets */
int16_t InitCounter;
int16_t InitCounter;
/* ms remaining in buffer when next packet will be sent */
int16_t StillBuffered;
int16_t StillBuffered;
} RateModel;
@ -271,112 +251,107 @@ typedef struct {
handle 60 ms of data.
*/
typedef struct {
/* Used to keep track of if it is first or second part of 60 msec packet */
int startIdx;
int startIdx;
/* Frame length in samples */
int16_t framelength;
int16_t framelength;
/* Pitch Gain */
int16_t pitchGain_index[2];
int16_t pitchGain_index[2];
/* Pitch Lag */
int32_t meanGain[2];
int16_t pitchIndex[PITCH_SUBFRAMES*2];
int32_t meanGain[2];
int16_t pitchIndex[PITCH_SUBFRAMES * 2];
/* LPC */
int32_t LPCcoeffs_g[12*2]; /* KLT_ORDER_GAIN = 12 */
int16_t LPCindex_s[108*2]; /* KLT_ORDER_SHAPE = 108 */
int16_t LPCindex_g[12*2]; /* KLT_ORDER_GAIN = 12 */
int32_t LPCcoeffs_g[12 * 2]; /* KLT_ORDER_GAIN = 12 */
int16_t LPCindex_s[108 * 2]; /* KLT_ORDER_SHAPE = 108 */
int16_t LPCindex_g[12 * 2]; /* KLT_ORDER_GAIN = 12 */
/* Encode Spec */
int16_t fre[FRAMESAMPLES];
int16_t fim[FRAMESAMPLES];
int16_t AvgPitchGain[2];
int16_t fre[FRAMESAMPLES];
int16_t fim[FRAMESAMPLES];
int16_t AvgPitchGain[2];
/* Used in adaptive mode only */
int minBytes;
int minBytes;
} IsacSaveEncoderData;
typedef struct {
Bitstr_enc bitstr_obj;
MaskFiltstr_enc maskfiltstr_obj;
PreFiltBankstr prefiltbankstr_obj;
PitchFiltstr pitchfiltstr_obj;
Bitstr_enc bitstr_obj;
MaskFiltstr_enc maskfiltstr_obj;
PreFiltBankstr prefiltbankstr_obj;
PitchFiltstr pitchfiltstr_obj;
PitchAnalysisStruct pitchanalysisstr_obj;
RateModel rate_data_obj;
RateModel rate_data_obj;
int16_t buffer_index;
int16_t current_framesamples;
int16_t buffer_index;
int16_t current_framesamples;
int16_t data_buffer_fix[FRAMESAMPLES]; // the size was MAX_FRAMESAMPLES
int16_t data_buffer_fix[FRAMESAMPLES]; // the size was MAX_FRAMESAMPLES
int16_t frame_nb;
int16_t BottleNeck;
int16_t MaxDelay;
int16_t new_framelength;
int16_t s2nr;
uint16_t MaxBits;
int16_t frame_nb;
int16_t BottleNeck;
int16_t MaxDelay;
int16_t new_framelength;
int16_t s2nr;
uint16_t MaxBits;
int16_t bitstr_seed;
int16_t bitstr_seed;
#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
PostFiltBankstr interpolatorstr_obj;
PostFiltBankstr interpolatorstr_obj;
#endif
IsacSaveEncoderData *SaveEnc_ptr;
int16_t payloadLimitBytes30; /* Maximum allowed number of bits for a 30 msec packet */
int16_t payloadLimitBytes60; /* Maximum allowed number of bits for a 30 msec packet */
int16_t maxPayloadBytes; /* Maximum allowed number of bits for both 30 and 60 msec packet */
int16_t maxRateInBytes; /* Maximum allowed rate in bytes per 30 msec packet */
int16_t enforceFrameSize; /* If set iSAC will never change packet size */
IsacSaveEncoderData* SaveEnc_ptr;
int16_t payloadLimitBytes30; /* Maximum allowed number of bits for a 30 msec
packet */
int16_t payloadLimitBytes60; /* Maximum allowed number of bits for a 30 msec
packet */
int16_t maxPayloadBytes; /* Maximum allowed number of bits for both 30 and 60
msec packet */
int16_t maxRateInBytes; /* Maximum allowed rate in bytes per 30 msec packet */
int16_t enforceFrameSize; /* If set iSAC will never change packet size */
} IsacFixEncoderInstance;
typedef struct {
Bitstr_dec bitstr_obj;
MaskFiltstr_dec maskfiltstr_obj;
PostFiltBankstr postfiltbankstr_obj;
PitchFiltstr pitchfiltstr_obj;
PLCstr plcstr_obj; /* TS; for packet loss concealment */
Bitstr_dec bitstr_obj;
MaskFiltstr_dec maskfiltstr_obj;
PostFiltBankstr postfiltbankstr_obj;
PitchFiltstr pitchfiltstr_obj;
PLCstr plcstr_obj; /* TS; for packet loss concealment */
#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
PreFiltBankstr decimatorstr_obj;
PreFiltBankstr decimatorstr_obj;
#endif
} IsacFixDecoderInstance;
typedef struct {
IsacFixEncoderInstance ISACenc_obj;
IsacFixDecoderInstance ISACdec_obj;
BwEstimatorstr bwestimator_obj;
int16_t CodingMode; /* 0 = adaptive; 1 = instantaneous */
int16_t errorcode;
int16_t initflag; /* 0 = nothing initiated; 1 = encoder or decoder */
BwEstimatorstr bwestimator_obj;
int16_t CodingMode; /* 0 = adaptive; 1 = instantaneous */
int16_t errorcode;
int16_t initflag; /* 0 = nothing initiated; 1 = encoder or decoder */
/* not initiated; 2 = all initiated */
} ISACFIX_SubStruct;
typedef struct {
int32_t lpcGains[12]; /* 6 lower-band & 6 upper-band we may need to double it for 60*/
int32_t lpcGains
[12]; /* 6 lower-band & 6 upper-band we may need to double it for 60*/
/* */
uint32_t W_upper; /* Upper boundary of interval W */
uint32_t streamval;
uint16_t stream_index; /* Index to the current position in bytestream */
int16_t full; /* 0 - first byte in memory filled, second empty*/
uint32_t W_upper; /* Upper boundary of interval W */
uint32_t streamval;
uint16_t stream_index; /* Index to the current position in bytestream */
int16_t full; /* 0 - first byte in memory filled, second empty*/
/* 1 - both bytes are empty (we just filled the previous memory */
uint16_t beforeLastWord;
uint16_t lastWord;
uint16_t beforeLastWord;
uint16_t lastWord;
} transcode_obj;
// Bitstr_enc myBitStr;
//Bitstr_enc myBitStr;
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_STRUCTS_H_ */
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_STRUCTS_H_ */

View File

@ -12,147 +12,156 @@
#include "system_wrappers/include/cpu_features_wrapper.h"
#include "test/gtest.h"
static const int kSamples = FRAMESAMPLES/2;
static const int kSamples = FRAMESAMPLES / 2;
static const int32_t spec2time_out_expected_1[kSamples] = {
-3366470, -2285227,
-3415765, -2310215, -3118030, -2222470, -3030254, -2192091, -3423170,
-2216041, -3305541, -2171936, -3195767, -2095779, -3153304, -2157560,
-3071167, -2032108, -3101190, -1972016, -3103824, -2089118, -3139811,
-1898337, -3102801, -2055082, -3029665, -1854140, -2962586, -1966454,
-3071167, -1894588, -2851743, -1917315, -2848087, -1594932, -2799242,
-1462184, -2845887, -1437599, -2691776, -1329637, -2770659, -1268491,
-2625161, -1578991, -2460299, -1186385, -2365613, -1039354, -2322608,
-958518, -2271749, -789860, -2254538, -850308, -2384436, -850959, -2133734,
-587678, -2093316, -495115, -1973364, -475177, -1801282, -173507,
-1848516, -158015, -1792018, -62648, -1643313, 214746, -1500758, 267077,
-1450193, 560521, -1521579, 675283, -1345408, 857559, -1300822, 1116332,
-1294533, 1241117, -1070027, 1263503, -983816, 1529821, -1019586,
1910421, -955420, 2073688, -836459, 2401105, -653905, 2690474, -731425,
2930131, -935234, 3299500, -875978, 3523432, -878906, 3924822, -1081630,
4561267, -1203023, 5105274, -1510983, 6052762, -2294646, 7021597,
-3108053, 8826736, -4935222, 11678789, -8442713, 18725700, -21526692,
25420577, 19589811, -28108666, 12634054, -14483066, 6263217, -9979706,
3665661, -7909736, 2531530, -6434896, 1700772, -5525393, 1479473,
-4894262, 1231760, -4353044, 1032940, -3786590, 941152, -3331614,
665090, -2851619, 830696, -2762201, 958007, -2483118, 788233, -2184965,
804825, -1967306, 1007255, -1862474, 920889, -1457506, 755406, -1405841,
890230, -1302124, 1161599, -701867, 1154163, -1083366, 1204743, -513581,
1547264, -650636, 1493384, -285543, 1771863, -277906, 1841343, -9078,
1751863, 230222, 1819578, 207170, 1978972, 398137, 2106468, 552155,
1997624, 685213, 2129520, 601078, 2238736, 944591, 2441879, 1194178,
2355280, 986124, 2393328, 1049005, 2417944, 1208368, 2489516, 1352023,
2572118, 1445283, 2856081, 1532997, 2742279, 1615877, 2915274, 1808036,
2856871, 1806936, 3241747, 1622461, 2978558, 1841297, 3010378, 1923666,
3271367, 2126700, 3070935, 1956958, 3107588, 2128405, 3288872, 2114911,
3315952, 2406651, 3344038, 2370199, 3368980, 2144361, 3305030, 2183803,
3401450, 2523102, 3405463, 2452475, 3463355, 2421678, 3551968, 2431949,
3477251, 2148125, 3244489, 2174090};
-3366470, -2285227, -3415765, -2310215, -3118030, -2222470, -3030254,
-2192091, -3423170, -2216041, -3305541, -2171936, -3195767, -2095779,
-3153304, -2157560, -3071167, -2032108, -3101190, -1972016, -3103824,
-2089118, -3139811, -1898337, -3102801, -2055082, -3029665, -1854140,
-2962586, -1966454, -3071167, -1894588, -2851743, -1917315, -2848087,
-1594932, -2799242, -1462184, -2845887, -1437599, -2691776, -1329637,
-2770659, -1268491, -2625161, -1578991, -2460299, -1186385, -2365613,
-1039354, -2322608, -958518, -2271749, -789860, -2254538, -850308,
-2384436, -850959, -2133734, -587678, -2093316, -495115, -1973364,
-475177, -1801282, -173507, -1848516, -158015, -1792018, -62648,
-1643313, 214746, -1500758, 267077, -1450193, 560521, -1521579,
675283, -1345408, 857559, -1300822, 1116332, -1294533, 1241117,
-1070027, 1263503, -983816, 1529821, -1019586, 1910421, -955420,
2073688, -836459, 2401105, -653905, 2690474, -731425, 2930131,
-935234, 3299500, -875978, 3523432, -878906, 3924822, -1081630,
4561267, -1203023, 5105274, -1510983, 6052762, -2294646, 7021597,
-3108053, 8826736, -4935222, 11678789, -8442713, 18725700, -21526692,
25420577, 19589811, -28108666, 12634054, -14483066, 6263217, -9979706,
3665661, -7909736, 2531530, -6434896, 1700772, -5525393, 1479473,
-4894262, 1231760, -4353044, 1032940, -3786590, 941152, -3331614,
665090, -2851619, 830696, -2762201, 958007, -2483118, 788233,
-2184965, 804825, -1967306, 1007255, -1862474, 920889, -1457506,
755406, -1405841, 890230, -1302124, 1161599, -701867, 1154163,
-1083366, 1204743, -513581, 1547264, -650636, 1493384, -285543,
1771863, -277906, 1841343, -9078, 1751863, 230222, 1819578,
207170, 1978972, 398137, 2106468, 552155, 1997624, 685213,
2129520, 601078, 2238736, 944591, 2441879, 1194178, 2355280,
986124, 2393328, 1049005, 2417944, 1208368, 2489516, 1352023,
2572118, 1445283, 2856081, 1532997, 2742279, 1615877, 2915274,
1808036, 2856871, 1806936, 3241747, 1622461, 2978558, 1841297,
3010378, 1923666, 3271367, 2126700, 3070935, 1956958, 3107588,
2128405, 3288872, 2114911, 3315952, 2406651, 3344038, 2370199,
3368980, 2144361, 3305030, 2183803, 3401450, 2523102, 3405463,
2452475, 3463355, 2421678, 3551968, 2431949, 3477251, 2148125,
3244489, 2174090};
static const int32_t spec2time_out_expected_2[kSamples] = {
1691694, -2499988, -2035547,
1060469, 988634, -2044502, -306271, 2041000, 201454, -2289456, 93694,
2129427, -369152, -1887834, 860796, 2089102, -929424, -1673956, 1395291,
1785651, -1619673, -1380109, 1963449, 1093311, -2111007, -840456,
2372786, 578119, -2242702, 89774, 2463304, -132717, -2121480, 643634,
2277636, -1125999, -1995858, 1543748, 2227861, -1483779, -1495491,
2102642, 1833876, -1920568, -958378, 2485101, 772261, -2454257, -24942,
2918714, 136838, -2500453, 816118, 3039735, -746560, -2365815, 1586396,
2714951, -1511696, -1942334, 2571792, 2182827, -2325335, -1311543,
3055970, 1367220, -2737182, -110626, 3889222, 631008, -3280879, 853066,
4122279, -706638, -3334449, 2148311, 3993512, -1846301, -3004894,
3426779, 3329522, -3165264, -2242423, 4756866, 2557711, -4131280,
-805259, 5702711, 1120592, -4852821, 743664, 6476444, -621186, -5465828,
2815787, 6768835, -3017442, -5338409, 5658126, 6838454, -5492288,
-4682382, 8874947, 6153814, -8832561, -2649251, 12817398, 4237692,
-13000247, 1190661, 18986363, -115738, -19693978, 9908367, 30660381,
-10632635, -37962068, 47022884, 89744622, -42087632, 40279224,
-88869341, -47542383, 38572364, 10441576, -30339718, -9926740, 19896578,
28009, -18886612, -1124047, 13232498, -4150304, -12770551, 2637074,
9051831, -6162211, -8713972, 4557937, 5489716, -6862312, -5532349,
5415449, 2791310, -6999367, -2790102, 5375806, 546222, -6486452,
-821261, 4994973, -1278840, -5645501, 1060484, 3996285, -2503954,
-4653629, 2220549, 3036977, -3282133, -3318585, 2780636, 1789880,
-4004589, -2041031, 3105373, 574819, -3992722, -971004, 3001703,
-676739, -3841508, 417284, 2897970, -1427018, -3058480, 1189948,
2210960, -2268992, -2603272, 1949785, 1576172, -2720404, -1891738,
2309456, 769178, -2975646, -707150, 2424652, -88039, -2966660, -65452,
2320780, -957557, -2798978, 744640, 1879794, -1672081, -2365319,
1253309, 1366383, -2204082, -1544367, 1801452, 613828, -2531994,
-983847, 2064842, 118326, -2613790, -203220, 2219635, -730341, -2641861,
563557, 1765434, -1329916, -2272927, 1037138, 1266725, -1939220,
-1588643, 1754528, 816552, -2376303, -1099167, 1864999, 122477,
-2422762, -400027, 1889228, -579916, -2490353, 287139, 2011318,
-1176657, -2502978, 812896, 1116502, -1940211};
1691694, -2499988, -2035547, 1060469, 988634, -2044502, -306271,
2041000, 201454, -2289456, 93694, 2129427, -369152, -1887834,
860796, 2089102, -929424, -1673956, 1395291, 1785651, -1619673,
-1380109, 1963449, 1093311, -2111007, -840456, 2372786, 578119,
-2242702, 89774, 2463304, -132717, -2121480, 643634, 2277636,
-1125999, -1995858, 1543748, 2227861, -1483779, -1495491, 2102642,
1833876, -1920568, -958378, 2485101, 772261, -2454257, -24942,
2918714, 136838, -2500453, 816118, 3039735, -746560, -2365815,
1586396, 2714951, -1511696, -1942334, 2571792, 2182827, -2325335,
-1311543, 3055970, 1367220, -2737182, -110626, 3889222, 631008,
-3280879, 853066, 4122279, -706638, -3334449, 2148311, 3993512,
-1846301, -3004894, 3426779, 3329522, -3165264, -2242423, 4756866,
2557711, -4131280, -805259, 5702711, 1120592, -4852821, 743664,
6476444, -621186, -5465828, 2815787, 6768835, -3017442, -5338409,
5658126, 6838454, -5492288, -4682382, 8874947, 6153814, -8832561,
-2649251, 12817398, 4237692, -13000247, 1190661, 18986363, -115738,
-19693978, 9908367, 30660381, -10632635, -37962068, 47022884, 89744622,
-42087632, 40279224, -88869341, -47542383, 38572364, 10441576, -30339718,
-9926740, 19896578, 28009, -18886612, -1124047, 13232498, -4150304,
-12770551, 2637074, 9051831, -6162211, -8713972, 4557937, 5489716,
-6862312, -5532349, 5415449, 2791310, -6999367, -2790102, 5375806,
546222, -6486452, -821261, 4994973, -1278840, -5645501, 1060484,
3996285, -2503954, -4653629, 2220549, 3036977, -3282133, -3318585,
2780636, 1789880, -4004589, -2041031, 3105373, 574819, -3992722,
-971004, 3001703, -676739, -3841508, 417284, 2897970, -1427018,
-3058480, 1189948, 2210960, -2268992, -2603272, 1949785, 1576172,
-2720404, -1891738, 2309456, 769178, -2975646, -707150, 2424652,
-88039, -2966660, -65452, 2320780, -957557, -2798978, 744640,
1879794, -1672081, -2365319, 1253309, 1366383, -2204082, -1544367,
1801452, 613828, -2531994, -983847, 2064842, 118326, -2613790,
-203220, 2219635, -730341, -2641861, 563557, 1765434, -1329916,
-2272927, 1037138, 1266725, -1939220, -1588643, 1754528, 816552,
-2376303, -1099167, 1864999, 122477, -2422762, -400027, 1889228,
-579916, -2490353, 287139, 2011318, -1176657, -2502978, 812896,
1116502, -1940211};
static const int16_t time2spec_out_expected_1[kSamples] = {
20342, 23889, -10063, -9419,
3242, 7280, -2012, -5029, 332, 4478, -97, -3244, -891, 3117, 773, -2204,
-1335, 2009, 1236, -1469, -1562, 1277, 1366, -815, -1619, 599, 1449, -177,
-1507, 116, 1294, 263, -1338, -244, 1059, 553, -1045, -549, 829, 826,
-731, -755, 516, 909, -427, -853, 189, 1004, -184, -828, -108, 888, 72,
-700, -280, 717, 342, -611, -534, 601, 534, -374, -646, 399, 567, -171,
-720, 234, 645, -11, -712, -26, 593, 215, -643, -172, 536, 361, -527,
-403, 388, 550, -361, -480, 208, 623, -206, -585, 41, 578, 12, -504,
-182, 583, 218, -437, -339, 499, 263, -354, -450, 347, 456, -193, -524,
212, 475, -74, -566, 94, 511, 112, -577, -201, 408, 217, -546, -295, 338,
387, -13, 4, -46, 2, -76, 103, -83, 108, -55, 100, -150, 131, -156, 141,
-171, 179, -190, 128, -227, 172, -214, 215, -189, 265, -244, 322, -335,
337, -352, 358, -368, 362, -355, 366, -381, 403, -395, 411, -392, 446,
-458, 504, -449, 507, -464, 452, -491, 481, -534, 486, -516, 560, -535,
525, -537, 559, -554, 570, -616, 591, -585, 627, -509, 588, -584, 547,
-610, 580, -614, 635, -620, 655, -554, 546, -591, 642, -590, 660, -656,
629, -604, 620, -580, 617, -645, 648, -573, 612, -604, 584, -571, 597,
-562, 627, -550, 560, -606, 529, -584, 568, -503, 532, -463, 512, -440,
399, -457, 437, -349, 278, -317, 257, -220, 163, -8, -61, 18, -161, 367,
-1306};
20342, 23889, -10063, -9419, 3242, 7280, -2012, -5029, 332, 4478,
-97, -3244, -891, 3117, 773, -2204, -1335, 2009, 1236, -1469,
-1562, 1277, 1366, -815, -1619, 599, 1449, -177, -1507, 116,
1294, 263, -1338, -244, 1059, 553, -1045, -549, 829, 826,
-731, -755, 516, 909, -427, -853, 189, 1004, -184, -828,
-108, 888, 72, -700, -280, 717, 342, -611, -534, 601,
534, -374, -646, 399, 567, -171, -720, 234, 645, -11,
-712, -26, 593, 215, -643, -172, 536, 361, -527, -403,
388, 550, -361, -480, 208, 623, -206, -585, 41, 578,
12, -504, -182, 583, 218, -437, -339, 499, 263, -354,
-450, 347, 456, -193, -524, 212, 475, -74, -566, 94,
511, 112, -577, -201, 408, 217, -546, -295, 338, 387,
-13, 4, -46, 2, -76, 103, -83, 108, -55, 100,
-150, 131, -156, 141, -171, 179, -190, 128, -227, 172,
-214, 215, -189, 265, -244, 322, -335, 337, -352, 358,
-368, 362, -355, 366, -381, 403, -395, 411, -392, 446,
-458, 504, -449, 507, -464, 452, -491, 481, -534, 486,
-516, 560, -535, 525, -537, 559, -554, 570, -616, 591,
-585, 627, -509, 588, -584, 547, -610, 580, -614, 635,
-620, 655, -554, 546, -591, 642, -590, 660, -656, 629,
-604, 620, -580, 617, -645, 648, -573, 612, -604, 584,
-571, 597, -562, 627, -550, 560, -606, 529, -584, 568,
-503, 532, -463, 512, -440, 399, -457, 437, -349, 278,
-317, 257, -220, 163, -8, -61, 18, -161, 367, -1306};
static const int16_t time2spec_out_expected_2[kSamples] = {
14283, -11552, -15335, 6626,
7554, -2150, -6309, 1307, 4523, -4, -3908, -314, 3001, 914, -2715, -1042,
2094, 1272, -1715, -1399, 1263, 1508, -1021, -1534, 735, 1595, -439, -1447,
155, 1433, 22, -1325, -268, 1205, 424, -1030, -608, 950, 643, -733, -787,
661, 861, -502, -888, 331, 852, -144, -849, 19, 833, 99, -826, -154,
771, 368, -735, -459, 645, 513, -491, -604, 431, 630, -314, -598, 183,
622, -78, -612, -48, 641, 154, -645, -257, 610, 281, -529, -444, 450,
441, -327, -506, 274, 476, -232, -570, 117, 554, -86, -531, -21, 572,
151, -606, -221, 496, 322, -407, -388, 407, 394, -268, -428, 280, 505,
-115, -588, 19, 513, -29, -539, -109, 468, 173, -501, -242, 442, 278,
-478, -680, 656, -659, 656, -669, 602, -688, 612, -667, 612, -642, 627,
-648, 653, -676, 596, -680, 655, -649, 678, -672, 587, -608, 637, -645,
637, -620, 556, -580, 553, -635, 518, -599, 583, -501, 536, -544, 473,
-552, 583, -511, 541, -532, 563, -486, 461, -453, 486, -388, 424, -416,
432, -374, 399, -462, 364, -346, 293, -329, 331, -313, 281, -247, 309,
-337, 241, -190, 207, -194, 179, -163, 155, -156, 117, -135, 107, -126,
29, -22, 81, -8, 17, -61, -10, 8, -37, 80, -44, 72, -88, 65, -89, 130,
-114, 181, -215, 189, -245, 260, -288, 294, -339, 344, -396, 407, -429,
438, -439, 485, -556, 629, -612, 637, -645, 661, -737, 829, -830, 831,
-1041};
14283, -11552, -15335, 6626, 7554, -2150, -6309, 1307, 4523, -4,
-3908, -314, 3001, 914, -2715, -1042, 2094, 1272, -1715, -1399,
1263, 1508, -1021, -1534, 735, 1595, -439, -1447, 155, 1433,
22, -1325, -268, 1205, 424, -1030, -608, 950, 643, -733,
-787, 661, 861, -502, -888, 331, 852, -144, -849, 19,
833, 99, -826, -154, 771, 368, -735, -459, 645, 513,
-491, -604, 431, 630, -314, -598, 183, 622, -78, -612,
-48, 641, 154, -645, -257, 610, 281, -529, -444, 450,
441, -327, -506, 274, 476, -232, -570, 117, 554, -86,
-531, -21, 572, 151, -606, -221, 496, 322, -407, -388,
407, 394, -268, -428, 280, 505, -115, -588, 19, 513,
-29, -539, -109, 468, 173, -501, -242, 442, 278, -478,
-680, 656, -659, 656, -669, 602, -688, 612, -667, 612,
-642, 627, -648, 653, -676, 596, -680, 655, -649, 678,
-672, 587, -608, 637, -645, 637, -620, 556, -580, 553,
-635, 518, -599, 583, -501, 536, -544, 473, -552, 583,
-511, 541, -532, 563, -486, 461, -453, 486, -388, 424,
-416, 432, -374, 399, -462, 364, -346, 293, -329, 331,
-313, 281, -247, 309, -337, 241, -190, 207, -194, 179,
-163, 155, -156, 117, -135, 107, -126, 29, -22, 81,
-8, 17, -61, -10, 8, -37, 80, -44, 72, -88,
65, -89, 130, -114, 181, -215, 189, -245, 260, -288,
294, -339, 344, -396, 407, -429, 438, -439, 485, -556,
629, -612, 637, -645, 661, -737, 829, -830, 831, -1041};
class TransformTest : public testing::Test {
protected:
TransformTest() {
WebRtcSpl_Init();
}
TransformTest() { WebRtcSpl_Init(); }
// Pass a function pointer to the Tester function.
void Time2SpecTester(Time2Spec Time2SpecFunction) {
// WebRtcIsacfix_Time2Spec functions hard coded the buffer lengths. It's a
// large buffer but we have to test it here.
int16_t data_in_1[kSamples] = {0};
int16_t data_in_2[kSamples] = {0};
int16_t data_out_1[kSamples] = {0};
int16_t data_out_2[kSamples] = {0};
// Pass a function pointer to the Tester function.
void Time2SpecTester(Time2Spec Time2SpecFunction) {
// WebRtcIsacfix_Time2Spec functions hard coded the buffer lengths. It's a
// large buffer but we have to test it here.
int16_t data_in_1[kSamples] = {0};
int16_t data_in_2[kSamples] = {0};
int16_t data_out_1[kSamples] = {0};
int16_t data_out_2[kSamples] = {0};
for(int i = 0; i < kSamples; i++) {
data_in_1[i] = i * i + 1777;
data_in_2[i] = WEBRTC_SPL_WORD16_MAX / (i + 1) + 17;
}
for (int i = 0; i < kSamples; i++) {
data_in_1[i] = i * i + 1777;
data_in_2[i] = WEBRTC_SPL_WORD16_MAX / (i + 1) + 17;
}
Time2SpecFunction(data_in_1, data_in_2, data_out_1, data_out_2);
Time2SpecFunction(data_in_1, data_in_2, data_out_1, data_out_2);
for (int i = 0; i < kSamples; i++) {
// We don't require bit-exact for ARM assembly code.
EXPECT_LE(abs(time2spec_out_expected_1[i] - data_out_1[i]), 1);
EXPECT_LE(abs(time2spec_out_expected_2[i] - data_out_2[i]), 1);
}
}
for (int i = 0; i < kSamples; i++) {
// We don't require bit-exact for ARM assembly code.
EXPECT_LE(abs(time2spec_out_expected_1[i] - data_out_1[i]), 1);
EXPECT_LE(abs(time2spec_out_expected_2[i] - data_out_2[i]), 1);
}
}
// Pass a function pointer to the Tester function.
void Spec2TimeTester(Spec2Time Spec2TimeFunction) {
@ -162,7 +171,7 @@ class TransformTest : public testing::Test {
int16_t data_in_2[kSamples] = {0};
int32_t data_out_1[kSamples] = {0};
int32_t data_out_2[kSamples] = {0};
for(int i = 0; i < kSamples; i++) {
for (int i = 0; i < kSamples; i++) {
data_in_1[i] = i * i + 1777;
data_in_2[i] = WEBRTC_SPL_WORD16_MAX / (i + 1) + 17;
}
@ -175,7 +184,6 @@ class TransformTest : public testing::Test {
EXPECT_LE(abs(spec2time_out_expected_2[i] - data_out_2[i]), 16);
}
}
};
TEST_F(TransformTest, Time2SpecTest) {

View File

@ -25,19 +25,21 @@ class IsacSpeedTest : public AudioCodecSpeedTest {
IsacSpeedTest();
void SetUp() override;
void TearDown() override;
float EncodeABlock(int16_t* in_data, uint8_t* bit_stream,
size_t max_bytes, size_t* encoded_bytes) override;
float DecodeABlock(const uint8_t* bit_stream, size_t encoded_bytes,
float EncodeABlock(int16_t* in_data,
uint8_t* bit_stream,
size_t max_bytes,
size_t* encoded_bytes) override;
float DecodeABlock(const uint8_t* bit_stream,
size_t encoded_bytes,
int16_t* out_data) override;
ISACFIX_MainStruct *ISACFIX_main_inst_;
ISACFIX_MainStruct* ISACFIX_main_inst_;
};
IsacSpeedTest::IsacSpeedTest()
: AudioCodecSpeedTest(kIsacBlockDurationMs,
kIsacInputSamplingKhz,
kIsacOutputSamplingKhz),
ISACFIX_main_inst_(NULL) {
}
ISACFIX_main_inst_(NULL) {}
void IsacSpeedTest::SetUp() {
AudioCodecSpeedTest::SetUp();
@ -60,8 +62,10 @@ void IsacSpeedTest::TearDown() {
EXPECT_EQ(0, WebRtcIsacfix_Free(ISACFIX_main_inst_));
}
float IsacSpeedTest::EncodeABlock(int16_t* in_data, uint8_t* bit_stream,
size_t max_bytes, size_t* encoded_bytes) {
float IsacSpeedTest::EncodeABlock(int16_t* in_data,
uint8_t* bit_stream,
size_t max_bytes,
size_t* encoded_bytes) {
// ISAC takes 10 ms everycall
const int subblocks = block_duration_ms_ / 10;
const int subblock_length = 10 * input_sampling_khz_;
@ -70,8 +74,8 @@ float IsacSpeedTest::EncodeABlock(int16_t* in_data, uint8_t* bit_stream,
clock_t clocks = clock();
size_t pointer = 0;
for (int idx = 0; idx < subblocks; idx++, pointer += subblock_length) {
value = WebRtcIsacfix_Encode(ISACFIX_main_inst_, &in_data[pointer],
bit_stream);
value =
WebRtcIsacfix_Encode(ISACFIX_main_inst_, &in_data[pointer], bit_stream);
if (idx == subblocks - 1)
EXPECT_GT(value, 0);
else
@ -108,7 +112,6 @@ const coding_param param_set[] = {
string("pcm"),
true)};
INSTANTIATE_TEST_CASE_P(AllTest, IsacSpeedTest,
::testing::ValuesIn(param_set));
INSTANTIATE_TEST_CASE_P(AllTest, IsacSpeedTest, ::testing::ValuesIn(param_set));
} // namespace webrtc

View File

@ -8,11 +8,11 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <ctype.h>
#include "modules/audio_coding/codecs/isac/fix/include/isacfix.h"
#include "test/gtest.h"
@ -22,14 +22,16 @@
// separate encoder and decoder.
/* Defines */
#define SEED_FILE "randseed.txt" /* Used when running decoder on garbage data */
#define MAX_FRAMESAMPLES 960 /* max number of samples per frame (= 60 ms frame) */
#define FRAMESAMPLES_10ms 160 /* number of samples per 10ms frame */
#define FS 16000 /* sampling frequency (Hz) */
#define SEED_FILE \
"randseed.txt" /* Used when running decoder on garbage data \
*/
#define MAX_FRAMESAMPLES \
960 /* max number of samples per frame (= 60 ms frame) */
#define FRAMESAMPLES_10ms 160 /* number of samples per 10ms frame */
#define FS 16000 /* sampling frequency (Hz) */
/* Function for reading audio data from PCM file */
int readframe(int16_t *data, FILE *inp, int length) {
int readframe(int16_t* data, FILE* inp, int length) {
short k, rlen, status = 0;
rlen = fread(data, sizeof(int16_t), length, inp);
@ -45,25 +47,24 @@ int readframe(int16_t *data, FILE *inp, int length) {
// Globals needed because gtest does not provide access to argv.
// This should be reworked to use flags.
static int global_argc;
static char **global_argv;
static char** global_argv;
/* Struct for bottleneck model */
typedef struct {
uint32_t send_time; /* samples */
uint32_t arrival_time; /* samples */
uint32_t sample_count; /* samples */
uint32_t send_time; /* samples */
uint32_t arrival_time; /* samples */
uint32_t sample_count; /* samples */
uint16_t rtp_number;
} BottleNeckModel;
void get_arrival_time(int current_framesamples, /* samples */
size_t packet_size, /* bytes */
int bottleneck, /* excluding headers; bits/s */
BottleNeckModel *BN_data)
{
void get_arrival_time(int current_framesamples, /* samples */
size_t packet_size, /* bytes */
int bottleneck, /* excluding headers; bits/s */
BottleNeckModel* BN_data) {
const int HeaderSize = 35;
int HeaderRate;
HeaderRate = HeaderSize * 8 * FS / current_framesamples; /* bits/s */
HeaderRate = HeaderSize * 8 * FS / current_framesamples; /* bits/s */
/* everything in samples */
BN_data->sample_count = BN_data->sample_count + current_framesamples;
@ -80,29 +81,27 @@ void get_arrival_time(int current_framesamples, /* samples */
void get_arrival_time2(int current_framesamples,
int current_delay,
BottleNeckModel *BN_data)
{
BottleNeckModel* BN_data) {
if (current_delay == -1)
//dropped packet
// dropped packet
{
BN_data->arrival_time += current_framesamples;
}
else if (current_delay != -2)
{
} else if (current_delay != -2) {
//
BN_data->arrival_time += (current_framesamples + ((FS/1000) * current_delay));
BN_data->arrival_time +=
(current_framesamples + ((FS / 1000) * current_delay));
}
//else
//current packet has same timestamp as previous packet
// else
// current packet has same timestamp as previous packet
BN_data->rtp_number++;
}
TEST(IsacFixTest, Kenny) {
int argc = global_argc;
char **argv = global_argv;
char** argv = global_argv;
char inname[100], outname[100], outbitsname[100], bottleneck_file[100];
char inname[100], outname[100], outbitsname[100], bottleneck_file[100];
FILE *inp, *outp, *f_bn, *outbits;
int endfile;
@ -112,7 +111,7 @@ TEST(IsacFixTest, Kenny) {
int errtype, h = 0, k, packetLossPercent = 0;
int16_t CodingMode;
int16_t bottleneck;
int framesize = 30; /* ms */
int framesize = 30; /* ms */
int cur_framesmpls, err = 0, lostPackets = 0;
/* Runtime statistics */
@ -133,16 +132,16 @@ TEST(IsacFixTest, Kenny) {
int32_t payloadRate = 0;
int setControlBWE = 0;
int readLoss;
FILE *plFile = NULL;
FILE* plFile = NULL;
char version_number[20];
char tmpBit[5] = ".bit";
int totalbits =0;
int totalsmpls =0;
int totalbits = 0;
int totalsmpls = 0;
int16_t testNum, testCE;
FILE *fp_gns = NULL;
FILE* fp_gns = NULL;
int gns = 0;
int cur_delay = 0;
char gns_file[100];
@ -151,20 +150,20 @@ TEST(IsacFixTest, Kenny) {
int16_t lostFrame;
float scale = (float)0.7;
/* only one structure used for ISAC encoder */
ISACFIX_MainStruct *ISAC_main_inst = NULL;
ISACFIX_MainStruct* ISAC_main_inst = NULL;
/* For fault test 10, garbage data */
FILE *seedfile;
unsigned int random_seed = (unsigned int) time(NULL);//1196764538
FILE* seedfile;
unsigned int random_seed = (unsigned int)time(NULL); // 1196764538
BottleNeckModel BN_data;
f_bn = NULL;
BottleNeckModel BN_data;
f_bn = NULL;
readLoss = 0;
packetLossPercent = 0;
/* Handling wrong input arguments in the command line */
if ((argc<3) || (argc>22)) {
if ((argc < 3) || (argc > 22)) {
printf("\n\nWrong number of arguments or flag values.\n\n");
printf("\n");
@ -182,61 +181,75 @@ TEST(IsacFixTest, Kenny) {
printf(" read from a file (e.g. bottleneck.txt)\n\n");
printf("infile :Normal speech input file\n\n");
printf("outfile :Speech output file\n\n");
printf("[-INITRATE num] :Set a new value for initial rate. Note! Only used"
" in adaptive mode.\n\n");
printf("[-FL num] :Set (initial) frame length in msec. Valid length"
" are 30 and 60 msec.\n\n");
printf(
"[-INITRATE num] :Set a new value for initial rate. Note! Only used"
" in adaptive mode.\n\n");
printf(
"[-FL num] :Set (initial) frame length in msec. Valid length"
" are 30 and 60 msec.\n\n");
printf("[-FIXED_FL] :Frame length to be fixed to initial value.\n\n");
printf("[-MAX num] :Set the limit for the payload size of iSAC"
" in bytes. \n");
printf(
"[-MAX num] :Set the limit for the payload size of iSAC"
" in bytes. \n");
printf(" Minimum 100, maximum 400.\n\n");
printf("[-MAXRATE num] :Set the maxrate for iSAC in bits per second. \n");
printf(" Minimum 32000, maximum 53400.\n\n");
printf("[-F num] :if -F option is specified, the test function\n");
printf(" will run the iSAC API fault scenario specified"
" by the\n");
printf(
" will run the iSAC API fault scenario specified"
" by the\n");
printf(" supplied number.\n");
printf(" F 1 - Call encoder prior to init encoder call\n");
printf(" F 2 - Call decoder prior to init decoder call\n");
printf(" F 3 - Call decoder prior to encoder call\n");
printf(" F 4 - Call decoder with a too short coded"
" sequence\n");
printf(" F 5 - Call decoder with a too long coded"
" sequence\n");
printf(
" F 4 - Call decoder with a too short coded"
" sequence\n");
printf(
" F 5 - Call decoder with a too long coded"
" sequence\n");
printf(" F 6 - Call decoder with random bit stream\n");
printf(" F 7 - Call init encoder/decoder at random"
" during a call\n");
printf(" F 8 - Call encoder/decoder without having"
" allocated memory for \n");
printf(
" F 7 - Call init encoder/decoder at random"
" during a call\n");
printf(
" F 8 - Call encoder/decoder without having"
" allocated memory for \n");
printf(" encoder/decoder instance\n");
printf(" F 9 - Call decodeB without calling decodeA\n");
printf(" F 10 - Call decodeB with garbage data\n");
printf("[-PL num] :if -PL option is specified 0<num<100 will "
"specify the\n");
printf(
"[-PL num] :if -PL option is specified 0<num<100 will "
"specify the\n");
printf(" percentage of packet loss\n\n");
printf("[-G file] :if -G option is specified the file given is"
" a .gns file\n");
printf(
"[-G file] :if -G option is specified the file given is"
" a .gns file\n");
printf(" that represents a network profile\n\n");
printf("[-NB num] :if -NB option, use the narrowband interfaces\n");
printf(" num=1 => encode with narrowband encoder"
" (infile is narrowband)\n");
printf(" num=2 => decode with narrowband decoder"
" (outfile is narrowband)\n\n");
printf(
" num=1 => encode with narrowband encoder"
" (infile is narrowband)\n");
printf(
" num=2 => decode with narrowband decoder"
" (outfile is narrowband)\n\n");
printf("[-CE num] :Test of APIs used by Conference Engine.\n");
printf(" CE 1 - createInternal, freeInternal,"
" getNewBitstream \n");
printf(
" CE 1 - createInternal, freeInternal,"
" getNewBitstream \n");
printf(" CE 2 - transcode, getBWE \n");
printf(" CE 3 - getSendBWE, setSendBWE. \n\n");
printf("[-RTP_INIT num] :if -RTP_INIT option is specified num will be"
" the initial\n");
printf(
"[-RTP_INIT num] :if -RTP_INIT option is specified num will be"
" the initial\n");
printf(" value of the rtp sequence number.\n\n");
printf("[--isolated-script-test-perf-output=file]\n");
printf(" :If this option is specified, perf values will be"
" written to this file in a JSON format.\n\n");
printf(
" :If this option is specified, perf values will be"
" written to this file in a JSON format.\n\n");
printf("Example usage :\n\n");
printf("%s -I bottleneck.txt speechIn.pcm speechOut.pcm\n\n", argv[0]);
exit(1);
}
/* Print version number */
@ -250,7 +263,7 @@ TEST(IsacFixTest, Kenny) {
i = 1;
/* Instantaneous mode */
if (!strcmp ("-I", argv[i])) {
if (!strcmp("-I", argv[i])) {
printf("\nInstantaneous BottleNeck\n");
CodingMode = 1;
i++;
@ -265,7 +278,7 @@ TEST(IsacFixTest, Kenny) {
for (; i < argc; i++) {
/* Set (initial) bottleneck value */
if (!strcmp ("-INITRATE", argv[i])) {
if (!strcmp("-INITRATE", argv[i])) {
if (i + 1 >= argc) {
printf("-INITRATE requires a parameter.\n");
exit(1);
@ -273,8 +286,10 @@ TEST(IsacFixTest, Kenny) {
rateBPS = atoi(argv[i + 1]);
setControlBWE = 1;
if ((rateBPS < 10000) || (rateBPS > 32000)) {
printf("\n%d is not a initial rate. "
"Valid values are in the range 10000 to 32000.\n", rateBPS);
printf(
"\n%d is not a initial rate. "
"Valid values are in the range 10000 to 32000.\n",
rateBPS);
exit(1);
}
printf("\nNew initial rate: %d\n", rateBPS);
@ -282,15 +297,17 @@ TEST(IsacFixTest, Kenny) {
}
/* Set (initial) framelength */
if (!strcmp ("-FL", argv[i])) {
if (!strcmp("-FL", argv[i])) {
if (i + 1 >= argc) {
printf("-FL requires a parameter.\n");
exit(1);
}
framesize = atoi(argv[i + 1]);
if ((framesize != 30) && (framesize != 60)) {
printf("\n%d is not a valid frame length. "
"Valid length are 30 and 60 msec.\n", framesize);
printf(
"\n%d is not a valid frame length. "
"Valid length are 30 and 60 msec.\n",
framesize);
exit(1);
}
printf("\nFrame Length: %d\n", framesize);
@ -298,13 +315,13 @@ TEST(IsacFixTest, Kenny) {
}
/* Fixed frame length */
if (!strcmp ("-FIXED_FL", argv[i])) {
if (!strcmp("-FIXED_FL", argv[i])) {
fixedFL = 1;
setControlBWE = 1;
}
/* Set maximum allowed payload size in bytes */
if (!strcmp ("-MAX", argv[i])) {
if (!strcmp("-MAX", argv[i])) {
if (i + 1 >= argc) {
printf("-MAX requires a parameter.\n");
exit(1);
@ -315,7 +332,7 @@ TEST(IsacFixTest, Kenny) {
}
/* Set maximum rate in bytes */
if (!strcmp ("-MAXRATE", argv[i])) {
if (!strcmp("-MAXRATE", argv[i])) {
if (i + 1 >= argc) {
printf("-MAXRATE requires a parameter.\n");
exit(1);
@ -326,7 +343,7 @@ TEST(IsacFixTest, Kenny) {
}
/* Test of fault scenarious */
if (!strcmp ("-F", argv[i])) {
if (!strcmp("-F", argv[i])) {
if (i + 1 >= argc) {
printf("-F requires a parameter.");
exit(1);
@ -334,59 +351,63 @@ TEST(IsacFixTest, Kenny) {
testNum = atoi(argv[i + 1]);
printf("\nFault test: %d\n", testNum);
if (testNum < 1 || testNum > 10) {
printf("\n%d is not a valid Fault Scenario number."
" Valid Fault Scenarios are numbered 1-10.\n", testNum);
printf(
"\n%d is not a valid Fault Scenario number."
" Valid Fault Scenarios are numbered 1-10.\n",
testNum);
exit(1);
}
i++;
}
/* Packet loss test */
if (!strcmp ("-PL", argv[i])) {
if (!strcmp("-PL", argv[i])) {
if (i + 1 >= argc) {
printf("-PL requires a parameter.\n");
exit(1);
}
if( isdigit( *argv[i+1] ) ) {
packetLossPercent = atoi( argv[i+1] );
if( (packetLossPercent < 0) | (packetLossPercent > 100) ) {
printf( "\nInvalid packet loss perentage \n" );
exit( 1 );
if (isdigit(*argv[i + 1])) {
packetLossPercent = atoi(argv[i + 1]);
if ((packetLossPercent < 0) | (packetLossPercent > 100)) {
printf("\nInvalid packet loss perentage \n");
exit(1);
}
if( packetLossPercent > 0 ) {
printf( "\nSimulating %d %% of independent packet loss\n",
packetLossPercent );
if (packetLossPercent > 0) {
printf("\nSimulating %d %% of independent packet loss\n",
packetLossPercent);
} else {
printf( "\nNo Packet Loss Is Simulated \n" );
printf("\nNo Packet Loss Is Simulated \n");
}
readLoss = 0;
} else {
readLoss = 1;
plFile = fopen( argv[i+1], "rb" );
if( plFile == NULL ) {
FAIL() << "Couldn't open the frameloss file: " << argv[i+1];
plFile = fopen(argv[i + 1], "rb");
if (plFile == NULL) {
FAIL() << "Couldn't open the frameloss file: " << argv[i + 1];
}
printf( "\nSimulating packet loss through the given "
"channel file: %s\n", argv[i+1] );
printf(
"\nSimulating packet loss through the given "
"channel file: %s\n",
argv[i + 1]);
}
i++;
}
/* Random packetlosses */
if (!strcmp ("-rnd", argv[i])) {
srand(time(NULL) );
printf( "\n Random pattern in lossed packets \n" );
if (!strcmp("-rnd", argv[i])) {
srand(time(NULL));
printf("\n Random pattern in lossed packets \n");
}
/* Use gns file */
if (!strcmp ("-G", argv[i])) {
if (!strcmp("-G", argv[i])) {
if (i + 1 >= argc) {
printf("-G requires a parameter.\n");
exit(1);
}
sscanf(argv[i + 1], "%s", gns_file);
fp_gns = fopen(gns_file, "rb");
if (fp_gns == NULL) {
if (fp_gns == NULL) {
FAIL() << "Cannot read file " << gns_file << ".";
}
gns = 1;
@ -394,7 +415,7 @@ TEST(IsacFixTest, Kenny) {
}
/* Run Narrowband interfaces (either encoder or decoder) */
if (!strcmp ("-NB", argv[i])) {
if (!strcmp("-NB", argv[i])) {
if (i + 1 >= argc) {
printf("-NB requires a parameter.\n");
exit(1);
@ -404,25 +425,27 @@ TEST(IsacFixTest, Kenny) {
}
/* Run Conference Engine APIs */
if (!strcmp ("-CE", argv[i])) {
if (!strcmp("-CE", argv[i])) {
if (i + 1 >= argc) {
printf("-CE requires a parameter.\n");
exit(1);
}
testCE = atoi(argv[i + 1]);
if (testCE==1 || testCE==2) {
if (testCE == 1 || testCE == 2) {
i++;
scale = (float)atof( argv[i+1] );
scale = (float)atof(argv[i + 1]);
} else if (testCE < 1 || testCE > 3) {
printf("\n%d is not a valid CE-test number, valid Fault "
"Scenarios are numbered 1-3\n", testCE);
printf(
"\n%d is not a valid CE-test number, valid Fault "
"Scenarios are numbered 1-3\n",
testCE);
exit(1);
}
i++;
}
/* Set initial RTP number */
if (!strcmp ("-RTP_INIT", argv[i])) {
if (!strcmp("-RTP_INIT", argv[i])) {
if (i + 1 >= argc) {
printf("-RTP_INIT requires a parameter.\n");
exit(1);
@ -442,16 +465,16 @@ TEST(IsacFixTest, Kenny) {
/* Get Bottleneck value */
/* Gns files and bottleneck should not and can not be used simultaneously */
bottleneck = atoi(argv[CodingMode+1]);
bottleneck = atoi(argv[CodingMode + 1]);
if (bottleneck == 0 && gns == 0) {
sscanf(argv[CodingMode+1], "%s", bottleneck_file);
sscanf(argv[CodingMode + 1], "%s", bottleneck_file);
f_bn = fopen(bottleneck_file, "rb");
if (f_bn == NULL) {
if (f_bn == NULL) {
printf("No value provided for BottleNeck\n");
FAIL() << "Cannot read file " << bottleneck_file;
} else {
int aux_var;
printf("reading bottleneck rates from file %s\n\n",bottleneck_file);
printf("reading bottleneck rates from file %s\n\n", bottleneck_file);
if (fscanf(f_bn, "%d", &aux_var) == EOF) {
/* Set pointer to beginning of file */
fseek(f_bn, 0L, SEEK_SET);
@ -481,18 +504,18 @@ TEST(IsacFixTest, Kenny) {
outbitsname[h] = outname[h];
h++;
}
for (k=0; k<5; k++) {
for (k = 0; k < 5; k++) {
outbitsname[h] = tmpBit[k];
h++;
}
if ((inp = fopen(inname,"rb")) == NULL) {
if ((inp = fopen(inname, "rb")) == NULL) {
FAIL() << " iSAC: Cannot read file " << inname;
}
if ((outp = fopen(outname,"wb")) == NULL) {
if ((outp = fopen(outname, "wb")) == NULL) {
FAIL() << " iSAC: Cannot write file " << outname;
}
if ((outbits = fopen(outbitsname,"wb")) == NULL) {
if ((outbits = fopen(outbitsname, "wb")) == NULL) {
FAIL() << " iSAC: Cannot write file " << outbitsname;
}
printf("\nInput:%s\nOutput:%s\n\n", inname, outname);
@ -502,30 +525,28 @@ TEST(IsacFixTest, Kenny) {
/* Test to run decoder with garbage data */
srand(random_seed);
if ( (seedfile = fopen(SEED_FILE, "a+t") ) == NULL ) {
if ((seedfile = fopen(SEED_FILE, "a+t")) == NULL) {
printf("Error: Could not open file %s\n", SEED_FILE);
}
else {
} else {
fprintf(seedfile, "%u\n", random_seed);
fclose(seedfile);
}
}
/* Runtime statistics */
starttime = clock()/(double)CLOCKS_PER_SEC;
starttime = clock() / (double)CLOCKS_PER_SEC;
/* Initialize the ISAC and BN structs */
if (testNum != 8)
{
if(1){
err =WebRtcIsacfix_Create(&ISAC_main_inst);
}else{
if (testNum != 8) {
if (1) {
err = WebRtcIsacfix_Create(&ISAC_main_inst);
} else {
/* Test the Assign functions */
int sss;
void *ppp;
err =WebRtcIsacfix_AssignSize(&sss);
ppp=malloc(sss);
err =WebRtcIsacfix_Assign(&ISAC_main_inst,ppp);
void* ppp;
err = WebRtcIsacfix_AssignSize(&sss);
ppp = malloc(sss);
err = WebRtcIsacfix_Assign(&ISAC_main_inst, ppp);
}
/* Error check */
if (err < 0) {
@ -541,13 +562,13 @@ TEST(IsacFixTest, Kenny) {
}
/* Init of bandwidth data */
BN_data.send_time = 0;
BN_data.arrival_time = 0;
BN_data.sample_count = 0;
BN_data.rtp_number = 0;
BN_data.send_time = 0;
BN_data.arrival_time = 0;
BN_data.sample_count = 0;
BN_data.rtp_number = 0;
/* Initialize encoder and decoder */
framecnt= 0;
framecnt = 0;
endfile = 0;
if (testNum != 1) {
WebRtcIsacfix_EncoderInit(ISAC_main_inst, CodingMode);
@ -560,10 +581,10 @@ TEST(IsacFixTest, Kenny) {
err = WebRtcIsacfix_Control(ISAC_main_inst, bottleneck, framesize);
if (err < 0) {
/* exit if returned with error */
errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
printf("\n\n Error in control: %d.\n\n", errtype);
}
} else if(setControlBWE == 1) {
} else if (setControlBWE == 1) {
err = WebRtcIsacfix_ControlBwe(ISAC_main_inst, rateBPS, framesize, fixedFL);
}
@ -571,7 +592,7 @@ TEST(IsacFixTest, Kenny) {
err = WebRtcIsacfix_SetMaxPayloadSize(ISAC_main_inst, payloadSize);
if (err < 0) {
/* exit if returned with error */
errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
FAIL() << "Error in SetMaxPayloadSize: " << errtype;
}
}
@ -579,35 +600,32 @@ TEST(IsacFixTest, Kenny) {
err = WebRtcIsacfix_SetMaxRate(ISAC_main_inst, payloadRate);
if (err < 0) {
/* exit if returned with error */
errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
FAIL() << "Error in SetMaxRateInBytes: " << errtype;
}
}
*speechType = 1;
while (endfile == 0) {
if(testNum == 7 && (rand()%2 == 0)) {
if (testNum == 7 && (rand() % 2 == 0)) {
err = WebRtcIsacfix_EncoderInit(ISAC_main_inst, CodingMode);
/* Error check */
if (err < 0) {
errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
printf("\n\n Error in encoderinit: %d.\n\n", errtype);
}
WebRtcIsacfix_DecoderInit(ISAC_main_inst);
}
cur_framesmpls = 0;
while (1) {
/* Read 10 ms speech block */
if (nbTest != 1) {
endfile = readframe(shortdata, inp, FRAMESAMPLES_10ms);
} else {
endfile = readframe(shortdata, inp, (FRAMESAMPLES_10ms/2));
endfile = readframe(shortdata, inp, (FRAMESAMPLES_10ms / 2));
}
if (testNum == 7) {
@ -620,22 +638,18 @@ TEST(IsacFixTest, Kenny) {
short bwe;
/* Encode */
stream_len_int = WebRtcIsacfix_Encode(ISAC_main_inst,
shortdata,
stream_len_int = WebRtcIsacfix_Encode(ISAC_main_inst, shortdata,
(uint8_t*)streamdata);
/* If packet is ready, and CE testing, call the different API
functions from the internal API. */
if (stream_len_int>0) {
if (stream_len_int > 0) {
if (testCE == 1) {
err = WebRtcIsacfix_ReadBwIndex(
reinterpret_cast<const uint8_t*>(streamdata),
static_cast<size_t>(stream_len_int),
&bwe);
static_cast<size_t>(stream_len_int), &bwe);
stream_len_int = WebRtcIsacfix_GetNewBitStream(
ISAC_main_inst,
bwe,
scale,
ISAC_main_inst, bwe, scale,
reinterpret_cast<uint8_t*>(streamdata));
} else if (testCE == 2) {
/* transcode function not supported */
@ -646,37 +660,33 @@ TEST(IsacFixTest, Kenny) {
err = WebRtcIsacfix_GetDownLinkBwIndex(ISAC_main_inst, &bwe);
/* Error Check */
if (err < 0) {
errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
printf("\nError in getSendBWE: %d.\n", errtype);
}
err = WebRtcIsacfix_UpdateUplinkBw(ISAC_main_inst, bwe);
/* Error Check */
if (err < 0) {
errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
printf("\nError in setBWE: %d.\n", errtype);
}
}
}
} else {
#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
stream_len_int = WebRtcIsacfix_EncodeNb(ISAC_main_inst,
shortdata,
streamdata);
stream_len_int =
WebRtcIsacfix_EncodeNb(ISAC_main_inst, shortdata, streamdata);
#else
stream_len_int = -1;
#endif
}
}
else
{
} else {
break;
}
if (stream_len_int < 0 || err < 0) {
/* exit if returned with error */
errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
printf("\nError in encoder: %d.\n", errtype);
} else {
stream_len = static_cast<size_t>(stream_len_int);
@ -705,7 +715,8 @@ TEST(IsacFixTest, Kenny) {
}
/* exit encoder loop if the encoder returned a bitstream */
if (stream_len != 0) break;
if (stream_len != 0)
break;
}
/* make coded sequence to short be inreasing */
@ -722,7 +733,7 @@ TEST(IsacFixTest, Kenny) {
if (testNum == 6) {
srand(time(NULL));
for (i = 0; i < static_cast<int>(stream_len); i++ ) {
for (i = 0; i < static_cast<int>(stream_len); i++) {
streamdata[i] = rand();
}
}
@ -740,8 +751,7 @@ TEST(IsacFixTest, Kenny) {
/* simulate packet handling through NetEq and the modem */
if (!(testNum == 3 && framecnt == 0)) {
if (gns == 0) {
get_arrival_time(cur_framesmpls, stream_len, bottleneck,
&BN_data);
get_arrival_time(cur_framesmpls, stream_len, bottleneck, &BN_data);
} else {
get_arrival_time2(cur_framesmpls, cur_delay, &BN_data);
}
@ -749,44 +759,38 @@ TEST(IsacFixTest, Kenny) {
/* packet not dropped */
if (cur_delay != -1) {
/* Error test number 10, garbage data */
if (testNum == 10) {
for ( i = 0; i < static_cast<int>(stream_len); i++) {
streamdata[i] = (short) (streamdata[i] + (short) rand());
for (i = 0; i < static_cast<int>(stream_len); i++) {
streamdata[i] = (short)(streamdata[i] + (short)rand());
}
}
if (testNum != 9) {
err = WebRtcIsacfix_UpdateBwEstimate(
ISAC_main_inst,
reinterpret_cast<const uint8_t*>(streamdata),
stream_len,
BN_data.rtp_number,
BN_data.send_time,
ISAC_main_inst, reinterpret_cast<const uint8_t*>(streamdata),
stream_len, BN_data.rtp_number, BN_data.send_time,
BN_data.arrival_time);
if (err < 0) {
/* exit if returned with error */
errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
printf("\nError in decoder: %d.\n", errtype);
}
}
if( readLoss == 1 ) {
if( fread( &lostFrame, sizeof(int16_t), 1, plFile ) != 1 ) {
rewind( plFile );
if (readLoss == 1) {
if (fread(&lostFrame, sizeof(int16_t), 1, plFile) != 1) {
rewind(plFile);
}
lostFrame = !lostFrame;
} else {
lostFrame = (rand()%100 < packetLossPercent);
lostFrame = (rand() % 100 < packetLossPercent);
}
/* iSAC decoding */
if( lostFrame && framecnt > 0) {
if (nbTest !=2) {
if (lostFrame && framecnt > 0) {
if (nbTest != 2) {
declen = static_cast<int>(
WebRtcIsacfix_DecodePlc(ISAC_main_inst, decoded, prevFrameSize));
} else {
@ -799,32 +803,29 @@ TEST(IsacFixTest, Kenny) {
}
lostPackets++;
} else {
if (nbTest !=2 ) {
if (nbTest != 2) {
size_t FL;
/* Call getFramelen, only used here for function test */
err = WebRtcIsacfix_ReadFrameLen(
reinterpret_cast<const uint8_t*>(streamdata), stream_len, &FL);
declen = WebRtcIsacfix_Decode(
ISAC_main_inst,
reinterpret_cast<const uint8_t*>(streamdata),
stream_len,
decoded,
speechType);
ISAC_main_inst, reinterpret_cast<const uint8_t*>(streamdata),
stream_len, decoded, speechType);
/* Error check */
if (err < 0 || declen < 0 || FL != static_cast<size_t>(declen)) {
errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
printf(
"\nError %d in ReadFrameLen (%s), Decode (%s), with FL %zu and "
"declen %d.\n",
errtype, err < 0 ? "yes" : "no", declen < 0 ? "yes" : "no", FL,
declen);
}
prevFrameSize = static_cast<size_t>(declen/480);
prevFrameSize = static_cast<size_t>(declen / 480);
} else {
#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
declen = WebRtcIsacfix_DecodeNb( ISAC_main_inst, streamdata,
stream_len, decoded, speechType );
declen = WebRtcIsacfix_DecodeNb(ISAC_main_inst, streamdata,
stream_len, decoded, speechType);
#else
declen = -1;
#endif
@ -834,13 +835,12 @@ TEST(IsacFixTest, Kenny) {
if (declen <= 0) {
/* exit if returned with error */
errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
printf("\nError in decoder: %d.\n", errtype);
}
/* Write decoded speech frame to file */
if (fwrite(decoded, sizeof(int16_t),
declen, outp) != (size_t)declen) {
if (fwrite(decoded, sizeof(int16_t), declen, outp) != (size_t)declen) {
FAIL();
}
// fprintf( ratefile, "%f \n", stream_len / ( ((double)declen)/
@ -855,30 +855,28 @@ TEST(IsacFixTest, Kenny) {
/* Error test number 10, garbage data */
if (testNum == 10) {
if ( (seedfile = fopen(SEED_FILE, "a+t") ) == NULL ) {
printf( "Error: Could not open file %s\n", SEED_FILE);
}
else {
if ((seedfile = fopen(SEED_FILE, "a+t")) == NULL) {
printf("Error: Could not open file %s\n", SEED_FILE);
} else {
fprintf(seedfile, "ok\n\n");
fclose(seedfile);
}
}
}
printf("\nLost Frames %d ~ %4.1f%%\n", lostPackets,
(double)lostPackets/(double)framecnt*100.0 );
(double)lostPackets / (double)framecnt * 100.0);
printf("\n\ntotal bits = %d bits", totalbits);
printf("\nmeasured average bitrate = %0.3f kbits/s",
(double)totalbits *(FS/1000) / totalsmpls);
(double)totalbits * (FS / 1000) / totalsmpls);
printf("\n");
/* Runtime statistics */
runtime = (double)(((double)clock()/(double)CLOCKS_PER_SEC)-starttime);
length_file = ((double)framecnt*(double)declen/FS);
runtime = (double)(((double)clock() / (double)CLOCKS_PER_SEC) - starttime);
length_file = ((double)framecnt * (double)declen / FS);
printf("\n\nLength of speech file: %.1f s\n", length_file);
printf("Time to run iSAC: %.2f s (%.2f %% of realtime)\n\n",
runtime, (100*runtime/length_file));
printf("Time to run iSAC: %.2f s (%.2f %% of realtime)\n\n", runtime,
(100 * runtime / length_file));
printf("\n\n_______________________________________________\n");
// Record the results with Perf test tools.
@ -893,7 +891,7 @@ TEST(IsacFixTest, Kenny) {
fclose(outp);
fclose(outbits);
if ( testCE == 1) {
if (testCE == 1) {
WebRtcIsacfix_FreeInternal(ISAC_main_inst);
}
WebRtcIsacfix_Free(ISAC_main_inst);

File diff suppressed because it is too large Load Diff

View File

@ -21,42 +21,47 @@
#include "modules/audio_coding/codecs/isac/main/source/structs.h"
int WebRtcIsac_EncLogisticMulti2(
Bitstr *streamdata, /* in-/output struct containing bitstream */
int16_t *dataQ7, /* input: data vector */
const uint16_t *env, /* input: side info vector defining the width of the pdf */
const int N, /* input: data vector length */
Bitstr* streamdata, /* in-/output struct containing bitstream */
int16_t* dataQ7, /* input: data vector */
const uint16_t*
env, /* input: side info vector defining the width of the pdf */
const int N, /* input: data vector length */
const int16_t isSWB12kHz); /* if the codec is working in 12kHz bandwidth */
/* returns the number of bytes in the stream */
int WebRtcIsac_EncTerminate(Bitstr *streamdata); /* in-/output struct containing bitstream */
int WebRtcIsac_EncTerminate(
Bitstr* streamdata); /* in-/output struct containing bitstream */
/* returns the number of bytes in the stream so far */
int WebRtcIsac_DecLogisticMulti2(
int16_t *data, /* output: data vector */
Bitstr *streamdata, /* in-/output struct containing bitstream */
const uint16_t *env, /* input: side info vector defining the width of the pdf */
const int16_t *dither, /* input: dither vector */
const int N, /* input: data vector length */
int16_t* data, /* output: data vector */
Bitstr* streamdata, /* in-/output struct containing bitstream */
const uint16_t*
env, /* input: side info vector defining the width of the pdf */
const int16_t* dither, /* input: dither vector */
const int N, /* input: data vector length */
const int16_t isSWB12kHz); /* if the codec is working in 12kHz bandwidth */
void WebRtcIsac_EncHistMulti(
Bitstr *streamdata, /* in-/output struct containing bitstream */
const int *data, /* input: data vector */
const uint16_t *const *cdf, /* input: array of cdf arrays */
Bitstr* streamdata, /* in-/output struct containing bitstream */
const int* data, /* input: data vector */
const uint16_t* const* cdf, /* input: array of cdf arrays */
const int N); /* input: data vector length */
int WebRtcIsac_DecHistBisectMulti(
int *data, /* output: data vector */
Bitstr *streamdata, /* in-/output struct containing bitstream */
const uint16_t *const *cdf, /* input: array of cdf arrays */
const uint16_t *cdf_size, /* input: array of cdf table sizes+1 (power of two: 2^k) */
const int N); /* input: data vector length */
int* data, /* output: data vector */
Bitstr* streamdata, /* in-/output struct containing bitstream */
const uint16_t* const* cdf, /* input: array of cdf arrays */
const uint16_t*
cdf_size, /* input: array of cdf table sizes+1 (power of two: 2^k) */
const int N); /* input: data vector length */
int WebRtcIsac_DecHistOneStepMulti(
int *data, /* output: data vector */
Bitstr *streamdata, /* in-/output struct containing bitstream */
const uint16_t *const *cdf, /* input: array of cdf arrays */
const uint16_t *init_index,/* input: vector of initial cdf table search entries */
const int N); /* input: data vector length */
int* data, /* output: data vector */
Bitstr* streamdata, /* in-/output struct containing bitstream */
const uint16_t* const* cdf, /* input: array of cdf arrays */
const uint16_t*
init_index, /* input: vector of initial cdf table search entries */
const int N); /* input: data vector length */
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ARITH_ROUTINES_H_ */

View File

@ -29,7 +29,11 @@ void TestGoodConfig(const AudioEncoderIsacFloatImpl::Config& config) {
// Wrap subroutine calls that test things in this, so that the error messages
// will be accompanied by stack traces that make it possible to tell which
// subroutine invocation caused the failure.
#define S(x) do { SCOPED_TRACE(#x); x; } while (0)
#define S(x) \
do { \
SCOPED_TRACE(#x); \
x; \
} while (0)
} // namespace

View File

@ -24,162 +24,151 @@
#include "modules/audio_coding/codecs/isac/main/source/settings.h"
#include "modules/audio_coding/codecs/isac/main/source/structs.h"
#define MIN_ISAC_BW 10000
#define MIN_ISAC_BW_LB 10000
#define MIN_ISAC_BW_UB 25000
#define MIN_ISAC_BW 10000
#define MIN_ISAC_BW_LB 10000
#define MIN_ISAC_BW_UB 25000
#define MAX_ISAC_BW 56000
#define MAX_ISAC_BW_UB 32000
#define MAX_ISAC_BW_LB 32000
#define MAX_ISAC_BW 56000
#define MAX_ISAC_BW_UB 32000
#define MAX_ISAC_BW_LB 32000
#define MIN_ISAC_MD 5
#define MAX_ISAC_MD 25
#define MIN_ISAC_MD 5
#define MAX_ISAC_MD 25
// assumed header size, in bytes; we don't know the exact number
// (header compression may be used)
#define HEADER_SIZE 35
#define HEADER_SIZE 35
// Initial Frame-Size, in ms, for Wideband & Super-Wideband Mode
#define INIT_FRAME_LEN_WB 60
#define INIT_FRAME_LEN_WB 60
#define INIT_FRAME_LEN_SWB 30
// Initial Bottleneck Estimate, in bits/sec, for
// Wideband & Super-wideband mode
#define INIT_BN_EST_WB 20e3f
#define INIT_BN_EST_SWB 56e3f
#define INIT_BN_EST_WB 20e3f
#define INIT_BN_EST_SWB 56e3f
// Initial Header rate (header rate depends on frame-size),
// in bits/sec, for Wideband & Super-Wideband mode.
#define INIT_HDR_RATE_WB \
#define INIT_HDR_RATE_WB \
((float)HEADER_SIZE * 8.0f * 1000.0f / (float)INIT_FRAME_LEN_WB)
#define INIT_HDR_RATE_SWB \
#define INIT_HDR_RATE_SWB \
((float)HEADER_SIZE * 8.0f * 1000.0f / (float)INIT_FRAME_LEN_SWB)
// number of packets in a row for a high rate burst
#define BURST_LEN 3
#define BURST_LEN 3
// ms, max time between two full bursts
#define BURST_INTERVAL 500
#define BURST_INTERVAL 500
// number of packets in a row for initial high rate burst
#define INIT_BURST_LEN 5
#define INIT_BURST_LEN 5
// bits/s, rate for the first BURST_LEN packets
#define INIT_RATE_WB INIT_BN_EST_WB
#define INIT_RATE_SWB INIT_BN_EST_SWB
#define INIT_RATE_WB INIT_BN_EST_WB
#define INIT_RATE_SWB INIT_BN_EST_SWB
#if defined(__cplusplus)
extern "C" {
#endif
/* This function initializes the struct */
/* to be called before using the struct for anything else */
/* returns 0 if everything went fine, -1 otherwise */
int32_t WebRtcIsac_InitBandwidthEstimator(
BwEstimatorstr* bwest_str,
enum IsacSamplingRate encoderSampRate,
enum IsacSamplingRate decoderSampRate);
/* This function initializes the struct */
/* to be called before using the struct for anything else */
/* returns 0 if everything went fine, -1 otherwise */
int32_t WebRtcIsac_InitBandwidthEstimator(
BwEstimatorstr* bwest_str,
enum IsacSamplingRate encoderSampRate,
enum IsacSamplingRate decoderSampRate);
/* This function updates the receiving estimate */
/* Parameters: */
/* rtp_number - value from RTP packet, from NetEq */
/* frame length - length of signal frame in ms, from iSAC decoder */
/* send_ts - value in RTP header giving send time in samples */
/* arr_ts - value given by timeGetTime() time of arrival in samples of packet from NetEq */
/* pksize - size of packet in bytes, from NetEq */
/* Index - integer (range 0...23) indicating bottle neck & jitter as estimated by other side */
/* returns 0 if everything went fine, -1 otherwise */
int16_t WebRtcIsac_UpdateBandwidthEstimator(
BwEstimatorstr* bwest_str,
const uint16_t rtp_number,
const int32_t frame_length,
const uint32_t send_ts,
const uint32_t arr_ts,
const size_t pksize);
/* This function updates the receiving estimate */
/* Parameters: */
/* rtp_number - value from RTP packet, from NetEq */
/* frame length - length of signal frame in ms, from iSAC decoder */
/* send_ts - value in RTP header giving send time in samples */
/* arr_ts - value given by timeGetTime() time of arrival in samples of
* packet from NetEq */
/* pksize - size of packet in bytes, from NetEq */
/* Index - integer (range 0...23) indicating bottle neck & jitter as
* estimated by other side */
/* returns 0 if everything went fine, -1 otherwise */
int16_t WebRtcIsac_UpdateBandwidthEstimator(BwEstimatorstr* bwest_str,
const uint16_t rtp_number,
const int32_t frame_length,
const uint32_t send_ts,
const uint32_t arr_ts,
const size_t pksize);
/* Update receiving estimates. Used when we only receive BWE index, no iSAC data packet. */
int16_t WebRtcIsac_UpdateUplinkBwImpl(
BwEstimatorstr* bwest_str,
int16_t Index,
enum IsacSamplingRate encoderSamplingFreq);
/* Update receiving estimates. Used when we only receive BWE index, no iSAC data
* packet. */
int16_t WebRtcIsac_UpdateUplinkBwImpl(
BwEstimatorstr* bwest_str,
int16_t Index,
enum IsacSamplingRate encoderSamplingFreq);
/* Returns the bandwidth/jitter estimation code (integer 0...23) to put in the sending iSAC payload */
void WebRtcIsac_GetDownlinkBwJitIndexImpl(
BwEstimatorstr* bwest_str,
int16_t* bottleneckIndex,
int16_t* jitterInfo,
enum IsacSamplingRate decoderSamplingFreq);
/* Returns the bandwidth/jitter estimation code (integer 0...23) to put in the
* sending iSAC payload */
void WebRtcIsac_GetDownlinkBwJitIndexImpl(
BwEstimatorstr* bwest_str,
int16_t* bottleneckIndex,
int16_t* jitterInfo,
enum IsacSamplingRate decoderSamplingFreq);
/* Returns the bandwidth estimation (in bps) */
int32_t WebRtcIsac_GetDownlinkBandwidth(
const BwEstimatorstr *bwest_str);
/* Returns the bandwidth estimation (in bps) */
int32_t WebRtcIsac_GetDownlinkBandwidth(const BwEstimatorstr* bwest_str);
/* Returns the max delay (in ms) */
int32_t WebRtcIsac_GetDownlinkMaxDelay(
const BwEstimatorstr *bwest_str);
/* Returns the max delay (in ms) */
int32_t WebRtcIsac_GetDownlinkMaxDelay(const BwEstimatorstr* bwest_str);
/* Returns the bandwidth that iSAC should send with in bps */
int32_t WebRtcIsac_GetUplinkBandwidth(const BwEstimatorstr* bwest_str);
/* Returns the bandwidth that iSAC should send with in bps */
int32_t WebRtcIsac_GetUplinkBandwidth(const BwEstimatorstr* bwest_str);
/* Returns the max delay value from the other side in ms */
int32_t WebRtcIsac_GetUplinkMaxDelay(
const BwEstimatorstr *bwest_str);
/* Returns the max delay value from the other side in ms */
int32_t WebRtcIsac_GetUplinkMaxDelay(const BwEstimatorstr* bwest_str);
/* Fills in an IsacExternalBandwidthInfo struct. */
void WebRtcIsacBw_GetBandwidthInfo(
BwEstimatorstr* bwest_str,
enum IsacSamplingRate decoder_sample_rate_hz,
IsacBandwidthInfo* bwinfo);
/* Fills in an IsacExternalBandwidthInfo struct. */
void WebRtcIsacBw_GetBandwidthInfo(BwEstimatorstr* bwest_str,
enum IsacSamplingRate decoder_sample_rate_hz,
IsacBandwidthInfo* bwinfo);
/* Uses the values from an IsacExternalBandwidthInfo struct. */
void WebRtcIsacBw_SetBandwidthInfo(BwEstimatorstr* bwest_str,
const IsacBandwidthInfo* bwinfo);
/* Uses the values from an IsacExternalBandwidthInfo struct. */
void WebRtcIsacBw_SetBandwidthInfo(BwEstimatorstr* bwest_str,
const IsacBandwidthInfo* bwinfo);
/*
* update amount of data in bottle neck buffer and burst handling
* returns minimum payload size (bytes)
*/
int WebRtcIsac_GetMinBytes(
RateModel* State,
int StreamSize, /* bytes in bitstream */
const int FrameLen, /* ms per frame */
const double BottleNeck, /* bottle neck rate; excl headers (bps) */
const double DelayBuildUp, /* max delay from bottleneck buffering (ms) */
enum ISACBandwidth bandwidth
/*,int16_t frequentLargePackets*/);
/*
* update amount of data in bottle neck buffer and burst handling
* returns minimum payload size (bytes)
*/
int WebRtcIsac_GetMinBytes(
RateModel* State,
int StreamSize, /* bytes in bitstream */
const int FrameLen, /* ms per frame */
const double BottleNeck, /* bottle neck rate; excl headers (bps) */
const double DelayBuildUp, /* max delay from bottleneck buffering (ms) */
enum ISACBandwidth bandwidth
/*,int16_t frequentLargePackets*/);
/*
* update long-term average bitrate and amount of data in buffer
*/
void WebRtcIsac_UpdateRateModel(
RateModel* State,
int StreamSize, /* bytes in bitstream */
const int FrameSamples, /* samples per frame */
const double BottleNeck); /* bottle neck rate; excl headers (bps) */
/*
* update long-term average bitrate and amount of data in buffer
*/
void WebRtcIsac_UpdateRateModel(
RateModel* State,
int StreamSize, /* bytes in bitstream */
const int FrameSamples, /* samples per frame */
const double BottleNeck); /* bottle neck rate; excl headers (bps) */
void WebRtcIsac_InitRateModel(RateModel* State);
void WebRtcIsac_InitRateModel(
RateModel *State);
/* Returns the new framelength value (input argument: bottle_neck) */
int WebRtcIsac_GetNewFrameLength(double bottle_neck, int current_framelength);
/* Returns the new framelength value (input argument: bottle_neck) */
int WebRtcIsac_GetNewFrameLength(
double bottle_neck,
int current_framelength);
/* Returns the new SNR value (input argument: bottle_neck) */
double WebRtcIsac_GetSnr(double bottle_neck, int new_framelength);
/* Returns the new SNR value (input argument: bottle_neck) */
double WebRtcIsac_GetSnr(
double bottle_neck,
int new_framelength);
int16_t WebRtcIsac_UpdateUplinkJitter(
BwEstimatorstr* bwest_str,
int32_t index);
int16_t WebRtcIsac_UpdateUplinkJitter(BwEstimatorstr* bwest_str, int32_t index);
#if defined(__cplusplus)
}
#endif
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_BANDWIDTH_ESTIMATOR_H_ */
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_BANDWIDTH_ESTIMATOR_H_ \
*/

View File

@ -25,10 +25,12 @@
void WebRtcIsac_ResetBitstream(Bitstr* bit_stream);
int WebRtcIsac_EstimateBandwidth(BwEstimatorstr* bwest_str, Bitstr* streamdata,
int WebRtcIsac_EstimateBandwidth(BwEstimatorstr* bwest_str,
Bitstr* streamdata,
size_t packet_size,
uint16_t rtp_seq_number,
uint32_t send_ts, uint32_t arr_ts,
uint32_t send_ts,
uint32_t arr_ts,
enum IsacSamplingRate encoderSampRate,
enum IsacSamplingRate decoderSampRate);
@ -38,7 +40,8 @@ int WebRtcIsac_DecodeLb(const TransformTables* transform_tables,
int16_t* current_framesamples,
int16_t isRCUPayload);
int WebRtcIsac_DecodeRcuLb(float* signal_out, ISACLBDecStruct* ISACdec_obj,
int WebRtcIsac_DecodeRcuLb(float* signal_out,
ISACLBDecStruct* ISACdec_obj,
int16_t* current_framesamples);
int WebRtcIsac_EncodeLb(const TransformTables* transform_tables,
@ -48,15 +51,20 @@ int WebRtcIsac_EncodeLb(const TransformTables* transform_tables,
int16_t bottleneckIndex);
int WebRtcIsac_EncodeStoredDataLb(const IsacSaveEncoderData* ISACSavedEnc_obj,
Bitstr* ISACBitStr_obj, int BWnumber,
Bitstr* ISACBitStr_obj,
int BWnumber,
float scale);
int WebRtcIsac_EncodeStoredDataUb(
const ISACUBSaveEncDataStruct* ISACSavedEnc_obj, Bitstr* bitStream,
int32_t jitterInfo, float scale, enum ISACBandwidth bandwidth);
const ISACUBSaveEncDataStruct* ISACSavedEnc_obj,
Bitstr* bitStream,
int32_t jitterInfo,
float scale,
enum ISACBandwidth bandwidth);
int16_t WebRtcIsac_GetRedPayloadUb(
const ISACUBSaveEncDataStruct* ISACSavedEncObj, Bitstr* bitStreamObj,
const ISACUBSaveEncDataStruct* ISACSavedEncObj,
Bitstr* bitStreamObj,
enum ISACBandwidth bandwidth);
/******************************************************************************
@ -82,7 +90,6 @@ int16_t WebRtcIsac_RateAllocation(int32_t inRateBitPerSec,
double* rateUBBitPerSec,
enum ISACBandwidth* bandwidthKHz);
/******************************************************************************
* WebRtcIsac_DecodeUb16()
*
@ -169,7 +176,6 @@ void WebRtcIsac_InitMasking(MaskFiltstr* maskdata);
void WebRtcIsac_InitPostFilterbank(PostFiltBankstr* postfiltdata);
/**************************** transform functions ****************************/
void WebRtcIsac_InitTransform(TransformTables* tables);
@ -190,18 +196,25 @@ void WebRtcIsac_Spec2time(const TransformTables* tables,
/***************************** filterbank functions **************************/
void WebRtcIsac_FilterAndCombineFloat(float* InLP, float* InHP, float* Out,
void WebRtcIsac_FilterAndCombineFloat(float* InLP,
float* InHP,
float* Out,
PostFiltBankstr* postfiltdata);
/************************* normalized lattice filters ************************/
void WebRtcIsac_NormLatticeFilterMa(int orderCoef, float* stateF, float* stateG,
float* lat_in, double* filtcoeflo,
void WebRtcIsac_NormLatticeFilterMa(int orderCoef,
float* stateF,
float* stateG,
float* lat_in,
double* filtcoeflo,
double* lat_out);
void WebRtcIsac_NormLatticeFilterAr(int orderCoef, float* stateF, float* stateG,
double* lat_in, double* lo_filt_coef,
void WebRtcIsac_NormLatticeFilterAr(int orderCoef,
float* stateF,
float* stateG,
double* lat_in,
double* lo_filt_coef,
float* lat_out);
void WebRtcIsac_Dir2Lat(double* a, int orderCoef, float* sth, float* cth);

View File

@ -36,11 +36,6 @@
* -1 - Error
*/
int WebRtcIsac_GetCrc(
const int16_t* encoded,
int no_of_word8s,
uint32_t* crc);
int WebRtcIsac_GetCrc(const int16_t* encoded, int no_of_word8s, uint32_t* crc);
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_CRC_H_ */

View File

@ -39,9 +39,7 @@
*
*
*/
int16_t WebRtcIsac_RemoveLarMean(
double* lar,
int16_t bandwidth);
int16_t WebRtcIsac_RemoveLarMean(double* lar, int16_t bandwidth);
/******************************************************************************
* WebRtcIsac_DecorrelateIntraVec()
@ -59,11 +57,9 @@ int16_t WebRtcIsac_RemoveLarMean(
* Output:
* -out : decorrelated LAR vectors.
*/
int16_t WebRtcIsac_DecorrelateIntraVec(
const double* inLAR,
double* out,
int16_t bandwidth);
int16_t WebRtcIsac_DecorrelateIntraVec(const double* inLAR,
double* out,
int16_t bandwidth);
/******************************************************************************
* WebRtcIsac_DecorrelateInterVec()
@ -82,11 +78,9 @@ int16_t WebRtcIsac_DecorrelateIntraVec(
* Output:
* -out : decorrelated LAR vectors.
*/
int16_t WebRtcIsac_DecorrelateInterVec(
const double* data,
double* out,
int16_t bandwidth);
int16_t WebRtcIsac_DecorrelateInterVec(const double* data,
double* out,
int16_t bandwidth);
/******************************************************************************
* WebRtcIsac_QuantizeUncorrLar()
@ -102,11 +96,7 @@ int16_t WebRtcIsac_DecorrelateInterVec(
* -data : quantized version of the input.
* -idx : pointer to quantization indices.
*/
double WebRtcIsac_QuantizeUncorrLar(
double* data,
int* idx,
int16_t bandwidth);
double WebRtcIsac_QuantizeUncorrLar(double* data, int* idx, int16_t bandwidth);
/******************************************************************************
* WebRtcIsac_CorrelateIntraVec()
@ -121,11 +111,9 @@ double WebRtcIsac_QuantizeUncorrLar(
* Output:
* -out : correlated parametrs.
*/
int16_t WebRtcIsac_CorrelateIntraVec(
const double* data,
double* out,
int16_t bandwidth);
int16_t WebRtcIsac_CorrelateIntraVec(const double* data,
double* out,
int16_t bandwidth);
/******************************************************************************
* WebRtcIsac_CorrelateInterVec()
@ -140,17 +128,15 @@ int16_t WebRtcIsac_CorrelateIntraVec(
* Output:
* -out : correlated parametrs.
*/
int16_t WebRtcIsac_CorrelateInterVec(
const double* data,
double* out,
int16_t bandwidth);
int16_t WebRtcIsac_CorrelateInterVec(const double* data,
double* out,
int16_t bandwidth);
/******************************************************************************
* WebRtcIsac_AddLarMean()
*
* This is the inverse of WebRtcIsac_RemoveLarMean()
*
*
* Input:
* -data : pointer to mean-removed LAR:s.
* -bandwidth : indicates if the given LAR vectors belong
@ -159,10 +145,7 @@ int16_t WebRtcIsac_CorrelateInterVec(
* Output:
* -data : pointer to LARs.
*/
int16_t WebRtcIsac_AddLarMean(
double* data,
int16_t bandwidth);
int16_t WebRtcIsac_AddLarMean(double* data, int16_t bandwidth);
/******************************************************************************
* WebRtcIsac_DequantizeLpcParam()
@ -177,11 +160,9 @@ int16_t WebRtcIsac_AddLarMean(
* Output:
* -out : pointer to quantized values.
*/
int16_t WebRtcIsac_DequantizeLpcParam(
const int* idx,
double* out,
int16_t bandwidth);
int16_t WebRtcIsac_DequantizeLpcParam(const int* idx,
double* out,
int16_t bandwidth);
/******************************************************************************
* WebRtcIsac_ToLogDomainRemoveMean()
@ -194,9 +175,7 @@ int16_t WebRtcIsac_DequantizeLpcParam(
* Output:
* -lpcGain : mean-removed in log domain.
*/
int16_t WebRtcIsac_ToLogDomainRemoveMean(
double* lpGains);
int16_t WebRtcIsac_ToLogDomainRemoveMean(double* lpGains);
/******************************************************************************
* WebRtcIsac_DecorrelateLPGain()
@ -210,16 +189,13 @@ int16_t WebRtcIsac_ToLogDomainRemoveMean(
* Output:
* -out : decorrelated parameters.
*/
int16_t WebRtcIsac_DecorrelateLPGain(
const double* data,
double* out);
int16_t WebRtcIsac_DecorrelateLPGain(const double* data, double* out);
/******************************************************************************
* WebRtcIsac_QuantizeLpcGain()
*
* Quantize the decorrelated log-domain gains.
*
*
* Input:
* -lpcGain : uncorrelated LPC gains.
*
@ -227,10 +203,7 @@ int16_t WebRtcIsac_DecorrelateLPGain(
* -idx : quantization indices
* -lpcGain : quantized value of the inpt.
*/
double WebRtcIsac_QuantizeLpcGain(
double* lpGains,
int* idx);
double WebRtcIsac_QuantizeLpcGain(double* lpGains, int* idx);
/******************************************************************************
* WebRtcIsac_DequantizeLpcGain()
@ -243,10 +216,7 @@ double WebRtcIsac_QuantizeLpcGain(
* Output:
* -lpcGains : quantized values of the given parametes.
*/
int16_t WebRtcIsac_DequantizeLpcGain(
const int* idx,
double* lpGains);
int16_t WebRtcIsac_DequantizeLpcGain(const int* idx, double* lpGains);
/******************************************************************************
* WebRtcIsac_CorrelateLpcGain()
@ -259,10 +229,7 @@ int16_t WebRtcIsac_DequantizeLpcGain(
* Output:
* -out : correlated parameters.
*/
int16_t WebRtcIsac_CorrelateLpcGain(
const double* data,
double* out);
int16_t WebRtcIsac_CorrelateLpcGain(const double* data, double* out);
/******************************************************************************
* WebRtcIsac_AddMeanToLinearDomain()
@ -275,8 +242,6 @@ int16_t WebRtcIsac_CorrelateLpcGain(
* Output:
* -lpcGain : LPC gain in normal domain.
*/
int16_t WebRtcIsac_AddMeanToLinearDomain(
double* lpcGains);
int16_t WebRtcIsac_AddMeanToLinearDomain(double* lpcGains);
#endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ENCODE_LPC_SWB_H_

View File

@ -46,8 +46,11 @@
* Return value : < 0 if an error occures
* 0 if succeeded.
*/
int WebRtcIsac_DecodeSpec(Bitstr* streamdata, int16_t AvgPitchGain_Q12,
enum ISACBand band, double* fr, double* fi);
int WebRtcIsac_DecodeSpec(Bitstr* streamdata,
int16_t AvgPitchGain_Q12,
enum ISACBand band,
double* fr,
double* fi);
/******************************************************************************
* WebRtcIsac_EncodeSpec()
@ -72,24 +75,31 @@ int WebRtcIsac_DecodeSpec(Bitstr* streamdata, int16_t AvgPitchGain_Q12,
* Return value : < 0 if an error occures
* 0 if succeeded.
*/
int WebRtcIsac_EncodeSpec(const int16_t* fr, const int16_t* fi,
int16_t AvgPitchGain_Q12, enum ISACBand band,
int WebRtcIsac_EncodeSpec(const int16_t* fr,
const int16_t* fi,
int16_t AvgPitchGain_Q12,
enum ISACBand band,
Bitstr* streamdata);
/* decode & dequantize LPC Coef */
int WebRtcIsac_DecodeLpcCoef(Bitstr* streamdata, double* LPCCoef);
int WebRtcIsac_DecodeLpcCoefUB(Bitstr* streamdata, double* lpcVecs,
int WebRtcIsac_DecodeLpcCoefUB(Bitstr* streamdata,
double* lpcVecs,
double* percepFilterGains,
int16_t bandwidth);
int WebRtcIsac_DecodeLpc(Bitstr* streamdata, double* LPCCoef_lo,
int WebRtcIsac_DecodeLpc(Bitstr* streamdata,
double* LPCCoef_lo,
double* LPCCoef_hi);
/* quantize & code LPC Coef */
void WebRtcIsac_EncodeLpcLb(double* LPCCoef_lo, double* LPCCoef_hi,
Bitstr* streamdata, IsacSaveEncoderData* encData);
void WebRtcIsac_EncodeLpcLb(double* LPCCoef_lo,
double* LPCCoef_hi,
Bitstr* streamdata,
IsacSaveEncoderData* encData);
void WebRtcIsac_EncodeLpcGainLb(double* LPCCoef_lo, double* LPCCoef_hi,
void WebRtcIsac_EncodeLpcGainLb(double* LPCCoef_lo,
double* LPCCoef_hi,
Bitstr* streamdata,
IsacSaveEncoderData* encData);
@ -126,7 +136,8 @@ void WebRtcIsac_EncodeLpcGainLb(double* LPCCoef_lo, double* LPCCoef_hi,
* Return value : 0 if encoding is successful,
* <0 if failed to encode.
*/
int16_t WebRtcIsac_EncodeLpcUB(double* lpcCoeff, Bitstr* streamdata,
int16_t WebRtcIsac_EncodeLpcUB(double* lpcCoeff,
Bitstr* streamdata,
double* interpolLPCCoeff,
int16_t bandwidth,
ISACUBSaveEncDataStruct* encData);
@ -184,9 +195,9 @@ void WebRtcIsac_EncodePitchLag(double* PitchLags,
Bitstr* streamdata,
IsacSaveEncoderData* encData);
int WebRtcIsac_DecodePitchGain(Bitstr* streamdata,
int16_t* PitchGain_Q12);
int WebRtcIsac_DecodePitchLag(Bitstr* streamdata, int16_t* PitchGain_Q12,
int WebRtcIsac_DecodePitchGain(Bitstr* streamdata, int16_t* PitchGain_Q12);
int WebRtcIsac_DecodePitchLag(Bitstr* streamdata,
int16_t* PitchGain_Q12,
double* PitchLag);
int WebRtcIsac_DecodeFrameLen(Bitstr* streamdata, int16_t* framelength);
@ -200,10 +211,10 @@ void WebRtcIsac_Poly2Rc(double* a, int N, double* RC);
/* Step-up */
void WebRtcIsac_Rc2Poly(double* RC, int N, double* a);
void WebRtcIsac_TranscodeLPCCoef(double* LPCCoef_lo, double* LPCCoef_hi,
void WebRtcIsac_TranscodeLPCCoef(double* LPCCoef_lo,
double* LPCCoef_hi,
int* index_g);
/******************************************************************************
* WebRtcIsac_EncodeLpcGainUb()
* Encode LPC gains of sub-Frames.
@ -220,10 +231,10 @@ void WebRtcIsac_TranscodeLPCCoef(double* LPCCoef_lo, double* LPCCoef_hi,
* - lpcGainIndex : quantization indices for lpc gains, these will
* be stored to be used for FEC.
*/
void WebRtcIsac_EncodeLpcGainUb(double* lpGains, Bitstr* streamdata,
void WebRtcIsac_EncodeLpcGainUb(double* lpGains,
Bitstr* streamdata,
int* lpcGainIndex);
/******************************************************************************
* WebRtcIsac_EncodeLpcGainUb()
* Store LPC gains of sub-Frames in 'streamdata'.
@ -239,7 +250,6 @@ void WebRtcIsac_EncodeLpcGainUb(double* lpGains, Bitstr* streamdata,
*/
void WebRtcIsac_StoreLpcGainUb(double* lpGains, Bitstr* streamdata);
/******************************************************************************
* WebRtcIsac_DecodeLpcGainUb()
* Decode the LPC gain of sub-frames.
@ -257,7 +267,6 @@ void WebRtcIsac_StoreLpcGainUb(double* lpGains, Bitstr* streamdata);
*/
int16_t WebRtcIsac_DecodeLpcGainUb(double* lpGains, Bitstr* streamdata);
/******************************************************************************
* WebRtcIsac_EncodeBandwidth()
* Encode if the bandwidth of encoded audio is 0-12 kHz or 0-16 kHz.
@ -277,7 +286,6 @@ int16_t WebRtcIsac_DecodeLpcGainUb(double* lpGains, Bitstr* streamdata);
int16_t WebRtcIsac_EncodeBandwidth(enum ISACBandwidth bandwidth,
Bitstr* streamData);
/******************************************************************************
* WebRtcIsac_DecodeBandwidth()
* Decode the bandwidth of the encoded audio, i.e. if the bandwidth is 0-12 kHz
@ -298,7 +306,6 @@ int16_t WebRtcIsac_EncodeBandwidth(enum ISACBandwidth bandwidth,
int16_t WebRtcIsac_DecodeBandwidth(Bitstr* streamData,
enum ISACBandwidth* bandwidth);
/******************************************************************************
* WebRtcIsac_EncodeJitterInfo()
* Decode the jitter information.
@ -316,9 +323,7 @@ int16_t WebRtcIsac_DecodeBandwidth(Bitstr* streamData,
* Return value : 0 if succeeded.
* <0 if failed.
*/
int16_t WebRtcIsac_EncodeJitterInfo(int32_t jitterIndex,
Bitstr* streamData);
int16_t WebRtcIsac_EncodeJitterInfo(int32_t jitterIndex, Bitstr* streamData);
/******************************************************************************
* WebRtcIsac_DecodeJitterInfo()
@ -337,7 +342,6 @@ int16_t WebRtcIsac_EncodeJitterInfo(int32_t jitterIndex,
* Return value : 0 if succeeded.
* <0 if failed.
*/
int16_t WebRtcIsac_DecodeJitterInfo(Bitstr* streamData,
int32_t* jitterInfo);
int16_t WebRtcIsac_DecodeJitterInfo(Bitstr* streamData, int32_t* jitterInfo);
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ENTROPY_CODING_H_ */

View File

@ -34,10 +34,12 @@
/* double precision routine */
int WebRtcIsac_Fftns (unsigned int ndim, const int dims[], double Re[], double Im[],
int isign, double scaling, FFTstr *fftstate);
int WebRtcIsac_Fftns(unsigned int ndim,
const int dims[],
double Re[],
double Im[],
int isign,
double scaling,
FFTstr* fftstate);
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_FFT_H_ */

View File

@ -35,15 +35,13 @@ class IsacTest : public ::testing::Test {
uint8_t bitstream_small_[7]; // Simulate sync packets.
};
IsacTest::IsacTest()
: isac_codec_(NULL) {
}
IsacTest::IsacTest() : isac_codec_(NULL) {}
void IsacTest::SetUp() {
// Read some samples from a speech file, to be used in the encode test.
FILE* input_file;
const std::string file_name =
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
input_file = fopen(file_name.c_str(), "rb");
ASSERT_TRUE(input_file != NULL);
ASSERT_EQ(kIsacNumberOfSamples,
@ -69,7 +67,8 @@ TEST_F(IsacTest, IsacFreeFail) {
TEST_F(IsacTest, IsacCreateFree) {
EXPECT_EQ(0, WebRtcIsac_Create(&isac_codec_));
EXPECT_TRUE(isac_codec_ != NULL);
EXPECT_EQ(0, WebRtcIsac_Free(isac_codec_));}
EXPECT_EQ(0, WebRtcIsac_Free(isac_codec_));
}
TEST_F(IsacTest, IsacUpdateBWE) {
// Create encoder memory.
@ -86,17 +85,17 @@ TEST_F(IsacTest, IsacUpdateBWE) {
12345, 56789));
// Encode 60 ms of data (needed to create a first packet).
encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
EXPECT_EQ(0, encoded_bytes);
encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
EXPECT_EQ(0, encoded_bytes);
encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
EXPECT_EQ(0, encoded_bytes);
encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
EXPECT_EQ(0, encoded_bytes);
encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
EXPECT_EQ(0, encoded_bytes);
encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
EXPECT_GT(encoded_bytes, 0);
// Call to update bandwidth estimator with real data.

View File

@ -21,24 +21,26 @@
#include "modules/audio_coding/codecs/isac/main/source/settings.h"
#include "modules/audio_coding/codecs/isac/main/source/structs.h"
void WebRtcIsac_GetLpcCoefLb(double *inLo, double *inHi, MaskFiltstr *maskdata,
double signal_noise_ratio, const int16_t *pitchGains_Q12,
double *lo_coeff, double *hi_coeff);
void WebRtcIsac_GetLpcCoefLb(double* inLo,
double* inHi,
MaskFiltstr* maskdata,
double signal_noise_ratio,
const int16_t* pitchGains_Q12,
double* lo_coeff,
double* hi_coeff);
void WebRtcIsac_GetLpcGain(
double signal_noise_ratio,
const double* filtCoeffVecs,
int numVecs,
double* gain,
double corrLo[][UB_LPC_ORDER + 1],
const double* varscale);
void WebRtcIsac_GetLpcGain(double signal_noise_ratio,
const double* filtCoeffVecs,
int numVecs,
double* gain,
double corrLo[][UB_LPC_ORDER + 1],
const double* varscale);
void WebRtcIsac_GetLpcCoefUb(
double* inSignal,
MaskFiltstr* maskdata,
double* lpCoeff,
double corr[][UB_LPC_ORDER + 1],
double* varscale,
int16_t bandwidth);
void WebRtcIsac_GetLpcCoefUb(double* inSignal,
MaskFiltstr* maskdata,
double* lpCoeff,
double corr[][UB_LPC_ORDER + 1],
double* varscale,
int16_t bandwidth);
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_ANALYIS_H_ */

View File

@ -46,4 +46,4 @@ extern const uint16_t* WebRtcIsac_kLpcGainCdfMat[SUBFRAMES];
extern const double WebRtcIsac_kLpcGainDecorrMat[SUBFRAMES][SUBFRAMES];
#endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_GAIN_SWB_TABLES_H_
#endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_GAIN_SWB_TABLES_H_

View File

@ -26,22 +26,22 @@ extern const double WebRtcIsac_kMeanLarUb12[UB_LPC_ORDER];
extern const double WebRtcIsac_kMeanLpcGain;
extern const double WebRtcIsac_kIntraVecDecorrMatUb12[UB_LPC_ORDER][UB_LPC_ORDER];
extern const double WebRtcIsac_kIntraVecDecorrMatUb12[UB_LPC_ORDER]
[UB_LPC_ORDER];
extern const double WebRtcIsac_kInterVecDecorrMatUb12
[UB_LPC_VEC_PER_FRAME][UB_LPC_VEC_PER_FRAME];
extern const double WebRtcIsac_kInterVecDecorrMatUb12[UB_LPC_VEC_PER_FRAME]
[UB_LPC_VEC_PER_FRAME];
extern const double WebRtcIsac_kLpcShapeQStepSizeUb12;
extern const double WebRtcIsac_kLpcShapeLeftRecPointUb12
[UB_LPC_ORDER*UB_LPC_VEC_PER_FRAME];
extern const double
WebRtcIsac_kLpcShapeLeftRecPointUb12[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME];
extern const int16_t
WebRtcIsac_kLpcShapeNumRecPointUb12[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME];
extern const int16_t WebRtcIsac_kLpcShapeNumRecPointUb12
[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME];
extern const uint16_t WebRtcIsac_kLpcShapeEntropySearchUb12
[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME];
extern const uint16_t
WebRtcIsac_kLpcShapeEntropySearchUb12[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME];
extern const uint16_t WebRtcIsac_kLpcShapeCdfVec0Ub12[14];
@ -59,7 +59,7 @@ extern const uint16_t WebRtcIsac_kLpcShapeCdfVec6Ub12[33];
extern const uint16_t WebRtcIsac_kLpcShapeCdfVec7Ub12[49];
extern const uint16_t* WebRtcIsac_kLpcShapeCdfMatUb12
[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME];
extern const uint16_t*
WebRtcIsac_kLpcShapeCdfMatUb12[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME];
#endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_SHAPE_SWB12_TABLES_H_
#endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_SHAPE_SWB12_TABLES_H_

View File

@ -24,10 +24,11 @@
extern const double WebRtcIsac_kMeanLarUb16[UB_LPC_ORDER];
extern const double WebRtcIsac_kIintraVecDecorrMatUb16[UB_LPC_ORDER][UB_LPC_ORDER];
extern const double WebRtcIsac_kIintraVecDecorrMatUb16[UB_LPC_ORDER]
[UB_LPC_ORDER];
extern const double WebRtcIsac_kInterVecDecorrMatUb16
[UB16_LPC_VEC_PER_FRAME][UB16_LPC_VEC_PER_FRAME];
extern const double WebRtcIsac_kInterVecDecorrMatUb16[UB16_LPC_VEC_PER_FRAME]
[UB16_LPC_VEC_PER_FRAME];
extern const uint16_t WebRtcIsac_kLpcShapeCdfVec01Ub16[14];
@ -61,18 +62,19 @@ extern const uint16_t WebRtcIsac_kLpcShapeCdfVec01Ub165[34];
extern const uint16_t WebRtcIsac_kLpcShapeCdfVec01Ub166[71];
extern const uint16_t* WebRtcIsac_kLpcShapeCdfMatUb16
[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME];
extern const uint16_t*
WebRtcIsac_kLpcShapeCdfMatUb16[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME];
extern const double WebRtcIsac_kLpcShapeLeftRecPointUb16
[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME];
extern const double
WebRtcIsac_kLpcShapeLeftRecPointUb16[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME];
extern const int16_t WebRtcIsac_kLpcShapeNumRecPointUb16
[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME];
extern const int16_t
WebRtcIsac_kLpcShapeNumRecPointUb16[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME];
extern const uint16_t WebRtcIsac_kLpcShapeEntropySearchUb16
[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME];
extern const uint16_t
WebRtcIsac_kLpcShapeEntropySearchUb16[UB_LPC_ORDER *
UB16_LPC_VEC_PER_FRAME];
extern const double WebRtcIsac_kLpcShapeQStepSizeUb16;
#endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_SHAPE_SWB16_TABLES_H_
#endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_SHAPE_SWB16_TABLES_H_

View File

@ -22,27 +22,27 @@
#include "modules/audio_coding/codecs/isac/main/source/settings.h"
#define KLT_STEPSIZE 1.00000000
#define KLT_NUM_AVG_GAIN 0
#define KLT_NUM_AVG_SHAPE 0
#define KLT_NUM_MODELS 3
#define LPC_GAIN_SCALE 4.000f
#define LPC_LOBAND_SCALE 2.100f
#define LPC_LOBAND_ORDER ORDERLO
#define LPC_HIBAND_SCALE 0.450f
#define LPC_HIBAND_ORDER ORDERHI
#define LPC_GAIN_ORDER 2
#define KLT_STEPSIZE 1.00000000
#define KLT_NUM_AVG_GAIN 0
#define KLT_NUM_AVG_SHAPE 0
#define KLT_NUM_MODELS 3
#define LPC_GAIN_SCALE 4.000f
#define LPC_LOBAND_SCALE 2.100f
#define LPC_LOBAND_ORDER ORDERLO
#define LPC_HIBAND_SCALE 0.450f
#define LPC_HIBAND_ORDER ORDERHI
#define LPC_GAIN_ORDER 2
#define LPC_SHAPE_ORDER (LPC_LOBAND_ORDER + LPC_HIBAND_ORDER)
#define LPC_SHAPE_ORDER (LPC_LOBAND_ORDER + LPC_HIBAND_ORDER)
#define KLT_ORDER_GAIN (LPC_GAIN_ORDER * SUBFRAMES)
#define KLT_ORDER_SHAPE (LPC_SHAPE_ORDER * SUBFRAMES)
#define KLT_ORDER_GAIN (LPC_GAIN_ORDER * SUBFRAMES)
#define KLT_ORDER_SHAPE (LPC_SHAPE_ORDER * SUBFRAMES)
/* cdf array for model indicator */
extern const uint16_t WebRtcIsac_kQKltModelCdf[KLT_NUM_MODELS+1];
extern const uint16_t WebRtcIsac_kQKltModelCdf[KLT_NUM_MODELS + 1];
/* pointer to cdf array for model indicator */
extern const uint16_t *WebRtcIsac_kQKltModelCdfPtr[1];
extern const uint16_t* WebRtcIsac_kQKltModelCdfPtr[1];
/* initial cdf index for decoder of model indicator */
extern const uint16_t WebRtcIsac_kQKltModelInitIndex[1];
@ -78,9 +78,9 @@ extern const uint16_t WebRtcIsac_kQKltCdfGain[404];
extern const uint16_t WebRtcIsac_kQKltCdfShape[686];
/* pointers to cdf tables for quantizer indices */
extern const uint16_t *WebRtcIsac_kQKltCdfPtrGain[12];
extern const uint16_t* WebRtcIsac_kQKltCdfPtrGain[12];
extern const uint16_t *WebRtcIsac_kQKltCdfPtrShape[108];
extern const uint16_t* WebRtcIsac_kQKltCdfPtrShape[108];
/* left KLT transforms */
extern const double WebRtcIsac_kKltT1Gain[4];

View File

@ -8,7 +8,6 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_
#define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_
@ -24,11 +23,12 @@ static __inline long int WebRtcIsac_lrint(double x_dbl) {
__asm {
fld x_dbl
fistp x_int
};
}
;
return x_int;
}
#else // Do a slow but correct implementation of lrint
#else // Do a slow but correct implementation of lrint
static __inline long int WebRtcIsac_lrint(double x_dbl) {
long int x_int;

View File

@ -22,10 +22,11 @@
#include "modules/audio_coding/codecs/isac/main/source/structs.h"
void WebRtcIsac_PitchAnalysis(const double *in, /* PITCH_FRAME_LEN samples */
double *out, /* PITCH_FRAME_LEN+QLOOKAHEAD samples */
PitchAnalysisStruct *State,
double *lags,
double *gains);
void WebRtcIsac_PitchAnalysis(
const double* in, /* PITCH_FRAME_LEN samples */
double* out, /* PITCH_FRAME_LEN+QLOOKAHEAD samples */
PitchAnalysisStruct* State,
double* lags,
double* gains);
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_ESTIMATOR_H_ */

View File

@ -11,7 +11,8 @@
/*
* pitch_gain_tables.h
*
* This file contains tables for the pitch filter side-info in the entropy coder.
* This file contains tables for the pitch filter side-info in the entropy
* coder.
*
*/
@ -20,8 +21,10 @@
#include "typedefs.h" // NOLINT(build/include)
/* header file for coding tables for the pitch filter side-info in the entropy coder */
/********************* Pitch Filter Gain Coefficient Tables ************************/
/* header file for coding tables for the pitch filter side-info in the entropy
* coder */
/********************* Pitch Filter Gain Coefficient Tables
* ************************/
/* cdf for quantized pitch filter gains */
extern const uint16_t WebRtcIsac_kQPitchGainCdf[255];

View File

@ -11,7 +11,8 @@
/*
* pitch_lag_tables.h
*
* This file contains tables for the pitch filter side-info in the entropy coder.
* This file contains tables for the pitch filter side-info in the entropy
* coder.
*
*/
@ -19,8 +20,10 @@
#define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_LAG_TABLES_H_
#include "typedefs.h" // NOLINT(build/include)
/* header file for coding tables for the pitch filter side-info in the entropy coder */
/********************* Pitch Filter Lag Coefficient Tables ************************/
/* header file for coding tables for the pitch filter side-info in the entropy
* coder */
/********************* Pitch Filter Lag Coefficient Tables
* ************************/
/* tables for use with small pitch gain */
@ -30,7 +33,7 @@ extern const uint16_t WebRtcIsac_kQPitchLagCdf2Lo[20];
extern const uint16_t WebRtcIsac_kQPitchLagCdf3Lo[2];
extern const uint16_t WebRtcIsac_kQPitchLagCdf4Lo[10];
extern const uint16_t *WebRtcIsac_kQPitchLagCdfPtrLo[4];
extern const uint16_t* WebRtcIsac_kQPitchLagCdfPtrLo[4];
/* size of first cdf table */
extern const uint16_t WebRtcIsac_kQPitchLagCdfSizeLo[1];
@ -49,7 +52,6 @@ extern const double WebRtcIsac_kQMeanLag4Lo[9];
extern const double WebRtcIsac_kQPitchLagStepsizeLo;
/* tables for use with medium pitch gain */
/* cdfs for quantized pitch lags */
@ -58,7 +60,7 @@ extern const uint16_t WebRtcIsac_kQPitchLagCdf2Mid[36];
extern const uint16_t WebRtcIsac_kQPitchLagCdf3Mid[2];
extern const uint16_t WebRtcIsac_kQPitchLagCdf4Mid[20];
extern const uint16_t *WebRtcIsac_kQPitchLagCdfPtrMid[4];
extern const uint16_t* WebRtcIsac_kQPitchLagCdfPtrMid[4];
/* size of first cdf table */
extern const uint16_t WebRtcIsac_kQPitchLagCdfSizeMid[1];
@ -77,7 +79,6 @@ extern const double WebRtcIsac_kQMeanLag4Mid[19];
extern const double WebRtcIsac_kQPitchLagStepsizeMid;
/* tables for use with large pitch gain */
/* cdfs for quantized pitch lags */
@ -86,7 +87,7 @@ extern const uint16_t WebRtcIsac_kQPitchLagCdf2Hi[68];
extern const uint16_t WebRtcIsac_kQPitchLagCdf3Hi[2];
extern const uint16_t WebRtcIsac_kQPitchLagCdf4Hi[35];
extern const uint16_t *WebRtcIsac_kQPitchLagCdfPtrHi[4];
extern const uint16_t* WebRtcIsac_kQPitchLagCdfPtrHi[4];
/* size of first cdf table */
extern const uint16_t WebRtcIsac_kQPitchLagCdfSizeHi[1];

View File

@ -19,187 +19,181 @@
#define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_SETTINGS_H_
/* sampling frequency (Hz) */
#define FS 16000
#define FS 16000
/* number of samples per frame (either 320 (20ms), 480 (30ms) or 960 (60ms)) */
#define INITIAL_FRAMESAMPLES 960
#define INITIAL_FRAMESAMPLES 960
#define MAXFFTSIZE 2048
#define NFACTOR 11
/* do not modify the following; this will have to be modified if we
* have a 20ms framesize option */
/**********************************************************************/
/* miliseconds */
#define FRAMESIZE 30
#define FRAMESIZE 30
/* number of samples per frame processed in the encoder, 480 */
#define FRAMESAMPLES 480 /* ((FRAMESIZE*FS)/1000) */
#define FRAMESAMPLES_HALF 240
#define FRAMESAMPLES_QUARTER 120
#define FRAMESAMPLES 480 /* ((FRAMESIZE*FS)/1000) */
#define FRAMESAMPLES_HALF 240
#define FRAMESAMPLES_QUARTER 120
/**********************************************************************/
/* max number of samples per frame (= 60 ms frame) */
#define MAX_FRAMESAMPLES 960
#define MAX_SWBFRAMESAMPLES (MAX_FRAMESAMPLES * 2)
#define MAX_FRAMESAMPLES 960
#define MAX_SWBFRAMESAMPLES (MAX_FRAMESAMPLES * 2)
/* number of samples per 10ms frame */
#define FRAMESAMPLES_10ms ((10*FS)/1000)
#define SWBFRAMESAMPLES_10ms (FRAMESAMPLES_10ms * 2)
#define FRAMESAMPLES_10ms ((10 * FS) / 1000)
#define SWBFRAMESAMPLES_10ms (FRAMESAMPLES_10ms * 2)
/* number of samples in 30 ms frame */
#define FRAMESAMPLES_30ms 480
#define FRAMESAMPLES_30ms 480
/* number of subframes */
#define SUBFRAMES 6
#define SUBFRAMES 6
/* length of a subframe */
#define UPDATE 80
#define UPDATE 80
/* length of half a subframe (low/high band) */
#define HALF_SUBFRAMELEN (UPDATE/2)
#define HALF_SUBFRAMELEN (UPDATE / 2)
/* samples of look ahead (in a half-band, so actually
* half the samples of look ahead @ FS) */
#define QLOOKAHEAD 24 /* 3 ms */
#define QLOOKAHEAD 24 /* 3 ms */
/* order of AR model in spectral entropy coder */
#define AR_ORDER 6
#define AR_ORDER 6
/* order of LP model in spectral entropy coder */
#define LP_ORDER 0
#define LP_ORDER 0
/* window length (masking analysis) */
#define WINLEN 256
#define WINLEN 256
/* order of low-band pole filter used to approximate masking curve */
#define ORDERLO 12
#define ORDERLO 12
/* order of hi-band pole filter used to approximate masking curve */
#define ORDERHI 6
#define UB_LPC_ORDER 4
#define UB_LPC_VEC_PER_FRAME 2
#define UB16_LPC_VEC_PER_FRAME 4
#define UB_ACTIVE_SUBFRAMES 2
#define UB_MAX_LPC_ORDER 6
#define UB_INTERPOL_SEGMENTS 1
#define UB16_INTERPOL_SEGMENTS 3
#define LB_TOTAL_DELAY_SAMPLES 48
enum ISACBandwidth {isac8kHz = 8, isac12kHz = 12, isac16kHz = 16};
enum ISACBand {kIsacLowerBand = 0, kIsacUpperBand12 = 1, kIsacUpperBand16 = 2};
enum IsacSamplingRate {kIsacWideband = 16, kIsacSuperWideband = 32};
#define UB_LPC_GAIN_DIM SUBFRAMES
#define FB_STATE_SIZE_WORD32 6
#define ORDERHI 6
#define UB_LPC_ORDER 4
#define UB_LPC_VEC_PER_FRAME 2
#define UB16_LPC_VEC_PER_FRAME 4
#define UB_ACTIVE_SUBFRAMES 2
#define UB_MAX_LPC_ORDER 6
#define UB_INTERPOL_SEGMENTS 1
#define UB16_INTERPOL_SEGMENTS 3
#define LB_TOTAL_DELAY_SAMPLES 48
enum ISACBandwidth { isac8kHz = 8, isac12kHz = 12, isac16kHz = 16 };
enum ISACBand {
kIsacLowerBand = 0,
kIsacUpperBand12 = 1,
kIsacUpperBand16 = 2
};
enum IsacSamplingRate { kIsacWideband = 16, kIsacSuperWideband = 32 };
#define UB_LPC_GAIN_DIM SUBFRAMES
#define FB_STATE_SIZE_WORD32 6
/* order for post_filter_bank */
#define POSTQORDER 3
#define POSTQORDER 3
/* order for pre-filterbank */
#define QORDER 3
#define QORDER 3
/* another order */
#define QORDER_ALL (POSTQORDER+QORDER-1)
#define QORDER_ALL (POSTQORDER + QORDER - 1)
/* for decimator */
#define ALLPASSSECTIONS 2
#define ALLPASSSECTIONS 2
/* array size for byte stream in number of bytes. */
/* The old maximum size still needed for the decoding */
#define STREAM_SIZE_MAX 600
#define STREAM_SIZE_MAX_30 200 /* 200 bytes=53.4 kbps @ 30 ms.framelength */
#define STREAM_SIZE_MAX_60 400 /* 400 bytes=53.4 kbps @ 60 ms.framelength */
#define STREAM_SIZE_MAX 600
#define STREAM_SIZE_MAX_30 200 /* 200 bytes=53.4 kbps @ 30 ms.framelength */
#define STREAM_SIZE_MAX_60 400 /* 400 bytes=53.4 kbps @ 60 ms.framelength */
/* storage size for bit counts */
#define BIT_COUNTER_SIZE 30
#define BIT_COUNTER_SIZE 30
/* maximum order of any AR model or filter */
#define MAX_AR_MODEL_ORDER 12//50
#define MAX_AR_MODEL_ORDER 12 // 50
/* For pitch analysis */
#define PITCH_FRAME_LEN (FRAMESAMPLES_HALF) /* 30 ms */
#define PITCH_MAX_LAG 140 /* 57 Hz */
#define PITCH_MIN_LAG 20 /* 400 Hz */
#define PITCH_MAX_GAIN 0.45
#define PITCH_MAX_GAIN_06 0.27 /* PITCH_MAX_GAIN*0.6 */
#define PITCH_MAX_GAIN_Q12 1843
#define PITCH_LAG_SPAN2 (PITCH_MAX_LAG/2-PITCH_MIN_LAG/2+5)
#define PITCH_CORR_LEN2 60 /* 15 ms */
#define PITCH_CORR_STEP2 (PITCH_FRAME_LEN/4)
#define PITCH_BW 11 /* half the band width of correlation surface */
#define PITCH_SUBFRAMES 4
#define PITCH_GRAN_PER_SUBFRAME 5
#define PITCH_SUBFRAME_LEN (PITCH_FRAME_LEN/PITCH_SUBFRAMES)
#define PITCH_UPDATE (PITCH_SUBFRAME_LEN/PITCH_GRAN_PER_SUBFRAME)
#define PITCH_FRAME_LEN (FRAMESAMPLES_HALF) /* 30 ms */
#define PITCH_MAX_LAG 140 /* 57 Hz */
#define PITCH_MIN_LAG 20 /* 400 Hz */
#define PITCH_MAX_GAIN 0.45
#define PITCH_MAX_GAIN_06 0.27 /* PITCH_MAX_GAIN*0.6 */
#define PITCH_MAX_GAIN_Q12 1843
#define PITCH_LAG_SPAN2 (PITCH_MAX_LAG / 2 - PITCH_MIN_LAG / 2 + 5)
#define PITCH_CORR_LEN2 60 /* 15 ms */
#define PITCH_CORR_STEP2 (PITCH_FRAME_LEN / 4)
#define PITCH_BW 11 /* half the band width of correlation surface */
#define PITCH_SUBFRAMES 4
#define PITCH_GRAN_PER_SUBFRAME 5
#define PITCH_SUBFRAME_LEN (PITCH_FRAME_LEN / PITCH_SUBFRAMES)
#define PITCH_UPDATE (PITCH_SUBFRAME_LEN / PITCH_GRAN_PER_SUBFRAME)
/* maximum number of peaks to be examined in correlation surface */
#define PITCH_MAX_NUM_PEAKS 10
#define PITCH_PEAK_DECAY 0.85
#define PITCH_MAX_NUM_PEAKS 10
#define PITCH_PEAK_DECAY 0.85
/* For weighting filter */
#define PITCH_WLPCORDER 6
#define PITCH_WLPCWINLEN PITCH_FRAME_LEN
#define PITCH_WLPCASYM 0.3 /* asymmetry parameter */
#define PITCH_WLPCBUFLEN PITCH_WLPCWINLEN
#define PITCH_WLPCORDER 6
#define PITCH_WLPCWINLEN PITCH_FRAME_LEN
#define PITCH_WLPCASYM 0.3 /* asymmetry parameter */
#define PITCH_WLPCBUFLEN PITCH_WLPCWINLEN
/* For pitch filter */
/* Extra 50 for fraction and LP filters */
#define PITCH_BUFFSIZE (PITCH_MAX_LAG + 50)
#define PITCH_INTBUFFSIZE (PITCH_FRAME_LEN+PITCH_BUFFSIZE)
#define PITCH_BUFFSIZE (PITCH_MAX_LAG + 50)
#define PITCH_INTBUFFSIZE (PITCH_FRAME_LEN + PITCH_BUFFSIZE)
/* Max rel. step for interpolation */
#define PITCH_UPSTEP 1.5
#define PITCH_UPSTEP 1.5
/* Max rel. step for interpolation */
#define PITCH_DOWNSTEP 0.67
#define PITCH_FRACS 8
#define PITCH_FRACORDER 9
#define PITCH_DAMPORDER 5
#define PITCH_FILTDELAY 1.5f
#define PITCH_DOWNSTEP 0.67
#define PITCH_FRACS 8
#define PITCH_FRACORDER 9
#define PITCH_DAMPORDER 5
#define PITCH_FILTDELAY 1.5f
/* stepsize for quantization of the pitch Gain */
#define PITCH_GAIN_STEPSIZE 0.125
#define PITCH_GAIN_STEPSIZE 0.125
/* Order of high pass filter */
#define HPORDER 2
#define HPORDER 2
/* some mathematical constants */
/* log2(exp) */
#define LOG2EXP 1.44269504088896
#define PI 3.14159265358979
#define LOG2EXP 1.44269504088896
#define PI 3.14159265358979
/* Maximum number of iterations allowed to limit payload size */
#define MAX_PAYLOAD_LIMIT_ITERATION 5
#define MAX_PAYLOAD_LIMIT_ITERATION 5
/* Redundant Coding */
#define RCU_BOTTLENECK_BPS 16000
#define RCU_TRANSCODING_SCALE 0.40f
#define RCU_TRANSCODING_SCALE_INVERSE 2.5f
#define RCU_BOTTLENECK_BPS 16000
#define RCU_TRANSCODING_SCALE 0.40f
#define RCU_TRANSCODING_SCALE_INVERSE 2.5f
#define RCU_TRANSCODING_SCALE_UB 0.50f
#define RCU_TRANSCODING_SCALE_UB_INVERSE 2.0f
#define RCU_TRANSCODING_SCALE_UB 0.50f
#define RCU_TRANSCODING_SCALE_UB_INVERSE 2.0f
/* Define Error codes */
/* 6000 General */
#define ISAC_MEMORY_ALLOCATION_FAILED 6010
#define ISAC_MODE_MISMATCH 6020
#define ISAC_DISALLOWED_BOTTLENECK 6030
#define ISAC_DISALLOWED_FRAME_LENGTH 6040
#define ISAC_UNSUPPORTED_SAMPLING_FREQUENCY 6050
#define ISAC_MEMORY_ALLOCATION_FAILED 6010
#define ISAC_MODE_MISMATCH 6020
#define ISAC_DISALLOWED_BOTTLENECK 6030
#define ISAC_DISALLOWED_FRAME_LENGTH 6040
#define ISAC_UNSUPPORTED_SAMPLING_FREQUENCY 6050
/* 6200 Bandwidth estimator */
#define ISAC_RANGE_ERROR_BW_ESTIMATOR 6240
#define ISAC_RANGE_ERROR_BW_ESTIMATOR 6240
/* 6400 Encoder */
#define ISAC_ENCODER_NOT_INITIATED 6410
#define ISAC_DISALLOWED_CODING_MODE 6420
#define ISAC_DISALLOWED_FRAME_MODE_ENCODER 6430
#define ISAC_DISALLOWED_BITSTREAM_LENGTH 6440
#define ISAC_PAYLOAD_LARGER_THAN_LIMIT 6450
#define ISAC_DISALLOWED_ENCODER_BANDWIDTH 6460
#define ISAC_ENCODER_NOT_INITIATED 6410
#define ISAC_DISALLOWED_CODING_MODE 6420
#define ISAC_DISALLOWED_FRAME_MODE_ENCODER 6430
#define ISAC_DISALLOWED_BITSTREAM_LENGTH 6440
#define ISAC_PAYLOAD_LARGER_THAN_LIMIT 6450
#define ISAC_DISALLOWED_ENCODER_BANDWIDTH 6460
/* 6600 Decoder */
#define ISAC_DECODER_NOT_INITIATED 6610
#define ISAC_EMPTY_PACKET 6620
#define ISAC_DISALLOWED_FRAME_MODE_DECODER 6630
#define ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH 6640
#define ISAC_RANGE_ERROR_DECODE_BANDWIDTH 6650
#define ISAC_RANGE_ERROR_DECODE_PITCH_GAIN 6660
#define ISAC_RANGE_ERROR_DECODE_PITCH_LAG 6670
#define ISAC_RANGE_ERROR_DECODE_LPC 6680
#define ISAC_RANGE_ERROR_DECODE_SPECTRUM 6690
#define ISAC_LENGTH_MISMATCH 6730
#define ISAC_RANGE_ERROR_DECODE_BANDWITH 6740
#define ISAC_DISALLOWED_BANDWIDTH_MODE_DECODER 6750
#define ISAC_DISALLOWED_LPC_MODEL 6760
#define ISAC_DECODER_NOT_INITIATED 6610
#define ISAC_EMPTY_PACKET 6620
#define ISAC_DISALLOWED_FRAME_MODE_DECODER 6630
#define ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH 6640
#define ISAC_RANGE_ERROR_DECODE_BANDWIDTH 6650
#define ISAC_RANGE_ERROR_DECODE_PITCH_GAIN 6660
#define ISAC_RANGE_ERROR_DECODE_PITCH_LAG 6670
#define ISAC_RANGE_ERROR_DECODE_LPC 6680
#define ISAC_RANGE_ERROR_DECODE_SPECTRUM 6690
#define ISAC_LENGTH_MISMATCH 6730
#define ISAC_RANGE_ERROR_DECODE_BANDWITH 6740
#define ISAC_DISALLOWED_BANDWIDTH_MODE_DECODER 6750
#define ISAC_DISALLOWED_LPC_MODEL 6760
/* 6800 Call setup formats */
#define ISAC_INCOMPATIBLE_FORMATS 6810
#define ISAC_INCOMPATIBLE_FORMATS 6810
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_SETTINGS_H_ */

View File

@ -11,7 +11,7 @@
/*
* spectrum_ar_model_tables.h
*
* This file contains definitions of tables with AR coefficients,
* This file contains definitions of tables with AR coefficients,
* Gain coefficients and cosine tables.
*
*/
@ -45,15 +45,15 @@ extern const uint16_t WebRtcIsac_kQArRc6Cdf[NUM_AR_RC_QUANT_BAUNDARY];
/* quantization boundary levels for reflection coefficients */
extern const int16_t WebRtcIsac_kQArBoundaryLevels[NUM_AR_RC_QUANT_BAUNDARY];
/* initial indices for AR reflection coefficient quantizer and cdf table search */
/* initial indices for AR reflection coefficient quantizer and cdf table search
*/
extern const uint16_t WebRtcIsac_kQArRcInitIndex[AR_ORDER];
/* pointers to AR cdf tables */
extern const uint16_t *WebRtcIsac_kQArRcCdfPtr[AR_ORDER];
extern const uint16_t* WebRtcIsac_kQArRcCdfPtr[AR_ORDER];
/* pointers to AR representation levels tables */
extern const int16_t *WebRtcIsac_kQArRcLevelsPtr[AR_ORDER];
extern const int16_t* WebRtcIsac_kQArRcLevelsPtr[AR_ORDER];
/******************** GAIN Coefficient Tables ***********************/
/* cdf for Gain coefficient */
@ -66,7 +66,7 @@ extern const int32_t WebRtcIsac_kQGain2Levels[18];
extern const int32_t WebRtcIsac_kQGain2BoundaryLevels[19];
/* pointer to Gain cdf table */
extern const uint16_t *WebRtcIsac_kQGainCdf_ptr[1];
extern const uint16_t* WebRtcIsac_kQGainCdf_ptr[1];
/* Gain initial index for gain quantizer and cdf table search */
extern const uint16_t WebRtcIsac_kQGainInitIndex[1];
@ -75,4 +75,5 @@ extern const uint16_t WebRtcIsac_kQGainInitIndex[1];
/* Cosine table */
extern const int16_t WebRtcIsac_kCos[6][60];
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_SPECTRUM_AR_MODEL_TABLES_H_ */
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_SPECTRUM_AR_MODEL_TABLES_H_ \
*/

View File

@ -23,178 +23,166 @@
#include "typedefs.h" // NOLINT(build/include)
typedef struct Bitstreamstruct {
uint8_t stream[STREAM_SIZE_MAX];
uint32_t W_upper;
uint32_t streamval;
uint32_t stream_index;
uint8_t stream[STREAM_SIZE_MAX];
uint32_t W_upper;
uint32_t streamval;
uint32_t stream_index;
} Bitstr;
typedef struct {
double DataBufferLo[WINLEN];
double DataBufferHi[WINLEN];
double DataBufferLo[WINLEN];
double DataBufferHi[WINLEN];
double CorrBufLo[ORDERLO + 1];
double CorrBufHi[ORDERHI + 1];
double CorrBufLo[ORDERLO+1];
double CorrBufHi[ORDERHI+1];
float PreStateLoF[ORDERLO + 1];
float PreStateLoG[ORDERLO + 1];
float PreStateHiF[ORDERHI + 1];
float PreStateHiG[ORDERHI + 1];
float PostStateLoF[ORDERLO + 1];
float PostStateLoG[ORDERLO + 1];
float PostStateHiF[ORDERHI + 1];
float PostStateHiG[ORDERHI + 1];
float PreStateLoF[ORDERLO+1];
float PreStateLoG[ORDERLO+1];
float PreStateHiF[ORDERHI+1];
float PreStateHiG[ORDERHI+1];
float PostStateLoF[ORDERLO+1];
float PostStateLoG[ORDERLO+1];
float PostStateHiF[ORDERHI+1];
float PostStateHiG[ORDERHI+1];
double OldEnergy;
double OldEnergy;
} MaskFiltstr;
typedef struct {
// state vectors for each of the two analysis filters
double INSTAT1[2 * (QORDER - 1)];
double INSTAT2[2 * (QORDER - 1)];
double INSTATLA1[2 * (QORDER - 1)];
double INSTATLA2[2 * (QORDER - 1)];
double INLABUF1[QLOOKAHEAD];
double INLABUF2[QLOOKAHEAD];
//state vectors for each of the two analysis filters
double INSTAT1[2*(QORDER-1)];
double INSTAT2[2*(QORDER-1)];
double INSTATLA1[2*(QORDER-1)];
double INSTATLA2[2*(QORDER-1)];
double INLABUF1[QLOOKAHEAD];
double INLABUF2[QLOOKAHEAD];
float INSTAT1_float[2*(QORDER-1)];
float INSTAT2_float[2*(QORDER-1)];
float INSTATLA1_float[2*(QORDER-1)];
float INSTATLA2_float[2*(QORDER-1)];
float INLABUF1_float[QLOOKAHEAD];
float INLABUF2_float[QLOOKAHEAD];
float INSTAT1_float[2 * (QORDER - 1)];
float INSTAT2_float[2 * (QORDER - 1)];
float INSTATLA1_float[2 * (QORDER - 1)];
float INSTATLA2_float[2 * (QORDER - 1)];
float INLABUF1_float[QLOOKAHEAD];
float INLABUF2_float[QLOOKAHEAD];
/* High pass filter */
double HPstates[HPORDER];
float HPstates_float[HPORDER];
double HPstates[HPORDER];
float HPstates_float[HPORDER];
} PreFiltBankstr;
typedef struct {
//state vectors for each of the two analysis filters
double STATE_0_LOWER[2*POSTQORDER];
double STATE_0_UPPER[2*POSTQORDER];
// state vectors for each of the two analysis filters
double STATE_0_LOWER[2 * POSTQORDER];
double STATE_0_UPPER[2 * POSTQORDER];
/* High pass filter */
double HPstates1[HPORDER];
double HPstates2[HPORDER];
double HPstates1[HPORDER];
double HPstates2[HPORDER];
float STATE_0_LOWER_float[2*POSTQORDER];
float STATE_0_UPPER_float[2*POSTQORDER];
float STATE_0_LOWER_float[2 * POSTQORDER];
float STATE_0_UPPER_float[2 * POSTQORDER];
float HPstates1_float[HPORDER];
float HPstates2_float[HPORDER];
float HPstates1_float[HPORDER];
float HPstates2_float[HPORDER];
} PostFiltBankstr;
typedef struct {
// data buffer for pitch filter
double ubuf[PITCH_BUFFSIZE];
//data buffer for pitch filter
double ubuf[PITCH_BUFFSIZE];
// low pass state vector
double ystate[PITCH_DAMPORDER];
//low pass state vector
double ystate[PITCH_DAMPORDER];
//old lag and gain
double oldlagp[1];
double oldgainp[1];
// old lag and gain
double oldlagp[1];
double oldgainp[1];
} PitchFiltstr;
typedef struct {
// data buffer
double buffer[PITCH_WLPCBUFLEN];
//data buffer
double buffer[PITCH_WLPCBUFLEN];
// state vectors
double istate[PITCH_WLPCORDER];
double weostate[PITCH_WLPCORDER];
double whostate[PITCH_WLPCORDER];
//state vectors
double istate[PITCH_WLPCORDER];
double weostate[PITCH_WLPCORDER];
double whostate[PITCH_WLPCORDER];
//LPC window -> should be a global array because constant
double window[PITCH_WLPCWINLEN];
// LPC window -> should be a global array because constant
double window[PITCH_WLPCWINLEN];
} WeightFiltstr;
typedef struct {
// for inital estimator
double dec_buffer[PITCH_CORR_LEN2 + PITCH_CORR_STEP2 + PITCH_MAX_LAG / 2 -
PITCH_FRAME_LEN / 2 + 2];
double decimator_state[2 * ALLPASSSECTIONS + 1];
double hp_state[2];
//for inital estimator
double dec_buffer[PITCH_CORR_LEN2 + PITCH_CORR_STEP2 +
PITCH_MAX_LAG/2 - PITCH_FRAME_LEN/2+2];
double decimator_state[2*ALLPASSSECTIONS+1];
double hp_state[2];
double whitened_buf[QLOOKAHEAD];
double whitened_buf[QLOOKAHEAD];
double inbuf[QLOOKAHEAD];
double inbuf[QLOOKAHEAD];
PitchFiltstr PFstr_wght;
PitchFiltstr PFstr;
PitchFiltstr PFstr_wght;
PitchFiltstr PFstr;
WeightFiltstr Wghtstr;
} PitchAnalysisStruct;
/* Have instance of struct together with other iSAC structs */
typedef struct {
/* Previous frame length (in ms) */
int32_t prev_frame_length;
int32_t prev_frame_length;
/* Previous RTP timestamp from received
packet (in samples relative beginning) */
int32_t prev_rec_rtp_number;
int32_t prev_rec_rtp_number;
/* Send timestamp for previous packet (in ms using timeGetTime()) */
uint32_t prev_rec_send_ts;
uint32_t prev_rec_send_ts;
/* Arrival time for previous packet (in ms using timeGetTime()) */
uint32_t prev_rec_arr_ts;
uint32_t prev_rec_arr_ts;
/* rate of previous packet, derived from RTP timestamps (in bits/s) */
float prev_rec_rtp_rate;
float prev_rec_rtp_rate;
/* Time sinse the last update of the BN estimate (in ms) */
uint32_t last_update_ts;
uint32_t last_update_ts;
/* Time sinse the last reduction (in ms) */
uint32_t last_reduction_ts;
uint32_t last_reduction_ts;
/* How many times the estimate was update in the beginning */
int32_t count_tot_updates_rec;
int32_t count_tot_updates_rec;
/* The estimated bottle neck rate from there to here (in bits/s) */
int32_t rec_bw;
float rec_bw_inv;
float rec_bw_avg;
float rec_bw_avg_Q;
int32_t rec_bw;
float rec_bw_inv;
float rec_bw_avg;
float rec_bw_avg_Q;
/* The estimated mean absolute jitter value,
as seen on this side (in ms) */
float rec_jitter;
float rec_jitter_short_term;
float rec_jitter_short_term_abs;
float rec_max_delay;
float rec_max_delay_avg_Q;
float rec_jitter;
float rec_jitter_short_term;
float rec_jitter_short_term_abs;
float rec_max_delay;
float rec_max_delay_avg_Q;
/* (assumed) bitrate for headers (bps) */
float rec_header_rate;
float rec_header_rate;
/* The estimated bottle neck rate from here to there (in bits/s) */
float send_bw_avg;
float send_bw_avg;
/* The estimated mean absolute jitter value, as seen on
the other siee (in ms) */
float send_max_delay_avg;
float send_max_delay_avg;
// number of packets received since last update
int num_pkts_rec;
@ -217,35 +205,31 @@ typedef struct {
int change_to_WB;
uint32_t senderTimestamp;
uint32_t receiverTimestamp;
//enum IsacSamplingRate incomingStreamSampFreq;
uint16_t numConsecLatePkts;
float consecLatency;
int16_t inWaitLatePkts;
uint32_t senderTimestamp;
uint32_t receiverTimestamp;
// enum IsacSamplingRate incomingStreamSampFreq;
uint16_t numConsecLatePkts;
float consecLatency;
int16_t inWaitLatePkts;
IsacBandwidthInfo external_bw_info;
} BwEstimatorstr;
typedef struct {
/* boolean, flags if previous packet exceeded B.N. */
int PrevExceed;
int PrevExceed;
/* ms */
int ExceedAgo;
int ExceedAgo;
/* packets left to send in current burst */
int BurstCounter;
int BurstCounter;
/* packets */
int InitCounter;
int InitCounter;
/* ms remaining in buffer when next packet will be sent */
double StillBuffered;
} RateModel;
typedef struct {
unsigned int SpaceAlloced;
unsigned int MaxPermAlloced;
double Tmp0[MAXFFTSIZE];
@ -253,36 +237,34 @@ typedef struct {
double Tmp2[MAXFFTSIZE];
double Tmp3[MAXFFTSIZE];
int Perm[MAXFFTSIZE];
int factor [NFACTOR];
int factor[NFACTOR];
} FFTstr;
/* The following strutc is used to store data from encoding, to make it
fast and easy to construct a new bitstream with a different Bandwidth
estimate. All values (except framelength and minBytes) is double size to
handle 60 ms of data.
*/
typedef struct {
/* Used to keep track of if it is first or second part of 60 msec packet */
int startIdx;
int startIdx;
/* Frame length in samples */
int16_t framelength;
/* Pitch Gain */
int pitchGain_index[2];
int pitchGain_index[2];
/* Pitch Lag */
double meanGain[2];
int pitchIndex[PITCH_SUBFRAMES*2];
double meanGain[2];
int pitchIndex[PITCH_SUBFRAMES * 2];
/* LPC */
int LPCindex_s[108*2]; /* KLT_ORDER_SHAPE = 108 */
int LPCindex_g[12*2]; /* KLT_ORDER_GAIN = 12 */
double LPCcoeffs_lo[(ORDERLO+1)*SUBFRAMES*2];
double LPCcoeffs_hi[(ORDERHI+1)*SUBFRAMES*2];
int LPCindex_s[108 * 2]; /* KLT_ORDER_SHAPE = 108 */
int LPCindex_g[12 * 2]; /* KLT_ORDER_GAIN = 12 */
double LPCcoeffs_lo[(ORDERLO + 1) * SUBFRAMES * 2];
double LPCcoeffs_hi[(ORDERHI + 1) * SUBFRAMES * 2];
/* Encode Spec */
int16_t fre[FRAMESAMPLES];
@ -290,59 +272,54 @@ typedef struct {
int16_t AvgPitchGain[2];
/* Used in adaptive mode only */
int minBytes;
int minBytes;
} IsacSaveEncoderData;
typedef struct {
int indexLPCShape[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME];
double lpcGain[SUBFRAMES << 1];
int lpcGainIndex[SUBFRAMES << 1];
int indexLPCShape[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME];
double lpcGain[SUBFRAMES<<1];
int lpcGainIndex[SUBFRAMES<<1];
Bitstr bitStreamObj;
Bitstr bitStreamObj;
int16_t realFFT[FRAMESAMPLES_HALF];
int16_t imagFFT[FRAMESAMPLES_HALF];
} ISACUBSaveEncDataStruct;
typedef struct {
Bitstr bitstr_obj;
MaskFiltstr maskfiltstr_obj;
PreFiltBankstr prefiltbankstr_obj;
PitchFiltstr pitchfiltstr_obj;
Bitstr bitstr_obj;
MaskFiltstr maskfiltstr_obj;
PreFiltBankstr prefiltbankstr_obj;
PitchFiltstr pitchfiltstr_obj;
PitchAnalysisStruct pitchanalysisstr_obj;
FFTstr fftstr_obj;
FFTstr fftstr_obj;
IsacSaveEncoderData SaveEnc_obj;
int buffer_index;
int16_t current_framesamples;
int buffer_index;
int16_t current_framesamples;
float data_buffer_float[FRAMESAMPLES_30ms];
float data_buffer_float[FRAMESAMPLES_30ms];
int frame_nb;
double bottleneck;
int16_t new_framelength;
double s2nr;
int frame_nb;
double bottleneck;
int16_t new_framelength;
double s2nr;
/* Maximum allowed number of bits for a 30 msec packet */
int16_t payloadLimitBytes30;
int16_t payloadLimitBytes30;
/* Maximum allowed number of bits for a 30 msec packet */
int16_t payloadLimitBytes60;
int16_t payloadLimitBytes60;
/* Maximum allowed number of bits for both 30 and 60 msec packet */
int16_t maxPayloadBytes;
int16_t maxPayloadBytes;
/* Maximum allowed rate in bytes per 30 msec packet */
int16_t maxRateInBytes;
int16_t maxRateInBytes;
/*---
If set to 1 iSAC will not addapt the frame-size, if used in
channel-adaptive mode. The initial value will be used for all rates.
---*/
int16_t enforceFrameSize;
int16_t enforceFrameSize;
/*-----
This records the BWE index the encoder injected into the bit-stream.
@ -351,64 +328,53 @@ typedef struct {
a recursive procedure (WebRtcIsac_GetDownlinkBwJitIndexImpl) and has to be
called only once per each encode.
-----*/
int16_t lastBWIdx;
int16_t lastBWIdx;
} ISACLBEncStruct;
typedef struct {
Bitstr bitstr_obj;
MaskFiltstr maskfiltstr_obj;
PreFiltBankstr prefiltbankstr_obj;
FFTstr fftstr_obj;
Bitstr bitstr_obj;
MaskFiltstr maskfiltstr_obj;
PreFiltBankstr prefiltbankstr_obj;
FFTstr fftstr_obj;
ISACUBSaveEncDataStruct SaveEnc_obj;
int buffer_index;
float data_buffer_float[MAX_FRAMESAMPLES +
LB_TOTAL_DELAY_SAMPLES];
double bottleneck;
int buffer_index;
float data_buffer_float[MAX_FRAMESAMPLES + LB_TOTAL_DELAY_SAMPLES];
double bottleneck;
/* Maximum allowed number of bits for a 30 msec packet */
//int16_t payloadLimitBytes30;
// int16_t payloadLimitBytes30;
/* Maximum allowed number of bits for both 30 and 60 msec packet */
//int16_t maxPayloadBytes;
int16_t maxPayloadSizeBytes;
// int16_t maxPayloadBytes;
int16_t maxPayloadSizeBytes;
double lastLPCVec[UB_LPC_ORDER];
int16_t numBytesUsed;
int16_t lastJitterInfo;
double lastLPCVec[UB_LPC_ORDER];
int16_t numBytesUsed;
int16_t lastJitterInfo;
} ISACUBEncStruct;
typedef struct {
Bitstr bitstr_obj;
MaskFiltstr maskfiltstr_obj;
Bitstr bitstr_obj;
MaskFiltstr maskfiltstr_obj;
PostFiltBankstr postfiltbankstr_obj;
PitchFiltstr pitchfiltstr_obj;
FFTstr fftstr_obj;
PitchFiltstr pitchfiltstr_obj;
FFTstr fftstr_obj;
} ISACLBDecStruct;
typedef struct {
Bitstr bitstr_obj;
MaskFiltstr maskfiltstr_obj;
Bitstr bitstr_obj;
MaskFiltstr maskfiltstr_obj;
PostFiltBankstr postfiltbankstr_obj;
FFTstr fftstr_obj;
FFTstr fftstr_obj;
} ISACUBDecStruct;
typedef struct {
ISACLBEncStruct ISACencLB_obj;
ISACLBDecStruct ISACdecLB_obj;
} ISACLBStruct;
typedef struct {
ISACUBEncStruct ISACencUB_obj;
ISACUBDecStruct ISACdecUB_obj;
} ISACUBStruct;
@ -420,14 +386,14 @@ typedef struct {
*/
typedef struct {
/* 6 lower-band & 6 upper-band */
double loFiltGain[SUBFRAMES];
double hiFiltGain[SUBFRAMES];
double loFiltGain[SUBFRAMES];
double hiFiltGain[SUBFRAMES];
/* Upper boundary of interval W */
uint32_t W_upper;
uint32_t streamval;
/* Index to the current position in bytestream */
uint32_t stream_index;
uint8_t stream[3];
uint8_t stream[3];
} transcode_obj;
typedef struct {
@ -443,46 +409,46 @@ typedef struct {
typedef struct {
// lower-band codec instance
ISACLBStruct instLB;
ISACLBStruct instLB;
// upper-band codec instance
ISACUBStruct instUB;
ISACUBStruct instUB;
// Bandwidth Estimator and model for the rate.
BwEstimatorstr bwestimator_obj;
RateModel rate_data_obj;
double MaxDelay;
BwEstimatorstr bwestimator_obj;
RateModel rate_data_obj;
double MaxDelay;
/* 0 = adaptive; 1 = instantaneous */
int16_t codingMode;
int16_t codingMode;
// overall bottleneck of the codec
int32_t bottleneck;
int32_t bottleneck;
// QMF Filter state
int32_t analysisFBState1[FB_STATE_SIZE_WORD32];
int32_t analysisFBState2[FB_STATE_SIZE_WORD32];
int32_t synthesisFBState1[FB_STATE_SIZE_WORD32];
int32_t synthesisFBState2[FB_STATE_SIZE_WORD32];
int32_t analysisFBState1[FB_STATE_SIZE_WORD32];
int32_t analysisFBState2[FB_STATE_SIZE_WORD32];
int32_t synthesisFBState1[FB_STATE_SIZE_WORD32];
int32_t synthesisFBState2[FB_STATE_SIZE_WORD32];
// Error Code
int16_t errorCode;
int16_t errorCode;
// bandwidth of the encoded audio 8, 12 or 16 kHz
enum ISACBandwidth bandwidthKHz;
enum ISACBandwidth bandwidthKHz;
// Sampling rate of audio, encoder and decode, 8 or 16 kHz
enum IsacSamplingRate encoderSamplingRateKHz;
enum IsacSamplingRate decoderSamplingRateKHz;
// Flag to keep track of initializations, lower & upper-band
// encoder and decoder.
int16_t initFlag;
int16_t initFlag;
// Flag to to indicate signal bandwidth switch
int16_t resetFlag_8kHz;
int16_t resetFlag_8kHz;
// Maximum allowed rate, measured in Bytes per 30 ms.
int16_t maxRateBytesPer30Ms;
int16_t maxRateBytesPer30Ms;
// Maximum allowed payload-size, measured in Bytes.
int16_t maxPayloadSizeBytes;
int16_t maxPayloadSizeBytes;
/* The expected sampling rate of the input signal. Valid values are 16000
* and 32000. This is not the operation sampling rate of the codec. */
uint16_t in_sample_rate_hz;

View File

@ -11,11 +11,11 @@
// ReleaseTest-API.cpp : Defines the entry point for the console application.
//
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <ctype.h>
#include <iostream>
/* include API */
@ -24,10 +24,13 @@
#include "rtc_base/format_macros.h"
/* Defines */
#define SEED_FILE "randseed.txt" /* Used when running decoder on garbage data */
#define MAX_FRAMESAMPLES 960 /* max number of samples per frame
(= 60 ms frame & 16 kHz) or
(= 30 ms frame & 32 kHz) */
#define SEED_FILE \
"randseed.txt" /* Used when running decoder on garbage data \
*/
#define MAX_FRAMESAMPLES \
960 /* max number of samples per frame \
(= 60 ms frame & 16 kHz) or \
(= 30 ms frame & 32 kHz) */
#define FRAMESAMPLES_10ms 160 /* number of samples per 10ms frame */
#define SWBFRAMESAMPLES_10ms 320
//#define FS 16000 /* sampling frequency (Hz) */
@ -42,7 +45,7 @@ using namespace std;
int main(int argc, char* argv[]) {
char inname[100], outname[100], bottleneck_file[100], vadfile[100];
FILE* inp, *outp, * f_bn = NULL, * vadp = NULL, *bandwidthp;
FILE *inp, *outp, *f_bn = NULL, *vadp = NULL, *bandwidthp;
int framecnt, endfile;
size_t i;
@ -230,8 +233,10 @@ int main(int argc, char* argv[]) {
rateBPS = atoi(argv[i + 1]);
setControlBWE = 1;
if ((rateBPS < 10000) || (rateBPS > 32000)) {
printf("\n%d is not a initial rate. Valid values are in the range "
"10000 to 32000.\n", rateBPS);
printf(
"\n%d is not a initial rate. Valid values are in the range "
"10000 to 32000.\n",
rateBPS);
exit(0);
}
printf("New initial rate: %d\n", rateBPS);
@ -242,8 +247,10 @@ int main(int argc, char* argv[]) {
if (!strcmp("-FL", argv[i])) {
framesize = atoi(argv[i + 1]);
if ((framesize != 30) && (framesize != 60)) {
printf("\n%d is not a valid frame length. Valid length are 30 and 60 "
"msec.\n", framesize);
printf(
"\n%d is not a valid frame length. Valid length are 30 and 60 "
"msec.\n",
framesize);
exit(0);
}
setControlBWE = 1;
@ -277,8 +284,10 @@ int main(int argc, char* argv[]) {
testNum = atoi(argv[i + 1]);
printf("Fault test: %d\n", testNum);
if (testNum < 1 || testNum > 10) {
printf("\n%d is not a valid Fault Scenario number. Valid Fault "
"Scenarios are numbered 1-10.\n", testNum);
printf(
"\n%d is not a valid Fault Scenario number. Valid Fault "
"Scenarios are numbered 1-10.\n",
testNum);
exit(0);
}
i++;
@ -336,8 +345,10 @@ int main(int argc, char* argv[]) {
sscanf(argv[i], "%s", bottleneck_file);
f_bn = fopen(bottleneck_file, "rb");
if (f_bn == NULL) {
printf("Error No value provided for BottleNeck and cannot read file "
"%s.\n", bottleneck_file);
printf(
"Error No value provided for BottleNeck and cannot read file "
"%s.\n",
bottleneck_file);
exit(0);
} else {
printf("reading bottleneck rates from file %s\n\n", bottleneck_file);
@ -637,8 +648,8 @@ int main(int argc, char* argv[]) {
}
if (fwrite(streamDataTransCoding, sizeof(uint8_t),
streamLenTransCoding, transcodingBitstream) !=
streamLenTransCoding) {
streamLenTransCoding,
transcodingBitstream) != streamLenTransCoding) {
return -1;
}
@ -718,8 +729,7 @@ int main(int argc, char* argv[]) {
fprintf(stderr, "Error in RED trans-coding\n");
exit(0);
}
streamLenTransCoding =
static_cast<size_t>(streamLenTransCoding_int);
streamLenTransCoding = static_cast<size_t>(streamLenTransCoding_int);
}
}

View File

@ -18,16 +18,14 @@
#include "modules/audio_coding/codecs/isac/main/include/isac.h"
#include "modules/audio_coding/codecs/isac/main/util/utility.h"
#define MAX_FILE_NAME 500
#define MAX_FILE_NAME 500
#define MAX_NUM_CLIENTS 2
#define NUM_CLIENTS 2
using namespace std;
int main(int argc, char* argv[])
{
int main(int argc, char* argv[]) {
char fileNameWB[MAX_FILE_NAME];
char fileNameSWB[MAX_FILE_NAME];
@ -68,21 +66,18 @@ int main(int argc, char* argv[])
printf(" iSAC-swb version %s\n", versionNumber);
printf("____________________________________________\n");
fileNameWB[0] = '\0';
fileNameWB[0] = '\0';
fileNameSWB[0] = '\0';
char myFlag[20];
strcpy(myFlag, "-wb");
// READ THE WIDEBAND AND SUPER-WIDEBAND FILE NAMES
if(readParamString(argc, argv, myFlag, fileNameWB, MAX_FILE_NAME) <= 0)
{
if (readParamString(argc, argv, myFlag, fileNameWB, MAX_FILE_NAME) <= 0) {
printf("No wideband file is specified");
}
strcpy(myFlag, "-swb");
if(readParamString(argc, argv, myFlag, fileNameSWB, MAX_FILE_NAME) <= 0)
{
if (readParamString(argc, argv, myFlag, fileNameSWB, MAX_FILE_NAME) <= 0) {
printf("No super-wideband file is specified");
}
@ -97,16 +92,15 @@ int main(int argc, char* argv[])
strcpy(myFlag, "-I");
short codingMode = readSwitch(argc, argv, myFlag);
for(clientCntr = 0; clientCntr < NUM_CLIENTS; clientCntr++)
{
for (clientCntr = 0; clientCntr < NUM_CLIENTS; clientCntr++) {
codecInstance[clientCntr] = NULL;
printf("\n");
printf("Client %d\n", clientCntr + 1);
printf("---------\n");
printf("Starting %s",
(encoderSampRate[clientCntr] == 16000)
? "wideband":"super-wideband");
printf("Starting %s", (encoderSampRate[clientCntr] == 16000)
? "wideband"
: "super-wideband");
// Open output File Name
OPEN_FILE_WB(outFile[clientCntr], outFileName[clientCntr]);
@ -114,30 +108,27 @@ int main(int argc, char* argv[])
samplesIn10ms[clientCntr] = encoderSampRate[clientCntr] * 10;
if(codingMode == 1)
{
bottleneck[clientCntr] = (clientCntr)? bnSWB:bnWB;
}
else
{
bottleneck[clientCntr] = (clientCntr)? minBn:maxBn;
if (codingMode == 1) {
bottleneck[clientCntr] = (clientCntr) ? bnSWB : bnWB;
} else {
bottleneck[clientCntr] = (clientCntr) ? minBn : maxBn;
}
printf("Bottleneck....................... %0.3f kbits/sec \n",
bottleneck[clientCntr] / 1000.0);
// coding-mode
printf("Encoding Mode.................... %s\n",
(codingMode == 1)? "Channel-Independent (Instantaneous)":"Adaptive");
printf(
"Encoding Mode.................... %s\n",
(codingMode == 1) ? "Channel-Independent (Instantaneous)" : "Adaptive");
lenEncodedInBytes[clientCntr] = 0;
lenAudioIn10ms[clientCntr] = 0;
lenEncodedInBytesTmp[clientCntr] = 0;
lenAudioIn10msTmp[clientCntr] = 0;
packetData[clientCntr] = (BottleNeckModel*)new(BottleNeckModel);
if(packetData[clientCntr] == NULL)
{
packetData[clientCntr] = (BottleNeckModel*)new (BottleNeckModel);
if (packetData[clientCntr] == NULL) {
printf("Could not allocate memory for packetData \n");
return -1;
}
@ -145,24 +136,22 @@ int main(int argc, char* argv[])
memset(resamplerState[clientCntr], 0, sizeof(int32_t) * 8);
}
for(clientCntr = 0; clientCntr < NUM_CLIENTS; clientCntr++)
{
for (clientCntr = 0; clientCntr < NUM_CLIENTS; clientCntr++) {
// Create
if(WebRtcIsac_Create(&codecInstance[clientCntr]))
{
if (WebRtcIsac_Create(&codecInstance[clientCntr])) {
printf("Could not creat client %d\n", clientCntr + 1);
return -1;
}
WebRtcIsac_SetEncSampRate(codecInstance[clientCntr], encoderSampRate[clientCntr]);
WebRtcIsac_SetEncSampRate(codecInstance[clientCntr],
encoderSampRate[clientCntr]);
WebRtcIsac_SetDecSampRate(codecInstance[clientCntr],
encoderSampRate[clientCntr + (1 - ((clientCntr & 1)<<1))]);
WebRtcIsac_SetDecSampRate(
codecInstance[clientCntr],
encoderSampRate[clientCntr + (1 - ((clientCntr & 1) << 1))]);
// Initialize Encoder
if(WebRtcIsac_EncoderInit(codecInstance[clientCntr],
codingMode) < 0)
{
if (WebRtcIsac_EncoderInit(codecInstance[clientCntr], codingMode) < 0) {
printf("Could not initialize client, %d\n", clientCntr + 1);
return -1;
}
@ -170,12 +159,10 @@ int main(int argc, char* argv[])
WebRtcIsac_DecoderInit(codecInstance[clientCntr]);
// setup Rate if in Instantaneous mode
if(codingMode != 0)
{
if (codingMode != 0) {
// ONLY Clients who are not in Adaptive mode
if(WebRtcIsac_Control(codecInstance[clientCntr],
bottleneck[clientCntr], 30) < 0)
{
if (WebRtcIsac_Control(codecInstance[clientCntr], bottleneck[clientCntr],
30) < 0) {
printf("Could not setup bottleneck and frame-size for client %d\n",
clientCntr + 1);
return -1;
@ -183,7 +170,6 @@ int main(int argc, char* argv[])
}
}
size_t streamLen;
short numSamplesRead;
size_t lenDecodedAudio;
@ -192,7 +178,7 @@ int main(int argc, char* argv[])
printf("\n");
short num10ms[MAX_NUM_CLIENTS];
memset(num10ms, 0, sizeof(short)*MAX_NUM_CLIENTS);
memset(num10ms, 0, sizeof(short) * MAX_NUM_CLIENTS);
FILE* arrivalTimeFile1 = fopen("arrivalTime1.dat", "wb");
FILE* arrivalTimeFile2 = fopen("arrivalTime2.dat", "wb");
short numPrint[MAX_NUM_CLIENTS];
@ -205,61 +191,60 @@ int main(int argc, char* argv[])
short audioBuff60ms[60 * 32];
short resampledAudio60ms[60 * 32];
unsigned short bitStream[600+600];
unsigned short bitStream[600 + 600];
short speechType[1];
short numSampFreqChanged = 0;
while(numSampFreqChanged < 10)
{
for(clientCntr = 0; clientCntr < NUM_CLIENTS; clientCntr++)
{
while (numSampFreqChanged < 10) {
for (clientCntr = 0; clientCntr < NUM_CLIENTS; clientCntr++) {
// Encoding/decoding for this pair of clients, if there is
// audio for any of them
//if(audioLeft[clientCntr] || audioLeft[clientCntr + 1])
// if(audioLeft[clientCntr] || audioLeft[clientCntr + 1])
//{
//for(pairCntr = 0; pairCntr < 2; pairCntr++)
// for(pairCntr = 0; pairCntr < 2; pairCntr++)
//{
senderIdx = clientCntr; // + pairCntr;
receiverIdx = 1 - clientCntr;// + (1 - pairCntr);
senderIdx = clientCntr; // + pairCntr;
receiverIdx = 1 - clientCntr; // + (1 - pairCntr);
//if(num10ms[senderIdx] > 6)
// if(num10ms[senderIdx] > 6)
//{
// printf("Too many frames read for client %d",
// senderIdx + 1);
// return -1;
//}
numSamplesRead = (short)fread(audioBuff10ms, sizeof(short),
samplesIn10ms[senderIdx], inFile[senderIdx]);
if(numSamplesRead != samplesIn10ms[senderIdx])
{
numSamplesRead =
(short)fread(audioBuff10ms, sizeof(short), samplesIn10ms[senderIdx],
inFile[senderIdx]);
if (numSamplesRead != samplesIn10ms[senderIdx]) {
// file finished switch encoder sampling frequency.
printf("Changing Encoder Sampling frequency in client %d to ", senderIdx+1);
printf("Changing Encoder Sampling frequency in client %d to ",
senderIdx + 1);
fclose(inFile[senderIdx]);
numSampFreqChanged++;
if(encoderSampRate[senderIdx] == 16000)
{
if (encoderSampRate[senderIdx] == 16000) {
printf("super-wideband.\n");
OPEN_FILE_RB(inFile[senderIdx], fileNameSWB);
encoderSampRate[senderIdx] = 32000;
}
else
{
} else {
printf("wideband.\n");
OPEN_FILE_RB(inFile[senderIdx], fileNameWB);
encoderSampRate[senderIdx] = 16000;
}
WebRtcIsac_SetEncSampRate(codecInstance[senderIdx], encoderSampRate[senderIdx]);
WebRtcIsac_SetDecSampRate(codecInstance[receiverIdx], encoderSampRate[senderIdx]);
WebRtcIsac_SetEncSampRate(codecInstance[senderIdx],
encoderSampRate[senderIdx]);
WebRtcIsac_SetDecSampRate(codecInstance[receiverIdx],
encoderSampRate[senderIdx]);
samplesIn10ms[clientCntr] = encoderSampRate[clientCntr] * 10;
numSamplesRead = (short)fread(audioBuff10ms, sizeof(short),
samplesIn10ms[senderIdx], inFile[senderIdx]);
if(numSamplesRead != samplesIn10ms[senderIdx])
{
numSamplesRead =
(short)fread(audioBuff10ms, sizeof(short), samplesIn10ms[senderIdx],
inFile[senderIdx]);
if (numSamplesRead != samplesIn10ms[senderIdx]) {
printf(" File %s for client %d has not enough audio\n",
(encoderSampRate[senderIdx]==16000)? "wideband":"super-wideband",
(encoderSampRate[senderIdx] == 16000) ? "wideband"
: "super-wideband",
senderIdx + 1);
return -1;
}
@ -267,39 +252,34 @@ int main(int argc, char* argv[])
num10ms[senderIdx]++;
// sanity check
//if(num10ms[senderIdx] > 6)
// if(num10ms[senderIdx] > 6)
//{
// printf("Client %d has got more than 60 ms audio and encoded no packet.\n",
// printf("Client %d has got more than 60 ms audio and encoded no
// packet.\n",
// senderIdx);
// return -1;
//}
// Encode
int streamLen_int = WebRtcIsac_Encode(codecInstance[senderIdx],
audioBuff10ms,
(uint8_t*)bitStream);
audioBuff10ms, (uint8_t*)bitStream);
int16_t ggg;
if (streamLen_int > 0) {
if ((WebRtcIsac_ReadFrameLen(
codecInstance[receiverIdx],
reinterpret_cast<const uint8_t*>(bitStream),
&ggg)) < 0)
reinterpret_cast<const uint8_t*>(bitStream), &ggg)) < 0)
printf("ERROR\n");
}
// Sanity check
if(streamLen_int < 0)
{
if (streamLen_int < 0) {
printf(" Encoder error in client %d \n", senderIdx + 1);
return -1;
}
streamLen = static_cast<size_t>(streamLen_int);
if(streamLen > 0)
{
if (streamLen > 0) {
// Packet generated; model sending through a channel, do bandwidth
// estimation at the receiver and decode.
lenEncodedInBytes[senderIdx] += streamLen;
@ -308,32 +288,30 @@ int main(int argc, char* argv[])
lenAudioIn10msTmp[senderIdx] += (unsigned int)num10ms[senderIdx];
// Print after ~5 sec.
if(lenAudioIn10msTmp[senderIdx] >= 100)
{
if (lenAudioIn10msTmp[senderIdx] >= 100) {
numPrint[senderIdx]++;
printf(" %d, %6.3f => %6.3f ", senderIdx+1,
printf(" %d, %6.3f => %6.3f ", senderIdx + 1,
bottleneck[senderIdx] / 1000.0,
lenEncodedInBytesTmp[senderIdx] * 0.8 /
lenAudioIn10msTmp[senderIdx]);
lenAudioIn10msTmp[senderIdx]);
if(codingMode == 0)
{
if (codingMode == 0) {
int32_t bn;
WebRtcIsac_GetUplinkBw(codecInstance[senderIdx], &bn);
printf("[%d] ", bn);
}
//int16_t rateIndexLB;
//int16_t rateIndexUB;
//WebRtcIsac_GetDownLinkBwIndex(codecInstance[receiverIdx],
// int16_t rateIndexLB;
// int16_t rateIndexUB;
// WebRtcIsac_GetDownLinkBwIndex(codecInstance[receiverIdx],
// &rateIndexLB, &rateIndexUB);
//printf(" (%2d, %2d) ", rateIndexLB, rateIndexUB);
// printf(" (%2d, %2d) ", rateIndexLB, rateIndexUB);
cout << flush;
lenEncodedInBytesTmp[senderIdx] = 0;
lenAudioIn10msTmp[senderIdx] = 0;
//if(senderIdx == (NUM_CLIENTS - 1))
lenAudioIn10msTmp[senderIdx] = 0;
// if(senderIdx == (NUM_CLIENTS - 1))
//{
printf(" %0.1f \n", lenAudioIn10ms[senderIdx] * 10. /1000);
printf(" %0.1f \n", lenAudioIn10ms[senderIdx] * 10. / 1000);
//}
// After ~20 sec change the bottleneck.
@ -385,23 +363,20 @@ int main(int argc, char* argv[])
// model a channel of given bottleneck, to get the receive timestamp
get_arrival_time(num10ms[senderIdx] * samplesIn10ms[senderIdx],
streamLen, bottleneck[senderIdx], packetData[senderIdx],
encoderSampRate[senderIdx]*1000, encoderSampRate[senderIdx]*1000);
streamLen, bottleneck[senderIdx],
packetData[senderIdx],
encoderSampRate[senderIdx] * 1000,
encoderSampRate[senderIdx] * 1000);
// Write the arrival time.
if(senderIdx == 0)
{
if (senderIdx == 0) {
if (fwrite(&(packetData[senderIdx]->arrival_time),
sizeof(unsigned int),
1, arrivalTimeFile1) != 1) {
sizeof(unsigned int), 1, arrivalTimeFile1) != 1) {
return -1;
}
}
else
{
} else {
if (fwrite(&(packetData[senderIdx]->arrival_time),
sizeof(unsigned int),
1, arrivalTimeFile2) != 1) {
sizeof(unsigned int), 1, arrivalTimeFile2) != 1) {
return -1;
}
}
@ -409,8 +384,7 @@ int main(int argc, char* argv[])
// BWE
if (WebRtcIsac_UpdateBwEstimate(
codecInstance[receiverIdx],
reinterpret_cast<const uint8_t*>(bitStream),
streamLen,
reinterpret_cast<const uint8_t*>(bitStream), streamLen,
packetData[senderIdx]->rtp_number,
packetData[senderIdx]->sample_count,
packetData[senderIdx]->arrival_time) < 0) {
@ -419,34 +393,27 @@ int main(int argc, char* argv[])
}
/**/
// Decode
int lenDecodedAudio_int = WebRtcIsac_Decode(
codecInstance[receiverIdx],
reinterpret_cast<const uint8_t*>(bitStream),
streamLen,
audioBuff60ms,
speechType);
if(lenDecodedAudio_int < 0)
{
int lenDecodedAudio_int =
WebRtcIsac_Decode(codecInstance[receiverIdx],
reinterpret_cast<const uint8_t*>(bitStream),
streamLen, audioBuff60ms, speechType);
if (lenDecodedAudio_int < 0) {
printf(" Decoder error in client %d \n", receiverIdx + 1);
return -1;
}
lenDecodedAudio = static_cast<size_t>(lenDecodedAudio_int);
if(encoderSampRate[senderIdx] == 16000)
{
WebRtcSpl_UpsampleBy2(audioBuff60ms, lenDecodedAudio, resampledAudio60ms,
if (encoderSampRate[senderIdx] == 16000) {
WebRtcSpl_UpsampleBy2(audioBuff60ms, lenDecodedAudio,
resampledAudio60ms,
resamplerState[receiverIdx]);
if (fwrite(resampledAudio60ms, sizeof(short), lenDecodedAudio << 1,
outFile[receiverIdx]) !=
lenDecodedAudio << 1) {
outFile[receiverIdx]) != lenDecodedAudio << 1) {
return -1;
}
}
else
{
} else {
if (fwrite(audioBuff60ms, sizeof(short), lenDecodedAudio,
outFile[receiverIdx]) !=
lenDecodedAudio) {
outFile[receiverIdx]) != lenDecodedAudio) {
return -1;
}
}

View File

@ -11,134 +11,98 @@
#ifndef MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_UTIL_UTILITY_H_
#define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_UTIL_UTILITY_H_
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#if defined(__cplusplus)
extern "C" {
#endif
#define OPEN_FILE_WB(filePtr, fullPath) \
do \
{ \
if(fullPath != NULL) \
{ \
filePtr = fopen(fullPath, "wb"); \
if(filePtr == NULL) \
{ \
printf("could not open %s to write to.", fullPath); \
return -1; \
} \
} \
else \
{ \
filePtr = NULL; \
} \
}while(0)
#define OPEN_FILE_WB(filePtr, fullPath) \
do { \
if (fullPath != NULL) { \
filePtr = fopen(fullPath, "wb"); \
if (filePtr == NULL) { \
printf("could not open %s to write to.", fullPath); \
return -1; \
} \
} else { \
filePtr = NULL; \
} \
} while (0)
#define OPEN_FILE_AB(filePtr, fullPath) \
do \
{ \
if(fullPath != NULL) \
{ \
filePtr = fopen(fullPath, "ab"); \
if(filePtr == NULL) \
{ \
printf("could not open %s to write to.", fullPath); \
return -1; \
} \
} \
else \
{ \
filePtr = NULL; \
} \
}while(0)
#define OPEN_FILE_AB(filePtr, fullPath) \
do { \
if (fullPath != NULL) { \
filePtr = fopen(fullPath, "ab"); \
if (filePtr == NULL) { \
printf("could not open %s to write to.", fullPath); \
return -1; \
} \
} else { \
filePtr = NULL; \
} \
} while (0)
#define OPEN_FILE_RB(filePtr, fullPath) \
do \
{ \
if(fullPath != NULL) \
{ \
filePtr = fopen(fullPath, "rb"); \
if(filePtr == NULL) \
{ \
printf("could not open %s to read from.", fullPath); \
return -1; \
} \
} \
else \
{ \
filePtr = NULL; \
} \
}while(0)
#define OPEN_FILE_RB(filePtr, fullPath) \
do { \
if (fullPath != NULL) { \
filePtr = fopen(fullPath, "rb"); \
if (filePtr == NULL) { \
printf("could not open %s to read from.", fullPath); \
return -1; \
} \
} else { \
filePtr = NULL; \
} \
} while (0)
#define WRITE_FILE_D(bufferPtr, len, filePtr) \
do \
{ \
if(filePtr != NULL) \
{ \
double dummy[1000]; \
int cntr; \
for(cntr = 0; cntr < (len); cntr++) \
{ \
dummy[cntr] = (double)bufferPtr[cntr]; \
} \
fwrite(dummy, sizeof(double), len, filePtr); \
fflush(filePtr); \
} \
} while(0)
#define WRITE_FILE_D(bufferPtr, len, filePtr) \
do { \
if (filePtr != NULL) { \
double dummy[1000]; \
int cntr; \
for (cntr = 0; cntr < (len); cntr++) { \
dummy[cntr] = (double)bufferPtr[cntr]; \
} \
fwrite(dummy, sizeof(double), len, filePtr); \
fflush(filePtr); \
} \
} while (0)
typedef struct {
unsigned int whenPackGeneratedMs;
unsigned int whenPrevPackLeftMs;
unsigned int sendTimeMs ; /* milisecond */
unsigned int arrival_time; /* samples */
unsigned int sample_count; /* samples, also used as "send time stamp" */
unsigned int rtp_number;
} BottleNeckModel;
typedef struct {
unsigned int whenPackGeneratedMs;
unsigned int whenPrevPackLeftMs;
unsigned int sendTimeMs; /* milisecond */
unsigned int arrival_time; /* samples */
unsigned int sample_count; /* samples, also used as "send time stamp" */
unsigned int rtp_number;
} BottleNeckModel;
void get_arrival_time(
int current_framesamples, /* samples */
size_t packet_size, /* bytes */
int bottleneck, /* excluding headers; bits/s */
BottleNeckModel* BN_data,
short senderSampFreqHz,
short receiverSampFreqHz);
void get_arrival_time(int current_framesamples, /* samples */
size_t packet_size, /* bytes */
int bottleneck, /* excluding headers; bits/s */
BottleNeckModel* BN_data,
short senderSampFreqHz,
short receiverSampFreqHz);
/* function for reading audio data from PCM file */
int readframe(
short* data,
FILE* inp,
int length);
/* function for reading audio data from PCM file */
int readframe(short* data, FILE* inp, int length);
short readSwitch(
int argc,
char* argv[],
char* strID);
short readSwitch(int argc, char* argv[], char* strID);
double readParamDouble(
int argc,
char* argv[],
char* strID,
double defaultVal);
double readParamDouble(int argc, char* argv[], char* strID, double defaultVal);
int readParamInt(
int argc,
char* argv[],
char* strID,
int defaultVal);
int readParamInt(int argc, char* argv[], char* strID, int defaultVal);
int readParamString(
int argc,
char* argv[],
char* strID,
char* stringParam,
int maxSize);
int readParamString(int argc,
char* argv[],
char* strID,
char* stringParam,
int maxSize);
#if defined(__cplusplus)
}
#endif
#endif