forked from JumpingYang001/webrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NetEq/Stats: Don't let concealed_samples decrease
When NetEq performs a merge operation, it will usually have to correct the stats for number of concealment samples produced, sometimes with decreasing it. This does not make sense in the context of the stats spec, and stats-consuming applications may not be prepared for it. With this change, only positive corrections are allowed for the concealed_samples value. This will sometimes lead to a small positive bias, but it will be negligible over time. Bug: webrtc:8253 Change-Id: Ie9de311ab16401f1a4b435f6269725901b8cf561 Reviewed-on: https://webrtc-review.googlesource.com/1583 Commit-Queue: Henrik Lundin <[email protected]> Reviewed-by: Gustaf Ullberg <[email protected]> Cr-Commit-Position: refs/heads/master@{#19941}
- Loading branch information
Henrik Lundin
authored and
Commit Bot
committed
Sep 25, 2017
1 parent
b4aeb5b
commit ac0a503
Showing
5 changed files
with
109 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
modules/audio_coding/neteq/statistics_calculator_unittest.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (c) 2017 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 "modules/audio_coding/neteq/statistics_calculator.h" | ||
|
||
#include "test/gtest.h" | ||
|
||
namespace webrtc { | ||
|
||
TEST(LifetimeStatistics, TotalSamplesReceived) { | ||
StatisticsCalculator stats; | ||
for (int i = 0; i < 10; ++i) { | ||
stats.IncreaseCounter(480, 48000); // 10 ms at 48 kHz. | ||
} | ||
EXPECT_EQ(10 * 480u, stats.GetLifetimeStatistics().total_samples_received); | ||
} | ||
|
||
TEST(LifetimeStatistics, SamplesConcealed) { | ||
StatisticsCalculator stats; | ||
stats.ExpandedVoiceSamples(100, false); | ||
stats.ExpandedNoiseSamples(17, false); | ||
EXPECT_EQ(100u + 17u, stats.GetLifetimeStatistics().concealed_samples); | ||
} | ||
|
||
// This test verifies that a negative correction of concealed_samples does not | ||
// result in a decrease in the stats value (because stats-consuming applications | ||
// would not expect the value to decrease). Instead, the correction should be | ||
// made to future increments to the stat. | ||
TEST(LifetimeStatistics, SamplesConcealedCorrection) { | ||
StatisticsCalculator stats; | ||
stats.ExpandedVoiceSamples(100, false); | ||
EXPECT_EQ(100u, stats.GetLifetimeStatistics().concealed_samples); | ||
stats.ExpandedVoiceSamplesCorrection(-10); | ||
// Do not subtract directly, but keep the correction for later. | ||
EXPECT_EQ(100u, stats.GetLifetimeStatistics().concealed_samples); | ||
stats.ExpandedVoiceSamplesCorrection(20); | ||
// The total correction is 20 - 10. | ||
EXPECT_EQ(110u, stats.GetLifetimeStatistics().concealed_samples); | ||
|
||
// Also test correction done to the next ExpandedVoiceSamples call. | ||
stats.ExpandedVoiceSamplesCorrection(-17); | ||
EXPECT_EQ(110u, stats.GetLifetimeStatistics().concealed_samples); | ||
stats.ExpandedVoiceSamples(100, false); | ||
EXPECT_EQ(110u + 100u - 17u, stats.GetLifetimeStatistics().concealed_samples); | ||
} | ||
|
||
// This test verifies that neither "accelerate" nor "pre-emptive expand" reults | ||
// in a modification to concealed_samples stats. Only PLC operations (i.e., | ||
// "expand" and "merge") should affect the stat. | ||
TEST(LifetimeStatistics, NoUpdateOnTimeStretch) { | ||
StatisticsCalculator stats; | ||
stats.ExpandedVoiceSamples(100, false); | ||
stats.AcceleratedSamples(4711); | ||
stats.PreemptiveExpandedSamples(17); | ||
stats.ExpandedVoiceSamples(100, false); | ||
EXPECT_EQ(200u, stats.GetLifetimeStatistics().concealed_samples); | ||
} | ||
|
||
} // namespace webrtc |