2014-10-01 17:42:18 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2014 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-08-31 10:41:37 +02:00
|
|
|
#include "modules/audio_coding/codecs/opus/test/blocker.h"
|
2014-10-01 17:42:18 +00:00
|
|
|
|
2016-02-24 05:22:32 -08:00
|
|
|
#include <memory>
|
2019-07-05 19:08:33 +02:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/arraysize.h"
|
|
|
|
|
#include "test/gtest.h"
|
2014-10-01 17:42:18 +00:00
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
// Callback Function to add 3 to every sample in the signal.
|
2015-01-13 22:28:35 +00:00
|
|
|
class PlusThreeBlockerCallback : public webrtc::BlockerCallback {
|
2014-10-01 17:42:18 +00:00
|
|
|
public:
|
2015-03-04 12:58:35 +00:00
|
|
|
void ProcessBlock(const float* const* input,
|
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
|
|
|
size_t num_frames,
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t num_input_channels,
|
|
|
|
|
size_t num_output_channels,
|
2015-03-04 12:58:35 +00:00
|
|
|
float* const* output) override {
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
for (size_t i = 0; i < num_output_channels; ++i) {
|
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 j = 0; j < num_frames; ++j) {
|
2014-10-01 17:42:18 +00:00
|
|
|
output[i][j] = input[i][j] + 3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2015-01-13 22:28:35 +00:00
|
|
|
// No-op Callback Function.
|
|
|
|
|
class CopyBlockerCallback : public webrtc::BlockerCallback {
|
|
|
|
|
public:
|
2015-03-04 12:58:35 +00:00
|
|
|
void ProcessBlock(const float* const* input,
|
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
|
|
|
size_t num_frames,
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t num_input_channels,
|
|
|
|
|
size_t num_output_channels,
|
2015-03-04 12:58:35 +00:00
|
|
|
float* const* output) override {
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
for (size_t i = 0; i < num_output_channels; ++i) {
|
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 j = 0; j < num_frames; ++j) {
|
2015-01-13 22:28:35 +00:00
|
|
|
output[i][j] = input[i][j];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2014-10-01 17:42:18 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
// Tests blocking with a window that multiplies the signal by 2, a callback
|
|
|
|
|
// that adds 3 to each sample in the signal, and different combinations of chunk
|
|
|
|
|
// size, block size, and shift amount.
|
|
|
|
|
class BlockerTest : public ::testing::Test {
|
|
|
|
|
protected:
|
|
|
|
|
void RunTest(Blocker* blocker,
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
size_t chunk_size,
|
|
|
|
|
size_t num_frames,
|
2014-10-01 17:42:18 +00:00
|
|
|
const float* const* input,
|
|
|
|
|
float* const* input_chunk,
|
|
|
|
|
float* const* output,
|
|
|
|
|
float* const* output_chunk,
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t num_input_channels,
|
|
|
|
|
size_t num_output_channels) {
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
size_t start = 0;
|
|
|
|
|
size_t end = chunk_size - 1;
|
2014-10-01 17:42:18 +00:00
|
|
|
while (end < num_frames) {
|
|
|
|
|
CopyTo(input_chunk, 0, start, num_input_channels, chunk_size, input);
|
|
|
|
|
blocker->ProcessChunk(input_chunk, chunk_size, num_input_channels,
|
|
|
|
|
num_output_channels, output_chunk);
|
|
|
|
|
CopyTo(output, start, 0, num_output_channels, chunk_size, output_chunk);
|
|
|
|
|
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
start += chunk_size;
|
|
|
|
|
end += chunk_size;
|
2014-10-01 17:42:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValidateSignalEquality(const float* const* expected,
|
|
|
|
|
const float* const* actual,
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t num_channels,
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
size_t num_frames) {
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
for (size_t i = 0; i < num_channels; ++i) {
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
for (size_t j = 0; j < num_frames; ++j) {
|
2014-10-01 17:42:18 +00:00
|
|
|
EXPECT_FLOAT_EQ(expected[i][j], actual[i][j]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-13 22:28:35 +00:00
|
|
|
void ValidateInitialDelay(const float* const* output,
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t num_channels,
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
size_t num_frames,
|
|
|
|
|
size_t initial_delay) {
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
for (size_t i = 0; i < num_channels; ++i) {
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
for (size_t j = 0; j < num_frames; ++j) {
|
2015-01-13 22:28:35 +00:00
|
|
|
if (j < initial_delay) {
|
|
|
|
|
EXPECT_FLOAT_EQ(output[i][j], 0.f);
|
|
|
|
|
} else {
|
|
|
|
|
EXPECT_GT(output[i][j], 0.f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-01 17:42:18 +00:00
|
|
|
static void CopyTo(float* const* dst,
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
size_t start_index_dst,
|
|
|
|
|
size_t start_index_src,
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t num_channels,
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
size_t num_frames,
|
2014-10-01 17:42:18 +00:00
|
|
|
const float* const* src) {
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
for (size_t i = 0; i < num_channels; ++i) {
|
2014-10-01 17:42:18 +00:00
|
|
|
memcpy(&dst[i][start_index_dst], &src[i][start_index_src],
|
|
|
|
|
num_frames * sizeof(float));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TEST_F(BlockerTest, TestBlockerMutuallyPrimeChunkandBlockSize) {
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
const size_t kNumInputChannels = 3;
|
|
|
|
|
const size_t kNumOutputChannels = 2;
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
const size_t kNumFrames = 10;
|
|
|
|
|
const size_t kBlockSize = 4;
|
|
|
|
|
const size_t kChunkSize = 5;
|
|
|
|
|
const size_t kShiftAmount = 2;
|
2014-10-01 17:42:18 +00:00
|
|
|
|
|
|
|
|
const float kInput[kNumInputChannels][kNumFrames] = {
|
|
|
|
|
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
|
|
|
|
|
{2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
|
|
|
|
|
{3, 3, 3, 3, 3, 3, 3, 3, 3, 3}};
|
2015-02-10 22:52:15 +00:00
|
|
|
ChannelBuffer<float> input_cb(kNumFrames, kNumInputChannels);
|
|
|
|
|
input_cb.SetDataForTesting(kInput[0], sizeof(kInput) / sizeof(**kInput));
|
2014-10-01 17:42:18 +00:00
|
|
|
|
|
|
|
|
const float kExpectedOutput[kNumInputChannels][kNumFrames] = {
|
2015-01-13 22:28:35 +00:00
|
|
|
{6, 6, 12, 20, 20, 20, 20, 20, 20, 20},
|
|
|
|
|
{6, 6, 12, 28, 28, 28, 28, 28, 28, 28}};
|
2015-02-10 22:52:15 +00:00
|
|
|
ChannelBuffer<float> expected_output_cb(kNumFrames, kNumInputChannels);
|
|
|
|
|
expected_output_cb.SetDataForTesting(
|
|
|
|
|
kExpectedOutput[0], sizeof(kExpectedOutput) / sizeof(**kExpectedOutput));
|
2014-10-01 17:42:18 +00:00
|
|
|
|
|
|
|
|
const float kWindow[kBlockSize] = {2.f, 2.f, 2.f, 2.f};
|
|
|
|
|
|
|
|
|
|
ChannelBuffer<float> actual_output_cb(kNumFrames, kNumOutputChannels);
|
|
|
|
|
ChannelBuffer<float> input_chunk_cb(kChunkSize, kNumInputChannels);
|
|
|
|
|
ChannelBuffer<float> output_chunk_cb(kChunkSize, kNumOutputChannels);
|
|
|
|
|
|
2015-01-13 22:28:35 +00:00
|
|
|
PlusThreeBlockerCallback callback;
|
2014-10-01 17:42:18 +00:00
|
|
|
Blocker blocker(kChunkSize, kBlockSize, kNumInputChannels, kNumOutputChannels,
|
|
|
|
|
kWindow, kShiftAmount, &callback);
|
2018-06-19 15:03:05 +02:00
|
|
|
|
2014-10-01 17:42:18 +00:00
|
|
|
RunTest(&blocker, kChunkSize, kNumFrames, input_cb.channels(),
|
|
|
|
|
input_chunk_cb.channels(), actual_output_cb.channels(),
|
|
|
|
|
output_chunk_cb.channels(), kNumInputChannels, kNumOutputChannels);
|
|
|
|
|
|
|
|
|
|
ValidateSignalEquality(expected_output_cb.channels(),
|
|
|
|
|
actual_output_cb.channels(), kNumOutputChannels,
|
|
|
|
|
kNumFrames);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(BlockerTest, TestBlockerMutuallyPrimeShiftAndBlockSize) {
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
const size_t kNumInputChannels = 3;
|
|
|
|
|
const size_t kNumOutputChannels = 2;
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
const size_t kNumFrames = 12;
|
|
|
|
|
const size_t kBlockSize = 4;
|
|
|
|
|
const size_t kChunkSize = 6;
|
|
|
|
|
const size_t kShiftAmount = 3;
|
2014-10-01 17:42:18 +00:00
|
|
|
|
|
|
|
|
const float kInput[kNumInputChannels][kNumFrames] = {
|
|
|
|
|
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
|
|
|
|
|
{2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
|
|
|
|
|
{3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}};
|
2015-02-10 22:52:15 +00:00
|
|
|
ChannelBuffer<float> input_cb(kNumFrames, kNumInputChannels);
|
|
|
|
|
input_cb.SetDataForTesting(kInput[0], sizeof(kInput) / sizeof(**kInput));
|
2014-10-01 17:42:18 +00:00
|
|
|
|
2015-01-13 22:28:35 +00:00
|
|
|
const float kExpectedOutput[kNumOutputChannels][kNumFrames] = {
|
|
|
|
|
{6, 10, 10, 20, 10, 10, 20, 10, 10, 20, 10, 10},
|
|
|
|
|
{6, 14, 14, 28, 14, 14, 28, 14, 14, 28, 14, 14}};
|
2015-02-10 22:52:15 +00:00
|
|
|
ChannelBuffer<float> expected_output_cb(kNumFrames, kNumOutputChannels);
|
|
|
|
|
expected_output_cb.SetDataForTesting(
|
|
|
|
|
kExpectedOutput[0], sizeof(kExpectedOutput) / sizeof(**kExpectedOutput));
|
2014-10-01 17:42:18 +00:00
|
|
|
|
|
|
|
|
const float kWindow[kBlockSize] = {2.f, 2.f, 2.f, 2.f};
|
|
|
|
|
|
|
|
|
|
ChannelBuffer<float> actual_output_cb(kNumFrames, kNumOutputChannels);
|
|
|
|
|
ChannelBuffer<float> input_chunk_cb(kChunkSize, kNumInputChannels);
|
|
|
|
|
ChannelBuffer<float> output_chunk_cb(kChunkSize, kNumOutputChannels);
|
|
|
|
|
|
2015-01-13 22:28:35 +00:00
|
|
|
PlusThreeBlockerCallback callback;
|
2014-10-01 17:42:18 +00:00
|
|
|
Blocker blocker(kChunkSize, kBlockSize, kNumInputChannels, kNumOutputChannels,
|
|
|
|
|
kWindow, kShiftAmount, &callback);
|
2018-06-19 15:03:05 +02:00
|
|
|
|
2014-10-01 17:42:18 +00:00
|
|
|
RunTest(&blocker, kChunkSize, kNumFrames, input_cb.channels(),
|
|
|
|
|
input_chunk_cb.channels(), actual_output_cb.channels(),
|
|
|
|
|
output_chunk_cb.channels(), kNumInputChannels, kNumOutputChannels);
|
|
|
|
|
|
|
|
|
|
ValidateSignalEquality(expected_output_cb.channels(),
|
|
|
|
|
actual_output_cb.channels(), kNumOutputChannels,
|
|
|
|
|
kNumFrames);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(BlockerTest, TestBlockerNoOverlap) {
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
const size_t kNumInputChannels = 3;
|
|
|
|
|
const size_t kNumOutputChannels = 2;
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
const size_t kNumFrames = 12;
|
|
|
|
|
const size_t kBlockSize = 4;
|
|
|
|
|
const size_t kChunkSize = 4;
|
|
|
|
|
const size_t kShiftAmount = 4;
|
2014-10-01 17:42:18 +00:00
|
|
|
|
|
|
|
|
const float kInput[kNumInputChannels][kNumFrames] = {
|
|
|
|
|
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
|
|
|
|
|
{2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
|
|
|
|
|
{3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}};
|
2015-02-10 22:52:15 +00:00
|
|
|
ChannelBuffer<float> input_cb(kNumFrames, kNumInputChannels);
|
|
|
|
|
input_cb.SetDataForTesting(kInput[0], sizeof(kInput) / sizeof(**kInput));
|
2014-10-01 17:42:18 +00:00
|
|
|
|
2015-01-13 22:28:35 +00:00
|
|
|
const float kExpectedOutput[kNumOutputChannels][kNumFrames] = {
|
|
|
|
|
{10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10},
|
|
|
|
|
{14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14}};
|
2015-02-10 22:52:15 +00:00
|
|
|
ChannelBuffer<float> expected_output_cb(kNumFrames, kNumOutputChannels);
|
|
|
|
|
expected_output_cb.SetDataForTesting(
|
|
|
|
|
kExpectedOutput[0], sizeof(kExpectedOutput) / sizeof(**kExpectedOutput));
|
2014-10-01 17:42:18 +00:00
|
|
|
|
|
|
|
|
const float kWindow[kBlockSize] = {2.f, 2.f, 2.f, 2.f};
|
|
|
|
|
|
|
|
|
|
ChannelBuffer<float> actual_output_cb(kNumFrames, kNumOutputChannels);
|
|
|
|
|
ChannelBuffer<float> input_chunk_cb(kChunkSize, kNumInputChannels);
|
|
|
|
|
ChannelBuffer<float> output_chunk_cb(kChunkSize, kNumOutputChannels);
|
|
|
|
|
|
2015-01-13 22:28:35 +00:00
|
|
|
PlusThreeBlockerCallback callback;
|
2014-10-01 17:42:18 +00:00
|
|
|
Blocker blocker(kChunkSize, kBlockSize, kNumInputChannels, kNumOutputChannels,
|
|
|
|
|
kWindow, kShiftAmount, &callback);
|
2018-06-19 15:03:05 +02:00
|
|
|
|
2014-10-01 17:42:18 +00:00
|
|
|
RunTest(&blocker, kChunkSize, kNumFrames, input_cb.channels(),
|
|
|
|
|
input_chunk_cb.channels(), actual_output_cb.channels(),
|
|
|
|
|
output_chunk_cb.channels(), kNumInputChannels, kNumOutputChannels);
|
|
|
|
|
|
|
|
|
|
ValidateSignalEquality(expected_output_cb.channels(),
|
|
|
|
|
actual_output_cb.channels(), kNumOutputChannels,
|
|
|
|
|
kNumFrames);
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-13 22:28:35 +00:00
|
|
|
TEST_F(BlockerTest, InitialDelaysAreMinimum) {
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
const size_t kNumInputChannels = 3;
|
|
|
|
|
const size_t kNumOutputChannels = 2;
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
const size_t kNumFrames = 1280;
|
|
|
|
|
const size_t kChunkSize[] = {80, 80, 80, 80, 80, 80,
|
2015-01-13 22:28:35 +00:00
|
|
|
160, 160, 160, 160, 160, 160};
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
const size_t kBlockSize[] = {64, 64, 64, 128, 128, 128,
|
2015-01-13 22:28:35 +00:00
|
|
|
128, 128, 128, 256, 256, 256};
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
const size_t kShiftAmount[] = {16, 32, 64, 32, 64, 128,
|
2015-01-13 22:28:35 +00:00
|
|
|
32, 64, 128, 64, 128, 256};
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
const size_t kInitialDelay[] = {48, 48, 48, 112, 112, 112,
|
2015-01-13 22:28:35 +00:00
|
|
|
96, 96, 96, 224, 224, 224};
|
|
|
|
|
|
|
|
|
|
float input[kNumInputChannels][kNumFrames];
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
for (size_t i = 0; i < kNumInputChannels; ++i) {
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
for (size_t j = 0; j < kNumFrames; ++j) {
|
2015-01-13 22:28:35 +00:00
|
|
|
input[i][j] = i + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-02-10 22:52:15 +00:00
|
|
|
ChannelBuffer<float> input_cb(kNumFrames, kNumInputChannels);
|
|
|
|
|
input_cb.SetDataForTesting(input[0], sizeof(input) / sizeof(**input));
|
2015-01-13 22:28:35 +00:00
|
|
|
|
|
|
|
|
ChannelBuffer<float> output_cb(kNumFrames, kNumOutputChannels);
|
|
|
|
|
|
|
|
|
|
CopyBlockerCallback callback;
|
|
|
|
|
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
for (size_t i = 0; i < arraysize(kChunkSize); ++i) {
|
2016-02-24 05:22:32 -08:00
|
|
|
std::unique_ptr<float[]> window(new float[kBlockSize[i]]);
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
for (size_t j = 0; j < kBlockSize[i]; ++j) {
|
2015-01-13 22:28:35 +00:00
|
|
|
window[j] = 1.f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ChannelBuffer<float> input_chunk_cb(kChunkSize[i], kNumInputChannels);
|
|
|
|
|
ChannelBuffer<float> output_chunk_cb(kChunkSize[i], kNumOutputChannels);
|
|
|
|
|
|
|
|
|
|
Blocker blocker(kChunkSize[i], kBlockSize[i], kNumInputChannels,
|
|
|
|
|
kNumOutputChannels, window.get(), kShiftAmount[i],
|
|
|
|
|
&callback);
|
|
|
|
|
|
|
|
|
|
RunTest(&blocker, kChunkSize[i], kNumFrames, input_cb.channels(),
|
|
|
|
|
input_chunk_cb.channels(), output_cb.channels(),
|
|
|
|
|
output_chunk_cb.channels(), kNumInputChannels, kNumOutputChannels);
|
2018-06-19 15:03:05 +02:00
|
|
|
|
2015-01-13 22:28:35 +00:00
|
|
|
ValidateInitialDelay(output_cb.channels(), kNumOutputChannels, kNumFrames,
|
|
|
|
|
kInitialDelay[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-01 17:42:18 +00:00
|
|
|
} // namespace webrtc
|