Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

71 lines
2.9 KiB
C++
Raw Normal View History

/*
* Copyright (c) 2018 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_processing/agc2/rnn_vad/pitch_search.h"
#include <array>
#include <cstddef>
#include "rtc_base/checks.h"
namespace webrtc {
namespace rnn_vad {
PitchEstimator::PitchEstimator(const AvailableCpuFeatures& cpu_features)
: cpu_features_(cpu_features),
y_energy_24kHz_(kRefineNumLags24kHz, 0.f),
Reland "RNN VAD: pitch search optimizations (part 2)" This reverts commit e6a731fceae9503f6237d3ea287323aeac732ea6. Reason for revert: bug in parent CL fixed Original change's description: > Revert "RNN VAD: pitch search optimizations (part 2)" > > This reverts commit 2f7d1c62e21e2f3786c0803c973d71b414726d8d. > > Reason for revert: bug in ancestor CL https://webrtc-review.googlesource.com/c/src/+/191320 > > Original change's description: > > RNN VAD: pitch search optimizations (part 2) > > > > This CL brings a large improvement to the VAD by precomputing the > > energy for the sliding frame `y` in the pitch buffer instead of > > computing them twice in two different places. The realtime factor > > has improved by about +16x. > > > > There is room for additional improvement (TODOs added), but that will > > be done in a follow up CL since the change won't be bit-exact and > > careful testing is needed. > > > > Benchmarked as follows: > > ``` > > out/release/modules_unittests \ > > --gtest_filter=*RnnVadTest.DISABLED_RnnVadPerformance* \ > > --gtest_also_run_disabled_tests --logs > > ``` > > > > Results: > > > > | baseline | this CL > > ------+----------------------+------------------------ > > run 1 | 23.568 +/- 0.990788 | 22.8319 +/- 1.46554 > > | 377.207x | 389.367x > > ------+----------------------+------------------------ > > run 2 | 23.3714 +/- 0.857523 | 22.4286 +/- 0.726449 > > | 380.379x | 396.369x > > ------+----------------------+------------------------ > > run 2 | 23.709 +/- 1.04477 | 22.5688 +/- 0.831341 > > | 374.963x | 393.906x > > > > Bug: webrtc:10480 > > Change-Id: I599a4dda2bde16dc6c2f42cf89e96afbd4630311 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/191484 > > Reviewed-by: Per Åhgren <peah@webrtc.org> > > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#32571} > > TBR=alessiob@webrtc.org,peah@webrtc.org > > Change-Id: I53e478d8d58912c7a5fae4ad8a8d1342a9a48091 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:10480 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192620 > Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#32580} TBR=alessiob@webrtc.org,peah@webrtc.org # Not skipping CQ checks because this is a reland. Bug: webrtc:10480 Change-Id: I0d6c89c64587bb6c38e69b968df12a5eb499ac6f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192782 Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Per Åhgren <peah@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32586}
2020-11-11 12:23:07 +01:00
pitch_buffer_12kHz_(kBufSize12kHz),
auto_correlation_12kHz_(kNumLags12kHz) {}
PitchEstimator::~PitchEstimator() = default;
Reland "RNN VAD: pitch search optimizations (part 1)" This reverts commit 1b6b958a4aa574b7852fe62efe5d4f96ce085d8b. Reason for revert: Bug fix Original change's description: > Revert "RNN VAD: pitch search optimizations (part 1)" > > This reverts commit 9da3e177fd5c2236cc15fea0ee8933e1dd0d8f6d. > > Reason for revert: bug in ComputePitchPeriod48kHz() > > Original change's description: > > RNN VAD: pitch search optimizations (part 1) > > > > TL;DR this CL improves efficiency and includes several code > > readability improvements mainly triggered by the comments to > > patch set #10. > > > > Highlights: > > - Split `FindBestPitchPeriods()` into 12 and 24 kHz versions > > to hard-code the input size and simplify the 24 kHz version > > - Loop in `ComputePitchPeriod48kHz()` (new name for > > `RefinePitchPeriod48kHz()`) removed since the lags for which > > we need to compute the auto correlation are a few > > - `ComputePitchGainThreshold()` was only used in unit tests; it's been > > moved into the anon ns and the test removed > > > > This CL makes `ComputePitchPeriod48kHz()` is about 10% faster (measured > > with https://webrtc-review.googlesource.com/c/src/+/191320/4/modules/audio_processing/agc2/rnn_vad/pitch_search_internal_unittest.cc). > > The realtime factor has improved by about +14%. > > > > Benchmarked as follows: > > ``` > > out/release/modules_unittests \ > > --gtest_filter=*RnnVadTest.DISABLED_RnnVadPerformance* \ > > --gtest_also_run_disabled_tests --logs > > ``` > > > > Results: > > > > | baseline | this CL > > ------+----------------------+------------------------ > > run 1 | 24.0231 +/- 0.591016 | 23.568 +/- 0.990788 > > | 370.06x | 377.207x > > ------+----------------------+------------------------ > > run 2 | 24.0485 +/- 0.957498 | 23.3714 +/- 0.857523 > > | 369.67x | 380.379x > > ------+----------------------+------------------------ > > run 2 | 25.4091 +/- 2.6123 | 23.709 +/- 1.04477 > > | 349.875x | 374.963x > > > > Bug: webrtc:10480 > > Change-Id: I9a3e9164b2442114b928de506c92a547c273882f > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/191320 > > Reviewed-by: Per Åhgren <peah@webrtc.org> > > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#32568} > > TBR=alessiob@webrtc.org,peah@webrtc.org > > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:10480 > Change-Id: I2a91f4f29566f872a7dfa220b31c6c625ed075db > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192660 > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> > Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#32581} TBR=alessiob@webrtc.org,peah@webrtc.org # Not skipping CQ checks because this is a reland. Bug: webrtc:10480 Change-Id: I66e3e8d73ebc04a437c01a0396cd5613c42a8cf5 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192780 Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Per Åhgren <peah@webrtc.org> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32585}
2020-11-11 12:06:09 +01:00
int PitchEstimator::Estimate(
rtc::ArrayView<const float, kBufSize24kHz> pitch_buffer) {
Reland "RNN VAD: pitch search optimizations (part 2)" This reverts commit e6a731fceae9503f6237d3ea287323aeac732ea6. Reason for revert: bug in parent CL fixed Original change's description: > Revert "RNN VAD: pitch search optimizations (part 2)" > > This reverts commit 2f7d1c62e21e2f3786c0803c973d71b414726d8d. > > Reason for revert: bug in ancestor CL https://webrtc-review.googlesource.com/c/src/+/191320 > > Original change's description: > > RNN VAD: pitch search optimizations (part 2) > > > > This CL brings a large improvement to the VAD by precomputing the > > energy for the sliding frame `y` in the pitch buffer instead of > > computing them twice in two different places. The realtime factor > > has improved by about +16x. > > > > There is room for additional improvement (TODOs added), but that will > > be done in a follow up CL since the change won't be bit-exact and > > careful testing is needed. > > > > Benchmarked as follows: > > ``` > > out/release/modules_unittests \ > > --gtest_filter=*RnnVadTest.DISABLED_RnnVadPerformance* \ > > --gtest_also_run_disabled_tests --logs > > ``` > > > > Results: > > > > | baseline | this CL > > ------+----------------------+------------------------ > > run 1 | 23.568 +/- 0.990788 | 22.8319 +/- 1.46554 > > | 377.207x | 389.367x > > ------+----------------------+------------------------ > > run 2 | 23.3714 +/- 0.857523 | 22.4286 +/- 0.726449 > > | 380.379x | 396.369x > > ------+----------------------+------------------------ > > run 2 | 23.709 +/- 1.04477 | 22.5688 +/- 0.831341 > > | 374.963x | 393.906x > > > > Bug: webrtc:10480 > > Change-Id: I599a4dda2bde16dc6c2f42cf89e96afbd4630311 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/191484 > > Reviewed-by: Per Åhgren <peah@webrtc.org> > > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#32571} > > TBR=alessiob@webrtc.org,peah@webrtc.org > > Change-Id: I53e478d8d58912c7a5fae4ad8a8d1342a9a48091 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:10480 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192620 > Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#32580} TBR=alessiob@webrtc.org,peah@webrtc.org # Not skipping CQ checks because this is a reland. Bug: webrtc:10480 Change-Id: I0d6c89c64587bb6c38e69b968df12a5eb499ac6f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192782 Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Per Åhgren <peah@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32586}
2020-11-11 12:23:07 +01:00
rtc::ArrayView<float, kBufSize12kHz> pitch_buffer_12kHz_view(
pitch_buffer_12kHz_.data(), kBufSize12kHz);
RTC_DCHECK_EQ(pitch_buffer_12kHz_.size(), pitch_buffer_12kHz_view.size());
rtc::ArrayView<float, kNumLags12kHz> auto_correlation_12kHz_view(
auto_correlation_12kHz_.data(), kNumLags12kHz);
RTC_DCHECK_EQ(auto_correlation_12kHz_.size(),
auto_correlation_12kHz_view.size());
// TODO(bugs.chromium.org/10480): Use `cpu_features_` to estimate pitch.
// Perform the initial pitch search at 12 kHz.
Reland "RNN VAD: pitch search optimizations (part 2)" This reverts commit e6a731fceae9503f6237d3ea287323aeac732ea6. Reason for revert: bug in parent CL fixed Original change's description: > Revert "RNN VAD: pitch search optimizations (part 2)" > > This reverts commit 2f7d1c62e21e2f3786c0803c973d71b414726d8d. > > Reason for revert: bug in ancestor CL https://webrtc-review.googlesource.com/c/src/+/191320 > > Original change's description: > > RNN VAD: pitch search optimizations (part 2) > > > > This CL brings a large improvement to the VAD by precomputing the > > energy for the sliding frame `y` in the pitch buffer instead of > > computing them twice in two different places. The realtime factor > > has improved by about +16x. > > > > There is room for additional improvement (TODOs added), but that will > > be done in a follow up CL since the change won't be bit-exact and > > careful testing is needed. > > > > Benchmarked as follows: > > ``` > > out/release/modules_unittests \ > > --gtest_filter=*RnnVadTest.DISABLED_RnnVadPerformance* \ > > --gtest_also_run_disabled_tests --logs > > ``` > > > > Results: > > > > | baseline | this CL > > ------+----------------------+------------------------ > > run 1 | 23.568 +/- 0.990788 | 22.8319 +/- 1.46554 > > | 377.207x | 389.367x > > ------+----------------------+------------------------ > > run 2 | 23.3714 +/- 0.857523 | 22.4286 +/- 0.726449 > > | 380.379x | 396.369x > > ------+----------------------+------------------------ > > run 2 | 23.709 +/- 1.04477 | 22.5688 +/- 0.831341 > > | 374.963x | 393.906x > > > > Bug: webrtc:10480 > > Change-Id: I599a4dda2bde16dc6c2f42cf89e96afbd4630311 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/191484 > > Reviewed-by: Per Åhgren <peah@webrtc.org> > > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#32571} > > TBR=alessiob@webrtc.org,peah@webrtc.org > > Change-Id: I53e478d8d58912c7a5fae4ad8a8d1342a9a48091 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:10480 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192620 > Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#32580} TBR=alessiob@webrtc.org,peah@webrtc.org # Not skipping CQ checks because this is a reland. Bug: webrtc:10480 Change-Id: I0d6c89c64587bb6c38e69b968df12a5eb499ac6f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192782 Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Per Åhgren <peah@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32586}
2020-11-11 12:23:07 +01:00
Decimate2x(pitch_buffer, pitch_buffer_12kHz_view);
auto_corr_calculator_.ComputeOnPitchBuffer(pitch_buffer_12kHz_view,
auto_correlation_12kHz_view);
CandidatePitchPeriods pitch_periods = ComputePitchPeriod12kHz(
pitch_buffer_12kHz_view, auto_correlation_12kHz_view, cpu_features_);
// The refinement is done using the pitch buffer that contains 24 kHz samples.
// Therefore, adapt the inverted lags in `pitch_candidates_inv_lags` from 12
// to 24 kHz.
Reland "RNN VAD: pitch search optimizations (part 2)" This reverts commit e6a731fceae9503f6237d3ea287323aeac732ea6. Reason for revert: bug in parent CL fixed Original change's description: > Revert "RNN VAD: pitch search optimizations (part 2)" > > This reverts commit 2f7d1c62e21e2f3786c0803c973d71b414726d8d. > > Reason for revert: bug in ancestor CL https://webrtc-review.googlesource.com/c/src/+/191320 > > Original change's description: > > RNN VAD: pitch search optimizations (part 2) > > > > This CL brings a large improvement to the VAD by precomputing the > > energy for the sliding frame `y` in the pitch buffer instead of > > computing them twice in two different places. The realtime factor > > has improved by about +16x. > > > > There is room for additional improvement (TODOs added), but that will > > be done in a follow up CL since the change won't be bit-exact and > > careful testing is needed. > > > > Benchmarked as follows: > > ``` > > out/release/modules_unittests \ > > --gtest_filter=*RnnVadTest.DISABLED_RnnVadPerformance* \ > > --gtest_also_run_disabled_tests --logs > > ``` > > > > Results: > > > > | baseline | this CL > > ------+----------------------+------------------------ > > run 1 | 23.568 +/- 0.990788 | 22.8319 +/- 1.46554 > > | 377.207x | 389.367x > > ------+----------------------+------------------------ > > run 2 | 23.3714 +/- 0.857523 | 22.4286 +/- 0.726449 > > | 380.379x | 396.369x > > ------+----------------------+------------------------ > > run 2 | 23.709 +/- 1.04477 | 22.5688 +/- 0.831341 > > | 374.963x | 393.906x > > > > Bug: webrtc:10480 > > Change-Id: I599a4dda2bde16dc6c2f42cf89e96afbd4630311 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/191484 > > Reviewed-by: Per Åhgren <peah@webrtc.org> > > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#32571} > > TBR=alessiob@webrtc.org,peah@webrtc.org > > Change-Id: I53e478d8d58912c7a5fae4ad8a8d1342a9a48091 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:10480 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192620 > Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#32580} TBR=alessiob@webrtc.org,peah@webrtc.org # Not skipping CQ checks because this is a reland. Bug: webrtc:10480 Change-Id: I0d6c89c64587bb6c38e69b968df12a5eb499ac6f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192782 Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Per Åhgren <peah@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32586}
2020-11-11 12:23:07 +01:00
pitch_periods.best *= 2;
pitch_periods.second_best *= 2;
// Refine the initial pitch period estimation from 12 kHz to 48 kHz.
// Pre-compute frame energies at 24 kHz.
rtc::ArrayView<float, kRefineNumLags24kHz> y_energy_24kHz_view(
y_energy_24kHz_.data(), kRefineNumLags24kHz);
RTC_DCHECK_EQ(y_energy_24kHz_.size(), y_energy_24kHz_view.size());
ComputeSlidingFrameSquareEnergies24kHz(pitch_buffer, y_energy_24kHz_view,
cpu_features_);
Reland "RNN VAD: pitch search optimizations (part 2)" This reverts commit e6a731fceae9503f6237d3ea287323aeac732ea6. Reason for revert: bug in parent CL fixed Original change's description: > Revert "RNN VAD: pitch search optimizations (part 2)" > > This reverts commit 2f7d1c62e21e2f3786c0803c973d71b414726d8d. > > Reason for revert: bug in ancestor CL https://webrtc-review.googlesource.com/c/src/+/191320 > > Original change's description: > > RNN VAD: pitch search optimizations (part 2) > > > > This CL brings a large improvement to the VAD by precomputing the > > energy for the sliding frame `y` in the pitch buffer instead of > > computing them twice in two different places. The realtime factor > > has improved by about +16x. > > > > There is room for additional improvement (TODOs added), but that will > > be done in a follow up CL since the change won't be bit-exact and > > careful testing is needed. > > > > Benchmarked as follows: > > ``` > > out/release/modules_unittests \ > > --gtest_filter=*RnnVadTest.DISABLED_RnnVadPerformance* \ > > --gtest_also_run_disabled_tests --logs > > ``` > > > > Results: > > > > | baseline | this CL > > ------+----------------------+------------------------ > > run 1 | 23.568 +/- 0.990788 | 22.8319 +/- 1.46554 > > | 377.207x | 389.367x > > ------+----------------------+------------------------ > > run 2 | 23.3714 +/- 0.857523 | 22.4286 +/- 0.726449 > > | 380.379x | 396.369x > > ------+----------------------+------------------------ > > run 2 | 23.709 +/- 1.04477 | 22.5688 +/- 0.831341 > > | 374.963x | 393.906x > > > > Bug: webrtc:10480 > > Change-Id: I599a4dda2bde16dc6c2f42cf89e96afbd4630311 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/191484 > > Reviewed-by: Per Åhgren <peah@webrtc.org> > > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#32571} > > TBR=alessiob@webrtc.org,peah@webrtc.org > > Change-Id: I53e478d8d58912c7a5fae4ad8a8d1342a9a48091 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:10480 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192620 > Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#32580} TBR=alessiob@webrtc.org,peah@webrtc.org # Not skipping CQ checks because this is a reland. Bug: webrtc:10480 Change-Id: I0d6c89c64587bb6c38e69b968df12a5eb499ac6f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192782 Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Per Åhgren <peah@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32586}
2020-11-11 12:23:07 +01:00
// Estimation at 48 kHz.
const int pitch_lag_48kHz = ComputePitchPeriod48kHz(
pitch_buffer, y_energy_24kHz_view, pitch_periods, cpu_features_);
Reland "RNN VAD: pitch search optimizations (part 1)" This reverts commit 1b6b958a4aa574b7852fe62efe5d4f96ce085d8b. Reason for revert: Bug fix Original change's description: > Revert "RNN VAD: pitch search optimizations (part 1)" > > This reverts commit 9da3e177fd5c2236cc15fea0ee8933e1dd0d8f6d. > > Reason for revert: bug in ComputePitchPeriod48kHz() > > Original change's description: > > RNN VAD: pitch search optimizations (part 1) > > > > TL;DR this CL improves efficiency and includes several code > > readability improvements mainly triggered by the comments to > > patch set #10. > > > > Highlights: > > - Split `FindBestPitchPeriods()` into 12 and 24 kHz versions > > to hard-code the input size and simplify the 24 kHz version > > - Loop in `ComputePitchPeriod48kHz()` (new name for > > `RefinePitchPeriod48kHz()`) removed since the lags for which > > we need to compute the auto correlation are a few > > - `ComputePitchGainThreshold()` was only used in unit tests; it's been > > moved into the anon ns and the test removed > > > > This CL makes `ComputePitchPeriod48kHz()` is about 10% faster (measured > > with https://webrtc-review.googlesource.com/c/src/+/191320/4/modules/audio_processing/agc2/rnn_vad/pitch_search_internal_unittest.cc). > > The realtime factor has improved by about +14%. > > > > Benchmarked as follows: > > ``` > > out/release/modules_unittests \ > > --gtest_filter=*RnnVadTest.DISABLED_RnnVadPerformance* \ > > --gtest_also_run_disabled_tests --logs > > ``` > > > > Results: > > > > | baseline | this CL > > ------+----------------------+------------------------ > > run 1 | 24.0231 +/- 0.591016 | 23.568 +/- 0.990788 > > | 370.06x | 377.207x > > ------+----------------------+------------------------ > > run 2 | 24.0485 +/- 0.957498 | 23.3714 +/- 0.857523 > > | 369.67x | 380.379x > > ------+----------------------+------------------------ > > run 2 | 25.4091 +/- 2.6123 | 23.709 +/- 1.04477 > > | 349.875x | 374.963x > > > > Bug: webrtc:10480 > > Change-Id: I9a3e9164b2442114b928de506c92a547c273882f > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/191320 > > Reviewed-by: Per Åhgren <peah@webrtc.org> > > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#32568} > > TBR=alessiob@webrtc.org,peah@webrtc.org > > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:10480 > Change-Id: I2a91f4f29566f872a7dfa220b31c6c625ed075db > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192660 > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> > Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#32581} TBR=alessiob@webrtc.org,peah@webrtc.org # Not skipping CQ checks because this is a reland. Bug: webrtc:10480 Change-Id: I66e3e8d73ebc04a437c01a0396cd5613c42a8cf5 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192780 Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Per Åhgren <peah@webrtc.org> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32585}
2020-11-11 12:06:09 +01:00
last_pitch_48kHz_ = ComputeExtendedPitchPeriod48kHz(
Reland "RNN VAD: pitch search optimizations (part 2)" This reverts commit e6a731fceae9503f6237d3ea287323aeac732ea6. Reason for revert: bug in parent CL fixed Original change's description: > Revert "RNN VAD: pitch search optimizations (part 2)" > > This reverts commit 2f7d1c62e21e2f3786c0803c973d71b414726d8d. > > Reason for revert: bug in ancestor CL https://webrtc-review.googlesource.com/c/src/+/191320 > > Original change's description: > > RNN VAD: pitch search optimizations (part 2) > > > > This CL brings a large improvement to the VAD by precomputing the > > energy for the sliding frame `y` in the pitch buffer instead of > > computing them twice in two different places. The realtime factor > > has improved by about +16x. > > > > There is room for additional improvement (TODOs added), but that will > > be done in a follow up CL since the change won't be bit-exact and > > careful testing is needed. > > > > Benchmarked as follows: > > ``` > > out/release/modules_unittests \ > > --gtest_filter=*RnnVadTest.DISABLED_RnnVadPerformance* \ > > --gtest_also_run_disabled_tests --logs > > ``` > > > > Results: > > > > | baseline | this CL > > ------+----------------------+------------------------ > > run 1 | 23.568 +/- 0.990788 | 22.8319 +/- 1.46554 > > | 377.207x | 389.367x > > ------+----------------------+------------------------ > > run 2 | 23.3714 +/- 0.857523 | 22.4286 +/- 0.726449 > > | 380.379x | 396.369x > > ------+----------------------+------------------------ > > run 2 | 23.709 +/- 1.04477 | 22.5688 +/- 0.831341 > > | 374.963x | 393.906x > > > > Bug: webrtc:10480 > > Change-Id: I599a4dda2bde16dc6c2f42cf89e96afbd4630311 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/191484 > > Reviewed-by: Per Åhgren <peah@webrtc.org> > > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#32571} > > TBR=alessiob@webrtc.org,peah@webrtc.org > > Change-Id: I53e478d8d58912c7a5fae4ad8a8d1342a9a48091 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:10480 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192620 > Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#32580} TBR=alessiob@webrtc.org,peah@webrtc.org # Not skipping CQ checks because this is a reland. Bug: webrtc:10480 Change-Id: I0d6c89c64587bb6c38e69b968df12a5eb499ac6f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192782 Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Per Åhgren <peah@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32586}
2020-11-11 12:23:07 +01:00
pitch_buffer, y_energy_24kHz_view,
/*initial_pitch_period_48kHz=*/kMaxPitch48kHz - pitch_lag_48kHz,
last_pitch_48kHz_, cpu_features_);
Reland "RNN VAD: pitch search optimizations (part 1)" This reverts commit 1b6b958a4aa574b7852fe62efe5d4f96ce085d8b. Reason for revert: Bug fix Original change's description: > Revert "RNN VAD: pitch search optimizations (part 1)" > > This reverts commit 9da3e177fd5c2236cc15fea0ee8933e1dd0d8f6d. > > Reason for revert: bug in ComputePitchPeriod48kHz() > > Original change's description: > > RNN VAD: pitch search optimizations (part 1) > > > > TL;DR this CL improves efficiency and includes several code > > readability improvements mainly triggered by the comments to > > patch set #10. > > > > Highlights: > > - Split `FindBestPitchPeriods()` into 12 and 24 kHz versions > > to hard-code the input size and simplify the 24 kHz version > > - Loop in `ComputePitchPeriod48kHz()` (new name for > > `RefinePitchPeriod48kHz()`) removed since the lags for which > > we need to compute the auto correlation are a few > > - `ComputePitchGainThreshold()` was only used in unit tests; it's been > > moved into the anon ns and the test removed > > > > This CL makes `ComputePitchPeriod48kHz()` is about 10% faster (measured > > with https://webrtc-review.googlesource.com/c/src/+/191320/4/modules/audio_processing/agc2/rnn_vad/pitch_search_internal_unittest.cc). > > The realtime factor has improved by about +14%. > > > > Benchmarked as follows: > > ``` > > out/release/modules_unittests \ > > --gtest_filter=*RnnVadTest.DISABLED_RnnVadPerformance* \ > > --gtest_also_run_disabled_tests --logs > > ``` > > > > Results: > > > > | baseline | this CL > > ------+----------------------+------------------------ > > run 1 | 24.0231 +/- 0.591016 | 23.568 +/- 0.990788 > > | 370.06x | 377.207x > > ------+----------------------+------------------------ > > run 2 | 24.0485 +/- 0.957498 | 23.3714 +/- 0.857523 > > | 369.67x | 380.379x > > ------+----------------------+------------------------ > > run 2 | 25.4091 +/- 2.6123 | 23.709 +/- 1.04477 > > | 349.875x | 374.963x > > > > Bug: webrtc:10480 > > Change-Id: I9a3e9164b2442114b928de506c92a547c273882f > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/191320 > > Reviewed-by: Per Åhgren <peah@webrtc.org> > > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#32568} > > TBR=alessiob@webrtc.org,peah@webrtc.org > > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:10480 > Change-Id: I2a91f4f29566f872a7dfa220b31c6c625ed075db > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192660 > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> > Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#32581} TBR=alessiob@webrtc.org,peah@webrtc.org # Not skipping CQ checks because this is a reland. Bug: webrtc:10480 Change-Id: I66e3e8d73ebc04a437c01a0396cd5613c42a8cf5 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192780 Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Per Åhgren <peah@webrtc.org> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32585}
2020-11-11 12:06:09 +01:00
return last_pitch_48kHz_.period;
}
} // namespace rnn_vad
} // namespace webrtc