Renamed the test::BitExactFrame method to test::VectorDifferenceBounded.
BUG= Review URL: https://codereview.webrtc.org/1841213002 Cr-Commit-Position: refs/heads/master@{#12162}
This commit is contained in:
parent
d53c389550
commit
7ea928e8e2
@ -111,16 +111,16 @@ void RunBitExactnessTest(int sample_rate_hz,
|
||||
test::ExtractVectorFromAudioBuffer(capture_config, &capture_buffer,
|
||||
&capture_output);
|
||||
|
||||
const float kTolerance = 1.f / static_cast<float>(1 << 15);
|
||||
const float kElementErrorBound = 1.f / static_cast<float>(1 << 15);
|
||||
|
||||
// Compare the output with the reference. Only the first values of the output
|
||||
// from last frame processed are compared in order not having to specify all
|
||||
// preceeding frames as testvectors. As the algorithm being tested has a
|
||||
// memory, testing only the last frame implicitly also tests the preceeding
|
||||
// frames.
|
||||
EXPECT_TRUE(test::BitExactFrame(
|
||||
EXPECT_TRUE(test::VerifyDeinterleavedArray(
|
||||
capture_config.num_frames(), capture_config.num_channels(),
|
||||
output_reference, capture_output, kTolerance));
|
||||
output_reference, capture_output, kElementErrorBound));
|
||||
}
|
||||
|
||||
// TODO(peah): Add bitexactness tests for scenarios with more than 2 input
|
||||
|
||||
@ -125,10 +125,10 @@ void RunBitexactnessTest(int sample_rate_hz,
|
||||
// preceeding frames as testvectors. As the algorithm being tested has a
|
||||
// memory, testing only the last frame implicitly also tests the preceeding
|
||||
// frames.
|
||||
const float kTolerance = 1.0f / 32768.0f;
|
||||
EXPECT_TRUE(test::BitExactFrame(
|
||||
const float kElementErrorBound = 1.0f / 32768.0f;
|
||||
EXPECT_TRUE(test::VerifyDeinterleavedArray(
|
||||
capture_config.num_frames(), capture_config.num_channels(),
|
||||
output_reference, capture_output, kTolerance));
|
||||
output_reference, capture_output, kElementErrorBound));
|
||||
}
|
||||
|
||||
const bool kStreamHasEchoReference = false;
|
||||
|
||||
@ -107,10 +107,10 @@ void RunBitexactnessTest(int sample_rate_hz,
|
||||
// preceeding frames as testvectors. As the algorithm being tested has a
|
||||
// memory, testing only the last frame implicitly also tests the preceeding
|
||||
// frames.
|
||||
const float kTolerance = 1.0f / 32768.0f;
|
||||
EXPECT_TRUE(test::BitExactFrame(
|
||||
const float kElementErrorBound = 1.0f / 32768.0f;
|
||||
EXPECT_TRUE(test::VerifyDeinterleavedArray(
|
||||
capture_config.num_frames(), capture_config.num_channels(),
|
||||
output_reference, capture_output, kTolerance));
|
||||
output_reference, capture_output, kElementErrorBound));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -124,10 +124,10 @@ void RunBitExactnessTest(int sample_rate_hz,
|
||||
// preceeding frames as testvectors. As the algorithm being tested has a
|
||||
// memory, testing only the last frame implicitly also tests the preceeding
|
||||
// frames.
|
||||
const float kTolerance = 1.0f / 32768.0f;
|
||||
EXPECT_TRUE(test::BitExactFrame(
|
||||
const float kElementErrorBound = 1.0f / 32768.0f;
|
||||
EXPECT_TRUE(test::VerifyDeinterleavedArray(
|
||||
capture_config.num_frames(), capture_config.num_channels(),
|
||||
output_reference, capture_output, kTolerance));
|
||||
output_reference, capture_output, kElementErrorBound));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -82,9 +82,10 @@ void RunBitexactnessTest(int sample_rate,
|
||||
reference_frame_length);
|
||||
}
|
||||
|
||||
const float kTolerance = 1.0f / 32768.0f;
|
||||
EXPECT_TRUE(test::BitExactFrame(reference_frame_length, num_channels,
|
||||
reference, output_to_verify, kTolerance));
|
||||
const float kElementErrorBound = 1.0f / 32768.0f;
|
||||
EXPECT_TRUE(test::VerifyDeinterleavedArray(
|
||||
reference_frame_length, num_channels, reference, output_to_verify,
|
||||
kElementErrorBound));
|
||||
}
|
||||
|
||||
// Method for forming a vector out of an array.
|
||||
|
||||
@ -299,16 +299,16 @@ void RunBitexactnessTest(int sample_rate_hz,
|
||||
test::ExtractVectorFromAudioBuffer(render_config, &render_buffer,
|
||||
&render_output);
|
||||
|
||||
const float kTolerance = 1.f / static_cast<float>(1 << 15);
|
||||
const float kElementErrorBound = 1.f / static_cast<float>(1 << 15);
|
||||
|
||||
// Compare the output with the reference. Only the first values of the output
|
||||
// from last frame processed are compared in order not having to specify all
|
||||
// preceeding frames as testvectors. As the algorithm being tested has a
|
||||
// memory, testing only the last frame implicitly also tests the preceeding
|
||||
// frames.
|
||||
EXPECT_TRUE(test::BitExactFrame(render_buffer.num_frames(),
|
||||
render_config.num_channels(),
|
||||
output_reference, render_output, kTolerance));
|
||||
EXPECT_TRUE(test::VerifyDeinterleavedArray(
|
||||
render_buffer.num_frames(), render_config.num_channels(),
|
||||
output_reference, render_output, kElementErrorBound));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -77,19 +77,19 @@ void RunBitexactnessTest(int sample_rate_hz,
|
||||
float speech_probability = noise_suppressor.speech_probability();
|
||||
std::vector<float> noise_estimate = noise_suppressor.NoiseEstimate();
|
||||
|
||||
const float kTolerance = 1.0f / 32768.0f;
|
||||
const float kVectorElementErrorBound = 1.0f / 32768.0f;
|
||||
EXPECT_FLOAT_EQ(speech_probability_reference, speech_probability);
|
||||
EXPECT_TRUE(test::BitExactVector(noise_estimate_reference, noise_estimate,
|
||||
kTolerance));
|
||||
EXPECT_TRUE(test::VerifyArray(noise_estimate_reference, noise_estimate,
|
||||
kVectorElementErrorBound));
|
||||
|
||||
// Compare the output with the reference. Only the first values of the output
|
||||
// from last frame processed are compared in order not having to specify all
|
||||
// preceeding frames as testvectors. As the algorithm being tested has a
|
||||
// memory, testing only the last frame implicitly also tests the preceeding
|
||||
// frames.
|
||||
EXPECT_TRUE(test::BitExactFrame(
|
||||
EXPECT_TRUE(test::VerifyDeinterleavedArray(
|
||||
capture_config.num_frames(), capture_config.num_channels(),
|
||||
output_reference, capture_output, kTolerance));
|
||||
output_reference, capture_output, kVectorElementErrorBound));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -70,11 +70,12 @@ void ReadFloatSamplesFromStereoFile(size_t samples_per_channel,
|
||||
}
|
||||
}
|
||||
|
||||
::testing::AssertionResult BitExactFrame(size_t samples_per_channel,
|
||||
size_t num_channels,
|
||||
rtc::ArrayView<const float> reference,
|
||||
rtc::ArrayView<const float> output,
|
||||
float tolerance) {
|
||||
::testing::AssertionResult VerifyDeinterleavedArray(
|
||||
size_t samples_per_channel,
|
||||
size_t num_channels,
|
||||
rtc::ArrayView<const float> reference,
|
||||
rtc::ArrayView<const float> output,
|
||||
float element_error_bound) {
|
||||
// Form vectors to compare the reference to. Only the first values of the
|
||||
// outputs are compared in order not having to specify all preceeding frames
|
||||
// as testvectors.
|
||||
@ -89,12 +90,12 @@ void ReadFloatSamplesFromStereoFile(size_t samples_per_channel,
|
||||
reference_frame_length);
|
||||
}
|
||||
|
||||
return BitExactVector(reference, output_to_verify, tolerance);
|
||||
return VerifyArray(reference, output_to_verify, element_error_bound);
|
||||
}
|
||||
|
||||
::testing::AssertionResult BitExactVector(rtc::ArrayView<const float> reference,
|
||||
rtc::ArrayView<const float> output,
|
||||
float tolerance) {
|
||||
::testing::AssertionResult VerifyArray(rtc::ArrayView<const float> reference,
|
||||
rtc::ArrayView<const float> output,
|
||||
float element_error_bound) {
|
||||
// The vectors are deemed to be bitexact only if
|
||||
// a) output have a size at least as long as the reference.
|
||||
// b) the samples in the reference are bitexact with the corresponding samples
|
||||
@ -106,7 +107,7 @@ void ReadFloatSamplesFromStereoFile(size_t samples_per_channel,
|
||||
} else {
|
||||
// Compare the first samples in the vectors.
|
||||
for (size_t k = 0; k < reference.size(); ++k) {
|
||||
if (fabs(output[k] - reference[k]) > tolerance) {
|
||||
if (fabs(output[k] - reference[k]) > element_error_bound) {
|
||||
equal = false;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -37,17 +37,18 @@ void ReadFloatSamplesFromStereoFile(size_t samples_per_channel,
|
||||
|
||||
// Verifies a frame against a reference and returns the results as an
|
||||
// AssertionResult.
|
||||
::testing::AssertionResult BitExactFrame(size_t samples_per_channel,
|
||||
size_t num_channels,
|
||||
rtc::ArrayView<const float> reference,
|
||||
rtc::ArrayView<const float> output,
|
||||
float tolerance);
|
||||
::testing::AssertionResult VerifyDeinterleavedArray(
|
||||
size_t samples_per_channel,
|
||||
size_t num_channels,
|
||||
rtc::ArrayView<const float> reference,
|
||||
rtc::ArrayView<const float> output,
|
||||
float element_error_bound);
|
||||
|
||||
// Verifies a vector against a reference and returns the results as an
|
||||
// AssertionResult.
|
||||
::testing::AssertionResult BitExactVector(rtc::ArrayView<const float> reference,
|
||||
rtc::ArrayView<const float> output,
|
||||
float tolerance);
|
||||
::testing::AssertionResult VerifyArray(rtc::ArrayView<const float> reference,
|
||||
rtc::ArrayView<const float> output,
|
||||
float element_error_bound);
|
||||
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user