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

@ -11,8 +11,8 @@
#include "modules/audio_coding/codecs/cng/audio_encoder_cng.h"
#include <algorithm>
#include <memory>
#include <limits>
#include <memory>
#include <utility>
namespace webrtc {
@ -158,9 +158,8 @@ void AudioEncoderCng::Reset() {
rtp_timestamps_.clear();
last_frame_active_ = true;
vad_->Reset();
cng_encoder_.reset(
new ComfortNoiseEncoder(SampleRateHz(), sid_frame_interval_ms_,
num_cng_coefficients_));
cng_encoder_.reset(new ComfortNoiseEncoder(
SampleRateHz(), sid_frame_interval_ms_, num_cng_coefficients_));
}
bool AudioEncoderCng::SetFec(bool enable) {
@ -217,11 +216,10 @@ AudioEncoder::EncodedInfo AudioEncoderCng::EncodePassive(
// that value, in which case we don't want to overwrite any value from
// an earlier iteration.
size_t encoded_bytes_tmp =
cng_encoder_->Encode(
rtc::ArrayView<const int16_t>(
&speech_buffer_[i * samples_per_10ms_frame],
samples_per_10ms_frame),
force_sid, encoded);
cng_encoder_->Encode(rtc::ArrayView<const int16_t>(
&speech_buffer_[i * samples_per_10ms_frame],
samples_per_10ms_frame),
force_sid, encoded);
if (encoded_bytes_tmp > 0) {
RTC_CHECK(!output_produced);
@ -238,9 +236,8 @@ AudioEncoder::EncodedInfo AudioEncoderCng::EncodePassive(
return info;
}
AudioEncoder::EncodedInfo AudioEncoderCng::EncodeActive(
size_t frames_to_encode,
rtc::Buffer* encoded) {
AudioEncoder::EncodedInfo AudioEncoderCng::EncodeActive(size_t frames_to_encode,
rtc::Buffer* encoded) {
const size_t samples_per_10ms_frame = SamplesPer10msFrame();
AudioEncoder::EncodedInfo info;
for (size_t i = 0; i < frames_to_encode; ++i) {

View File

@ -30,7 +30,7 @@ namespace {
static const size_t kMaxNumSamples = 48 * 10 * 2; // 10 ms @ 48 kHz stereo.
static const size_t kMockReturnEncodedBytes = 17;
static const int kCngPayloadType = 18;
}
} // namespace
class AudioEncoderCngTest : public ::testing::Test {
protected:
@ -94,8 +94,7 @@ class AudioEncoderCngTest : public ::testing::Test {
InSequence s;
AudioEncoder::EncodedInfo info;
for (size_t j = 0; j < num_calls - 1; ++j) {
EXPECT_CALL(*mock_encoder_, EncodeImpl(_, _, _))
.WillOnce(Return(info));
EXPECT_CALL(*mock_encoder_, EncodeImpl(_, _, _)).WillOnce(Return(info));
}
info.encoded_bytes = kMockReturnEncodedBytes;
EXPECT_CALL(*mock_encoder_, EncodeImpl(_, _, _))
@ -155,12 +154,14 @@ class AudioEncoderCngTest : public ::testing::Test {
EXPECT_CALL(
*mock_vad_,
VoiceActivity(_, expected_first_block_size_ms * sample_rate_hz_ / 1000,
sample_rate_hz_)).WillOnce(Return(Vad::kPassive));
sample_rate_hz_))
.WillOnce(Return(Vad::kPassive));
if (expected_second_block_size_ms > 0) {
EXPECT_CALL(*mock_vad_,
VoiceActivity(
_, expected_second_block_size_ms * sample_rate_hz_ / 1000,
sample_rate_hz_)).WillOnce(Return(Vad::kPassive));
sample_rate_hz_))
.WillOnce(Return(Vad::kPassive));
}
// With this call to Encode(), |mock_vad_| should be called according to the
@ -429,9 +430,7 @@ class AudioEncoderCngDeathTest : public AudioEncoderCngTest {
// Override AudioEncoderCngTest::TearDown, since that one expects a call to
// the destructor of |mock_vad_|. In this case, that object is already
// deleted.
void TearDown() override {
cng_.reset();
}
void TearDown() override { cng_.reset(); }
AudioEncoderCng::Config MakeCngConfig() {
// Don't provide a Vad mock object, since it would leak when the test dies.

View File

@ -29,10 +29,7 @@ enum : size_t {
kCNGNumParamsTooHigh = WEBRTC_CNG_MAX_LPC_ORDER + 1
};
enum {
kNoSid,
kForceSid
};
enum { kNoSid, kForceSid };
class CngTest : public ::testing::Test {
protected:
@ -46,11 +43,11 @@ class CngTest : public ::testing::Test {
void CngTest::SetUp() {
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(640, static_cast<int32_t>(fread(speech_data_, sizeof(int16_t),
640, input_file)));
ASSERT_EQ(640, static_cast<int32_t>(
fread(speech_data_, sizeof(int16_t), 640, input_file)));
fclose(input_file);
input_file = NULL;
}
@ -74,11 +71,18 @@ void CngTest::TestCngEncode(int sample_rate_hz, int quality) {
// Create CNG encoder, init with faulty values, free CNG encoder.
TEST_F(CngTest, CngInitFail) {
// Call with too few parameters.
EXPECT_DEATH({ ComfortNoiseEncoder(8000, kSidNormalIntervalUpdate,
kCNGNumParamsLow); }, "");
EXPECT_DEATH(
{
ComfortNoiseEncoder(8000, kSidNormalIntervalUpdate, kCNGNumParamsLow);
},
"");
// Call with too many parameters.
EXPECT_DEATH({ ComfortNoiseEncoder(8000, kSidNormalIntervalUpdate,
kCNGNumParamsTooHigh); }, "");
EXPECT_DEATH(
{
ComfortNoiseEncoder(8000, kSidNormalIntervalUpdate,
kCNGNumParamsTooHigh);
},
"");
}
// Encode Cng with too long input vector.
@ -209,13 +213,15 @@ TEST_F(CngTest, CngAutoSid) {
// Normal Encode, 100 msec, where no SID data should be generated.
for (int i = 0; i < 10; i++) {
EXPECT_EQ(0U, cng_encoder.Encode(
rtc::ArrayView<const int16_t>(speech_data_, 160), kNoSid, &sid_data));
EXPECT_EQ(
0U, cng_encoder.Encode(rtc::ArrayView<const int16_t>(speech_data_, 160),
kNoSid, &sid_data));
}
// We have reached 100 msec, and SID data should be generated.
EXPECT_EQ(kCNGNumParamsNormal + 1, cng_encoder.Encode(
rtc::ArrayView<const int16_t>(speech_data_, 160), kNoSid, &sid_data));
EXPECT_EQ(kCNGNumParamsNormal + 1,
cng_encoder.Encode(rtc::ArrayView<const int16_t>(speech_data_, 160),
kNoSid, &sid_data));
}
// Test automatic SID, with very short interval.
@ -228,13 +234,16 @@ TEST_F(CngTest, CngAutoSidShort) {
ComfortNoiseDecoder cng_decoder;
// First call will never generate SID, unless forced to.
EXPECT_EQ(0U, cng_encoder.Encode(
rtc::ArrayView<const int16_t>(speech_data_, 160), kNoSid, &sid_data));
EXPECT_EQ(0U,
cng_encoder.Encode(rtc::ArrayView<const int16_t>(speech_data_, 160),
kNoSid, &sid_data));
// Normal Encode, 100 msec, SID data should be generated all the time.
for (int i = 0; i < 10; i++) {
EXPECT_EQ(kCNGNumParamsNormal + 1, cng_encoder.Encode(
rtc::ArrayView<const int16_t>(speech_data_, 160), kNoSid, &sid_data));
EXPECT_EQ(
kCNGNumParamsNormal + 1,
cng_encoder.Encode(rtc::ArrayView<const int16_t>(speech_data_, 160),
kNoSid, &sid_data));
}
}

View File

@ -25,28 +25,26 @@ const size_t kCngMaxOutsizeOrder = 640;
void WebRtcCng_K2a16(int16_t* k, int useOrder, int16_t* a);
const int32_t WebRtcCng_kDbov[94] = {
1081109975, 858756178, 682134279, 541838517, 430397633, 341876992,
271562548, 215709799, 171344384, 136103682, 108110997, 85875618,
68213428, 54183852, 43039763, 34187699, 27156255, 21570980,
17134438, 13610368, 10811100, 8587562, 6821343, 5418385,
4303976, 3418770, 2715625, 2157098, 1713444, 1361037,
1081110, 858756, 682134, 541839, 430398, 341877,
271563, 215710, 171344, 136104, 108111, 85876,
68213, 54184, 43040, 34188, 27156, 21571,
17134, 13610, 10811, 8588, 6821, 5418,
4304, 3419, 2716, 2157, 1713, 1361,
1081, 859, 682, 542, 430, 342,
272, 216, 171, 136, 108, 86,
68, 54, 43, 34, 27, 22,
17, 14, 11, 9, 7, 5,
4, 3, 3, 2, 2, 1,
1, 1, 1, 1
};
1081109975, 858756178, 682134279, 541838517, 430397633, 341876992,
271562548, 215709799, 171344384, 136103682, 108110997, 85875618,
68213428, 54183852, 43039763, 34187699, 27156255, 21570980,
17134438, 13610368, 10811100, 8587562, 6821343, 5418385,
4303976, 3418770, 2715625, 2157098, 1713444, 1361037,
1081110, 858756, 682134, 541839, 430398, 341877,
271563, 215710, 171344, 136104, 108111, 85876,
68213, 54184, 43040, 34188, 27156, 21571,
17134, 13610, 10811, 8588, 6821, 5418,
4304, 3419, 2716, 2157, 1713, 1361,
1081, 859, 682, 542, 430, 342,
272, 216, 171, 136, 108, 86,
68, 54, 43, 34, 27, 22,
17, 14, 11, 9, 7, 5,
4, 3, 3, 2, 2, 1,
1, 1, 1, 1};
const int16_t WebRtcCng_kCorrWindow[WEBRTC_CNG_MAX_LPC_ORDER] = {
32702, 32636, 32570, 32505, 32439, 32374,
32309, 32244, 32179, 32114, 32049, 31985
};
32702, 32636, 32570, 32505, 32439, 32374,
32309, 32244, 32179, 32114, 32049, 31985};
} // namespace
@ -57,7 +55,7 @@ ComfortNoiseDecoder::ComfortNoiseDecoder() {
}
void ComfortNoiseDecoder::Reset() {
dec_seed_ = 7777; /* For debugging only. */
dec_seed_ = 7777; /* For debugging only. */
dec_target_energy_ = 0;
dec_used_energy_ = 0;
for (auto& c : dec_target_reflCoefs_)
@ -115,11 +113,11 @@ bool ComfortNoiseDecoder::Generate(rtc::ArrayView<int16_t> out_data,
int16_t excitation[kCngMaxOutsizeOrder];
int16_t low[kCngMaxOutsizeOrder];
int16_t lpPoly[WEBRTC_CNG_MAX_LPC_ORDER + 1];
int16_t ReflBetaStd = 26214; /* 0.8 in q15. */
int16_t ReflBetaCompStd = 6553; /* 0.2 in q15. */
int16_t ReflBetaNewP = 19661; /* 0.6 in q15. */
int16_t ReflBetaCompNewP = 13107; /* 0.4 in q15. */
int16_t Beta, BetaC; /* These are in Q15. */
int16_t ReflBetaStd = 26214; /* 0.8 in q15. */
int16_t ReflBetaCompStd = 6553; /* 0.2 in q15. */
int16_t ReflBetaNewP = 19661; /* 0.6 in q15. */
int16_t ReflBetaCompNewP = 13107; /* 0.4 in q15. */
int16_t Beta, BetaC; /* These are in Q15. */
int32_t targetEnergy;
int16_t En;
int16_t temp16;
@ -139,30 +137,28 @@ bool ComfortNoiseDecoder::Generate(rtc::ArrayView<int16_t> out_data,
}
/* Calculate new scale factor in Q13 */
dec_used_scale_factor_ =
rtc::checked_cast<int16_t>(
WEBRTC_SPL_MUL_16_16_RSFT(dec_used_scale_factor_, Beta >> 2, 13) +
WEBRTC_SPL_MUL_16_16_RSFT(dec_target_scale_factor_, BetaC >> 2, 13));
dec_used_scale_factor_ = rtc::checked_cast<int16_t>(
WEBRTC_SPL_MUL_16_16_RSFT(dec_used_scale_factor_, Beta >> 2, 13) +
WEBRTC_SPL_MUL_16_16_RSFT(dec_target_scale_factor_, BetaC >> 2, 13));
dec_used_energy_ = dec_used_energy_ >> 1;
dec_used_energy_ = dec_used_energy_ >> 1;
dec_used_energy_ += dec_target_energy_ >> 1;
/* Do the same for the reflection coeffs, albeit in Q15. */
for (size_t i = 0; i < WEBRTC_CNG_MAX_LPC_ORDER; i++) {
dec_used_reflCoefs_[i] = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(
dec_used_reflCoefs_[i], Beta, 15);
dec_used_reflCoefs_[i] += (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(
dec_target_reflCoefs_[i], BetaC, 15);
dec_used_reflCoefs_[i] =
(int16_t)WEBRTC_SPL_MUL_16_16_RSFT(dec_used_reflCoefs_[i], Beta, 15);
dec_used_reflCoefs_[i] +=
(int16_t)WEBRTC_SPL_MUL_16_16_RSFT(dec_target_reflCoefs_[i], BetaC, 15);
}
/* Compute the polynomial coefficients. */
WebRtcCng_K2a16(dec_used_reflCoefs_, WEBRTC_CNG_MAX_LPC_ORDER, lpPoly);
targetEnergy = dec_used_energy_;
/* Calculate scaling factor based on filter energy. */
En = 8192; /* 1.0 in Q13. */
En = 8192; /* 1.0 in Q13. */
for (size_t i = 0; i < (WEBRTC_CNG_MAX_LPC_ORDER); i++) {
/* Floating point value for reference.
E *= 1.0 - (dec_used_reflCoefs_[i] / 32768.0) *
@ -171,11 +167,11 @@ bool ComfortNoiseDecoder::Generate(rtc::ArrayView<int16_t> out_data,
/* Same in fixed point. */
/* K(i).^2 in Q15. */
temp16 = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(
dec_used_reflCoefs_[i], dec_used_reflCoefs_[i], 15);
temp16 = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(dec_used_reflCoefs_[i],
dec_used_reflCoefs_[i], 15);
/* 1 - K(i).^2 in Q15. */
temp16 = 0x7fff - temp16;
En = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(En, temp16, 15);
En = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(En, temp16, 15);
}
/* float scaling= sqrt(E * dec_target_energy_ / (1 << 24)); */
@ -183,8 +179,8 @@ bool ComfortNoiseDecoder::Generate(rtc::ArrayView<int16_t> out_data,
/* Calculate sqrt(En * target_energy / excitation energy) */
targetEnergy = WebRtcSpl_Sqrt(dec_used_energy_);
En = (int16_t) WebRtcSpl_Sqrt(En) << 6;
En = (En * 3) >> 1; /* 1.5 estimates sqrt(2). */
En = (int16_t)WebRtcSpl_Sqrt(En) << 6;
En = (En * 3) >> 1; /* 1.5 estimates sqrt(2). */
dec_used_scale_factor_ = (int16_t)((En * targetEnergy) >> 12);
/* Generate excitation. */
@ -217,7 +213,7 @@ ComfortNoiseEncoder::ComfortNoiseEncoder(int fs, int interval, int quality)
enc_Energy_(0),
enc_reflCoefs_{0},
enc_corrVector_{0},
enc_seed_(7777) /* For debugging only. */ {
enc_seed_(7777) /* For debugging only. */ {
RTC_CHECK_GT(quality, 0);
RTC_CHECK_LE(quality, WEBRTC_CNG_MAX_LPC_ORDER);
/* Needed to get the right function pointers in SPLIB. */
@ -236,7 +232,7 @@ void ComfortNoiseEncoder::Reset(int fs, int interval, int quality) {
c = 0;
for (auto& c : enc_corrVector_)
c = 0;
enc_seed_ = 7777; /* For debugging only. */
enc_seed_ = 7777; /* For debugging only. */
}
size_t ComfortNoiseEncoder::Encode(rtc::ArrayView<const int16_t> speech,
@ -312,20 +308,19 @@ size_t ComfortNoiseEncoder::Encode(rtc::ArrayView<const int16_t> speech,
if (negate)
*bptr = -*bptr;
blo = (int32_t) * aptr * (*bptr & 0xffff);
bhi = ((blo >> 16) & 0xffff)
+ ((int32_t)(*aptr++) * ((*bptr >> 16) & 0xffff));
blo = (int32_t)*aptr * (*bptr & 0xffff);
bhi = ((blo >> 16) & 0xffff) +
((int32_t)(*aptr++) * ((*bptr >> 16) & 0xffff));
blo = (blo & 0xffff) | ((bhi & 0xffff) << 16);
*bptr = (((bhi >> 16) & 0x7fff) << 17) | ((uint32_t) blo >> 15);
*bptr = (((bhi >> 16) & 0x7fff) << 17) | ((uint32_t)blo >> 15);
if (negate)
*bptr = -*bptr;
bptr++;
}
/* End of bandwidth expansion. */
stab = WebRtcSpl_LevinsonDurbin(corrVector, arCoefs, refCs,
enc_nrOfCoefs_);
stab = WebRtcSpl_LevinsonDurbin(corrVector, arCoefs, refCs, enc_nrOfCoefs_);
if (!stab) {
/* Disregard from this frame */
@ -345,13 +340,12 @@ size_t ComfortNoiseEncoder::Encode(rtc::ArrayView<const int16_t> speech,
} else {
/* Average history with new values. */
for (i = 0; i < enc_nrOfCoefs_; i++) {
enc_reflCoefs_[i] = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(
enc_reflCoefs_[i], ReflBeta, 15);
enc_reflCoefs_[i] =
(int16_t)WEBRTC_SPL_MUL_16_16_RSFT(enc_reflCoefs_[i], ReflBeta, 15);
enc_reflCoefs_[i] +=
(int16_t) WEBRTC_SPL_MUL_16_16_RSFT(refCs[i], ReflBetaComp, 15);
(int16_t)WEBRTC_SPL_MUL_16_16_RSFT(refCs[i], ReflBetaComp, 15);
}
enc_Energy_ =
(outEnergy >> 2) + (enc_Energy_ >> 1) + (enc_Energy_ >> 2);
enc_Energy_ = (outEnergy >> 2) + (enc_Energy_ >> 1) + (enc_Energy_ >> 2);
}
if (enc_Energy_ < 1) {
@ -372,25 +366,25 @@ size_t ComfortNoiseEncoder::Encode(rtc::ArrayView<const int16_t> speech,
index = 94;
const size_t output_coefs = enc_nrOfCoefs_ + 1;
output->AppendData(output_coefs, [&] (rtc::ArrayView<uint8_t> output) {
output[0] = (uint8_t)index;
output->AppendData(output_coefs, [&](rtc::ArrayView<uint8_t> output) {
output[0] = (uint8_t)index;
/* Quantize coefficients with tweak for WebRtc implementation of
* RFC3389. */
if (enc_nrOfCoefs_ == WEBRTC_CNG_MAX_LPC_ORDER) {
for (i = 0; i < enc_nrOfCoefs_; i++) {
/* Q15 to Q7 with rounding. */
output[i + 1] = ((enc_reflCoefs_[i] + 128) >> 8);
}
} else {
for (i = 0; i < enc_nrOfCoefs_; i++) {
/* Q15 to Q7 with rounding. */
output[i + 1] = (127 + ((enc_reflCoefs_[i] + 128) >> 8));
}
/* Quantize coefficients with tweak for WebRtc implementation of
* RFC3389. */
if (enc_nrOfCoefs_ == WEBRTC_CNG_MAX_LPC_ORDER) {
for (i = 0; i < enc_nrOfCoefs_; i++) {
/* Q15 to Q7 with rounding. */
output[i + 1] = ((enc_reflCoefs_[i] + 128) >> 8);
}
} else {
for (i = 0; i < enc_nrOfCoefs_; i++) {
/* Q15 to Q7 with rounding. */
output[i + 1] = (127 + ((enc_reflCoefs_[i] + 128) >> 8));
}
}
return output_coefs;
});
return output_coefs;
});
enc_msSinceSid_ =
static_cast<int16_t>((1000 * num_samples) / enc_sampfreq_);

View File

@ -8,7 +8,6 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_AUDIO_CODING_CODECS_CNG_WEBRTC_CNG_H_
#define MODULES_AUDIO_CODING_CODECS_CNG_WEBRTC_CNG_H_
@ -54,8 +53,8 @@ class ComfortNoiseDecoder {
int16_t dec_filtstate_[WEBRTC_CNG_MAX_LPC_ORDER + 1];
int16_t dec_filtstateLow_[WEBRTC_CNG_MAX_LPC_ORDER + 1];
uint16_t dec_order_;
int16_t dec_target_scale_factor_; /* Q29 */
int16_t dec_used_scale_factor_; /* Q29 */
int16_t dec_target_scale_factor_; /* Q29 */
int16_t dec_used_scale_factor_; /* Q29 */
};
class ComfortNoiseEncoder {

View File

@ -10,8 +10,8 @@
#include "modules/audio_coding/codecs/g711/audio_decoder_pcm.h"
#include "modules/audio_coding/codecs/legacy_encoded_audio_frame.h"
#include "modules/audio_coding/codecs/g711/g711_interface.h"
#include "modules/audio_coding/codecs/legacy_encoded_audio_frame.h"
namespace webrtc {

View File

@ -42,8 +42,8 @@ AudioEncoderPcm::AudioEncoderPcm(const Config& config, int sample_rate_hz)
payload_type_(config.payload_type),
num_10ms_frames_per_packet_(
static_cast<size_t>(config.frame_size_ms / 10)),
full_frame_samples_(
config.num_channels * config.frame_size_ms * sample_rate_hz / 1000),
full_frame_samples_(config.num_channels * config.frame_size_ms *
sample_rate_hz / 1000),
first_timestamp_in_buffer_(0) {
RTC_CHECK_GT(sample_rate_hz, 0) << "Sample rate must be larger than 0 Hz";
RTC_CHECK_EQ(config.frame_size_ms % 10, 0)
@ -70,8 +70,8 @@ size_t AudioEncoderPcm::Max10MsFramesInAPacket() const {
}
int AudioEncoderPcm::GetTargetBitrate() const {
return static_cast<int>(
8 * BytesPerSample() * SampleRateHz() * NumChannels());
return static_cast<int>(8 * BytesPerSample() * SampleRateHz() *
NumChannels());
}
AudioEncoder::EncodedInfo AudioEncoderPcm::EncodeImpl(
@ -89,13 +89,12 @@ AudioEncoder::EncodedInfo AudioEncoderPcm::EncodeImpl(
EncodedInfo info;
info.encoded_timestamp = first_timestamp_in_buffer_;
info.payload_type = payload_type_;
info.encoded_bytes =
encoded->AppendData(full_frame_samples_ * BytesPerSample(),
[&] (rtc::ArrayView<uint8_t> encoded) {
return EncodeCall(&speech_buffer_[0],
full_frame_samples_,
encoded.data());
});
info.encoded_bytes = encoded->AppendData(
full_frame_samples_ * BytesPerSample(),
[&](rtc::ArrayView<uint8_t> encoded) {
return EncodeCall(&speech_buffer_[0], full_frame_samples_,
encoded.data());
});
speech_buffer_.clear();
info.encoder_type = GetCodecType();
return info;

View File

@ -17,7 +17,8 @@
* Modifications for WebRtc, 2011/04/28, by tlegrand:
* -Changed to use WebRtc types
* -Changed __inline__ to __inline
* -Two changes to make implementation bitexact with ITU-T reference implementation
* -Two changes to make implementation bitexact with ITU-T reference
* implementation
*/
/*! \page g711_page A-law and mu-law handling
@ -58,10 +59,11 @@ extern "C" {
static __inline__ int top_bit(unsigned int bits) {
int res;
__asm__ __volatile__(" movl $-1,%%edx;\n"
" bsrl %%eax,%%edx;\n"
: "=d" (res)
: "a" (bits));
__asm__ __volatile__(
" movl $-1,%%edx;\n"
" bsrl %%eax,%%edx;\n"
: "=d"(res)
: "a"(bits));
return res;
}
@ -71,30 +73,33 @@ static __inline__ int top_bit(unsigned int bits) {
static __inline__ int bottom_bit(unsigned int bits) {
int res;
__asm__ __volatile__(" movl $-1,%%edx;\n"
" bsfl %%eax,%%edx;\n"
: "=d" (res)
: "a" (bits));
__asm__ __volatile__(
" movl $-1,%%edx;\n"
" bsfl %%eax,%%edx;\n"
: "=d"(res)
: "a"(bits));
return res;
}
#elif defined(__x86_64__)
static __inline__ int top_bit(unsigned int bits) {
int res;
__asm__ __volatile__(" movq $-1,%%rdx;\n"
" bsrq %%rax,%%rdx;\n"
: "=d" (res)
: "a" (bits));
__asm__ __volatile__(
" movq $-1,%%rdx;\n"
" bsrq %%rax,%%rdx;\n"
: "=d"(res)
: "a"(bits));
return res;
}
static __inline__ int bottom_bit(unsigned int bits) {
int res;
__asm__ __volatile__(" movq $-1,%%rdx;\n"
" bsfq %%rax,%%rdx;\n"
: "=d" (res)
: "a" (bits));
__asm__ __volatile__(
" movq $-1,%%rdx;\n"
" bsfq %%rax,%%rdx;\n"
: "=d"(res)
: "a"(bits));
return res;
}
#else
@ -166,8 +171,8 @@ static __inline int bottom_bit(unsigned int bits) {
* linear sound like peanuts these days, and shouldn't an array lookup be
* real fast? No! When the cache sloshes as badly as this one will, a tight
* calculation may be better. The messiest part is normally finding the
* segment, but a little inline assembly can fix that on an i386, x86_64 and
* many other modern processors.
* segment, but a little inline assembly can fix that on an i386, x86_64
* and many other modern processors.
*/
/*
@ -196,8 +201,9 @@ static __inline int bottom_bit(unsigned int bits) {
* John Wiley & Sons, pps 98-111 and 472-476.
*/
//#define ULAW_ZEROTRAP /* turn on the trap as per the MIL-STD */
#define ULAW_BIAS 0x84 /* Bias for linear code. */
//#define ULAW_ZEROTRAP /* turn on the trap as per the MIL-STD
//*/
#define ULAW_BIAS 0x84 /* Bias for linear code. */
/*! \brief Encode a linear sample to u-law
\param linear The sample to encode.
@ -249,7 +255,7 @@ static __inline int16_t ulaw_to_linear(uint8_t ulaw) {
* Extract and bias the quantization bits. Then
* shift up by the segment number and subtract out the bias.
*/
t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int) ulaw & 0x70) >> 4);
t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int)ulaw & 0x70) >> 4);
return (int16_t)((ulaw & 0x80) ? (ULAW_BIAS - t) : (t - ULAW_BIAS));
}
@ -317,7 +323,7 @@ static __inline int16_t alaw_to_linear(uint8_t alaw) {
alaw ^= ALAW_AMI_MASK;
i = ((alaw & 0x0F) << 4);
seg = (((int) alaw & 0x70) >> 4);
seg = (((int)alaw & 0x70) >> 4);
if (seg)
i = (i + 0x108) << (seg - 1);
else

View File

@ -112,19 +112,19 @@ size_t WebRtcG711_DecodeU(const uint8_t* encoded,
int16_t* speechType);
/**********************************************************************
* WebRtcG711_Version(...)
*
* This function gives the version string of the G.711 codec.
*
* Input:
* - lenBytes: the size of Allocated space (in Bytes) where
* the version number is written to (in string format).
*
* Output:
* - version: Pointer to a buffer where the version number is
* written to.
*
*/
* WebRtcG711_Version(...)
*
* This function gives the version string of the G.711 codec.
*
* Input:
* - lenBytes: the size of Allocated space (in Bytes) where
* the version number is written to (in string format).
*
* Output:
* - version: Pointer to a buffer where the version number is
* written to.
*
*/
int16_t WebRtcG711_Version(char* version, int16_t lenBytes);

View File

@ -69,7 +69,6 @@ int main(int argc, char* argv[]) {
printf("outfile : Speech output file\n\n");
printf("outbits : Output bitstream file [optional]\n\n");
exit(0);
}
/* Get version and print */
@ -80,8 +79,8 @@ int main(int argc, char* argv[]) {
/* Get frame length */
int framelength_int = atoi(argv[1]);
if (framelength_int < 0) {
printf(" G.722: Invalid framelength %d.\n", framelength_int);
exit(1);
printf(" G.722: Invalid framelength %d.\n", framelength_int);
exit(1);
}
framelength = static_cast<size_t>(framelength_int);
@ -112,7 +111,7 @@ int main(int argc, char* argv[]) {
printf("\nBitfile: %s\n", bitname);
}
starttime = clock() / (double) CLOCKS_PER_SEC_G711; /* Runtime statistics */
starttime = clock() / (double)CLOCKS_PER_SEC_G711; /* Runtime statistics */
/* Initialize encoder and decoder */
framecnt = 0;
@ -155,11 +154,10 @@ int main(int argc, char* argv[]) {
}
}
runtime = (double)(clock() / (double) CLOCKS_PER_SEC_G711 - starttime);
length_file = ((double) framecnt * (double) framelength / 8000);
runtime = (double)(clock() / (double)CLOCKS_PER_SEC_G711 - starttime);
length_file = ((double)framecnt * (double)framelength / 8000);
printf("\n\nLength of speech file: %.1f s\n", length_file);
printf("Time to run G.711: %.2f s (%.2f %% of realtime)\n\n",
runtime,
printf("Time to run G.711: %.2f s (%.2f %% of realtime)\n\n", runtime,
(100 * runtime / length_file));
printf("---------------------END----------------------\n");

View File

@ -123,7 +123,7 @@ AudioEncoder::EncodedInfo AudioEncoderG722Impl::EncodeImpl(
const size_t bytes_to_encode = samples_per_channel / 2 * num_channels_;
EncodedInfo info;
info.encoded_bytes = encoded->AppendData(
bytes_to_encode, [&] (rtc::ArrayView<uint8_t> encoded) {
bytes_to_encode, [&](rtc::ArrayView<uint8_t> encoded) {
// Interleave the encoded bytes of the different channels. Each separate
// channel and the interleaved stream encodes two samples per byte, most
// significant half first.

View File

@ -46,8 +46,8 @@ class AudioEncoderG722Impl final : public AudioEncoder {
// The encoder state for one channel.
struct EncoderState {
G722EncInst* encoder;
std::unique_ptr<int16_t[]> speech_buffer; // Queued up for encoding.
rtc::Buffer encoded_buffer; // Already encoded.
std::unique_ptr<int16_t[]> speech_buffer; // Queued up for encoding.
rtc::Buffer encoded_buffer; // Already encoded.
EncoderState();
~EncoderState();
};

View File

@ -7,7 +7,7 @@
*
* Copyright (C) 2005 Steve Underwood
*
* Despite my general liking of the GPL, I place my own contributions
* Despite my general liking of the GPL, I place my own contributions
* to this code in the public domain for the benefit of all mankind -
* even the slimy ones who might try to proprietize my work and use it
* to my detriment.
@ -25,7 +25,6 @@
* -Added new defines for minimum and maximum values of short int
*/
/*! \file */
#if !defined(_G722_ENC_DEC_H_)
@ -35,12 +34,14 @@
/*! \page g722_page G.722 encoding and decoding
\section g722_page_sec_1 What does it do?
The G.722 module is a bit exact implementation of the ITU G.722 specification for all three
specified bit rates - 64000bps, 56000bps and 48000bps. It passes the ITU tests.
The G.722 module is a bit exact implementation of the ITU G.722 specification
for all three specified bit rates - 64000bps, 56000bps and 48000bps. It passes
the ITU tests.
To allow fast and flexible interworking with narrow band telephony, the encoder and decoder
support an option for the linear audio to be an 8k samples/second stream. In this mode the
codec is considerably faster, and still fully compatible with wideband terminals using G.722.
To allow fast and flexible interworking with narrow band telephony, the encoder
and decoder support an option for the linear audio to be an 8k samples/second
stream. In this mode the codec is considerably faster, and still fully
compatible with wideband terminals using G.722.
\section g722_page_sec_2 How does it work?
???.
@ -49,86 +50,78 @@ codec is considerably faster, and still fully compatible with wideband terminals
#define WEBRTC_INT16_MAX 32767
#define WEBRTC_INT16_MIN -32768
enum
{
G722_SAMPLE_RATE_8000 = 0x0001,
G722_PACKED = 0x0002
};
enum { G722_SAMPLE_RATE_8000 = 0x0001, G722_PACKED = 0x0002 };
typedef struct
{
/*! TRUE if the operating in the special ITU test mode, with the band split filters
disabled. */
int itu_test_mode;
/*! TRUE if the G.722 data is packed */
int packed;
/*! TRUE if encode from 8k samples/second */
int eight_k;
/*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */
int bits_per_sample;
typedef struct {
/*! TRUE if the operating in the special ITU test mode, with the band split
filters disabled. */
int itu_test_mode;
/*! TRUE if the G.722 data is packed */
int packed;
/*! TRUE if encode from 8k samples/second */
int eight_k;
/*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */
int bits_per_sample;
/*! Signal history for the QMF */
int x[24];
/*! Signal history for the QMF */
int x[24];
struct
{
int s;
int sp;
int sz;
int r[3];
int a[3];
int ap[3];
int p[3];
int d[7];
int b[7];
int bp[7];
int sg[7];
int nb;
int det;
} band[2];
struct {
int s;
int sp;
int sz;
int r[3];
int a[3];
int ap[3];
int p[3];
int d[7];
int b[7];
int bp[7];
int sg[7];
int nb;
int det;
} band[2];
unsigned int in_buffer;
int in_bits;
unsigned int out_buffer;
int out_bits;
unsigned int in_buffer;
int in_bits;
unsigned int out_buffer;
int out_bits;
} G722EncoderState;
typedef struct
{
/*! TRUE if the operating in the special ITU test mode, with the band split filters
disabled. */
int itu_test_mode;
/*! TRUE if the G.722 data is packed */
int packed;
/*! TRUE if decode to 8k samples/second */
int eight_k;
/*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */
int bits_per_sample;
typedef struct {
/*! TRUE if the operating in the special ITU test mode, with the band split
filters disabled. */
int itu_test_mode;
/*! TRUE if the G.722 data is packed */
int packed;
/*! TRUE if decode to 8k samples/second */
int eight_k;
/*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */
int bits_per_sample;
/*! Signal history for the QMF */
int x[24];
/*! Signal history for the QMF */
int x[24];
struct
{
int s;
int sp;
int sz;
int r[3];
int a[3];
int ap[3];
int p[3];
int d[7];
int b[7];
int bp[7];
int sg[7];
int nb;
int det;
} band[2];
unsigned int in_buffer;
int in_bits;
unsigned int out_buffer;
int out_bits;
struct {
int s;
int sp;
int sz;
int r[3];
int a[3];
int ap[3];
int p[3];
int d[7];
int b[7];
int bp[7];
int sg[7];
int nb;
int det;
} band[2];
unsigned int in_buffer;
int in_bits;
unsigned int out_buffer;
int out_bits;
} G722DecoderState;
#ifdef __cplusplus
@ -138,8 +131,8 @@ extern "C" {
G722EncoderState* WebRtc_g722_encode_init(G722EncoderState* s,
int rate,
int options);
int WebRtc_g722_encode_release(G722EncoderState *s);
size_t WebRtc_g722_encode(G722EncoderState *s,
int WebRtc_g722_encode_release(G722EncoderState* s);
size_t WebRtc_g722_encode(G722EncoderState* s,
uint8_t g722_data[],
const int16_t amp[],
size_t len);
@ -147,8 +140,8 @@ size_t WebRtc_g722_encode(G722EncoderState *s,
G722DecoderState* WebRtc_g722_decode_init(G722DecoderState* s,
int rate,
int options);
int WebRtc_g722_decode_release(G722DecoderState *s);
size_t WebRtc_g722_decode(G722DecoderState *s,
int WebRtc_g722_decode_release(G722DecoderState* s);
size_t WebRtc_g722_decode(G722DecoderState* s,
int16_t amp[],
const uint8_t g722_data[],
size_t len);

View File

@ -17,21 +17,20 @@
* Solution to support multiple instances
*/
typedef struct WebRtcG722EncInst G722EncInst;
typedef struct WebRtcG722DecInst G722DecInst;
typedef struct WebRtcG722EncInst G722EncInst;
typedef struct WebRtcG722DecInst G722DecInst;
/*
* Comfort noise constants
*/
#define G722_WEBRTC_SPEECH 1
#define G722_WEBRTC_CNG 2
#define G722_WEBRTC_SPEECH 1
#define G722_WEBRTC_CNG 2
#ifdef __cplusplus
extern "C" {
#endif
/****************************************************************************
* WebRtcG722_CreateEncoder(...)
*
@ -43,8 +42,7 @@ extern "C" {
* Return value : 0 - Ok
* -1 - Error
*/
int16_t WebRtcG722_CreateEncoder(G722EncInst **G722enc_inst);
int16_t WebRtcG722_CreateEncoder(G722EncInst** G722enc_inst);
/****************************************************************************
* WebRtcG722_EncoderInit(...)
@ -59,8 +57,7 @@ int16_t WebRtcG722_CreateEncoder(G722EncInst **G722enc_inst);
* -1 - Error
*/
int16_t WebRtcG722_EncoderInit(G722EncInst *G722enc_inst);
int16_t WebRtcG722_EncoderInit(G722EncInst* G722enc_inst);
/****************************************************************************
* WebRtcG722_FreeEncoder(...)
@ -73,9 +70,7 @@ int16_t WebRtcG722_EncoderInit(G722EncInst *G722enc_inst);
* Return value : 0 - Ok
* -1 - Error
*/
int WebRtcG722_FreeEncoder(G722EncInst *G722enc_inst);
int WebRtcG722_FreeEncoder(G722EncInst* G722enc_inst);
/****************************************************************************
* WebRtcG722_Encode(...)
@ -99,7 +94,6 @@ size_t WebRtcG722_Encode(G722EncInst* G722enc_inst,
size_t len,
uint8_t* encoded);
/****************************************************************************
* WebRtcG722_CreateDecoder(...)
*
@ -111,7 +105,7 @@ size_t WebRtcG722_Encode(G722EncInst* G722enc_inst,
* Return value : 0 - Ok
* -1 - Error
*/
int16_t WebRtcG722_CreateDecoder(G722DecInst **G722dec_inst);
int16_t WebRtcG722_CreateDecoder(G722DecInst** G722dec_inst);
/****************************************************************************
* WebRtcG722_DecoderInit(...)
@ -136,8 +130,7 @@ void WebRtcG722_DecoderInit(G722DecInst* inst);
* -1 - Error
*/
int WebRtcG722_FreeDecoder(G722DecInst *G722dec_inst);
int WebRtcG722_FreeDecoder(G722DecInst* G722dec_inst);
/****************************************************************************
* WebRtcG722_Decode(...)
@ -159,11 +152,11 @@ int WebRtcG722_FreeDecoder(G722DecInst *G722dec_inst);
* Return value : Samples in decoded vector
*/
size_t WebRtcG722_Decode(G722DecInst *G722dec_inst,
size_t WebRtcG722_Decode(G722DecInst* G722dec_inst,
const uint8_t* encoded,
size_t len,
int16_t *decoded,
int16_t *speechType);
int16_t* decoded,
int16_t* speechType);
/****************************************************************************
* WebRtcG722_Version(...)
@ -171,12 +164,10 @@ size_t WebRtcG722_Decode(G722DecInst *G722dec_inst,
* Get a string with the current version of the codec
*/
int16_t WebRtcG722_Version(char *versionStr, short len);
int16_t WebRtcG722_Version(char* versionStr, short len);
#ifdef __cplusplus
}
#endif
#endif /* MODULES_AUDIO_CODING_CODECS_G722_G722_INTERFACE_H_ */

View File

@ -22,137 +22,135 @@
/* Runtime statistics */
#include <time.h>
#define CLOCKS_PER_SEC_G722 100000
#define CLOCKS_PER_SEC_G722 100000
// Forward declaration
typedef struct WebRtcG722EncInst G722EncInst;
typedef struct WebRtcG722DecInst G722DecInst;
typedef struct WebRtcG722EncInst G722EncInst;
typedef struct WebRtcG722DecInst G722DecInst;
/* function for reading audio data from PCM file */
bool readframe(int16_t *data, FILE *inp, size_t length)
{
size_t rlen = fread(data, sizeof(int16_t), length, inp);
if (rlen >= length)
return false;
memset(data + rlen, 0, (length - rlen) * sizeof(int16_t));
return true;
bool readframe(int16_t* data, FILE* inp, size_t length) {
size_t rlen = fread(data, sizeof(int16_t), length, inp);
if (rlen >= length)
return false;
memset(data + rlen, 0, (length - rlen) * sizeof(int16_t));
return true;
}
int main(int argc, char* argv[])
{
char inname[60], outbit[40], outname[40];
FILE *inp, *outbitp, *outp;
int main(int argc, char* argv[]) {
char inname[60], outbit[40], outname[40];
FILE *inp, *outbitp, *outp;
int framecnt;
bool endfile;
size_t framelength = 160;
G722EncInst *G722enc_inst;
G722DecInst *G722dec_inst;
int framecnt;
bool endfile;
size_t framelength = 160;
G722EncInst* G722enc_inst;
G722DecInst* G722dec_inst;
/* Runtime statistics */
double starttime;
double runtime = 0;
double length_file;
/* Runtime statistics */
double starttime;
double runtime = 0;
double length_file;
size_t stream_len = 0;
int16_t shortdata[960];
int16_t decoded[960];
uint8_t streamdata[80 * 6];
int16_t speechType[1];
size_t stream_len = 0;
int16_t shortdata[960];
int16_t decoded[960];
uint8_t streamdata[80 * 6];
int16_t speechType[1];
/* handling wrong input arguments in the command line */
if (argc!=5) {
printf("\n\nWrong number of arguments or flag values.\n\n");
/* handling wrong input arguments in the command line */
if (argc != 5) {
printf("\n\nWrong number of arguments or flag values.\n\n");
printf("\n");
printf("Usage:\n\n");
printf("./testG722.exe framelength infile outbitfile outspeechfile \n\n");
printf("with:\n");
printf("framelength : Framelength in samples.\n\n");
printf("infile : Normal speech input file\n\n");
printf("outbitfile : Bitstream output file\n\n");
printf("outspeechfile: Speech output file\n\n");
exit(0);
printf("\n");
printf("Usage:\n\n");
printf("./testG722.exe framelength infile outbitfile outspeechfile \n\n");
printf("with:\n");
printf("framelength : Framelength in samples.\n\n");
printf("infile : Normal speech input file\n\n");
printf("outbitfile : Bitstream output file\n\n");
printf("outspeechfile: Speech output file\n\n");
exit(0);
}
/* Get frame length */
int framelength_int = atoi(argv[1]);
if (framelength_int < 0) {
printf(" G.722: Invalid framelength %d.\n", framelength_int);
exit(1);
}
framelength = static_cast<size_t>(framelength_int);
/* Get Input and Output files */
sscanf(argv[2], "%s", inname);
sscanf(argv[3], "%s", outbit);
sscanf(argv[4], "%s", outname);
if ((inp = fopen(inname, "rb")) == NULL) {
printf(" G.722: Cannot read file %s.\n", inname);
exit(1);
}
if ((outbitp = fopen(outbit, "wb")) == NULL) {
printf(" G.722: Cannot write file %s.\n", outbit);
exit(1);
}
if ((outp = fopen(outname, "wb")) == NULL) {
printf(" G.722: Cannot write file %s.\n", outname);
exit(1);
}
printf("\nInput:%s\nOutput bitstream:%s\nOutput:%s\n", inname, outbit,
outname);
/* Create and init */
WebRtcG722_CreateEncoder((G722EncInst**)&G722enc_inst);
WebRtcG722_CreateDecoder((G722DecInst**)&G722dec_inst);
WebRtcG722_EncoderInit((G722EncInst*)G722enc_inst);
WebRtcG722_DecoderInit((G722DecInst*)G722dec_inst);
/* Initialize encoder and decoder */
framecnt = 0;
endfile = false;
while (!endfile) {
framecnt++;
/* Read speech block */
endfile = readframe(shortdata, inp, framelength);
/* Start clock before call to encoder and decoder */
starttime = clock() / (double)CLOCKS_PER_SEC_G722;
/* G.722 encoding + decoding */
stream_len = WebRtcG722_Encode((G722EncInst*)G722enc_inst, shortdata,
framelength, streamdata);
WebRtcG722_Decode(G722dec_inst, streamdata, stream_len, decoded,
speechType);
/* Stop clock after call to encoder and decoder */
runtime += (double)((clock() / (double)CLOCKS_PER_SEC_G722) - starttime);
/* Write coded bits to file */
if (fwrite(streamdata, sizeof(short), stream_len / 2, outbitp) !=
stream_len / 2) {
return -1;
}
/* Get frame length */
int framelength_int = atoi(argv[1]);
if (framelength_int < 0) {
printf(" G.722: Invalid framelength %d.\n", framelength_int);
exit(1);
/* Write coded speech to file */
if (fwrite(decoded, sizeof(short), framelength, outp) != framelength) {
return -1;
}
framelength = static_cast<size_t>(framelength_int);
}
/* Get Input and Output files */
sscanf(argv[2], "%s", inname);
sscanf(argv[3], "%s", outbit);
sscanf(argv[4], "%s", outname);
WebRtcG722_FreeEncoder((G722EncInst*)G722enc_inst);
WebRtcG722_FreeDecoder((G722DecInst*)G722dec_inst);
if ((inp = fopen(inname,"rb")) == NULL) {
printf(" G.722: Cannot read file %s.\n", inname);
exit(1);
}
if ((outbitp = fopen(outbit,"wb")) == NULL) {
printf(" G.722: Cannot write file %s.\n", outbit);
exit(1);
}
if ((outp = fopen(outname,"wb")) == NULL) {
printf(" G.722: Cannot write file %s.\n", outname);
exit(1);
}
printf("\nInput:%s\nOutput bitstream:%s\nOutput:%s\n", inname, outbit, outname);
length_file = ((double)framecnt * (double)framelength / 16000);
printf("\n\nLength of speech file: %.1f s\n", length_file);
printf("Time to run G.722: %.2f s (%.2f %% of realtime)\n\n", runtime,
(100 * runtime / length_file));
printf("---------------------END----------------------\n");
/* Create and init */
WebRtcG722_CreateEncoder((G722EncInst **)&G722enc_inst);
WebRtcG722_CreateDecoder((G722DecInst **)&G722dec_inst);
WebRtcG722_EncoderInit((G722EncInst *)G722enc_inst);
WebRtcG722_DecoderInit((G722DecInst *)G722dec_inst);
fclose(inp);
fclose(outbitp);
fclose(outp);
/* Initialize encoder and decoder */
framecnt = 0;
endfile = false;
while (!endfile) {
framecnt++;
/* Read speech block */
endfile = readframe(shortdata, inp, framelength);
/* Start clock before call to encoder and decoder */
starttime = clock()/(double)CLOCKS_PER_SEC_G722;
/* G.722 encoding + decoding */
stream_len = WebRtcG722_Encode((G722EncInst *)G722enc_inst, shortdata, framelength, streamdata);
WebRtcG722_Decode(G722dec_inst, streamdata, stream_len, decoded,
speechType);
/* Stop clock after call to encoder and decoder */
runtime += (double)((clock()/(double)CLOCKS_PER_SEC_G722)-starttime);
/* Write coded bits to file */
if (fwrite(streamdata, sizeof(short), stream_len / 2, outbitp) !=
stream_len / 2) {
return -1;
}
/* Write coded speech to file */
if (fwrite(decoded, sizeof(short), framelength, outp) !=
framelength) {
return -1;
}
}
WebRtcG722_FreeEncoder((G722EncInst *)G722enc_inst);
WebRtcG722_FreeDecoder((G722DecInst *)G722dec_inst);
length_file = ((double)framecnt*(double)framelength/16000);
printf("\n\nLength of speech file: %.1f s\n", length_file);
printf("Time to run G.722: %.2f s (%.2f %% of realtime)\n\n", runtime, (100*runtime/length_file));
printf("---------------------END----------------------\n");
fclose(inp);
fclose(outbitp);
fclose(outp);
return 0;
return 0;
}

View File

@ -27,13 +27,13 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_AbsQuant(
IlbcEncoder *iLBCenc_inst,
IlbcEncoder* iLBCenc_inst,
/* (i) Encoder instance */
iLBC_bits *iLBC_encbits, /* (i/o) Encoded bits (outputs idxForMax
iLBC_bits* iLBC_encbits, /* (i/o) Encoded bits (outputs idxForMax
and idxVec, uses state_first as
input) */
int16_t *in, /* (i) vector to encode */
int16_t *weightDenum /* (i) denominator of synthesis filter */
);
int16_t* in, /* (i) vector to encode */
int16_t* weightDenum /* (i) denominator of synthesis filter */
);
#endif

View File

@ -26,8 +26,10 @@
* (subrutine for WebRtcIlbcfix_StateSearch)
*---------------------------------------------------------------*/
void WebRtcIlbcfix_AbsQuantLoop(int16_t *syntOutIN, int16_t *in_weightedIN,
int16_t *weightDenumIN, size_t *quantLenIN,
int16_t *idxVecIN);
void WebRtcIlbcfix_AbsQuantLoop(int16_t* syntOutIN,
int16_t* in_weightedIN,
int16_t* weightDenumIN,
size_t* quantLenIN,
int16_t* idxVecIN);
#endif

View File

@ -33,10 +33,10 @@ bool AudioDecoderIlbcImpl::HasDecodePlc() const {
}
int AudioDecoderIlbcImpl::DecodeInternal(const uint8_t* encoded,
size_t encoded_len,
int sample_rate_hz,
int16_t* decoded,
SpeechType* speech_type) {
size_t encoded_len,
int sample_rate_hz,
int16_t* decoded,
SpeechType* speech_type) {
RTC_DCHECK_EQ(sample_rate_hz, 8000);
int16_t temp_type = 1; // Default is speech.
int ret = WebRtcIlbcfix_Decode(dec_state_, encoded, encoded_len, decoded,
@ -86,10 +86,9 @@ std::vector<AudioDecoder::ParseResult> AudioDecoderIlbcImpl::ParsePayload(
} else {
size_t byte_offset;
uint32_t timestamp_offset;
for (byte_offset = 0, timestamp_offset = 0;
byte_offset < payload.size();
for (byte_offset = 0, timestamp_offset = 0; byte_offset < payload.size();
byte_offset += bytes_per_frame,
timestamp_offset += timestamps_per_frame) {
timestamp_offset += timestamps_per_frame) {
std::unique_ptr<EncodedAudioFrame> frame(new LegacyEncodedAudioFrame(
this, rtc::Buffer(payload.data() + byte_offset, bytes_per_frame)));
results.emplace_back(timestamp + timestamp_offset, 0, std::move(frame));

View File

@ -89,7 +89,6 @@ AudioEncoder::EncodedInfo AudioEncoderIlbcImpl::EncodeImpl(
uint32_t rtp_timestamp,
rtc::ArrayView<const int16_t> audio,
rtc::Buffer* encoded) {
// Save timestamp if starting a new packet.
if (num_10ms_frames_buffered_ == 0)
first_timestamp_in_buffer_ = rtp_timestamp;
@ -107,19 +106,15 @@ AudioEncoder::EncodedInfo AudioEncoderIlbcImpl::EncodeImpl(
// Encode buffered input.
RTC_DCHECK_EQ(num_10ms_frames_buffered_, num_10ms_frames_per_packet_);
num_10ms_frames_buffered_ = 0;
size_t encoded_bytes =
encoded->AppendData(
RequiredOutputSizeBytes(),
[&] (rtc::ArrayView<uint8_t> encoded) {
const int r = WebRtcIlbcfix_Encode(
encoder_,
input_buffer_,
kSampleRateHz / 100 * num_10ms_frames_per_packet_,
encoded.data());
RTC_CHECK_GE(r, 0);
size_t encoded_bytes = encoded->AppendData(
RequiredOutputSizeBytes(), [&](rtc::ArrayView<uint8_t> encoded) {
const int r = WebRtcIlbcfix_Encode(
encoder_, input_buffer_,
kSampleRateHz / 100 * num_10ms_frames_per_packet_, encoded.data());
RTC_CHECK_GE(r, 0);
return static_cast<size_t>(r);
});
return static_cast<size_t>(r);
});
RTC_DCHECK_EQ(encoded_bytes, RequiredOutputSizeBytes());
@ -135,20 +130,24 @@ void AudioEncoderIlbcImpl::Reset() {
if (encoder_)
RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderFree(encoder_));
RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderCreate(&encoder_));
const int encoder_frame_size_ms = frame_size_ms_ > 30
? frame_size_ms_ / 2
: frame_size_ms_;
const int encoder_frame_size_ms =
frame_size_ms_ > 30 ? frame_size_ms_ / 2 : frame_size_ms_;
RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderInit(encoder_, encoder_frame_size_ms));
num_10ms_frames_buffered_ = 0;
}
size_t AudioEncoderIlbcImpl::RequiredOutputSizeBytes() const {
switch (num_10ms_frames_per_packet_) {
case 2: return 38;
case 3: return 50;
case 4: return 2 * 38;
case 6: return 2 * 50;
default: FATAL();
case 2:
return 38;
case 3:
return 50;
case 4:
return 2 * 38;
case 6:
return 2 * 50;
default:
FATAL();
}
}

View File

@ -26,16 +26,16 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_AugmentedCbCorr(
int16_t *target, /* (i) Target vector */
int16_t *buffer, /* (i) Memory buffer */
int16_t *interpSamples, /* (i) buffer with
int16_t* target, /* (i) Target vector */
int16_t* buffer, /* (i) Memory buffer */
int16_t* interpSamples, /* (i) buffer with
interpolated samples */
int32_t *crossDot, /* (o) The cross correlation between
the target and the Augmented
vector */
size_t low, /* (i) Lag to start from (typically
20) */
size_t high, /* (i) Lag to end at (typically 39 */
int scale); /* (i) Scale factor to use for the crossDot */
int32_t* crossDot, /* (o) The cross correlation between
the target and the Augmented
vector */
size_t low, /* (i) Lag to start from (typically
20) */
size_t high, /* (i) Lag to end at (typically 39 */
int scale); /* (i) Scale factor to use for the crossDot */
#endif

View File

@ -26,11 +26,11 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_BwExpand(
int16_t *out, /* (o) the bandwidth expanded lpc coefficients */
int16_t *in, /* (i) the lpc coefficients before bandwidth
expansion */
int16_t *coef, /* (i) the bandwidth expansion factor Q15 */
int16_t* out, /* (o) the bandwidth expanded lpc coefficients */
int16_t* in, /* (i) the lpc coefficients before bandwidth
expansion */
int16_t* coef, /* (i) the bandwidth expansion factor Q15 */
int16_t length /* (i) the length of lpc coefficient vectors */
);
);
#endif

View File

@ -21,14 +21,14 @@
void WebRtcIlbcfix_CbMemEnergy(
size_t range,
int16_t *CB, /* (i) The CB memory (1:st section) */
int16_t *filteredCB, /* (i) The filtered CB memory (2:nd section) */
size_t lMem, /* (i) Length of the CB memory */
size_t lTarget, /* (i) Length of the target vector */
int16_t *energyW16, /* (o) Energy in the CB vectors */
int16_t *energyShifts, /* (o) Shift value of the energy */
int scale, /* (i) The scaling of all energy values */
size_t base_size /* (i) Index to where energy values should be stored */
);
int16_t* CB, /* (i) The CB memory (1:st section) */
int16_t* filteredCB, /* (i) The filtered CB memory (2:nd section) */
size_t lMem, /* (i) Length of the CB memory */
size_t lTarget, /* (i) Length of the target vector */
int16_t* energyW16, /* (o) Energy in the CB vectors */
int16_t* energyShifts, /* (o) Shift value of the energy */
int scale, /* (i) The scaling of all energy values */
size_t base_size /* (i) Index to where energy values should be stored */
);
#endif

View File

@ -20,12 +20,12 @@
#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_AUGMENTATION_H_
void WebRtcIlbcfix_CbMemEnergyAugmentation(
int16_t *interpSamples, /* (i) The interpolated samples */
int16_t *CBmem, /* (i) The CB memory */
int scale, /* (i) The scaling of all energy values */
size_t base_size, /* (i) Index to where energy values should be stored */
int16_t *energyW16, /* (o) Energy in the CB vectors */
int16_t *energyShifts /* (o) Shift value of the energy */
);
int16_t* interpSamples, /* (i) The interpolated samples */
int16_t* CBmem, /* (i) The CB memory */
int scale, /* (i) The scaling of all energy values */
size_t base_size, /* (i) Index to where energy values should be stored */
int16_t* energyW16, /* (o) Energy in the CB vectors */
int16_t* energyShifts /* (o) Shift value of the energy */
);
#endif

View File

@ -20,14 +20,14 @@
#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_CALC_H_
void WebRtcIlbcfix_CbMemEnergyCalc(
int32_t energy, /* (i) input start energy */
size_t range, /* (i) number of iterations */
int16_t *ppi, /* (i) input pointer 1 */
int16_t *ppo, /* (i) input pointer 2 */
int16_t *energyW16, /* (o) Energy in the CB vectors */
int16_t *energyShifts, /* (o) Shift value of the energy */
int scale, /* (i) The scaling of all energy values */
size_t base_size /* (i) Index to where energy values should be stored */
);
int32_t energy, /* (i) input start energy */
size_t range, /* (i) number of iterations */
int16_t* ppi, /* (i) input pointer 1 */
int16_t* ppo, /* (i) input pointer 2 */
int16_t* energyW16, /* (o) Energy in the CB vectors */
int16_t* energyShifts, /* (o) Shift value of the energy */
int scale, /* (i) The scaling of all energy values */
size_t base_size /* (i) Index to where energy values should be stored */
);
#endif

View File

@ -20,16 +20,16 @@
#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_SEARCH_H_
void WebRtcIlbcfix_CbSearch(
IlbcEncoder *iLBCenc_inst,
IlbcEncoder* iLBCenc_inst,
/* (i) the encoder state structure */
int16_t *index, /* (o) Codebook indices */
int16_t *gain_index, /* (o) Gain quantization indices */
int16_t *intarget, /* (i) Target vector for encoding */
int16_t *decResidual,/* (i) Decoded residual for codebook construction */
size_t lMem, /* (i) Length of buffer */
size_t lTarget, /* (i) Length of vector */
int16_t *weightDenum,/* (i) weighting filter coefficients in Q12 */
size_t block /* (i) the subblock number */
);
int16_t* index, /* (o) Codebook indices */
int16_t* gain_index, /* (o) Gain quantization indices */
int16_t* intarget, /* (i) Target vector for encoding */
int16_t* decResidual, /* (i) Decoded residual for codebook construction */
size_t lMem, /* (i) Length of buffer */
size_t lTarget, /* (i) Length of vector */
int16_t* weightDenum, /* (i) weighting filter coefficients in Q12 */
size_t block /* (i) the subblock number */
);
#endif

View File

@ -22,19 +22,19 @@
#include "modules/audio_coding/codecs/ilbc/defines.h"
void WebRtcIlbcfix_CbSearchCore(
int32_t *cDot, /* (i) Cross Correlation */
size_t range, /* (i) Search range */
int16_t stage, /* (i) Stage of this search */
int16_t *inverseEnergy, /* (i) Inversed energy */
int16_t *inverseEnergyShift, /* (i) Shifts of inversed energy
int32_t* cDot, /* (i) Cross Correlation */
size_t range, /* (i) Search range */
int16_t stage, /* (i) Stage of this search */
int16_t* inverseEnergy, /* (i) Inversed energy */
int16_t* inverseEnergyShift, /* (i) Shifts of inversed energy
with the offset 2*16-29 */
int32_t *Crit, /* (o) The criteria */
size_t *bestIndex, /* (o) Index that corresponds to
maximum criteria (in this
vector) */
int32_t *bestCrit, /* (o) Value of critera for the
chosen index */
int16_t *bestCritSh); /* (o) The domain of the chosen
criteria */
int32_t* Crit, /* (o) The criteria */
size_t* bestIndex, /* (o) Index that corresponds to
maximum criteria (in this
vector) */
int32_t* bestCrit, /* (o) Value of critera for the
chosen index */
int16_t* bestCritSh); /* (o) The domain of the chosen
criteria */
#endif

View File

@ -22,17 +22,17 @@
#include "modules/audio_coding/codecs/ilbc/defines.h"
void WebRtcIlbcfix_CbUpdateBestIndex(
int32_t CritNew, /* (i) New Potentially best Criteria */
int16_t CritNewSh, /* (i) Shift value of above Criteria */
size_t IndexNew, /* (i) Index of new Criteria */
int32_t cDotNew, /* (i) Cross dot of new index */
int16_t invEnergyNew, /* (i) Inversed energy new index */
int16_t energyShiftNew, /* (i) Energy shifts of new index */
int32_t *CritMax, /* (i/o) Maximum Criteria (so far) */
int16_t *shTotMax, /* (i/o) Shifts of maximum criteria */
size_t *bestIndex, /* (i/o) Index that corresponds to
maximum criteria */
int16_t *bestGain); /* (i/o) Gain in Q14 that corresponds
to maximum criteria */
int32_t CritNew, /* (i) New Potentially best Criteria */
int16_t CritNewSh, /* (i) Shift value of above Criteria */
size_t IndexNew, /* (i) Index of new Criteria */
int32_t cDotNew, /* (i) Cross dot of new index */
int16_t invEnergyNew, /* (i) Inversed energy new index */
int16_t energyShiftNew, /* (i) Energy shifts of new index */
int32_t* CritMax, /* (i/o) Maximum Criteria (so far) */
int16_t* shTotMax, /* (i/o) Shifts of maximum criteria */
size_t* bestIndex, /* (i/o) Index that corresponds to
maximum criteria */
int16_t* bestGain); /* (i/o) Gain in Q14 that corresponds
to maximum criteria */
#endif

View File

@ -30,8 +30,8 @@
int16_t WebRtcIlbcfix_Chebyshev(
/* (o) Result of C(x) */
int16_t x, /* (i) Value to the Chevyshev polynomial */
int16_t *f /* (i) The coefficients in the polynomial */
);
int16_t x, /* (i) Value to the Chevyshev polynomial */
int16_t* f /* (i) The coefficients in the polynomial */
);
#endif

View File

@ -26,14 +26,13 @@
* of last subframe at given lag.
*---------------------------------------------------------------*/
void WebRtcIlbcfix_CompCorr(
int32_t *corr, /* (o) cross correlation */
int32_t *ener, /* (o) energy */
int16_t *buffer, /* (i) signal buffer */
size_t lag, /* (i) pitch lag */
size_t bLen, /* (i) length of buffer */
size_t sRange, /* (i) correlation search length */
int16_t scale /* (i) number of rightshifts to use */
void WebRtcIlbcfix_CompCorr(int32_t* corr, /* (o) cross correlation */
int32_t* ener, /* (o) energy */
int16_t* buffer, /* (i) signal buffer */
size_t lag, /* (i) pitch lag */
size_t bLen, /* (i) length of buffer */
size_t sRange, /* (i) correlation search length */
int16_t scale /* (i) number of rightshifts to use */
);
#endif

View File

@ -79,7 +79,8 @@ extern const int16_t WebRtcIlbcfix_kAlpha[];
/* enhancer definitions */
extern const int16_t WebRtcIlbcfix_kEnhPolyPhaser[ENH_UPS0][ENH_FLO_MULT2_PLUS1];
extern const int16_t WebRtcIlbcfix_kEnhPolyPhaser[ENH_UPS0]
[ENH_FLO_MULT2_PLUS1];
extern const int16_t WebRtcIlbcfix_kEnhWt[];
extern const size_t WebRtcIlbcfix_kEnhPlocs[];

View File

@ -27,8 +27,8 @@
*----------------------------------------------------------------*/
void WebRtcIlbcfix_CreateAugmentedVec(
size_t index, /* (i) Index for the augmented vector to be
created */
size_t index, /* (i) Index for the augmented vector to be
created */
const int16_t* buffer, /* (i) Pointer to the end of the codebook memory
that is used for creation of the augmented
codebook */

View File

@ -31,8 +31,8 @@ int WebRtcIlbcfix_DecodeImpl(
const uint16_t* bytes, /* (i) encoded signal bits */
IlbcDecoder* iLBCdec_inst, /* (i/o) the decoder state
structure */
int16_t mode /* (i) 0: bad packet, PLC,
1: normal */
int16_t mode /* (i) 0: bad packet, PLC,
1: normal */
) RTC_WARN_UNUSED_RESULT;
#endif

View File

@ -26,13 +26,13 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_DecoderInterpolateLsp(
int16_t *syntdenum, /* (o) synthesis filter coefficients */
int16_t *weightdenum, /* (o) weighting denumerator
int16_t* syntdenum, /* (o) synthesis filter coefficients */
int16_t* weightdenum, /* (o) weighting denumerator
coefficients */
int16_t *lsfdeq, /* (i) dequantized lsf coefficients */
int16_t length, /* (i) length of lsf coefficient vector */
IlbcDecoder *iLBCdec_inst
int16_t* lsfdeq, /* (i) dequantized lsf coefficients */
int16_t length, /* (i) length of lsf coefficient vector */
IlbcDecoder* iLBCdec_inst
/* (i) the decoder state structure */
);
);
#endif

View File

@ -25,103 +25,109 @@
/* general codec settings */
#define FS 8000
#define BLOCKL_20MS 160
#define BLOCKL_30MS 240
#define BLOCKL_MAX 240
#define NSUB_20MS 4
#define NSUB_30MS 6
#define NSUB_MAX 6
#define NASUB_20MS 2
#define NASUB_30MS 4
#define NASUB_MAX 4
#define SUBL 40
#define STATE_LEN 80
#define STATE_SHORT_LEN_30MS 58
#define STATE_SHORT_LEN_20MS 57
#define FS 8000
#define BLOCKL_20MS 160
#define BLOCKL_30MS 240
#define BLOCKL_MAX 240
#define NSUB_20MS 4
#define NSUB_30MS 6
#define NSUB_MAX 6
#define NASUB_20MS 2
#define NASUB_30MS 4
#define NASUB_MAX 4
#define SUBL 40
#define STATE_LEN 80
#define STATE_SHORT_LEN_30MS 58
#define STATE_SHORT_LEN_20MS 57
/* LPC settings */
#define LPC_FILTERORDER 10
#define LPC_LOOKBACK 60
#define LPC_N_20MS 1
#define LPC_N_30MS 2
#define LPC_N_MAX 2
#define LPC_ASYMDIFF 20
#define LSF_NSPLIT 3
#define LSF_NUMBER_OF_STEPS 4
#define LPC_HALFORDER 5
#define LPC_FILTERORDER 10
#define LPC_LOOKBACK 60
#define LPC_N_20MS 1
#define LPC_N_30MS 2
#define LPC_N_MAX 2
#define LPC_ASYMDIFF 20
#define LSF_NSPLIT 3
#define LSF_NUMBER_OF_STEPS 4
#define LPC_HALFORDER 5
#define COS_GRID_POINTS 60
/* cb settings */
#define CB_NSTAGES 3
#define CB_EXPAND 2
#define CB_MEML 147
#define CB_FILTERLEN (2*4)
#define CB_HALFFILTERLEN 4
#define CB_RESRANGE 34
#define CB_MAXGAIN_FIXQ6 83 /* error = -0.24% */
#define CB_MAXGAIN_FIXQ14 21299
#define CB_NSTAGES 3
#define CB_EXPAND 2
#define CB_MEML 147
#define CB_FILTERLEN (2 * 4)
#define CB_HALFFILTERLEN 4
#define CB_RESRANGE 34
#define CB_MAXGAIN_FIXQ6 83 /* error = -0.24% */
#define CB_MAXGAIN_FIXQ14 21299
/* enhancer */
#define ENH_BLOCKL 80 /* block length */
#define ENH_BLOCKL_HALF (ENH_BLOCKL/2)
#define ENH_HL 3 /* 2*ENH_HL+1 is number blocks
in said second sequence */
#define ENH_SLOP 2 /* max difference estimated and
correct pitch period */
#define ENH_PLOCSL 8 /* pitch-estimates and
pitch-locations buffer length */
#define ENH_OVERHANG 2
#define ENH_UPS0 4 /* upsampling rate */
#define ENH_FL0 3 /* 2*FLO+1 is the length of each filter */
#define ENH_FLO_MULT2_PLUS1 7
#define ENH_VECTL (ENH_BLOCKL+2*ENH_FL0)
#define ENH_CORRDIM (2*ENH_SLOP+1)
#define ENH_NBLOCKS (BLOCKL/ENH_BLOCKL)
#define ENH_NBLOCKS_EXTRA 5
#define ENH_NBLOCKS_TOT 8 /* ENH_NBLOCKS+ENH_NBLOCKS_EXTRA */
#define ENH_BUFL (ENH_NBLOCKS_TOT)*ENH_BLOCKL
#define ENH_BUFL_FILTEROVERHEAD 3
#define ENH_A0 819 /* Q14 */
#define ENH_A0_MINUS_A0A0DIV4 848256041 /* Q34 */
#define ENH_A0DIV2 26843546 /* Q30 */
#define ENH_BLOCKL 80 /* block length */
#define ENH_BLOCKL_HALF (ENH_BLOCKL / 2)
#define ENH_HL \
3 /* 2*ENH_HL+1 is number blocks \
in said second \
sequence */
#define ENH_SLOP \
2 /* max difference estimated and \
correct pitch period */
#define ENH_PLOCSL \
8 /* pitch-estimates and \
pitch-locations buffer \
length */
#define ENH_OVERHANG 2
#define ENH_UPS0 4 /* upsampling rate */
#define ENH_FL0 3 /* 2*FLO+1 is the length of each filter */
#define ENH_FLO_MULT2_PLUS1 7
#define ENH_VECTL (ENH_BLOCKL + 2 * ENH_FL0)
#define ENH_CORRDIM (2 * ENH_SLOP + 1)
#define ENH_NBLOCKS (BLOCKL / ENH_BLOCKL)
#define ENH_NBLOCKS_EXTRA 5
#define ENH_NBLOCKS_TOT 8 /* ENH_NBLOCKS+ENH_NBLOCKS_EXTRA */
#define ENH_BUFL (ENH_NBLOCKS_TOT) * ENH_BLOCKL
#define ENH_BUFL_FILTEROVERHEAD 3
#define ENH_A0 819 /* Q14 */
#define ENH_A0_MINUS_A0A0DIV4 848256041 /* Q34 */
#define ENH_A0DIV2 26843546 /* Q30 */
/* PLC */
/* Down sampling */
#define FILTERORDER_DS_PLUS1 7
#define DELAY_DS 3
#define FACTOR_DS 2
#define FILTERORDER_DS_PLUS1 7
#define DELAY_DS 3
#define FACTOR_DS 2
/* bit stream defs */
#define NO_OF_BYTES_20MS 38
#define NO_OF_BYTES_30MS 50
#define NO_OF_WORDS_20MS 19
#define NO_OF_WORDS_30MS 25
#define STATE_BITS 3
#define BYTE_LEN 8
#define ULP_CLASSES 3
#define NO_OF_BYTES_20MS 38
#define NO_OF_BYTES_30MS 50
#define NO_OF_WORDS_20MS 19
#define NO_OF_WORDS_30MS 25
#define STATE_BITS 3
#define BYTE_LEN 8
#define ULP_CLASSES 3
/* help parameters */
#define TWO_PI_FIX 25736 /* Q12 */
#define TWO_PI_FIX 25736 /* Q12 */
/* Constants for codebook search and creation */
#define ST_MEM_L_TBL 85
#define MEM_LF_TBL 147
#define ST_MEM_L_TBL 85
#define MEM_LF_TBL 147
/* Struct for the bits */
typedef struct iLBC_bits_t_ {
int16_t lsf[LSF_NSPLIT*LPC_N_MAX];
int16_t cb_index[CB_NSTAGES*(NASUB_MAX+1)]; /* First CB_NSTAGES values contains extra CB index */
int16_t gain_index[CB_NSTAGES*(NASUB_MAX+1)]; /* First CB_NSTAGES values contains extra CB gain */
int16_t lsf[LSF_NSPLIT * LPC_N_MAX];
int16_t cb_index[CB_NSTAGES * (NASUB_MAX + 1)]; /* First CB_NSTAGES values
contains extra CB index */
int16_t gain_index[CB_NSTAGES * (NASUB_MAX + 1)]; /* First CB_NSTAGES values
contains extra CB gain */
size_t idxForMax;
int16_t state_first;
int16_t idxVec[STATE_SHORT_LEN_30MS];
@ -131,7 +137,6 @@ typedef struct iLBC_bits_t_ {
/* type definition encoder instance */
typedef struct IlbcEncoder_ {
/* flag for frame size mode */
int16_t mode;
@ -172,7 +177,6 @@ typedef struct IlbcEncoder_ {
/* type definition decoder instance */
typedef struct IlbcDecoder_ {
/* flag for frame size mode */
int16_t mode;
@ -199,13 +203,13 @@ typedef struct IlbcDecoder_ {
int16_t prevScale, prevPLI;
size_t prevLag;
int16_t prevLpc[LPC_FILTERORDER+1];
int16_t prevResidual[NSUB_MAX*SUBL];
int16_t prevLpc[LPC_FILTERORDER + 1];
int16_t prevResidual[NSUB_MAX * SUBL];
int16_t seed;
/* previous synthesis filter parameters */
int16_t old_syntdenum[(LPC_FILTERORDER + 1)*NSUB_MAX];
int16_t old_syntdenum[(LPC_FILTERORDER + 1) * NSUB_MAX];
/* state of output HP filter */
int16_t hpimemx[2];
@ -213,7 +217,7 @@ typedef struct IlbcDecoder_ {
/* enhancer state information */
int use_enhancer;
int16_t enh_buf[ENH_BUFL+ENH_BUFL_FILTEROVERHEAD];
int16_t enh_buf[ENH_BUFL + ENH_BUFL_FILTEROVERHEAD];
size_t enh_period[ENH_NBLOCKS_TOT];
} IlbcDecoder;

View File

@ -27,15 +27,15 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_DoThePlc(
int16_t *PLCresidual, /* (o) concealed residual */
int16_t *PLClpc, /* (o) concealed LP parameters */
int16_t PLI, /* (i) packet loss indicator
0 - no PL, 1 = PL */
int16_t *decresidual, /* (i) decoded residual */
int16_t *lpc, /* (i) decoded LPC (only used for no PL) */
size_t inlag, /* (i) pitch lag */
IlbcDecoder *iLBCdec_inst
int16_t* PLCresidual, /* (o) concealed residual */
int16_t* PLClpc, /* (o) concealed LP parameters */
int16_t PLI, /* (i) packet loss indicator
0 - no PL, 1 = PL */
int16_t* decresidual, /* (i) decoded residual */
int16_t* lpc, /* (i) decoded LPC (only used for no PL) */
size_t inlag, /* (i) pitch lag */
IlbcDecoder* iLBCdec_inst
/* (i/o) decoder instance */
);
);
#endif

View File

@ -26,10 +26,10 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_EncodeImpl(
uint16_t *bytes, /* (o) encoded data bits iLBC */
const int16_t *block, /* (i) speech vector to encode */
IlbcEncoder *iLBCenc_inst /* (i/o) the general encoder
uint16_t* bytes, /* (o) encoded data bits iLBC */
const int16_t* block, /* (i) speech vector to encode */
IlbcEncoder* iLBCenc_inst /* (i/o) the general encoder
state */
);
);
#endif

View File

@ -24,9 +24,10 @@
/* Inverses the in vector in into Q29 domain */
void WebRtcIlbcfix_EnergyInverse(
int16_t *energy, /* (i/o) Energy and inverse
energy (in Q29) */
size_t noOfEnergies); /* (i) The length of the energy
vector */
int16_t*
energy, /* (i/o) Energy and inverse
energy (in Q29) */
size_t noOfEnergies); /* (i) The length of the energy
vector */
#endif

View File

@ -26,8 +26,8 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_EnhUpsample(
int32_t *useq1, /* (o) upsampled output sequence */
int16_t *seq1 /* (i) unupsampled sequence */
);
int32_t* useq1, /* (o) upsampled output sequence */
int16_t* seq1 /* (i) unupsampled sequence */
);
#endif

View File

@ -27,13 +27,13 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Enhancer(
int16_t *odata, /* (o) smoothed block, dimension blockl */
int16_t *idata, /* (i) data buffer used for enhancing */
size_t idatal, /* (i) dimension idata */
int16_t* odata, /* (o) smoothed block, dimension blockl */
int16_t* idata, /* (i) data buffer used for enhancing */
size_t idatal, /* (i) dimension idata */
size_t centerStartPos, /* (i) first sample current block within idata */
size_t *period, /* (i) pitch period array (pitch bward-in time) */
const size_t *plocs, /* (i) locations where period array values valid */
size_t periodl /* (i) dimension of period and plocs */
);
size_t* period, /* (i) pitch period array (pitch bward-in time) */
const size_t* plocs, /* (i) locations where period array values valid */
size_t periodl /* (i) dimension of period and plocs */
);
#endif

View File

@ -26,9 +26,8 @@
*---------------------------------------------------------------*/
size_t // (o) Estimated lag in end of in[]
WebRtcIlbcfix_EnhancerInterface(
int16_t* out, // (o) enhanced signal
const int16_t* in, // (i) unenhanced signal
IlbcDecoder* iLBCdec_inst); // (i) buffers etc
WebRtcIlbcfix_EnhancerInterface(int16_t* out, // (o) enhanced signal
const int16_t* in, // (i) unenhanced signal
IlbcDecoder* iLBCdec_inst); // (i) buffers etc
#endif

View File

@ -28,11 +28,11 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_FilteredCbVecs(
int16_t *cbvectors, /* (o) Codebook vector for the higher section */
int16_t *CBmem, /* (i) Codebook memory that is filtered to create a
second CB section */
size_t lMem, /* (i) Length of codebook memory */
size_t samples /* (i) Number of samples to filter */
);
int16_t* cbvectors, /* (o) Codebook vector for the higher section */
int16_t* CBmem, /* (i) Codebook memory that is filtered to create a
second CB section */
size_t lMem, /* (i) Length of codebook memory */
size_t samples /* (i) Number of samples to filter */
);
#endif

View File

@ -21,9 +21,9 @@
size_t WebRtcIlbcfix_FrameClassify(
/* (o) Index to the max-energy sub frame */
IlbcEncoder *iLBCenc_inst,
IlbcEncoder* iLBCenc_inst,
/* (i/o) the encoder state structure */
int16_t *residualFIX /* (i) lpc residual signal */
);
int16_t* residualFIX /* (i) lpc residual signal */
);
#endif

View File

@ -30,7 +30,7 @@ int16_t WebRtcIlbcfix_GainDequant(
/* (o) quantized gain value (Q14) */
int16_t index, /* (i) quantization index */
int16_t maxIn, /* (i) maximum of unquantized gain (Q14) */
int16_t stage /* (i) The stage of the search */
);
int16_t stage /* (i) The stage of the search */
);
#endif

View File

@ -25,11 +25,12 @@
* quantizer for the gain in the gain-shape coding of residual
*---------------------------------------------------------------*/
int16_t WebRtcIlbcfix_GainQuant( /* (o) quantized gain value */
int16_t gain, /* (i) gain value Q14 */
int16_t maxIn, /* (i) maximum of gain value Q14 */
int16_t stage, /* (i) The stage of the search */
int16_t *index /* (o) quantization index */
);
int16_t
WebRtcIlbcfix_GainQuant( /* (o) quantized gain value */
int16_t gain, /* (i) gain value Q14 */
int16_t maxIn, /* (i) maximum of gain value Q14 */
int16_t stage, /* (i) The stage of the search */
int16_t* index /* (o) quantization index */
);
#endif

View File

@ -40,8 +40,7 @@
* }
*---------------------------------------------------------------*/
void WebRtcIlbcfix_GetLspPoly(
int16_t *lsp, /* (i) LSP in Q15 */
int32_t *f); /* (o) polonymial in Q24 */
void WebRtcIlbcfix_GetLspPoly(int16_t* lsp, /* (i) LSP in Q15 */
int32_t* f); /* (o) polonymial in Q24 */
#endif

View File

@ -26,15 +26,15 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_GetSyncSeq(
int16_t *idata, /* (i) original data */
size_t idatal, /* (i) dimension of data */
int16_t* idata, /* (i) original data */
size_t idatal, /* (i) dimension of data */
size_t centerStartPos, /* (i) where current block starts */
size_t *period, /* (i) rough-pitch-period array (Q-2) */
const size_t *plocs, /* (i) where periods of period array are taken (Q-2) */
size_t periodl, /* (i) dimension period array */
size_t hl, /* (i) 2*hl+1 is the number of sequences */
int16_t *surround /* (i/o) The contribution from this sequence
summed with earlier contributions */
);
size_t* period, /* (i) rough-pitch-period array (Q-2) */
const size_t* plocs, /* (i) where periods of period array are taken (Q-2) */
size_t periodl, /* (i) dimension period array */
size_t hl, /* (i) 2*hl+1 is the number of sequences */
int16_t* surround /* (i/o) The contribution from this sequence
summed with earlier contributions */
);
#endif

View File

@ -22,13 +22,13 @@
#include "modules/audio_coding/codecs/ilbc/defines.h"
void WebRtcIlbcfix_HpInput(
int16_t *signal, /* (i/o) signal vector */
int16_t *ba, /* (i) B- and A-coefficients (2:nd order)
{b[0] b[1] b[2] -a[1] -a[2]} a[0]
is assumed to be 1.0 */
int16_t *y, /* (i/o) Filter state yhi[n-1] ylow[n-1]
yhi[n-2] ylow[n-2] */
int16_t *x, /* (i/o) Filter state x[n-1] x[n-2] */
int16_t* signal, /* (i/o) signal vector */
int16_t* ba, /* (i) B- and A-coefficients (2:nd order)
{b[0] b[1] b[2] -a[1] -a[2]}
a[0] is assumed to be 1.0 */
int16_t* y, /* (i/o) Filter state yhi[n-1] ylow[n-1]
yhi[n-2] ylow[n-2] */
int16_t* x, /* (i/o) Filter state x[n-1] x[n-2] */
size_t len); /* (i) Number of samples to filter */
#endif

View File

@ -22,13 +22,13 @@
#include "modules/audio_coding/codecs/ilbc/defines.h"
void WebRtcIlbcfix_HpOutput(
int16_t *signal, /* (i/o) signal vector */
int16_t *ba, /* (i) B- and A-coefficients (2:nd order)
{b[0] b[1] b[2] -a[1] -a[2]} a[0]
is assumed to be 1.0 */
int16_t *y, /* (i/o) Filter state yhi[n-1] ylow[n-1]
int16_t* signal, /* (i/o) signal vector */
int16_t* ba, /* (i) B- and A-coefficients (2:nd order)
{b[0] b[1] b[2] -a[1] -a[2]} a[0]
is assumed to be 1.0 */
int16_t* y, /* (i/o) Filter state yhi[n-1] ylow[n-1]
yhi[n-2] ylow[n-2] */
int16_t *x, /* (i/o) Filter state x[n-1] x[n-2] */
size_t len); /* (i) Number of samples to filter */
int16_t* x, /* (i/o) Filter state x[n-1] x[n-2] */
size_t len); /* (i) Number of samples to filter */
#endif

View File

@ -40,216 +40,214 @@ typedef struct iLBC_decinst_t_ IlbcDecoderInstance;
*/
#define ILBC_SPEECH 1
#define ILBC_CNG 2
#define ILBC_CNG 2
#ifdef __cplusplus
extern "C" {
#endif
/****************************************************************************
* WebRtcIlbcfix_XxxAssign(...)
*
* These functions assigns the encoder/decoder instance to the specified
* memory location
*
* Input:
* - XXX_xxxinst : Pointer to created instance that should be
* assigned
* - ILBCXXX_inst_Addr : Pointer to the desired memory space
* - size : The size that this structure occupies (in Word16)
*
* Return value : 0 - Ok
* -1 - Error
*/
/****************************************************************************
* WebRtcIlbcfix_XxxAssign(...)
*
* These functions assigns the encoder/decoder instance to the specified
* memory location
*
* Input:
* - XXX_xxxinst : Pointer to created instance that should be
* assigned
* - ILBCXXX_inst_Addr : Pointer to the desired memory space
* - size : The size that this structure occupies (in Word16)
*
* Return value : 0 - Ok
* -1 - Error
*/
int16_t WebRtcIlbcfix_EncoderAssign(IlbcEncoderInstance **iLBC_encinst,
int16_t *ILBCENC_inst_Addr,
int16_t *size);
int16_t WebRtcIlbcfix_DecoderAssign(IlbcDecoderInstance **iLBC_decinst,
int16_t *ILBCDEC_inst_Addr,
int16_t *size);
int16_t WebRtcIlbcfix_EncoderAssign(IlbcEncoderInstance** iLBC_encinst,
int16_t* ILBCENC_inst_Addr,
int16_t* size);
int16_t WebRtcIlbcfix_DecoderAssign(IlbcDecoderInstance** iLBC_decinst,
int16_t* ILBCDEC_inst_Addr,
int16_t* size);
/****************************************************************************
* WebRtcIlbcfix_XxxAssign(...)
*
* These functions create a instance to the specified structure
*
* Input:
* - XXX_inst : Pointer to created instance that should be created
*
* Return value : 0 - Ok
* -1 - Error
*/
/****************************************************************************
* WebRtcIlbcfix_XxxAssign(...)
*
* These functions create a instance to the specified structure
*
* Input:
* - XXX_inst : Pointer to created instance that should be created
*
* Return value : 0 - Ok
* -1 - Error
*/
int16_t WebRtcIlbcfix_EncoderCreate(IlbcEncoderInstance** iLBC_encinst);
int16_t WebRtcIlbcfix_DecoderCreate(IlbcDecoderInstance** iLBC_decinst);
int16_t WebRtcIlbcfix_EncoderCreate(IlbcEncoderInstance **iLBC_encinst);
int16_t WebRtcIlbcfix_DecoderCreate(IlbcDecoderInstance **iLBC_decinst);
/****************************************************************************
* WebRtcIlbcfix_XxxFree(...)
*
* These functions frees the dynamic memory of a specified instance
*
* Input:
* - XXX_inst : Pointer to created instance that should be freed
*
* Return value : 0 - Ok
* -1 - Error
*/
/****************************************************************************
* WebRtcIlbcfix_XxxFree(...)
*
* These functions frees the dynamic memory of a specified instance
*
* Input:
* - XXX_inst : Pointer to created instance that should be freed
*
* Return value : 0 - Ok
* -1 - Error
*/
int16_t WebRtcIlbcfix_EncoderFree(IlbcEncoderInstance* iLBC_encinst);
int16_t WebRtcIlbcfix_DecoderFree(IlbcDecoderInstance* iLBC_decinst);
int16_t WebRtcIlbcfix_EncoderFree(IlbcEncoderInstance *iLBC_encinst);
int16_t WebRtcIlbcfix_DecoderFree(IlbcDecoderInstance *iLBC_decinst);
/****************************************************************************
* WebRtcIlbcfix_EncoderInit(...)
*
* This function initializes a iLBC instance
*
* Input:
* - iLBCenc_inst : iLBC instance, i.e. the user that should receive
* be initialized
* - frameLen : The frame length of the codec 20/30 (ms)
*
* Return value : 0 - Ok
* -1 - Error
*/
int16_t WebRtcIlbcfix_EncoderInit(IlbcEncoderInstance* iLBCenc_inst,
int16_t frameLen);
/****************************************************************************
* WebRtcIlbcfix_EncoderInit(...)
*
* This function initializes a iLBC instance
*
* Input:
* - iLBCenc_inst : iLBC instance, i.e. the user that should receive
* be initialized
* - frameLen : The frame length of the codec 20/30 (ms)
*
* Return value : 0 - Ok
* -1 - Error
*/
/****************************************************************************
* WebRtcIlbcfix_Encode(...)
*
* This function encodes one iLBC frame. Input speech length has be a
* multiple of the frame length.
*
* Input:
* - iLBCenc_inst : iLBC instance, i.e. the user that should encode
* a package
* - speechIn : Input speech vector
* - len : Samples in speechIn (160, 240, 320 or 480)
*
* Output:
* - encoded : The encoded data vector
*
* Return value : >0 - Length (in bytes) of coded data
* -1 - Error
*/
int16_t WebRtcIlbcfix_EncoderInit(IlbcEncoderInstance *iLBCenc_inst,
int16_t frameLen);
int WebRtcIlbcfix_Encode(IlbcEncoderInstance* iLBCenc_inst,
const int16_t* speechIn,
size_t len,
uint8_t* encoded);
/****************************************************************************
* WebRtcIlbcfix_Encode(...)
*
* This function encodes one iLBC frame. Input speech length has be a
* multiple of the frame length.
*
* Input:
* - iLBCenc_inst : iLBC instance, i.e. the user that should encode
* a package
* - speechIn : Input speech vector
* - len : Samples in speechIn (160, 240, 320 or 480)
*
* Output:
* - encoded : The encoded data vector
*
* Return value : >0 - Length (in bytes) of coded data
* -1 - Error
*/
/****************************************************************************
* WebRtcIlbcfix_DecoderInit(...)
*
* This function initializes a iLBC instance with either 20 or 30 ms frames
* Alternatively the WebRtcIlbcfix_DecoderInit_XXms can be used. Then it's
* not needed to specify the frame length with a variable.
*
* Input:
* - IlbcDecoderInstance : iLBC decoder instance
* - frameLen : The frame length of the codec 20/30 (ms)
*
* Return value : 0 - Ok
* -1 - Error
*/
int WebRtcIlbcfix_Encode(IlbcEncoderInstance *iLBCenc_inst,
const int16_t *speechIn,
size_t len,
uint8_t* encoded);
int16_t WebRtcIlbcfix_DecoderInit(IlbcDecoderInstance* iLBCdec_inst,
int16_t frameLen);
void WebRtcIlbcfix_DecoderInit20Ms(IlbcDecoderInstance* iLBCdec_inst);
void WebRtcIlbcfix_Decoderinit30Ms(IlbcDecoderInstance* iLBCdec_inst);
/****************************************************************************
* WebRtcIlbcfix_DecoderInit(...)
*
* This function initializes a iLBC instance with either 20 or 30 ms frames
* Alternatively the WebRtcIlbcfix_DecoderInit_XXms can be used. Then it's
* not needed to specify the frame length with a variable.
*
* Input:
* - IlbcDecoderInstance : iLBC decoder instance
* - frameLen : The frame length of the codec 20/30 (ms)
*
* Return value : 0 - Ok
* -1 - Error
*/
/****************************************************************************
* WebRtcIlbcfix_Decode(...)
*
* This function decodes a packet with iLBC frame(s). Output speech length
* will be a multiple of 160 or 240 samples ((160 or 240)*frames/packet).
*
* Input:
* - iLBCdec_inst : iLBC instance, i.e. the user that should decode
* a packet
* - encoded : Encoded iLBC frame(s)
* - len : Bytes in encoded vector
*
* Output:
* - decoded : The decoded vector
* - speechType : 1 normal, 2 CNG
*
* Return value : >0 - Samples in decoded vector
* -1 - Error
*/
int16_t WebRtcIlbcfix_DecoderInit(IlbcDecoderInstance *iLBCdec_inst,
int16_t frameLen);
void WebRtcIlbcfix_DecoderInit20Ms(IlbcDecoderInstance* iLBCdec_inst);
void WebRtcIlbcfix_Decoderinit30Ms(IlbcDecoderInstance* iLBCdec_inst);
int WebRtcIlbcfix_Decode(IlbcDecoderInstance* iLBCdec_inst,
const uint8_t* encoded,
size_t len,
int16_t* decoded,
int16_t* speechType);
int WebRtcIlbcfix_Decode20Ms(IlbcDecoderInstance* iLBCdec_inst,
const uint8_t* encoded,
size_t len,
int16_t* decoded,
int16_t* speechType);
int WebRtcIlbcfix_Decode30Ms(IlbcDecoderInstance* iLBCdec_inst,
const uint8_t* encoded,
size_t len,
int16_t* decoded,
int16_t* speechType);
/****************************************************************************
* WebRtcIlbcfix_Decode(...)
*
* This function decodes a packet with iLBC frame(s). Output speech length
* will be a multiple of 160 or 240 samples ((160 or 240)*frames/packet).
*
* Input:
* - iLBCdec_inst : iLBC instance, i.e. the user that should decode
* a packet
* - encoded : Encoded iLBC frame(s)
* - len : Bytes in encoded vector
*
* Output:
* - decoded : The decoded vector
* - speechType : 1 normal, 2 CNG
*
* Return value : >0 - Samples in decoded vector
* -1 - Error
*/
/****************************************************************************
* WebRtcIlbcfix_DecodePlc(...)
*
* This function conducts PLC for iLBC frame(s). Output speech length
* will be a multiple of 160 or 240 samples.
*
* Input:
* - iLBCdec_inst : iLBC instance, i.e. the user that should perform
* a PLC
* - noOfLostFrames : Number of PLC frames to produce
*
* Output:
* - decoded : The "decoded" vector
*
* Return value : Samples in decoded PLC vector
*/
int WebRtcIlbcfix_Decode(IlbcDecoderInstance* iLBCdec_inst,
const uint8_t* encoded,
size_t len,
int16_t* decoded,
int16_t* speechType);
int WebRtcIlbcfix_Decode20Ms(IlbcDecoderInstance* iLBCdec_inst,
const uint8_t* encoded,
size_t len,
size_t WebRtcIlbcfix_DecodePlc(IlbcDecoderInstance* iLBCdec_inst,
int16_t* decoded,
int16_t* speechType);
int WebRtcIlbcfix_Decode30Ms(IlbcDecoderInstance* iLBCdec_inst,
const uint8_t* encoded,
size_t len,
int16_t* decoded,
int16_t* speechType);
size_t noOfLostFrames);
/****************************************************************************
* WebRtcIlbcfix_DecodePlc(...)
*
* This function conducts PLC for iLBC frame(s). Output speech length
* will be a multiple of 160 or 240 samples.
*
* Input:
* - iLBCdec_inst : iLBC instance, i.e. the user that should perform
* a PLC
* - noOfLostFrames : Number of PLC frames to produce
*
* Output:
* - decoded : The "decoded" vector
*
* Return value : Samples in decoded PLC vector
*/
/****************************************************************************
* WebRtcIlbcfix_NetEqPlc(...)
*
* This function updates the decoder when a packet loss has occured, but it
* does not produce any PLC data. Function can be used if another PLC method
* is used (i.e NetEq).
*
* Input:
* - iLBCdec_inst : iLBC instance that should be updated
* - noOfLostFrames : Number of lost frames
*
* Output:
* - decoded : The "decoded" vector (nothing in this case)
*
* Return value : Samples in decoded PLC vector
*/
size_t WebRtcIlbcfix_DecodePlc(IlbcDecoderInstance *iLBCdec_inst,
int16_t *decoded,
size_t noOfLostFrames);
size_t WebRtcIlbcfix_NetEqPlc(IlbcDecoderInstance* iLBCdec_inst,
int16_t* decoded,
size_t noOfLostFrames);
/****************************************************************************
* WebRtcIlbcfix_NetEqPlc(...)
*
* This function updates the decoder when a packet loss has occured, but it
* does not produce any PLC data. Function can be used if another PLC method
* is used (i.e NetEq).
*
* Input:
* - iLBCdec_inst : iLBC instance that should be updated
* - noOfLostFrames : Number of lost frames
*
* Output:
* - decoded : The "decoded" vector (nothing in this case)
*
* Return value : Samples in decoded PLC vector
*/
/****************************************************************************
* WebRtcIlbcfix_version(...)
*
* This function returns the version number of iLBC
*
* Output:
* - version : Version number of iLBC (maximum 20 char)
*/
size_t WebRtcIlbcfix_NetEqPlc(IlbcDecoderInstance *iLBCdec_inst,
int16_t *decoded,
size_t noOfLostFrames);
/****************************************************************************
* WebRtcIlbcfix_version(...)
*
* This function returns the version number of iLBC
*
* Output:
* - version : Version number of iLBC (maximum 20 char)
*/
void WebRtcIlbcfix_version(char *version);
void WebRtcIlbcfix_version(char* version);
#ifdef __cplusplus
}

View File

@ -71,7 +71,7 @@ class SplitIlbcTest : public ::testing::TestWithParam<std::pair<int, int> > {
TEST_P(SplitIlbcTest, NumFrames) {
AudioDecoderIlbcImpl decoder;
const size_t frame_length_samples = frame_length_ms_ * 8;
const auto generate_payload = [] (size_t payload_length_bytes) {
const auto generate_payload = [](size_t payload_length_bytes) {
rtc::Buffer payload(payload_length_bytes);
// Fill payload with increasing integers {0, 1, 2, ...}.
for (size_t i = 0; i < payload.size(); ++i) {
@ -104,7 +104,8 @@ TEST_P(SplitIlbcTest, NumFrames) {
// The maximum is defined by the largest payload length that can be uniquely
// resolved to a frame size of either 38 bytes (20 ms) or 50 bytes (30 ms).
INSTANTIATE_TEST_CASE_P(
IlbcTest, SplitIlbcTest,
IlbcTest,
SplitIlbcTest,
::testing::Values(std::pair<int, int>(1, 20), // 1 frame, 20 ms.
std::pair<int, int>(2, 20), // 2 frames, 20 ms.
std::pair<int, int>(3, 20), // And so on.

View File

@ -21,8 +21,7 @@
#include "modules/audio_coding/codecs/ilbc/defines.h"
void WebRtcIlbcfix_IndexConvDec(
int16_t *index /* (i/o) Codebook indexes */
void WebRtcIlbcfix_IndexConvDec(int16_t* index /* (i/o) Codebook indexes */
);
#endif

View File

@ -25,8 +25,7 @@
* Convert the codebook indexes to make the search easier
*---------------------------------------------------------------*/
void WebRtcIlbcfix_IndexConvEnc(
int16_t *index /* (i/o) Codebook indexes */
void WebRtcIlbcfix_IndexConvEnc(int16_t* index /* (i/o) Codebook indexes */
);
#endif

View File

@ -25,11 +25,12 @@
* Initiation of decoder instance.
*---------------------------------------------------------------*/
int WebRtcIlbcfix_InitDecode( /* (o) Number of decoded samples */
IlbcDecoder *iLBCdec_inst, /* (i/o) Decoder instance */
int16_t mode, /* (i) frame size mode */
int use_enhancer /* (i) 1 to use enhancer
0 to run without enhancer */
);
int WebRtcIlbcfix_InitDecode(/* (o) Number of decoded samples */
IlbcDecoder*
iLBCdec_inst, /* (i/o) Decoder instance */
int16_t mode, /* (i) frame size mode */
int use_enhancer /* (i) 1 to use enhancer
0 to run without enhancer */
);
#endif

View File

@ -25,9 +25,10 @@
* Initiation of encoder instance.
*---------------------------------------------------------------*/
int WebRtcIlbcfix_InitEncode( /* (o) Number of bytes encoded */
IlbcEncoder *iLBCenc_inst, /* (i/o) Encoder instance */
int16_t mode /* (i) frame size mode */
);
int WebRtcIlbcfix_InitEncode(/* (o) Number of bytes encoded */
IlbcEncoder*
iLBCenc_inst, /* (i/o) Encoder instance */
int16_t mode /* (i) frame size mode */
);
#endif

View File

@ -26,10 +26,10 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Interpolate(
int16_t *out, /* (o) output vector */
int16_t *in1, /* (i) first input vector */
int16_t *in2, /* (i) second input vector */
int16_t coef, /* (i) weight coefficient in Q14 */
int16_t* out, /* (o) output vector */
int16_t* in1, /* (i) first input vector */
int16_t* in2, /* (i) second input vector */
int16_t coef, /* (i) weight coefficient in Q14 */
int16_t length); /* (i) number of sample is vectors */
#endif

View File

@ -26,9 +26,9 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_InterpolateSamples(
int16_t *interpSamples, /* (o) The interpolated samples */
int16_t *CBmem, /* (i) The CB memory */
size_t lMem /* (i) Length of the CB memory */
);
int16_t* interpSamples, /* (o) The interpolated samples */
int16_t* CBmem, /* (i) The CB memory */
size_t lMem /* (i) Length of the CB memory */
);
#endif

View File

@ -26,14 +26,14 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_LpcEncode(
int16_t *syntdenum, /* (i/o) synthesis filter coefficients
before/after encoding */
int16_t *weightdenum, /* (i/o) weighting denumerator coefficients
int16_t* syntdenum, /* (i/o) synthesis filter coefficients
before/after encoding */
int16_t *lsf_index, /* (o) lsf quantization index */
int16_t *data, /* (i) Speech to do LPC analysis on */
IlbcEncoder *iLBCenc_inst
int16_t* weightdenum, /* (i/o) weighting denumerator coefficients
before/after encoding */
int16_t* lsf_index, /* (o) lsf quantization index */
int16_t* data, /* (i) Speech to do LPC analysis on */
IlbcEncoder* iLBCenc_inst
/* (i/o) the encoder state structure */
);
);
#endif

View File

@ -25,9 +25,8 @@
* check for stability of lsf coefficients
*---------------------------------------------------------------*/
int WebRtcIlbcfix_LsfCheck(
int16_t *lsf, /* LSF parameters */
int dim, /* dimension of LSF */
int NoAn); /* No of analysis per frame */
int WebRtcIlbcfix_LsfCheck(int16_t* lsf, /* LSF parameters */
int dim, /* dimension of LSF */
int NoAn); /* No of analysis per frame */
#endif

View File

@ -26,12 +26,12 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_LspInterpolate2PolyDec(
int16_t *a, /* (o) lpc coefficients Q12 */
int16_t *lsf1, /* (i) first set of lsf coefficients Q13 */
int16_t *lsf2, /* (i) second set of lsf coefficients Q13 */
int16_t* a, /* (o) lpc coefficients Q12 */
int16_t* lsf1, /* (i) first set of lsf coefficients Q13 */
int16_t* lsf2, /* (i) second set of lsf coefficients Q13 */
int16_t coef, /* (i) weighting coefficient to use between
lsf1 and lsf2 Q14 */
int16_t length /* (i) length of coefficient vectors */
);
int16_t length /* (i) length of coefficient vectors */
);
#endif

View File

@ -27,12 +27,12 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_LsfInterpolate2PloyEnc(
int16_t *a, /* (o) lpc coefficients Q12 */
int16_t *lsf1, /* (i) first set of lsf coefficients Q13 */
int16_t *lsf2, /* (i) second set of lsf coefficients Q13 */
int16_t coef, /* (i) weighting coefficient to use between
lsf1 and lsf2 Q14 */
int16_t* a, /* (o) lpc coefficients Q12 */
int16_t* lsf1, /* (i) first set of lsf coefficients Q13 */
int16_t* lsf2, /* (i) second set of lsf coefficients Q13 */
int16_t coef, /* (i) weighting coefficient to use between
lsf1 and lsf2 Q14 */
int16_t length /* (i) length of coefficient vectors */
);
);
#endif

View File

@ -26,9 +26,9 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Lsf2Lsp(
int16_t *lsf, /* (i) lsf in Q13 values between 0 and pi */
int16_t *lsp, /* (o) lsp in Q15 values between -1 and 1 */
int16_t* lsf, /* (i) lsf in Q13 values between 0 and pi */
int16_t* lsp, /* (o) lsp in Q15 values between -1 and 1 */
int16_t m /* (i) number of coefficients */
);
);
#endif

View File

@ -26,8 +26,8 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Lsf2Poly(
int16_t *a, /* (o) predictor coefficients (order = 10) in Q12 */
int16_t *lsf /* (i) line spectral frequencies in Q13 */
);
int16_t* a, /* (o) predictor coefficients (order = 10) in Q12 */
int16_t* lsf /* (i) line spectral frequencies in Q13 */
);
#endif

View File

@ -26,10 +26,10 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Lsp2Lsf(
int16_t *lsp, /* (i) lsp vector -1...+1 in Q15 */
int16_t *lsf, /* (o) Lsf vector 0...Pi in Q13
int16_t* lsp, /* (i) lsp vector -1...+1 in Q15 */
int16_t* lsf, /* (o) Lsf vector 0...Pi in Q13
(ordered, so that lsf[i]<lsf[i+1]) */
int16_t m /* (i) Number of coefficients */
);
int16_t m /* (i) Number of coefficients */
);
#endif

View File

@ -25,12 +25,11 @@
* compute cross correlation between sequences
*---------------------------------------------------------------*/
void WebRtcIlbcfix_MyCorr(
int32_t* corr, /* (o) correlation of seq1 and seq2 */
const int16_t* seq1, /* (i) first sequence */
size_t dim1, /* (i) dimension first seq1 */
const int16_t* seq2, /* (i) second sequence */
size_t dim2 /* (i) dimension seq2 */
void WebRtcIlbcfix_MyCorr(int32_t* corr, /* (o) correlation of seq1 and seq2 */
const int16_t* seq1, /* (i) first sequence */
size_t dim1, /* (i) dimension first seq1 */
const int16_t* seq2, /* (i) second sequence */
size_t dim2 /* (i) dimension seq2 */
);
#endif

View File

@ -27,10 +27,10 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_NearestNeighbor(
size_t* index, /* (o) index of array element closest to value */
size_t* index, /* (o) index of array element closest to value */
const size_t* array, /* (i) data array (Q2) */
size_t value, /* (i) value (Q2) */
size_t arlength /* (i) dimension of data array (==ENH_NBLOCKS_TOT) */
);
size_t value, /* (i) value (Q2) */
size_t arlength /* (i) dimension of data array (==ENH_NBLOCKS_TOT) */
);
#endif

View File

@ -25,10 +25,10 @@
* unpacking of bits from bitstream, i.e., vector of bytes
*---------------------------------------------------------------*/
void WebRtcIlbcfix_PackBits(
uint16_t *bitstream, /* (o) The packetized bitstream */
iLBC_bits *enc_bits, /* (i) Encoded bits */
int16_t mode /* (i) Codec mode (20 or 30) */
);
void WebRtcIlbcfix_PackBits(
uint16_t* bitstream, /* (o) The packetized bitstream */
iLBC_bits* enc_bits, /* (i) Encoded bits */
int16_t mode /* (i) Codec mode (20 or 30) */
);
#endif

View File

@ -25,9 +25,8 @@
* conversion from lpc coefficients to lsf coefficients
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Poly2Lsf(
int16_t *lsf, /* (o) lsf coefficients (Q13) */
int16_t *a /* (i) A coefficients (Q12) */
void WebRtcIlbcfix_Poly2Lsf(int16_t* lsf, /* (o) lsf coefficients (Q13) */
int16_t* a /* (i) A coefficients (Q12) */
);
#endif

View File

@ -27,10 +27,10 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Poly2Lsp(
int16_t *a, /* (o) A coefficients in Q12 */
int16_t *lsp, /* (i) LSP coefficients in Q15 */
int16_t *old_lsp /* (i) old LSP coefficients that are used if the new
int16_t* a, /* (o) A coefficients in Q12 */
int16_t* lsp, /* (i) LSP coefficients in Q15 */
int16_t* old_lsp /* (i) old LSP coefficients that are used if the new
coefficients turn out to be unstable */
);
);
#endif

View File

@ -30,14 +30,14 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Refiner(
size_t *updStartPos, /* (o) updated start point (Q-2) */
int16_t *idata, /* (i) original data buffer */
size_t idatal, /* (i) dimension of idata */
size_t* updStartPos, /* (o) updated start point (Q-2) */
int16_t* idata, /* (i) original data buffer */
size_t idatal, /* (i) dimension of idata */
size_t centerStartPos, /* (i) beginning center segment */
size_t estSegPos, /* (i) estimated beginning other segment (Q-2) */
int16_t *surround, /* (i/o) The contribution from this sequence
summed with earlier contributions */
int16_t gain /* (i) Gain to use for this sequence */
);
size_t estSegPos, /* (i) estimated beginning other segment (Q-2) */
int16_t* surround, /* (i/o) The contribution from this sequence
summed with earlier contributions */
int16_t gain /* (i) Gain to use for this sequence */
);
#endif

View File

@ -26,21 +26,21 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_SimpleInterpolateLsf(
int16_t *syntdenum, /* (o) the synthesis filter denominator
resulting from the quantized
interpolated lsf Q12 */
int16_t *weightdenum, /* (o) the weighting filter denominator
int16_t* syntdenum, /* (o) the synthesis filter denominator
resulting from the quantized
interpolated lsf Q12 */
int16_t* weightdenum, /* (o) the weighting filter denominator
resulting from the unquantized
interpolated lsf Q12 */
int16_t *lsf, /* (i) the unquantized lsf coefficients Q13 */
int16_t *lsfdeq, /* (i) the dequantized lsf coefficients Q13 */
int16_t *lsfold, /* (i) the unquantized lsf coefficients of
the previous signal frame Q13 */
int16_t *lsfdeqold, /* (i) the dequantized lsf coefficients of the
previous signal frame Q13 */
int16_t length, /* (i) should equate FILTERORDER */
IlbcEncoder *iLBCenc_inst
int16_t* lsf, /* (i) the unquantized lsf coefficients Q13 */
int16_t* lsfdeq, /* (i) the dequantized lsf coefficients Q13 */
int16_t* lsfold, /* (i) the unquantized lsf coefficients of
the previous signal frame Q13 */
int16_t* lsfdeqold, /* (i) the dequantized lsf coefficients of the
previous signal frame Q13 */
int16_t length, /* (i) should equate FILTERORDER */
IlbcEncoder* iLBCenc_inst
/* (i/o) the encoder state structure */
);
);
#endif

View File

@ -26,10 +26,10 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_SimpleLpcAnalysis(
int16_t *lsf, /* (o) lsf coefficients */
int16_t *data, /* (i) new block of speech */
IlbcEncoder *iLBCenc_inst
int16_t* lsf, /* (o) lsf coefficients */
int16_t* data, /* (i) new block of speech */
IlbcEncoder* iLBCenc_inst
/* (i/o) the encoder state structure */
);
);
#endif

View File

@ -26,9 +26,9 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_SimpleLsfDeQ(
int16_t *lsfdeq, /* (o) dequantized lsf coefficients */
int16_t *index, /* (i) quantization index */
int16_t lpc_n /* (i) number of LPCs */
);
int16_t* lsfdeq, /* (o) dequantized lsf coefficients */
int16_t* index, /* (i) quantization index */
int16_t lpc_n /* (i) number of LPCs */
);
#endif

View File

@ -26,12 +26,12 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_SimpleLsfQ(
int16_t *lsfdeq, /* (o) dequantized lsf coefficients
int16_t* lsfdeq, /* (o) dequantized lsf coefficients
(dimension FILTERORDER) Q13 */
int16_t *index, /* (o) quantization index */
int16_t *lsf, /* (i) the lsf coefficient vector to be
quantized (dimension FILTERORDER) Q13 */
int16_t lpc_n /* (i) number of lsf sets to quantize */
);
int16_t* index, /* (o) quantization index */
int16_t* lsf, /* (i) the lsf coefficient vector to be
quantized (dimension FILTERORDER) Q13 */
int16_t lpc_n /* (i) number of lsf sets to quantize */
);
#endif

View File

@ -25,12 +25,11 @@
* find the smoothed output data
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Smooth(
int16_t *odata, /* (o) smoothed output */
int16_t *current, /* (i) the un enhanced residual for
this block */
int16_t *surround /* (i) The approximation from the
surrounding sequences */
void WebRtcIlbcfix_Smooth(int16_t* odata, /* (o) smoothed output */
int16_t* current, /* (i) the un enhanced residual for
this block */
int16_t* surround /* (i) The approximation from the
surrounding sequences */
);
#endif

View File

@ -25,11 +25,9 @@
* help function to WebRtcIlbcfix_Smooth()
*---------------------------------------------------------------*/
int32_t WebRtcIlbcfix_Smooth_odata(
int16_t *odata,
int16_t *psseq,
int16_t *surround,
int16_t C);
int32_t WebRtcIlbcfix_Smooth_odata(int16_t* odata,
int16_t* psseq,
int16_t* surround,
int16_t C);
#endif

View File

@ -26,11 +26,11 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_SortSq(
int16_t *xq, /* (o) the quantized value */
int16_t *index, /* (o) the quantization index */
int16_t x, /* (i) the value to quantize */
const int16_t *cb, /* (i) the quantization codebook */
int16_t cb_size /* (i) the size of the quantization codebook */
);
int16_t* xq, /* (o) the quantized value */
int16_t* index, /* (o) the quantization index */
int16_t x, /* (i) the value to quantize */
const int16_t* cb, /* (i) the quantization codebook */
int16_t cb_size /* (i) the size of the quantization codebook */
);
#endif

View File

@ -26,13 +26,13 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_SplitVq(
int16_t *qX, /* (o) the quantized vector in Q13 */
int16_t *index, /* (o) a vector of indexes for all vector
int16_t* qX, /* (o) the quantized vector in Q13 */
int16_t* index, /* (o) a vector of indexes for all vector
codebooks in the split */
int16_t *X, /* (i) the vector to quantize */
int16_t *CB, /* (i) the quantizer codebook in Q13 */
int16_t *dim, /* (i) the dimension of X and qX */
int16_t *cbsize /* (i) the number of vectors in the codebook */
);
int16_t* X, /* (i) the vector to quantize */
int16_t* CB, /* (i) the quantizer codebook in Q13 */
int16_t* dim, /* (i) the dimension of X and qX */
int16_t* cbsize /* (i) the number of vectors in the codebook */
);
#endif

View File

@ -26,10 +26,10 @@
void WebRtcIlbcfix_StateConstruct(
size_t idxForMax, /* (i) 6-bit index for the quantization of
max amplitude */
int16_t *idxVec, /* (i) vector of quantization indexes */
int16_t *syntDenum, /* (i) synthesis filter denumerator */
int16_t *Out_fix, /* (o) the decoded state vector */
size_t len /* (i) length of a state vector */
);
int16_t* idxVec, /* (i) vector of quantization indexes */
int16_t* syntDenum, /* (i) synthesis filter denumerator */
int16_t* Out_fix, /* (o) the decoded state vector */
size_t len /* (i) length of a state vector */
);
#endif

View File

@ -26,13 +26,13 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_StateSearch(
IlbcEncoder *iLBCenc_inst,
IlbcEncoder* iLBCenc_inst,
/* (i) Encoder instance */
iLBC_bits *iLBC_encbits,/* (i/o) Encoded bits (output idxForMax
and idxVec, input state_first) */
int16_t *residual, /* (i) target residual vector */
int16_t *syntDenum, /* (i) lpc synthesis filter */
int16_t *weightDenum /* (i) weighting filter denuminator */
);
iLBC_bits* iLBC_encbits, /* (i/o) Encoded bits (output idxForMax
and idxVec, input state_first) */
int16_t* residual, /* (i) target residual vector */
int16_t* syntDenum, /* (i) lpc synthesis filter */
int16_t* weightDenum /* (i) weighting filter denuminator */
);
#endif

View File

@ -26,9 +26,9 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_SwapBytes(
const uint16_t* input, /* (i) the sequence to swap */
size_t wordLength, /* (i) number or uint16_t to swap */
uint16_t* output /* (o) the swapped sequence */
);
const uint16_t* input, /* (i) the sequence to swap */
size_t wordLength, /* (i) number or uint16_t to swap */
uint16_t* output /* (o) the swapped sequence */
);
#endif

View File

@ -25,10 +25,13 @@
* unpacking of bits from bitstream, i.e., vector of bytes
*---------------------------------------------------------------*/
int16_t WebRtcIlbcfix_UnpackBits( /* (o) "Empty" frame indicator */
const uint16_t *bitstream, /* (i) The packatized bitstream */
iLBC_bits *enc_bits, /* (o) Paramerers from bitstream */
int16_t mode /* (i) Codec mode (20 or 30) */
);
int16_t
WebRtcIlbcfix_UnpackBits(/* (o) "Empty" frame indicator */
const uint16_t*
bitstream, /* (i) The packatized bitstream */
iLBC_bits*
enc_bits, /* (o) Paramerers from bitstream */
int16_t mode /* (i) Codec mode (20 or 30) */
);
#endif

View File

@ -26,11 +26,11 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Vq3(
int16_t *Xq, /* (o) the quantized vector (Q13) */
int16_t *index, /* (o) the quantization index */
int16_t *CB, /* (i) the vector quantization codebook (Q13) */
int16_t *X, /* (i) the vector to quantize (Q13) */
int16_t n_cb /* (i) the number of vectors in the codebook */
);
int16_t* Xq, /* (o) the quantized vector (Q13) */
int16_t* index, /* (o) the quantization index */
int16_t* CB, /* (i) the vector quantization codebook (Q13) */
int16_t* X, /* (i) the vector to quantize (Q13) */
int16_t n_cb /* (i) the number of vectors in the codebook */
);
#endif

View File

@ -26,11 +26,11 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Vq4(
int16_t *Xq, /* (o) the quantized vector (Q13) */
int16_t *index, /* (o) the quantization index */
int16_t *CB, /* (i) the vector quantization codebook (Q13) */
int16_t *X, /* (i) the vector to quantize (Q13) */
int16_t n_cb /* (i) the number of vectors in the codebook */
);
int16_t* Xq, /* (o) the quantized vector (Q13) */
int16_t* index, /* (o) the quantization index */
int16_t* CB, /* (i) the vector quantization codebook (Q13) */
int16_t* X, /* (i) the vector to quantize (Q13) */
int16_t n_cb /* (i) the number of vectors in the codebook */
);
#endif

View File

@ -25,11 +25,10 @@
* window multiplication
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Window32W32(
int32_t *z, /* Output */
int32_t *x, /* Input (same domain as Output)*/
const int32_t *y, /* Q31 Window */
size_t N /* length to process */
void WebRtcIlbcfix_Window32W32(int32_t* z, /* Output */
int32_t* x, /* Input (same domain as Output)*/
const int32_t* y, /* Q31 Window */
size_t N /* length to process */
);
#endif

View File

@ -27,12 +27,12 @@
*---------------------------------------------------------------*/
size_t WebRtcIlbcfix_XcorrCoef(
int16_t *target, /* (i) first array */
int16_t *regressor, /* (i) second array */
size_t subl, /* (i) dimension arrays */
size_t searchLen, /* (i) the search lenght */
size_t offset, /* (i) samples offset between arrays */
int16_t step /* (i) +1 or -1 */
);
int16_t* target, /* (i) first array */
int16_t* regressor, /* (i) second array */
size_t subl, /* (i) dimension arrays */
size_t searchLen, /* (i) the search lenght */
size_t offset, /* (i) samples offset between arrays */
int16_t step /* (i) +1 or -1 */
);
#endif

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];

Some files were not shown because too many files have changed in this diff Show More