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:
@ -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) {
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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_);
|
||||
|
||||
@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user