2015-07-10 14:11:52 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <stdlib.h>
|
2016-02-19 07:04:49 -08:00
|
|
|
|
2015-07-10 14:11:52 -07:00
|
|
|
#include <algorithm>
|
2016-02-19 07:04:49 -08:00
|
|
|
#include <memory>
|
2015-07-10 14:11:52 -07:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#include "testing/gtest/include/gtest/gtest.h"
|
|
|
|
|
#include "webrtc/base/arraysize.h"
|
|
|
|
|
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
|
|
|
|
|
#include "webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.h"
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
// Target output for ERB create test. Generated with matlab.
|
|
|
|
|
const float kTestCenterFreqs[] = {
|
2016-02-22 15:57:38 -08:00
|
|
|
14.5213f, 29.735f, 45.6781f, 62.3884f, 79.9058f, 98.2691f, 117.521f,
|
|
|
|
|
137.708f, 158.879f, 181.084f, 204.378f, 228.816f, 254.459f, 281.371f,
|
|
|
|
|
309.618f, 339.273f, 370.411f, 403.115f, 437.469f, 473.564f, 511.497f,
|
|
|
|
|
551.371f, 593.293f, 637.386f, 683.77f, 732.581f, 783.96f, 838.06f,
|
|
|
|
|
895.046f, 955.09f, 1018.38f, 1085.13f, 1155.54f, 1229.85f, 1308.32f,
|
|
|
|
|
1391.22f, 1478.83f, 1571.5f, 1669.55f,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|
|
|
0.190476f, 0.133333f, 0.0689655f, 0.f, 0.f, 0.f,
|
|
|
|
|
0.f, 0.f, 0.f},
|
|
|
|
|
{0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
|
|
|
|
|
0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
|
|
|
|
|
0.f, 0.f, 0.f, 0.f, 0.333333f, 0.30303f, 0.253968f, 0.2f, 0.137931f,
|
|
|
|
|
0.0714286f, 0.f, 0.f, 0.f, 0.f, 0.f},
|
|
|
|
|
{0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
|
|
|
|
|
0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
|
|
|
|
|
0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
|
|
|
|
|
0.f, 0.f, 0.30303f, 0.31746f, 0.333333f, 0.275862f, 0.214286f,
|
|
|
|
|
0.125f, 0.0655738f, 0.f, 0.f, 0.f},
|
|
|
|
|
{0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
|
|
|
|
|
0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
|
|
|
|
|
0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
|
|
|
|
|
0.f, 0.f, 0.f, 0.15873f, 0.333333f, 0.344828f, 0.357143f,
|
|
|
|
|
0.25f, 0.196721f, 0.137931f, 0.0816327f, 0.f},
|
|
|
|
|
{0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
|
|
|
|
|
0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
|
|
|
|
|
0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
|
|
|
|
|
0.f, 0.f, 0.f, 0.f, 0.f, 0.172414f, 0.357143f,
|
|
|
|
|
0.3125f, 0.245902f, 0.172414f, 0.102041f, 0.f},
|
|
|
|
|
{0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
|
|
|
|
|
0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
|
|
|
|
|
0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
|
|
|
|
|
0.f, 0.3125f, 0.327869f, 0.344828f, 0.204082f, 0.f},
|
|
|
|
|
{0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
|
|
|
|
|
0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
|
|
|
|
|
0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.163934f, 0.344828f, 0.408163f, 0.5f},
|
|
|
|
|
{0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
|
|
|
|
|
0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
|
|
|
|
|
0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.204082f, 0.5f}};
|
2015-07-10 14:11:52 -07:00
|
|
|
static_assert(arraysize(kTestCenterFreqs) == arraysize(kTestFilterBank),
|
|
|
|
|
"Test filterbank badly initialized.");
|
|
|
|
|
|
|
|
|
|
// Target output for gain solving test. Generated with matlab.
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
const size_t kTestStartFreq = 12; // Lowest integral frequency for ERBs.
|
2016-02-24 17:25:42 -08:00
|
|
|
const float kTestZeroVar = 1.f;
|
2015-07-10 14:11:52 -07:00
|
|
|
const float kTestNonZeroVarLambdaTop[] = {
|
2016-02-24 17:25:42 -08:00
|
|
|
1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 0.f, 0.f,
|
2016-02-22 15:57:38 -08:00
|
|
|
0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
|
2016-02-24 17:25:42 -08:00
|
|
|
0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
|
2015-07-10 14:11:52 -07:00
|
|
|
static_assert(arraysize(kTestCenterFreqs) ==
|
|
|
|
|
arraysize(kTestNonZeroVarLambdaTop),
|
2016-02-17 20:04:19 -08:00
|
|
|
"Power test data badly initialized.");
|
2015-07-10 14:11:52 -07:00
|
|
|
const float kMaxTestError = 0.005f;
|
|
|
|
|
|
|
|
|
|
// Enhancer initialization parameters.
|
2016-02-22 15:57:38 -08:00
|
|
|
const int kSamples = 1000;
|
|
|
|
|
const int kSampleRate = 4000;
|
2015-07-10 14:11:52 -07:00
|
|
|
const int kNumChannels = 1;
|
2015-08-14 10:35:55 -07:00
|
|
|
const int kFragmentSize = kSampleRate / 100;
|
2016-03-09 16:24:34 +01:00
|
|
|
const size_t kNumNoiseBins = 129;
|
2015-07-10 14:11:52 -07:00
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
class IntelligibilityEnhancerTest : public ::testing::Test {
|
|
|
|
|
protected:
|
|
|
|
|
IntelligibilityEnhancerTest()
|
2015-08-14 10:35:55 -07:00
|
|
|
: clear_data_(kSamples), noise_data_(kSamples), orig_data_(kSamples) {
|
2016-03-09 16:24:34 +01:00
|
|
|
enh_.reset(
|
|
|
|
|
new IntelligibilityEnhancer(kSampleRate, kNumChannels, kNumNoiseBins));
|
2015-08-14 10:35:55 -07:00
|
|
|
}
|
2015-07-10 14:11:52 -07:00
|
|
|
|
2016-02-17 20:04:19 -08:00
|
|
|
bool CheckUpdate() {
|
2016-03-09 16:24:34 +01:00
|
|
|
enh_.reset(
|
|
|
|
|
new IntelligibilityEnhancer(kSampleRate, kNumChannels, kNumNoiseBins));
|
2016-02-26 17:17:38 -08:00
|
|
|
float* clear_cursor = clear_data_.data();
|
|
|
|
|
float* noise_cursor = noise_data_.data();
|
2015-07-10 14:11:52 -07:00
|
|
|
for (int i = 0; i < kSamples; i += kFragmentSize) {
|
2015-08-14 10:35:55 -07:00
|
|
|
enh_->ProcessRenderAudio(&clear_cursor, kSampleRate, kNumChannels);
|
2015-07-10 14:11:52 -07:00
|
|
|
clear_cursor += kFragmentSize;
|
|
|
|
|
noise_cursor += kFragmentSize;
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < kSamples; i++) {
|
|
|
|
|
if (std::fabs(clear_data_[i] - orig_data_[i]) > kMaxTestError) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-19 07:04:49 -08:00
|
|
|
std::unique_ptr<IntelligibilityEnhancer> enh_;
|
2016-02-17 20:04:19 -08:00
|
|
|
std::vector<float> clear_data_;
|
|
|
|
|
std::vector<float> noise_data_;
|
|
|
|
|
std::vector<float> orig_data_;
|
2015-07-10 14:11:52 -07:00
|
|
|
};
|
|
|
|
|
|
2016-02-17 20:04:19 -08:00
|
|
|
// For each class of generated data, tests that render stream is updated when
|
|
|
|
|
// it should be.
|
2015-07-10 14:11:52 -07:00
|
|
|
TEST_F(IntelligibilityEnhancerTest, TestRenderUpdate) {
|
2016-02-22 15:57:38 -08:00
|
|
|
std::fill(noise_data_.begin(), noise_data_.end(), 0.f);
|
|
|
|
|
std::fill(orig_data_.begin(), orig_data_.end(), 0.f);
|
|
|
|
|
std::fill(clear_data_.begin(), clear_data_.end(), 0.f);
|
2016-02-17 20:04:19 -08:00
|
|
|
EXPECT_FALSE(CheckUpdate());
|
2015-07-10 14:11:52 -07:00
|
|
|
std::srand(1);
|
|
|
|
|
auto float_rand = []() { return std::rand() * 2.f / RAND_MAX - 1; };
|
|
|
|
|
std::generate(noise_data_.begin(), noise_data_.end(), float_rand);
|
2016-02-17 20:04:19 -08:00
|
|
|
EXPECT_FALSE(CheckUpdate());
|
|
|
|
|
std::generate(clear_data_.begin(), clear_data_.end(), float_rand);
|
|
|
|
|
orig_data_ = clear_data_;
|
|
|
|
|
EXPECT_TRUE(CheckUpdate());
|
2015-07-10 14:11:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Tests ERB bank creation, comparing against matlab output.
|
|
|
|
|
TEST_F(IntelligibilityEnhancerTest, TestErbCreation) {
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
ASSERT_EQ(arraysize(kTestCenterFreqs), enh_->bank_size_);
|
|
|
|
|
for (size_t i = 0; i < enh_->bank_size_; ++i) {
|
2015-08-14 10:35:55 -07:00
|
|
|
EXPECT_NEAR(kTestCenterFreqs[i], enh_->center_freqs_[i], kMaxTestError);
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
ASSERT_EQ(arraysize(kTestFilterBank[0]), enh_->freqs_);
|
|
|
|
|
for (size_t j = 0; j < enh_->freqs_; ++j) {
|
2016-02-10 12:03:00 -08:00
|
|
|
EXPECT_NEAR(kTestFilterBank[i][j], enh_->render_filter_bank_[i][j],
|
2015-07-10 14:11:52 -07:00
|
|
|
kMaxTestError);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Tests analytic solution for optimal gains, comparing
|
|
|
|
|
// against matlab output.
|
|
|
|
|
TEST_F(IntelligibilityEnhancerTest, TestSolveForGains) {
|
2015-08-14 10:35:55 -07:00
|
|
|
ASSERT_EQ(kTestStartFreq, enh_->start_freq_);
|
2016-02-17 20:04:19 -08:00
|
|
|
std::vector<float> sols(enh_->bank_size_);
|
2015-07-10 14:11:52 -07:00
|
|
|
float lambda = -0.001f;
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
for (size_t i = 0; i < enh_->bank_size_; i++) {
|
2016-02-22 15:57:38 -08:00
|
|
|
enh_->filtered_clear_pow_[i] = 0.f;
|
|
|
|
|
enh_->filtered_noise_pow_[i] = 0.f;
|
2015-07-10 14:11:52 -07:00
|
|
|
}
|
2016-02-26 17:17:38 -08:00
|
|
|
enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, sols.data());
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
for (size_t i = 0; i < enh_->bank_size_; i++) {
|
2016-02-24 17:25:42 -08:00
|
|
|
EXPECT_NEAR(kTestZeroVar, sols[i], kMaxTestError);
|
2015-07-10 14:11:52 -07:00
|
|
|
}
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
for (size_t i = 0; i < enh_->bank_size_; i++) {
|
2016-02-17 20:04:19 -08:00
|
|
|
enh_->filtered_clear_pow_[i] = static_cast<float>(i + 1);
|
|
|
|
|
enh_->filtered_noise_pow_[i] = static_cast<float>(enh_->bank_size_ - i);
|
2015-07-10 14:11:52 -07:00
|
|
|
}
|
2016-02-26 17:17:38 -08:00
|
|
|
enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, sols.data());
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
for (size_t i = 0; i < enh_->bank_size_; i++) {
|
2015-07-10 14:11:52 -07:00
|
|
|
EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError);
|
|
|
|
|
}
|
2016-02-22 15:57:38 -08:00
|
|
|
lambda = -1.f;
|
2016-02-26 17:17:38 -08:00
|
|
|
enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, sols.data());
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
for (size_t i = 0; i < enh_->bank_size_; i++) {
|
2016-02-24 17:25:42 -08:00
|
|
|
EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError);
|
2015-07-10 14:11:52 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|