Commit graph

1233 commits

Author SHA1 Message Date
Hanna Silen
529131d3e4 Add AnalogGainStatsReporter to compute and report analog gain statistics
Implement AnalogGainStatsReporter and add it in AudioProcessingImpl.
This class computes statistics for analog gain updates and
periodically reports them into a histogram.

The added histograms for analog gain update statistics:

 - WebRTC.Audio.ApmAnalogGainDecreaseRate
 - WebRTC.Audio.ApmAnalogGainIncreaseRate
 - WebRTC.Audio.ApmAnalogGainUpdateRate
 - WebRTC.Audio.ApmAnalogGainDecreaseAverage
 - WebRTC.Audio.ApmAnalogGainIncreaseAverage
 - WebRTC.Audio.ApmAnalogGainUpdateAverage

The histograms are defined in
https://chromium-review.googlesource.com/c/chromium/src/+/3207987

Bug: webrtc:12774
Change-Id: I3c58d4bb3eb034a11c3f39ab8edb2bc67c5fd5e4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/234140
Commit-Queue: Hanna Silen <silen@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35301}
2021-11-03 06:32:33 +00:00
Hanna Silen
cd59704f8d AudioProcessing: Make minimum and maximum analog levels non-configurable
Remove analog_level_minimum and analog_level_maximum from
AudioProcessing GainController1 and replace their use with fixed
values 0 and 255, respectively.

Bug: webrtc:12774
Change-Id: Ia4bfe5ed43a65f1587ed67f36bfbb2966b6fdf26
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/235822
Commit-Queue: Hanna Silen <silen@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35297}
2021-11-02 12:49:50 +00:00
Alessio Bazzica
58d6bef0d4 AudioProcessingImplLockTest: stop using ApplyConfig()
`AudioProcessingImpl::ApplyConfig()` is deprecated, instead this CL uses
`AudioProcessingBuilderForTesting::SetConfig()`.

Also includes code style improvements.

Bug: webrtc:5298
Change-Id: Id6790bd110f2eb87deafa851f5c83c3fd00692b9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/235376
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35288}
2021-11-01 09:13:09 +00:00
Alessio Bazzica
2fa4618a3b AGC2: AdaptiveAgc ctor with sample rate and # of channels
The class has also been renamed to better reflect its purpose.

Bug: webrtc:7494
Change-Id: I223a364ab4f8b8a5fef765848bf05675d045cefd
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/236343
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35277}
2021-10-28 15:28:12 +00:00
Alessio Bazzica
2bf6d45f14 BiQuadFilter: API improvements
Bug: webrtc:7494
Change-Id: If0270cddeb46fa53c0fbb385c85e48f28f9e1a5c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/236342
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35274}
2021-10-28 14:04:09 +00:00
Mirko Bonadei
e5e78c4521 Fix -Wunused-but-set-variable.
Bug: None
Change-Id: I8943227108e46c4c942895e4bd8fb276947502e0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/236525
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35272}
2021-10-28 12:53:49 +00:00
Alessio Bazzica
60f675ff8d AGC2: fix fixed digital init, VAD before fixed digital
This CL includes two changes that break bit-exactness, but that haven't
changed the way AGC2 behaves - the new behavior has been verified with
audioproc_f on a collection of AEC dumps and Wav files (42 recordings
in total).

1) The fixed digital controller can directly be initialized in the
`GainController2` ctor. Before, `SetGainFactor()` was called after the
creation of the object and that caused an initial ramp up lasting one
10 ms frame from -inf to 0 dB. As an effect of the new initialization,
the initial ramp up doesn't happen anymore.

2) In [1] the AGC2 VAD has been moved from the adaptive digital
controller into `GainController2`. In order to not break bit-exactness,
the VAD was placed after the fixed digital controller and before the
adaptive digital one. However, to reduce the chance of incorrect
estimation of the speech probability, the VAD should analyze the
audio before any digital processing is applied inside AGC2.

[1] https://webrtc-review.googlesource.com/c/src/+/234583

Bug: webrtc:7494
Change-Id: I9418229cbe537014fed8271c5550c3ce2bc88e26
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/235240
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35252}
2021-10-20 20:28:23 +00:00
Alessio Bazzica
b4d4ae2c23 AGC2: VAD moved into GainController2
Bit exactness verified with audioproc_f on a collection of AEC dumps
and Wav files (42 recordings in total).

Bug: webrtc:7494
Change-Id: Id9849c4463791f5a203afe31efc163efb4d4458e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/234583
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35248}
2021-10-20 15:50:33 +00:00
Alessio Bazzica
183c64ce19 APM: remove LevelEstimator
Only used in unit tests and a duplication of what `capture_output_rms_`
already does.

This CL also removes `AudioProcessingStats::output_rms_dbfs`, which is
now unused.

Bug: webrtc:5298
Fix: chromium:1261339
Change-Id: I6e583c11d4abb58444c440509a8495a7f5ebc589
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/235664
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35246}
2021-10-20 10:52:17 +00:00
Alessio Bazzica
bf2a70a14d APM: fix level estimator null pointer bug
When APM is used without calling `ApplyConfig()` and the level
estimator sub-module, which is disabled by default (see [1]), is used,
APM crashes because the enabled config flag is true, but the unique
pointer object is unset.

[1] https://source.chromium.org/chromium/chromium/src/+/main:third_party/webrtc/modules/audio_processing/include/audio_processing.h;l=391?q=include%2Faudio_processing.h

Bug: webrtc:7494
Change-Id: I482a9aa4f6a0a56793769674aba7b2661330bb14
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/235375
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35230}
2021-10-18 15:59:07 +00:00
Alessio Bazzica
0b45462389 APM fuzzer: add SetConfig() to test builder
Also stop using ApplyConfig() and in [1] fix the build errors when
WEBRTC_EXCLUDE_AUDIO_PROCESSING_MODULE is defined.

[1] modules/audio_processing/test/audio_processing_builder_for_testing.cc

Bug: webrtc:5298
Change-Id: I50dc5668b952e7ca7fa83c7a5182c013e928c450
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/235365
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35228}
2021-10-18 14:53:37 +00:00
Alessio Bazzica
64e5830969 AGC2: VAD wrapper, add Initialize() method
Not passing the sample rate to the `VoiceActivityDetectorWrapper` ctor
yet since that would require an unnecessary refactoring of `AdaptiveAgc`
which will soon be removed.
Instead, to ensure correct initialization until the child CL [1] lands,
`VoiceActivityDetectorWrapper::initialized_` is temporarily added.

Bit exactness verified with audioproc_f on a collection of AEC dumps
and Wav files (42 recordings in total).

[1] https://webrtc-review.googlesource.com/c/src/+/234583

Bug: webrtc:7494
Change-Id: I4b4be7b8106ba36c958d91bf263a7b30271a1ee3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/234587
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35213}
2021-10-15 08:22:23 +00:00
Alessio Bazzica
8dbdf5e3bf AGC2: VadWithLevel -> VoiceActivityDetectorWrapper 2/2
Internal refactoring of AGC2 to decouple the VAD, its wrapper and the
peak and RMS level measurements.

Bit exactness verified with audioproc_f on a collection of AEC dumps
and Wav files (42 recordings in total).

Bug: webrtc:7494
Change-Id: Ib560f1fcaa601557f4f30e47025c69e91b1b62e0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/234524
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35208}
2021-10-14 13:32:25 +00:00
Alessio Bazzica
389010438d AGC2: GainController::ApplyConfig removed
When `AudioProcessingImpl::ApplyConfig()` is called, AGC2 is initialized
and then the new config is applied. That is error prone and for example
breaks bit exactness in [1].

Changes:
- `GainController2` must be created by passing configuration,
  sample rate and number of channels
- `GainController2::ApplyConfig()` removed

Bit exactness verified with audioproc_f on a collection of AEC dumps
and Wav files (42 recordings in total).

[1] https://webrtc-review.googlesource.com/c/src/+/234587.

Bug: webrtc:7494
Change-Id: I251e03603394a4fc8769b9b5c197a157893676a9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/235060
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35206}
2021-10-14 12:58:25 +00:00
Alessio Bazzica
f77f35b764 AGC2: gain_controller2 target isolated
Needed to restrict visibility.

Bug: webrtc:7494
Change-Id: I58a609666ca04d785c6dd2ed19233b395a94b06c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/234584
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35201}
2021-10-14 11:24:55 +00:00
Alessio Bazzica
20a9ac655c APM: add AudioProcessingBuilder::SetConfig()
Bug: webrtc:5298
Change-Id: If3468ebb841c49dcd410a8bea2f9f8111ee8bc06
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/234842
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35199}
2021-10-14 10:45:16 +00:00
Gustaf Ullberg
468bf9ac7f AEC3: Enable unbounded echo spectrum for dominant nearend detection by default
This change improves echo canceller transparency by enabling the use
of a non-capped ERLE when computing the residual echo spectrum for
dominant nearend detection.

Experimentation has shown that the feature improves echo canceller
transparency and user ratings.

Implementation CL:
https://webrtc-review.googlesource.com/c/src/+/221920

Bug: webrtc:12870
Change-Id: I7dc66810e8300cd35321bcd5b9fae9bc3386836d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/234841
Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35186}
2021-10-12 08:52:50 +00:00
Alessio Bazzica
585aad7323 AGC2: VadWithLevel -> VoiceActivityDetectorWrapper 1/2
Internal refactoring of AGC2. This CL is needed in preparation for its
child CL to correctly show the upcoming changes in the diff.

Bug: webrtc:7494
Change-Id: If7f837e064243d5ffe09e21fc68f489bb00dfdc5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/234527
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35170}
2021-10-08 16:15:24 +00:00
Alessio Bazzica
5c3ae49b44 AudioFrameView: size_t -> int
Bug: webrtc:7494
Change-Id: I46b1328f3d7da721e144cc3752ed4f458084cf62
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/234522
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35163}
2021-10-07 14:41:03 +00:00
Alessio Bazzica
82ea4ee9bf AGC2 refactoring: better names for GainController2 members
Bug: webrtc:7494
Change-Id: Ibac8a3953e68fa7bdbddfb9d4eb24f2712ba05b2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/234480
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35162}
2021-10-07 13:17:35 +00:00
Hanna Silen
5c7d5c9ce1 AudioProcessingImpl: Move analog gain change check
Move the check for analog gain changes so that it can be used
independently of echo_controller. This change is needed to land
https://webrtc-review.googlesource.com/c/src/+/234140.

Bug: webrtc:12774
Change-Id: I9ea127b0a4d374f31493d6f8afcacee40fa9257c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/234383
Commit-Queue: Hanna Silen <silen@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35159}
2021-10-06 17:13:52 +00:00
Alessio Bazzica
7b80d4480e AGC2: SIMD allowed config flags to field trials
Bug: webrtc:7494
Change-Id: I41fa05d2ef6d969750f3d4c1e40ecbcd30293b5a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/233741
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35144}
2021-10-05 12:01:38 +00:00
Alessio Bazzica
b8ffdc4bb3 APM: fix CaptureLevelAdjustment::operator==
Bug: webrtc:7494
Change-Id: I0ea13af2e23ed1490fa22d75d104bdd45b0452bf
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/233460
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35142}
2021-10-05 07:25:06 +00:00
Alessio Bazzica
a850e6c8b6 AGC2 config: allow tuning of headroom, max gain and initial gain
This CL does *not* change the behavior of the AGC2 adaptive digital
controller - bitexactness verified with audioproc_f on a collection of
AEC dumps and Wav files (42 recordings in total).

Tested: compiled Chrome with this patch and made an appr.tc test call

Bug: webrtc:7494
Change-Id: Ia8a9f6fbc3a3459b888a2eed87e108f0d39cfe99
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/233520
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35140}
2021-10-04 16:11:00 +00:00
Mirko Bonadei
54c90f2330 [-Wshadow] - Fix some warnings.
First CL to try to understand the extent of the cleanup needed in
order to remove -Wno-shadow and follow Chromium on enabling this
diagnostic.

Bug: webrtc:13219
Change-Id: Ie699762da50fe3dbc08b1fd92220962d4b7da86b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/233641
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35134}
2021-10-03 11:53:16 +00:00
Alessio Bazzica
43651f502c AdaptiveDigitalGainApplierTest parametric test fixed
Removing an unwanted change introduced by mistake in
https://webrtc-review.googlesource.com/c/src/+/232905.

Bug: webrtc:7494
Change-Id: Icc01952850f5e20debb42f8a5822fcef49769a6b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/233240
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35115}
2021-09-29 06:56:07 +00:00
Alessio Bazzica
5da581b564 AGC2: use only one headroom parameter
Instead of using two different headroom parameters, namely
`kHeadroomDbfs` and `kSaturationProtectorExtraHeadroomDb`, only use
the former that now also accounts for the deleted one - i.e., it equals
the sum of the two headrooms. In this way, tuning AGC2 will be easier.

This CL does *not* change the behavior of the AGC2 adaptive digital
controller - bitexactness verified with audioproc_f on a collection of
AEC dumps and Wav files (42 recordings in total).

The unit tests changes in agc2/saturation_protector_unittest.cc are
required since `extra_headroom_db` is removed and the changes in
agc2/adaptive_digital_gain_applier_unittest.cc are required because
`AdaptiveDigitalGainApplier` depends on `kHeadroomDbfs` which has been
updated as stated above.

Bug: webrtc:7494
Change-Id: I0a2a710bbede0caa53938090a004d185fdefaeb9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232905
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35109}
2021-09-28 16:52:16 +00:00
Alessio Bazzica
6ee9734887 AGC2: update adaptive digital test
This CL improves `GainController2::CheckGainAdaptiveDigital`, namely:
- correctly initialize AGC2 with the correct number of channels
- attenuate the input signal in order to avoid that the target gain is
  set to zero (which was the case before)
- run AG2 adaptive digital for a longer period to allow time to trigger
  the adaptive behavior (namely, from 2s to 10s)
- minor code style improvements

Bug: webrtc:7494
Change-Id: Ib41de088b341bb30460238b83e306a507b2bc5af
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/233101
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35099}
2021-09-27 16:05:25 +00:00
Alessio Bazzica
1ac4f2a29e AGC2: Remove unused parameters
- `NoiseEstimator` and `LevelEstimator` enums
- `vad_probability_attack`
- `level_estimator_adjacent_speech_frames_threshold`
- `use_saturation_protector`
- `gain_applier_adjacent_speech_frames_threshold`
- `initial_saturation_margin_db`
- `extra_saturation_margin_db`

Bug: webrtc:7494
Change-Id: I12e40c8efe2d2126d7597ec18a78cf9d5d39baf2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232903
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35096}
2021-09-27 11:14:35 +00:00
Hanna Silen
29386949a2 AudioProcessing: Add use_predicted_step in GainController1 comparison and string conversion
Bug: webrtc:12774
Change-Id: I8d268b343420108a715698ad45fec3c54f0962fd
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231644
Commit-Queue: Hanna Silen <silen@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35084}
2021-09-24 12:46:41 +00:00
Hanna Silen
8970b49c75 AgcManagerDirect: Add histograms for clipping prediction precision and recall
Add histograms WebRTC.Audio.Agc.ClippingPredictor.Precision and WebRTC.Audio.Agc.ClippingPredictor.Recall. The histograms are defined in https://chromium-review.googlesource.com/c/chromium/src/+/3150271.

Bug: webrtc:12774
Change-Id: I1561ec7a61377c262f636d7aa3a5d5fd60a8839d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231460
Commit-Queue: Hanna Silen <silen@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35083}
2021-09-24 12:42:13 +00:00
Alessio Bazzica
1b200b93d5 APM: remove webrtc::Config
Remove the deprecated way of configuring APM.

Bug: webrtc:5298
Change-Id: Idcedf1fe4a121adfcf2881003579cd58ac42a2b9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232302
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35026}
2021-09-17 11:21:32 +00:00
Alessio Bazzica
be1b8989d1 ExperimentalNs removed + APM not depending anymore on webrtc::Config
Thanks to the elimination of `ExperimentalNs`, there is no need anymore
to pass `webrtc::Config` to build APM.
Hence, `AudioProcessingBuilder::Create(const webrtc::Config&)` is also
removed.

Bug: webrtc:5298
Change-Id: I0a3482376a7753434486fe564681f7b9f83939c5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232128
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35025}
2021-09-17 10:53:43 +00:00
Alessio Bazzica
ff7e1bad1f APM config: remove ExperimentalAgc
Bug: webrtc:5298,webrtc:7494
Change-Id: Ic9bcb702603ec7900fbe9ae38ab49dff8fe99318
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/219463
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35015}
2021-09-16 13:28:51 +00:00
Jesús de Vicente Peña
5eb5bb5007 AEC3: Using a more conservative frequency response representation of the tails.
Bug: webrtc:13173
Change-Id: Ic469f6226fe079c306cec6f941eeb70d6d9094f3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231682
Commit-Queue: Jesus de Vicente Pena <devicentepena@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#34966}
2021-09-10 13:20:35 +00:00
Jesús de Vicente Peña
7d0203c723 AEC3: adding a milder exponential decay parameter that is used for dominant nearend regions when enabled.
Bug: webrtc:13143
Change-Id: Iedc6ff39ed5c7cd372b54a82c86354957c8852de
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231131
Commit-Queue: Per Åhgren <peah@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#34947}
2021-09-08 11:36:50 +00:00
Alessio Bazzica
f6c6b4a831 ClippingPredictorEvaluator: predictions only match future detections
To focus on the ability to predict clipping, the clipping predictor
evaluator doesn't increment the true positive count anymore when a
prediction is simultaneously observed with a detection.

Note that `WebRTC.Audio.Agc.ClippingPredictor.F1Score` is still used
to log the F1 score - i.e., the histogram hasn't been renamed.

Bug: webrtc:12774
Change-Id: Ia987e568a6df2a3ddba7fa1b5697d6feda22d20c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231233
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#34942}
2021-09-07 15:26:27 +00:00
Hanna Silen
0dfd69bf4e AgcManagerDirect: Fix the use of use_clipping_predictor_step_
Evaluate the clipping predictor whenever injected but keep using the
predictions only when allowed.

Bug: webrtc:12774
Change-Id: I9e8930a528d1d514d52b821a28b6c8ad0c3aeb5e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231137
Reviewed-by: Minyue Li <minyue@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#34937}
2021-09-07 12:44:07 +00:00
Alessio Bazzica
1ce81d6bf5 AGC clipping predictor eval: add ComputeClippingPredictionMetrics()
Move Precision, Recall and F1-score computation from `AgcManagerDirect`
to a separate function that can be tested.

Bug: webrtc:12774
Change-Id: Iba20f153a72b7f957bf938e0642055d421045c02
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231228
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#34933}
2021-09-06 20:03:51 +00:00
Hanna Silen
2986e6a791 AgcManagerDirect: Refine unit tests
Add unit tests `UsedClippingPredictionsProduceLowerAnalogLevels` and
`UnusedClippingPredictionsProduceEqualAnalogLevels`. These tests replace
the existing tests `EnableClippingPredictorLowersVolume` and
`EnableClippingPredictorWithUnusedPredictedStepDoesNotLowerVolume`.

Bug: webrtc:12774
Change-Id: I2f5b726d58d8afb3d3bf39a3c96fa8d3910fa9e0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231225
Commit-Queue: Hanna Silen <silen@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#34932}
2021-09-06 17:46:21 +00:00
Alessio Bazzica
b8a19df71c AGC2: removed unused noise estimator implementation
This CL also includes the following changes:
- `AudioProcessing::Config::GainController2::noise_estimator`
  deprecated
- `EnergyToDbfs()` optimized by removing unnecessary `sqrt`
- Unit test minor fix, incorrect type was used

Bug: webrtc:7494
Change-Id: I88a6672d6f7cd03fcf6a3031883522d256880140
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/230940
Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#34893}
2021-09-01 12:45:20 +00:00
Mirko Bonadei
f135800b5c Roll chromium_revision 47dc8e2f50..680b7dae9d (912091:912910)
Change log: 47dc8e2f50..680b7dae9d
Full diff: 47dc8e2f50..680b7dae9d

Changed dependencies
* src/base: 959457e3f3..4bcc0feab1
* src/build: a0d51919fe..02ca29f24d
* src/buildtools: 6810b870e0..6f9b470988
* src/buildtools/third_party/libc++abi/trunk: 671803fd96..8452f0657d
* src/ios: 6a9bd7348f..4bdd6cc72d
* src/testing: c0ea7c3386..e3201c323d
* src/third_party: 56c558ed2e..0f2f057998
* src/third_party/androidx: v5A41FDtUTUgWmjkgJS42X4yMcKx2zbPp8fWod32rhsC..8ehN1uRQQBM3VrBh28TpSvhV4AmGQRMCfN6Fm1L5y9QC
* src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/126f6a8996..77a7089299
* src/third_party/depot_tools: 0c42eff6d1..9a0189cd7a
* src/third_party/perfetto: 303b88cfe5..95e9c5e207
* src/tools: b54abb9ed0..bb864a1e83
DEPS diff: 47dc8e2f50..680b7dae9d/DEPS

Clang version changed llvmorg-14-init-1002-gb5e470aa:llvmorg-14-init-1380-gee659383
Details: 47dc8e2f50..680b7dae9d/tools/clang/scripts/update.py

TBR=mbonadei@webrtc.org,
BUG=None


Fix roll

Change-Id: Ie0b20fe417ce893b6905f0b3c02053e09b83de8d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/229102
Reviewed-by: Per Åhgren <peah@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Andrey Logvin <landrey@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34792}
2021-08-18 10:22:27 +00:00
Mirko Bonadei
24e79f6962 Add missing header (for unique_ptr).
Bug: None
Change-Id: I2ee004ac4feca9a0c25551fc1709069e8df836b4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/229026
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34783}
2021-08-17 12:19:01 +00:00
Nico Weber
19214818d7 Fix some -Wunreachable-code-aggressive warnings
Bug: chromium:1066980
Change-Id: I24fea094f28577799c5fcbcf2e9657ffa9bfd076
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/228760
Reviewed-by: Jamie Walch <jamiewalch@chromium.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34766}
2021-08-16 11:09:16 +00:00
Niels Möller
4f776ac7de Use make_ref_counted in AudioProcessingBuilder
Bug: webrtc:12701
Change-Id: I51ca5a54f812a1620ee2e6605c9ff67b92e2a5f8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/224547
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34725}
2021-08-11 15:40:28 +00:00
Alessio Bazzica
0441bb625f APM: add HW-only denormal disabler
Denormal numbers (see [1]) may origin in APM when the input is zeroed
after a non-zero signal. In extreme cases, instructions involving
denormal operands may run as much as 100 times slower, which seems to
be the case (to some extent) of crbug.com/1227566.

This CL adds a class that disables denormals only via hardware on x86
and on ARM. The class is used in APM and it is an adaption of [2].

Tested: appr.tc call on Chromium (Win, Mac)

[1] https://en.wikipedia.org/wiki/Denormal_number
[2] https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/audio/denormal_disabler.h

Fixed: chromium:1227566
Change-Id: I0ed2eab55dc597529f09f93c26c7a01de051fdbe
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227768
Reviewed-by: Magnus Flodman <mflodman@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34701}
2021-08-10 15:48:22 +00:00
Artem Titov
cfea2182f8 Use backticks not vertical bars to denote variables in comments
Bug: webrtc:12338
Change-Id: I89c8b3a328d04203177522cbdfd9e606fd4bce4c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/228246
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34696}
2021-08-10 10:40:03 +00:00
Artem Titov
0b489303d2 Use backticks not vertical bars to denote variables in comments for /modules/audio_processing
Bug: webrtc:12338
Change-Id: I85bff694dd2ead83c939c4d1945eff82e1296001
No-Presubmit: True
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227161
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34690}
2021-08-09 21:49:02 +00:00
Peter Kasting
55ec1a43bb Fix some instances of -Wunused-but-set-variable.
Bug: chromium:1203071
Change-Id: I1ef3c8fd1f8e2bbf980d5d5217257e919f4564c2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226961
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34579}
2021-07-28 02:08:30 +00:00
Niels Möller
5b747233a3 Add method Mutex::AssertHeld
Acts as a compile time annotation, with corresponding run-time check
only when DCHECKs are enabled, and built using absl or pthreads mutexes.

Bug: None
Change-Id: Ie044c1ea1e576df71d634301f7df9d75cdf10b1b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226328
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34555}
2021-07-27 07:46:32 +00:00
Tony Herre
b0ed12099f Update links to point at main branch
As part of go/coil update code search links to not point to the
"master" branch.

Bug: chromium:1226942
Change-Id: I0ae9e84ecc660f789a69fe0b226f93bbc39a8a66
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226081
Commit-Queue: Tony Herre <toprice@chromium.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34531}
2021-07-22 16:41:26 +00:00
Hanna Silen
e7e9292fe8 Analog AGC: Add clipping rate metrics
Add a histogram WebRTC.Audio.Agc.InputClippingRate and logging of
max clipping rate in AgcManagerDirect.

Bug: webrtc:12774
Change-Id: I4a72119b65ad032fc50672e2a8fb4a4d55e1ff24
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/225264
Commit-Queue: Hanna Silen <silen@webrtc.org>
Reviewed-by: Minyue Li <minyue@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34450}
2021-07-10 13:13:46 +00:00
Peter Kasting
286b1db1b2 Fix -Wunreachable-code-aggressive.
Bug: chromium:1066980
Change-Id: I6888ea1fbc458c9b3063b3f60a7732af16ab5fc9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/224266
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#34393}
2021-06-30 11:14:37 +00:00
Alessio Bazzica
42dacda82c AGC analog clipping predictor: integrate evaluator
Integrate ClippingPredictorEvaluator in AgcManagerDirect adding the
possibility to run the predictor without affecting the analog gain
adjustment process.

The evaluator is used to compute precision, recall and F1 score.
F1 score and the measured clipping prediction intervals are logged as
`WebRTC.Audio.Agc.ClippingPredictor.F1Score` and `.PredictionInterval`
histograms respectively.

Bug: webrtc:12774
Change-Id: I708dcda9321f92d5bd17ec4c36ebce1165ead57f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221921
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34327}
2021-06-17 16:16:53 +00:00
Alessio Bazzica
5b9d0c70c2 AGC1 add clipping predictor evaluator
Observes clipping predictions and detections and computes evaluation
metrics for the predictor.

Bug: webrtc:12774
Change-Id: I83f5942a3b6491de288510f2200f2f5c0e099bf2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221619
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34305}
2021-06-16 15:33:51 +00:00
Alessio Bazzica
98ff0280ce AGC analog ClippingPredictor refactoring 2/2
Uunit test code readability improvements.

Bug: webrtc:12774
Change-Id: I66f552d23680ddb03824618dab869946e0940334
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221900
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34300}
2021-06-16 10:28:57 +00:00
Alessio Bazzica
b237a87a25 AGC analog ClippingPredictor refactoring 1/2
- ClippingPredictor API and docstring changes
- Unified ClippingPredictor factory function

Bug: webrtc:12774
Change-Id: Iafaddae52addc00eb790ac165bf407a4bdd1cb52
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221540
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34279}
2021-06-14 12:21:31 +00:00
Gustaf Ullberg
a63d152423 AEC3: Unbounded echo spectrum for dominant nearend detection.
The dominant nearend detector uses the residual echo spectrum for
determining whether in nearend state. The residual echo spectrum in
computed using the ERLE. To reduce the risk of echo leaks in the
suppressor, the ERLE is capped. While minimizing echo leaks, the
capping of the ERLE can affect the dominant nearend classification
negatively as the residual echo spectrum is often over estimated.

This change enables the dominant nearend detector to use a residual
echo spectrum computed with a virtually non-capped ERLE. This ERLE
is only used for dominant nearend detection and leads to increased
transparency.

The feature is currently disabled by default and can be enabled
with the field trial "WebRTC-Aec3UseUnboundedEchoSpectrum".

Bug: webrtc:12870
Change-Id: Icb675c6f5d42ab9286e623b5fb38424d5c9cbee4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221920
Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34270}
2021-06-11 13:30:00 +00:00
Hanna Silen
a004715d13 Integrate ClippingPredictor into AudioProcessingImpl and AgcManagerDirect
Integrate ClippingPredictor in AgcManagerDirect and
AudioProcessingImpl. Disable functionality by default.

Bug: webrtc:12774
Change-Id: Ic67a47f439c89b75066506fca8acaf636d8812f0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221100
Commit-Queue: Hanna Silen <silen@webrtc.org>
Reviewed-by: Minyue Li <minyue@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34207}
2021-06-03 02:35:05 +00:00
Hanna Silen
4b3a06139b Add ClippingPredictor implementation
Add implementation for clipping prediction and clipped level step estimation.

Bug: webrtc:12774
Change-Id: I855d22980302aac7d49078ca29755f9422af9cb5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/220935
Commit-Queue: Hanna Silen <silen@webrtc.org>
Reviewed-by: Minyue Li <minyue@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34206}
2021-06-02 22:45:46 +00:00
Hanna Silen
a43953a518 Add ClippingPredictor config in AudioProcessing config
Bug: webrtc:12774
Change-Id: Id8cdb6b5499a22cbca40d424cf936f81c1e7d8d7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221104
Reviewed-by: Minyue Li <minyue@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34204}
2021-06-02 16:16:25 +00:00
Per Åhgren
cbdbb8c166 Add ability to adjust the suppressor smoothing in AEC3
Bug: b/177359044
Change-Id: I5eddb6fa6f01aa14426161204e37a9097b182234
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217889
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34203}
2021-06-02 15:21:35 +00:00
Hanna Silen
ea72ee6350 Add ClippingPredictorLevelBuffer circular buffer.
Bug: webrtc:12774
Change-Id: I2b26660e3fe051ab358dd5298ba5098f275943da
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/219631
Reviewed-by: Minyue Li <minyue@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34167}
2021-05-31 14:04:54 +00:00
Hanna Silen
b8dc7fa5a6 Make AgcManagerDirect clipping parameters configurable
Bug: webrtc:12774
Change-Id: I99824b5aabe6f921a5db425dd1c1c1d4c606186c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/219681
Commit-Queue: Hanna Silen <silen@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34069}
2021-05-20 16:53:59 +00:00
Gustaf Ullberg
398def6828 Improvements to AEC3 logging to simplify debugging
Adds log messages for
- AEC3 creation
- Transparent mode implementation selection
- Config parameter changes via RetrieveFieldTrialValue

Bug: webrtc:8671
Change-Id: Ibb1e76d66975a3a3c1227e31b9916a17b76e6c29
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/219468
Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34056}
2021-05-19 14:28:44 +00:00
Gustaf Ullberg
aeb8ce882f AEC3: Change adaptation speed of the matched filter after a delay is found
This change enables the use of two different adaptation speeds of the
matched filter of the delay estimator of AEC3.

One speed is used when no delay has been found, and one is used after a
reliable delay has been found. The purpose is to use a slower adaptation
speed to reduce the risk of divergence during double-talk without
slowing down the search for the initial delay.

The CL prepares for experimentation by adding field trials for
controlling the two adaptation speeds.

Bug: webrtc:12775
Change-Id: I817a1ab5ded0f78d20de45edcf04c708290173fc
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/219083
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34055}
2021-05-19 13:37:13 +00:00
Per Åhgren
91a892f8ed Add ability to dump the coarse filter in the echo subtractor
Bug: b/155316201
Change-Id: I008cdf1531af3c3c0fff4ce19ad5dd74f8e73f65
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217891
Reviewed-by: Sam Zackrisson <saza@google.com>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34047}
2021-05-19 08:24:16 +00:00
Gustaf Ullberg
a399c823bb Field trial to disable the transient suppressor
This change adds the field trial "WebRTC-TransientSuppressorForcedOff"
that can be used to disable the transient suppressor (removal of
keyboard typing sounds). The field trial can be enabled by users via
command-line or via experimentation.

Bug: chromium:1186705
Change-Id: I7272df6a20fbbee24a7ba0904502c76bd775d275
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/219282
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34038}
2021-05-18 12:34:37 +00:00
Alessio Bazzica
7ddadbc108 APM: dump GainController1::AnalogGainController in Config::ToString
Update `AudioProcessing::Config::ToString()` to also dump the config
from `AnalogGainController` which is missing.

Bug: webrtc:7494
Change-Id: Iea5dab1f6abb9ec8581ce690a2a119f202b4d1e1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/219082
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34025}
2021-05-17 16:37:37 +00:00
Markus Handell
ad5037b4a8 Reland "Refactor the PlatformThread API."
This reverts commit 793bac569f.

Reason for revert: rare compilation error fixed

Original change's description:
> Revert "Refactor the PlatformThread API."
>
> This reverts commit c89fdd716c.
>
> Reason for revert: Causes rare compilation error on win-libfuzzer-asan trybot.
> See https://ci.chromium.org/p/chromium/builders/try/win-libfuzzer-asan-rel/713745?
>
> Original change's description:
> > Refactor the PlatformThread API.
> >
> > PlatformThread's API is using old style function pointers, causes
> > casting, is unintuitive and forces artificial call sequences, and
> > is additionally possible to misuse in release mode.
> >
> > Fix this by an API face lift:
> > 1. The class is turned into a handle, which can be empty.
> > 2. The only way of getting a non-empty PlatformThread is by calling
> > SpawnJoinable or SpawnDetached, clearly conveying the semantics to the
> > code reader.
> > 3. Handles can be Finalized, which works differently for joinable and
> > detached threads:
> >   a) Handles for detached threads are simply closed where applicable.
> >   b) Joinable threads are joined before handles are closed.
> > 4. The destructor finalizes handles. No explicit call is needed.
> >
> > Fixed: webrtc:12727
> > Change-Id: Id00a0464edf4fc9e552b6a1fbb5d2e1280e88811
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215075
> > Commit-Queue: Markus Handell <handellm@webrtc.org>
> > Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> > Reviewed-by: Tommi <tommi@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#33923}
>
> # Not skipping CQ checks because original CL landed > 1 day ago.
>
> TBR=handellm@webrtc.org
>
> Bug: webrtc:12727
> Change-Id: Ic0146be8866f6dd3ad9c364fb8646650b8e07419
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217583
> Reviewed-by: Guido Urdaneta <guidou@webrtc.org>
> Reviewed-by: Markus Handell <handellm@webrtc.org>
> Commit-Queue: Guido Urdaneta <guidou@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#33936}

# Not skipping CQ checks because this is a reland.

Bug: webrtc:12727
Change-Id: Ifd6f44eac72fed84474277a1be03eb84d2f4376e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217881
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Markus Handell <handellm@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33950}
2021-05-07 14:14:43 +00:00
Alessio Bazzica
dfc11d55af Add RTC_EXPORT to APM config structs with overloaded operators
Bug: webrtc:7494
Change-Id: I9b627709d8c5bb47d73fd7981259a95e6b51e16c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217766
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33946}
2021-05-07 11:31:18 +00:00
Guido Urdaneta
793bac569f Revert "Refactor the PlatformThread API."
This reverts commit c89fdd716c.

Reason for revert: Causes rare compilation error on win-libfuzzer-asan trybot.
See https://ci.chromium.org/p/chromium/builders/try/win-libfuzzer-asan-rel/713745?

Original change's description:
> Refactor the PlatformThread API.
>
> PlatformThread's API is using old style function pointers, causes
> casting, is unintuitive and forces artificial call sequences, and
> is additionally possible to misuse in release mode.
>
> Fix this by an API face lift:
> 1. The class is turned into a handle, which can be empty.
> 2. The only way of getting a non-empty PlatformThread is by calling
> SpawnJoinable or SpawnDetached, clearly conveying the semantics to the
> code reader.
> 3. Handles can be Finalized, which works differently for joinable and
> detached threads:
>   a) Handles for detached threads are simply closed where applicable.
>   b) Joinable threads are joined before handles are closed.
> 4. The destructor finalizes handles. No explicit call is needed.
>
> Fixed: webrtc:12727
> Change-Id: Id00a0464edf4fc9e552b6a1fbb5d2e1280e88811
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215075
> Commit-Queue: Markus Handell <handellm@webrtc.org>
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> Reviewed-by: Tommi <tommi@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#33923}

# Not skipping CQ checks because original CL landed > 1 day ago.

TBR=handellm@webrtc.org

Bug: webrtc:12727
Change-Id: Ic0146be8866f6dd3ad9c364fb8646650b8e07419
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217583
Reviewed-by: Guido Urdaneta <guidou@webrtc.org>
Reviewed-by: Markus Handell <handellm@webrtc.org>
Commit-Queue: Guido Urdaneta <guidou@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33936}
2021-05-06 14:22:57 +00:00
Markus Handell
c89fdd716c Refactor the PlatformThread API.
PlatformThread's API is using old style function pointers, causes
casting, is unintuitive and forces artificial call sequences, and
is additionally possible to misuse in release mode.

Fix this by an API face lift:
1. The class is turned into a handle, which can be empty.
2. The only way of getting a non-empty PlatformThread is by calling
SpawnJoinable or SpawnDetached, clearly conveying the semantics to the
code reader.
3. Handles can be Finalized, which works differently for joinable and
detached threads:
  a) Handles for detached threads are simply closed where applicable.
  b) Joinable threads are joined before handles are closed.
4. The destructor finalizes handles. No explicit call is needed.

Fixed: webrtc:12727
Change-Id: Id00a0464edf4fc9e552b6a1fbb5d2e1280e88811
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215075
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33923}
2021-05-05 09:59:07 +00:00
Alessio Bazzica
a2efd15627 AGC2 config operator= and unit tests update
Bug: webrtc:7494
Change-Id: I7957602d60658b84175a617f9c283ea44eafe57d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/216260
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@google.com>
Cr-Commit-Position: refs/heads/master@{#33876}
2021-04-29 16:37:17 +00:00
Alessio Bazzica
d66a60597d AGC2 adaptive digital dry run mode
Add the option to run the adaptive digital controller of AGC2 without
side-effects - i.e., no gain applied.

Tested: adapation verified during a video call in chromium

Bug: webrtc:7494
Change-Id: I4776f6012907d76a17a3bca89991da97dc38657f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215964
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33875}
2021-04-29 16:05:57 +00:00
Tommi
87f7090fd9 Replace more instances of rtc::RefCountedObject with make_ref_counted.
This is essentially replacing `new rtc::RefCountedObject` with
`rtc::make_ref_counted` in many files. In a couple of places I
made minor tweaks to make things compile such as adding parenthesis
when they were missing.

Bug: webrtc:12701
Change-Id: I3828dbf3ee0eb0232f3a47067474484ac2f4aed2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215973
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33852}
2021-04-27 17:01:59 +00:00
Markus Handell
97c4458c8f PlatformThread: add support for detached threads.
The change introduces support for detachable PlatformThreads, for which
the Stop() call doesn't wait until the thread has finished executing.

The change also introduces rtc::ThreadAttributes that carries priority
and detachability thread attributes. It additionally refactors all
known use to use the new semantics.

Bug: b:181572711, webrtc:12659
Change-Id: Id96e87c2a0dafabc8047767d241fd5da4505d14c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/214704
Reviewed-by: Tommi <tommi@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33796}
2021-04-21 07:44:31 +00:00
Gustaf Ullberg
437d129ef5 AEC3: Avoid overcompensating for render onsets during dominant nearend
The ERLE is used to estimate residual echo for echo suppression. The
ERLE is reduced during far-end offset to avoid echo leakage. When there
is a strong near-end present this can cause unnecessary transparency loss.

This change adds an ERLE estimation that does not compensate for onsets and
uses it for residual echo estimation when the suppressor considers the near-end to be dominant.

Bug: webrtc:12686
Change-Id: Ida78eeacf1f95c6e62403f86ba3f2ff055898a84
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215323
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33786}
2021-04-20 12:33:02 +00:00
Alessio Bazzica
980c4601e1 AGC2: retuning and large refactoring
- Bug fix: the desired initial gain quickly dropped to 0 dB hence
  starting a call with a too low level
- New tuning to make AGC2 more robust to VAD mistakes
- Smarter max gain increase speed: to deal with an increased threshold
  of adjacent speech frames, the gain applier temporarily allows a
  faster gain increase to deal with a longer time spent waiting for
  enough speech frames in a row to be observed
- Saturation protector isolated from `AdaptiveModeLevelEstimator` to
  simplify the unit tests for the latter (non bit-exact change)
- AGC2 adaptive digital config: unnecessary params deprecated
- Code readability improvements
- Data dumps clean-up and better naming

Bug: webrtc:7494
Change-Id: I4e36059bdf2566cc2a7e1a7e95b7430ba9ae9844
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215140
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33736}
2021-04-14 19:01:01 +00:00
Alessio Bazzica
61982a7f2d AGC2 lightweight noise floor estimator
The current noise level estimator has a bug due to which the estimated
level decays to the lower bound in a few seconds when speech is observed.
Instead of fixing the current implementation, which is based on a
stationarity classifier, an alternative, lightweight, noise floor
estimator has been added and tuned for AGC2.

Tested on several AEC dumps including HW mute, music and fast talking.

Bug: webrtc:7494
Change-Id: Iae4cff9fc955a716878f830957e893cd5bc59446
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/214133
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33733}
2021-04-14 15:56:41 +00:00
Per Åhgren
dea5721efb Adding g3doc for AudioProcessingModule (APM)
Bug: webrtc:12569
Change-Id: I8fa896a5afa9791ad6d8c2b5011d1e75ca068df4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215141
Commit-Queue: Per Åhgren <peah@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33726}
2021-04-14 09:40:25 +00:00
Gustaf Ullberg
1fad94f502 Remove ErleUncertainty
Erle Uncertainty changes the residual echo computation during saturated
echo. However, the case of saturated echo is already handled by the
residual echo estimator causing the ErleUncertainty to be a no-op.

The change has been tested for bit-exactness.

Bug: webrtc:8671
Change-Id: I779ba67f99f29d4475a0465d05da03d42d50e075
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215072
Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33719}
2021-04-14 07:01:14 +00:00
Alessio Bazzica
11bd143974 AGC2 add an interface for the noise level estimator
Done in preparation for the child CL which adds an alternative
implementation.

Bug: webrtc:7494
Change-Id: I4963376afc917eae434a0d0ccee18f21880eefe0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/214125
Reviewed-by: Jakob Ivarsson <jakobi@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33646}
2021-04-08 07:34:22 +00:00
Alessio Bazzica
70b775d77f AGC2 noise estimator code style improvements
Code style improvements done in preparation for a bug fix (TODO added)
which requires changes in the unit tests.

Note that one expected value in the unit tests has been adjusted since
the white noise generator is now instanced in each separate test and
therefore, even if the seed remained the same, the generated sequences
differ.

Bug: webrtc:7494
Change-Id: I497513b84f50b5c66cf6241a09946ce853eb1cd2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/214122
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33636}
2021-04-07 11:57:55 +00:00
Alessio Bazzica
8aaa604375 AGC2 new data dumps
Bug: webrtc:7494
Change-Id: Id288dd426e1c2754805bc548fbffe0eaeaacf3da
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/213420
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33605}
2021-03-31 14:55:42 +00:00
Alessio Bazzica
841d74ea80 AGC2 periodically reset VAD state
Bug: webrtc:7494
Change-Id: I880ef3991ade4e429ccde843571f069ede149c0e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/213342
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33604}
2021-03-31 14:15:10 +00:00
Alessio Bazzica
b995bb86df AGC2 size_t -> int
Bug: webrtc:7494
Change-Id: I5ecf242e83b509931c1764a37339d11506c5afc6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/213341
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33600}
2021-03-31 11:18:30 +00:00
Per Åhgren
19775cbd29 Reland "Reduce complexity in the APM pipeline when the output is not used"
This is a reland of aa6adffba3

What was changed in the reland is that the merging of the bands is
excluded from the code that is not run when the output is not used.
I.e., the merging is always done.

This is important to have since some clients may apply muting before APM,
and still flag to APM that the signal is muted. If the merging is not
always done, those clients will get nonzero output from APM during muting.


Original change's description:
> Reduce complexity in the APM pipeline when the output is not used
>
> This CL selectively turns off parts of the audio processing when
> the output of APM is not used. The parts turned off are such that
> don't need to continuously need to be trained, but rather can be
> temporarily deactivated.
>
> The purpose of this CL is to allow CPU to be reduced when the
> client is muted.
>
> The CL will be follow by additional CLs, adding similar functionality
> in the echo canceller and the noiser suppressor
>
> Bug: b/177830919
> Change-Id: I72d24505197a53872562c0955f3e7b670c43df6b
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/209703
> Commit-Queue: Per Åhgren <peah@webrtc.org>
> Reviewed-by: Sam Zackrisson <saza@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#33431}

Bug: b/177830919
Change-Id: Ib74dd1cefa173d45101e26c4f2b931860abc6d08
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/211760
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33478}
2021-03-16 09:33:02 +00:00
Per Åhgren
15179a9986 Allowing reduced computations in the noise suppressor when the output is not used
This CL adds functionality in the noise suppressor that allows the
computational complexity to be reduced when the output of APM is not used.

Bug: b/177830919
Change-Id: I849351ba9559fae770e4667d78e38abde5230eed
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/211342
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33477}
2021-03-16 09:28:42 +00:00
Per Åhgren
8ee1ec82e4 Allowing reduced computations in the AEC3 when the output is not used
This CL adds functionality in AEC3 that allows the computational
complexity to be reduced when the output of APM is not used.

Bug: b/177830919
Change-Id: I08121364bf966f34311f54ffa5affbfd8b4db1e2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/211341
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33476}
2021-03-16 09:16:32 +00:00
Per Åhgren
db5d728878 Add refined handling of the internal scaling of the audio in APM
This CL adds functionality that allows adjusting the audio levels
internally in APM. The main purpose of the functionality is to allow
APM to optionally be moved to an integration that does not provide an
analog gain to control, and the implementation of this has been
tailored specifically to meet the requirements for that.

More specifically, this CL does
-Add a new variant of the pre-amplifier gain that is intended to replace
 the pre-amplifier gain (but at the moment can coexist with that). The
 main differences with the pre-amplifier gain is that an attenuating
 gain is allowed, the gain is applied jointly with any emulated analog
 gain, and that its packaging fits better with the post gain.
-Add an emulation of an analog microphone gain. The emulation is
 designed to match the analog mic gain functionality in Chrome OS (which
 is digital) but should be usable also on other platforms.
-Add a post-gain which is applied after all processing has been applied.
 The purpose of this gain is for it to work well with the integration
 in ChromeOS, and be used to compensate for the offset that there is
 applied on some USB audio devices.


Bug: b/177830918
Change-Id: I0f312996e4088c9bd242a713a703eaaeb17f188a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/209707
Commit-Queue: Per Åhgren <peah@webrtc.org>
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33466}
2021-03-15 19:12:02 +00:00
Gustaf Ullberg
fdd6099348 Rework transient suppressor configuration in audioproc_f
The transient suppressor can be configured as:
0 - Deactivated
1 - Activated with key events from aecdump
2 - Activated with continuous key events (for debugging purposes)

Bug: webrtc:5298
Change-Id: I116eb08ad50178dc5116d5d967084e6c9967f258
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/211869
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33464}
2021-03-15 15:19:09 +00:00
Per Åhgren
55bc077b45 Add one frame (10 ms) of silence in APM output after unmuting
This CL adds one frame (10 ms) of silence in APM output after unmuting to mask
audio resulting from the turning on the processing that was deactivated
during the muting.

Bug: b/177830919
Change-Id: If44cfb0ef270dde839dcd3f0b98d1c91e81668dd
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/211343
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33454}
2021-03-13 01:05:45 +00:00
Ilya Nikolaevskiy
8097935df3 Revert "Reduce complexity in the APM pipeline when the output is not used"
This reverts commit aa6adffba3.

Reason for revert: breaks webrtc-importer

Original change's description:
> Reduce complexity in the APM pipeline when the output is not used
>
> This CL selectively turns off parts of the audio processing when
> the output of APM is not used. The parts turned off are such that
> don't need to continuously need to be trained, but rather can be
> temporarily deactivated.
>
> The purpose of this CL is to allow CPU to be reduced when the
> client is muted.
>
> The CL will be follow by additional CLs, adding similar functionality
> in the echo canceller and the noiser suppressor
>
> Bug: b/177830919
> Change-Id: I72d24505197a53872562c0955f3e7b670c43df6b
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/209703
> Commit-Queue: Per Åhgren <peah@webrtc.org>
> Reviewed-by: Sam Zackrisson <saza@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#33431}

Bug: b/177830919
Change-Id: I937cd61dedcd43150933eb1b9d65aebe68401e91
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/211348
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33433}
2021-03-11 11:41:20 +00:00
Per Åhgren
aa6adffba3 Reduce complexity in the APM pipeline when the output is not used
This CL selectively turns off parts of the audio processing when
the output of APM is not used. The parts turned off are such that
don't need to continuously need to be trained, but rather can be
temporarily deactivated.

The purpose of this CL is to allow CPU to be reduced when the
client is muted.

The CL will be follow by additional CLs, adding similar functionality
in the echo canceller and the noiser suppressor

Bug: b/177830919
Change-Id: I72d24505197a53872562c0955f3e7b670c43df6b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/209703
Commit-Queue: Per Åhgren <peah@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33431}
2021-03-11 10:06:58 +00:00
Per Åhgren
34fdc92119 Add audioproc_f support for testing the runtime settings of whether the output is used
Bug: b/177830919
Change-Id: Iddcb79000f471eac165e3f44f14fad41435e6ccb
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/211241
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33426}
2021-03-10 23:19:30 +00:00
Per Åhgren
652ada5029 Enabling a safe fall-back functionality for overruns in the runtime settings
Bug: b/177830919
Change-Id: I9369f6fc004ceb2b626d33b36262bc8aeabdb1a0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/206988
Commit-Queue: Per Åhgren <peah@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33371}
2021-03-03 12:06:54 +00:00
Gustaf Ullberg
09226fc832 Disable high-pass filtering of the AEC reference
Currently the echo canceller reference signal is high-pass filtered to
avoid the need of modeling the capture-side high-pass filter as part of
the echo path.

This can lead to the lowest frequency bins of the linear filter
diverging as there is little low-frequency content available for
training. Over time the filter can output an increasing amount of
low-frequency power, which in turn affects the filter's ability to
adapt properly.

Disabling the high-pass filtering of the echo canceller reference solves
this issue, resulting in improved filter convergence.

Bug: webrtc:12265
Change-Id: Ic526a4b1b73e1808cfcd96a8cdee801b96a27671
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/208288
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33322}
2021-02-23 07:06:11 +00:00
Danil Chapovalov
e904161cec Replace RTC_DEPRECATED with ABSL_DEPRECATED
This remove webrtc-specific macro that has no reason to be webrtc specific
ABSL_DEPRECATED takes a message parameter encouraging to write text how class or function is deprecated.

Bug: webrtc:12484
Change-Id: I89f1398f91dacadc37f7db469dcd985e3724e444
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/208282
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33314}
2021-02-22 12:53:23 +00:00
Per Åhgren
8eea117dea Make PostRuntimeSetting pure virtual
Bug: b/177830919
Change-Id: I92e30e9b65c8f851444268f0824a676044504814
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/206640
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33252}
2021-02-12 22:49:43 +00:00
Alessio Bazzica
5a585952da Update AGC2 tuning
Bug: webrtc:7494
Change-Id: Ifcc5b6c846476ce7d6862fba2cb53e426b5855dc
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/206800
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33238}
2021-02-11 18:14:34 +00:00
Per Åhgren
0a144a705a Adding initial support for lock-less informing of muting
This CL adds the initial support for letting APM know when its output
will be used or not.
It also adds a new method for passing RuntimeInformation to APM that
returns a bool indicating the success of the passing of information.

Bug: b/177830919
Change-Id: Ic2e1b92c37241d74ca6394b785b91736ca7532aa
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/206061
Commit-Queue: Per Åhgren <peah@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33201}
2021-02-09 12:08:54 +00:00
Per Åhgren
68c225d76d Make 48 kHz maximum rate default for all devices
Bug: b/169918549
Change-Id: I2f4b7ced5ae6efcae3cd59c0a42610a54f5e2dc7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/203260
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33192}
2021-02-08 15:06:05 +00:00
Per Åhgren
879d33b9f8 Add more refined control over dumping of data and the aecdump content
This CL adds the ability in audioproc_f and unpack_aecdump to:
-Clearly identify the Init events and when those occur.
-Optionally only process a specific Init section of an aecdump.
-Optionally selectively turn on dumping of internal data for a
 specific init section, and a specific time interval.
-Optionally let unpack_aecdump produce file names based on inits.

Bug: webrtc:5298
Change-Id: Id654b7175407a23ef634fca832994d87d1073239
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196160
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33181}
2021-02-06 00:36:10 +00:00
Sam Zackrisson
53610223a8 Delete unused function webrtc::AudioProcessing::MutateConfig
Bug: None
Change-Id: Ibc70e5246a3f7b89775c65a19c808c1f030b8ac6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/205522
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33147}
2021-02-03 12:55:23 +00:00
Alessio Bazzica
6f75f6b3bd APM: add AGC2 SIMD kill switches in AudioProcessing::Config::ToString()
Bug: webrtc:7494
Change-Id: Icba5f6be689a57ef4748ae816565349fd1ad2108
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/205322
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33146}
2021-02-03 12:31:56 +00:00
Andrey Logvin
e7c79fd3d6 Remove from chromium build targets that are not compatible with it.
We need to be able build chromium with rtc_include_tests = true. It
reveals a lot of targets that are not compatible with chromium but
aren't marked so.

`rtc_include_tests=true` has been considered a way to disable targets for the Chromium build, causing an overload on rtc_include_tests while the meaning of the two GN args (rtc_include_tests and build_with_chromium) should be kept separated.

Bug: webrtc:12404
Change-Id: I2f72825445916eae7c20ef9338672d6a07a9b9ff
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/203890
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Andrey Logvin <landrey@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33124}
2021-02-01 13:46:19 +00:00
Andrey Logvin
b79acd8ce9 Format webrtc/modules/audio_processing/transient/BUILD.gn file
Bug: webrtc:12404
Change-Id: I3cb6b96255409709fa3144d2f83d13d12e39ab2a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/204064
Commit-Queue: Andrey Logvin <landrey@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33107}
2021-01-29 16:33:19 +00:00
Per Åhgren
c2ae4c8a37 Allow separate dump sets for the data dumper in APM
This CL allows separate dump sets to be used when dumping internal
APM data using audioproc_f, opening up for reducing the amount of
data to be dumped.

Bug: webrtc:5298
Change-Id: I8286933ceed10db074f2064414cc08e8b12653fa
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196089
Commit-Queue: Per Åhgren <peah@webrtc.org>
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33047}
2021-01-20 16:38:17 +00:00
Gustaf Ullberg
5c3ff6b60f Switch to enable the HMM transparent mode classifier
Bug: chromium:1155071,webrtc:12265,chromium:1155477
Change-Id: I9d3119e9cbfdd5d7b41de2ed0f9dec92f7bf753d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/202258
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33037}
2021-01-19 16:26:11 +00:00
Alessio Bazzica
42eef86c4f Remove unused code in APM
- The injection of the AGC2 level estimator into `AgcManagerDirect`
  is not used anymore
- `ExperimentalAgc::enabled_agc2_level_estimator` can also be removed
- 3 ctors of `ExperimentalAgc` are unused
- `AgcManagerDirectStandaloneTest::AgcMinMicLevelExperiment` can be
  split into separate unit tests (better code clarity)

Bug: webrtc:7494
Change-Id: I5843147c38cf7cb5ee484b0a72fe13dcf363efaf
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/202025
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33027}
2021-01-18 13:40:27 +00:00
Mirko Bonadei
e5f4c6b8d2 Reland "Refactor rtc_base build targets."
This is a reland of 69241a93fb

Fix: The problem was related to NO_MAIN_THREAD_WRAPPING, which
affects https://source.chromium.org/chromium/chromium/src/+/master:third_party/webrtc/rtc_base/thread.cc;l=257-263;drc=7acc2d9fe3a6e3c4d8881d2bdfc9b8968a724cd5.
The original CL didn't attach the definition of the macro
NO_MAIN_THREAD_WRAPPING when building for Chromium (which doesn't have
to be related to //rtc_base anymore but to //rtc_base:threading).

Original change's description:
> Refactor rtc_base build targets.
>
> The "//rtc_base:rtc_base" build target has historically been one of the
> biggest targets in the WebRTC build. Big targets are the main source of
> circular dependencies and non-API types leakage.
>
> This CL is a step forward into splitting "//rtc_base:rtc_base" into
> smaller targets (as originally started in 2018).
>
> The only non-automated changes are (like re-wiring the build system):
> * The creation of //rtc_base/async_resolver.{h,cc} which allows to
>   break a circular dependency (is has been extracted from
>   //rtc_base/net_helpers.{h,cc}).
> * The creation of //rtc_base/internal/default_socket_server.{h,cc} to
>   break another circular dependency.
>
> Bug: webrtc:9987
> Change-Id: I0c8f5e7efe2c8fd8e6bffa0d6dd2dd494cf3df02
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196903
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#32941}

Bug: webrtc:9987
Change-Id: I7cdf49d2aac8357f1f50f90010bf2c2f62fa19f6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/202021
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33001}
2021-01-15 17:00:05 +00:00
Mirko Bonadei
7acc2d9fe3 Revert "Refactor rtc_base build targets."
This reverts commit 69241a93fb.

Reason for revert: Breaks WebRTC roll into Chromium.

Original change's description:
> Refactor rtc_base build targets.
>
> The "//rtc_base:rtc_base" build target has historically been one of the
> biggest targets in the WebRTC build. Big targets are the main source of
> circular dependencies and non-API types leakage.
>
> This CL is a step forward into splitting "//rtc_base:rtc_base" into
> smaller targets (as originally started in 2018).
>
> The only non-automated changes are (like re-wiring the build system):
> * The creation of //rtc_base/async_resolver.{h,cc} which allows to
>   break a circular dependency (is has been extracted from
>   //rtc_base/net_helpers.{h,cc}).
> * The creation of //rtc_base/internal/default_socket_server.{h,cc} to
>   break another circular dependency.
>
> Bug: webrtc:9987
> Change-Id: I0c8f5e7efe2c8fd8e6bffa0d6dd2dd494cf3df02
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196903
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#32941}

TBR=mbonadei@webrtc.org,hta@webrtc.org

# Not skipping CQ checks because original CL landed > 1 day ago.

No-Try: True
Bug: webrtc:9987
Change-Id: I1e36ad64cc60092f38d6886153a94f1a58339256
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/201840
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32986}
2021-01-14 21:27:38 +00:00
Hua, Chunbo
e61a40e4ef Fix typo in audio processing header.
Bug: None
Change-Id: Ia47f8229cdfbbcfec3aa7539c587d4e1fdc4ae3a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/200926
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32974}
2021-01-14 10:59:13 +00:00
Hua, Chunbo
dbcaff0925 Fix AudioProcessing::Config::ToString() implementation.
residual_echo_detector and level_estimation is not part of gain_controller2
in AudioProcessing::Config.

Bug: None
Change-Id: Ic31b8c6bb4d9ed59b4f337e5dc8b8c587ae54202
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/200924
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32972}
2021-01-14 10:27:18 +00:00
Alessio Bazzica
76714a6cc8 AGC2 minor code clean up
Dead code removed plus const ref std::string to avoid copies.

Bug: webrtc:7494
Change-Id: Ic408a810ae310fea942f25fc697ab81017c8a739
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/201624
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32968}
2021-01-14 08:03:17 +00:00
Mirko Bonadei
69241a93fb Refactor rtc_base build targets.
The "//rtc_base:rtc_base" build target has historically been one of the
biggest targets in the WebRTC build. Big targets are the main source of
circular dependencies and non-API types leakage.

This CL is a step forward into splitting "//rtc_base:rtc_base" into
smaller targets (as originally started in 2018).

The only non-automated changes are (like re-wiring the build system):
* The creation of //rtc_base/async_resolver.{h,cc} which allows to
  break a circular dependency (is has been extracted from
  //rtc_base/net_helpers.{h,cc}).
* The creation of //rtc_base/internal/default_socket_server.{h,cc} to
  break another circular dependency.

Bug: webrtc:9987
Change-Id: I0c8f5e7efe2c8fd8e6bffa0d6dd2dd494cf3df02
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196903
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32941}
2021-01-11 18:32:30 +00:00
Alessio Bazzica
5247070f5d RNN VAD: add missing CPU features to test FC and GRU layers
Bug: webrtc:10480
Change-Id: I6c49e728ed61647b098c20a6d8a856005066ab75
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/200840
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32930}
2021-01-10 12:42:39 +00:00
Alessio Bazzica
524f682184 SSE2 and NEON kill switches for AGC2
Bug: webrtc:7494
Change-Id: I221b717b5cf3c41b7b637e9234d1e339a0e6c7e5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/199967
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32918}
2021-01-07 11:41:28 +00:00
Alessio Bazzica
ed9f5f85fd RNN VAD optimizations: VectorMath::DotProduct() NEON arm64
Results: RNN VAD realtime factor improved from 140x to 195x (+55x)
Test device: Pixel 2 XL
Benchmark setup: max clock speed forced on all the cores by
setting "performance" as scaling governor

Bug: webrtc:10480
Change-Id: I3e92f643853ad1fe990db909c578ce78ee826c03
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/198842
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32888}
2020-12-30 10:47:01 +00:00
Jesús de Vicente Peña
16dd6b0ce4 Fixing the bounds for the max and min erle in the erle instantaneous estimation.
Bug: webrtc:12283
Change-Id: I534a5da30e575f9b100046fff31a84774afbf67f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196654
Commit-Queue: Jesus de Vicente Pena <devicentepena@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32834}
2020-12-15 14:29:52 +00:00
Jesús de Vicente Peña
3bda2362f1 Erle metric: avoid the decreasing of the metric when there is no render activity.
This change just affects the ERLE metric that is reported. The rest is unaffected and bitexact.

Bug: webrtc:12280
Change-Id: I2d28ef14a9b704c83aba18b624f67671eec4a042
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196649
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Jesus de Vicente Pena <devicentepena@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32809}
2020-12-09 11:48:11 +00:00
Alessio Bazzica
e8ee462681 RNN VAD: FC layer simplified
The implementations for the fully connected layer can be simlpified by
using `VectorMath:DotProduct()`. In this way, it is also possible to
remove (nearly) duplicated SIMD code, reduce the binary size and more
easily maintain the code.

This CL also forces unoptimized code for the output layer of the VAD,
which is a FC 24x1 layer. A slight improvement of the realtime has
been measured (delta ~ +5x).

Bug: webrtc:10480
Change-Id: Iee93bd59f7905ebf96275dbbfeb3c921baf4e8db
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/195580
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32806}
2020-12-09 00:04:50 +00:00
Alessio Bazzica
4e9c5b592a RNN VAD: GRU layer optimized
Using `VectorMath::DotProduct()` in GatedRecurrentLayer to reuse existing
SIMD optimizations. Results:
- When SSE2/AVX2 is avilable, the GRU layer takes 40% of the unoptimized
  code
- The realtime factor for the VAD improved as follows
  - SSE2: from 570x to 630x
  - AVX2: from 610x to 680x

This CL also improved the GRU layer benchmark by (i) benchmarking a GRU
layer havibng the same size of that used in the VAD and (ii) by prefetching
a long input sequence.

Bug: webrtc:10480
Change-Id: I9716b15661e4c6b81592b4cf7c172d90e41b5223
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/195545
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32803}
2020-12-08 15:37:38 +00:00
Gustaf Ullberg
992a96f68e AEC3: Prevent diverging coarse filter from influencing the refined filter
After the refined filter has been determined to perform better than
the coarse filter, and the coefficients of the coarse filters are
overwritten by the ones from the refined filter, at least 100 ms have
to pass before the adaptation of the refined filter is allowed to speed
up due to good coarse filter performance.

This change solves the vicious circle described in webrtc:12265, where
the coarse and refined filters can diverge over time.

This feature can be disabled remotely via a kill-switch. When disabled
the AEC output is bit-exact to before the change.

Bug: webrtc:12265,chromium:1155477
Change-Id: Iacd6e325e987dd8a475bb3e8163fee714c65b20a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196501
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32801}
2020-12-08 15:05:23 +00:00
Per Åhgren
12dc274749 Make the static variable kChunkSizeMs constexpr
This CL makes the static variable kChunkSizeMs constexpr to avoid
potential issues on some compilers.

Bug: None
Change-Id: I8e2b1819561ec96fb17d3899af95405cc36a6097
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196640
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32795}
2020-12-08 10:46:15 +00:00
Alessio Bazzica
bb1a28de3c RNN VAD: unit test code clean-up
- test_utils.h/.cc simplified
- webrtc::rnnvad::test -> webrtc::rnnvad
- all unit test code inside the anonymous namespace
- names improved

Bug: webrtc:10480
Change-Id: I0a0f056f9728bb8a1b93006b95d7ed5bf5bd4adb
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196509
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32789}
2020-12-07 17:35:45 +00:00
Alessio Bazzica
3ee4af4509 AGC2: Fix GetAvailableCpuFeatures()
Handle the case in which neither WEBRTC_ARCH_X86_FAMILY nor
WEBRTC_HAS_NEON are defined.

Bug: webrtc:10480
Change-Id: I241583911d8e5645dfbd39b60337dd20b2d9f046
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196525
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32786}
2020-12-07 13:34:58 +00:00
Alex Konradi
c20baf6067 Remove nesting of Naggy/Strict/NiceMock
This will soon become a compile-time error. Fix class hierarchies that
wrap StrictMock in a NiceMock or vice-versa by removing redundant
wrappings and removing inheritance from Nice/StrictMock and fixing the
call sites as appropriate.

Bug: b/173702213
Change-Id: Ic90b1f270c180f7308f40e52e358a8f6a6baad86
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196461
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32783}
2020-12-07 08:19:50 +00:00
Alessio Bazzica
9131313913 RNN VAD: GRU layer isolated into rnn_gru.h/.cc
Refactoring done to more easily and cleanly add SIMD optimizations and
to remove `GatedRecurrentLayer` from the RNN VAD api.

Bug: webrtc:10480
Change-Id: Ie1dffdd9b19c57c03a0b634f6818c0780456a66c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/195445
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Jakob Ivarsson <jakobi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32770}
2020-12-04 07:40:41 +00:00
Alessio Bazzica
31d3b217d3 RNN VAD: FC layer isolated into rnn_fc.h/.cc
Refactoring done to more easily and cleanly add SIMD optimizations and
to remove `FullyConnectedLayer` from the RNN VAD api.

Minor improvements (readability, API):
- `FullyConnectedLayer` gets the ActivationFunction enum and not
  a function view anymore
- SSE2 optimization moved into `FullyConnectedLayer::ComputeOutputSse2`
- layer name added for improved logs

Bug: webrtc:10480
Change-Id: Ida4903a67655e19ef0464f378c433c1f6e96dca7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/195444
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32766}
2020-12-03 23:25:22 +00:00
Alessio Bazzica
812dc072c6 RNN VAD: FC and GRU layers implicit conversion to ArrayView
Plus a few minor code readability improvements.

Bug: webrtc:10480
Change-Id: I590d8e203b1d05959a8c15373841e37abe83237e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/195334
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32764}
2020-12-03 18:02:25 +00:00
Alessio Bazzica
e7b5c1a235 RNN VAD: unit tests for RnnBasedVad
Bug: webrtc:10480
Change-Id: I4ac8ae044261f94db7a1e9559aa61f532602b408
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/195446
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Jakob Ivarsson <jakobi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32758}
2020-12-03 14:00:03 +00:00
Gustaf Ullberg
d891fd3f6f Disable HMM based transparent mode classifier
The HMM based transparent mode classifier is disabled until an issue
with diverging filters is resolved.

Bug: chromium:1155071
Change-Id: Iee249869f6ece1e48e834b3a4b9249c69a51286c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196341
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32756}
2020-12-03 12:15:49 +00:00
Alessio Bazzica
fd5dadbea9 RNN VAD: use VectorMath::DotProduct() for pitch search
This CL brings a large improvement to the RNN VAD CPU performance
by finally using `VectorMath::DotProduct()` for pitch search.

The realtime factor improved from about 390x to 570x for SSE2
(+180x, 45% faster) and to 610x for AVX2 (+235x, 60% faster).

RNN VAD benchmark results:
```
+-----+-------+------+------+
| run | none* | SSE2 | AVX2 |
+-----+-------+------+------+
|   1 | 393x  | 572x | 618x |
|   2 | 388x  | 568x | 607x |
|   3 | 393x  | 564x | 599x |
+-----+-------+------+------+
```
*: baseline, no SIMD used for pitch search, but SSE2 used for the RNN

Results obtained as follows:
1. Force SSE2 in `DISABLED_RnnVadPerformance` for the RNN part in
   order to measure the baseline correctly:
```
RnnBasedVad rnn_vad({/*sse2=*/true, /*avx2=*/true, /*neon=*/false});
```
2. Run the test:
```
$ ./out/release/modules_unittests \
  --gtest_filter=*RnnVadTest*DISABLED_RnnVadPerformance* \
  --gtest_also_run_disabled_tests --logs
```

Bug: webrtc:10480
Change-Id: I89a2bd420265540026944b9c0f1fdd4bfda7f475
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/195001
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32755}
2020-12-03 11:50:09 +00:00
Alessio Bazzica
b6e840c036 RNN VAD: SSE2 optimization for VectorMath::DotProduct
Bug: webrtc:10480
Change-Id: I9f40352308bbfd5ea72a2607e7d1184cb6b85333
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/194328
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32745}
2020-12-02 16:59:06 +00:00
Alessio Bazzica
01b3e24a83 RNN VAD: VectorMath::DotProduct with AVX2 optimization
This CL adds a new library for the RNN VAD that provides (optimized)
vector math ops. The scheme is the same of the `VectorMath` class of AEC3
to ensure correct builds across different platforms.

Bug: webrtc:10480
Change-Id: I96bcfbf930ca27388ab5f2d52c022ddb73acf8e6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/194326
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32741}
2020-12-02 15:13:15 +00:00
Alessio Bazzica
253f8369bb AGC2 RNN VAD: safe SIMD optimizations scheme + AVX2 kill switch
In preparation for adding AVX2 code, a safe scheme to support
different SIMD optimizations is added.

Safety features:
- AVX2 kill switch to stop using it even if supported by the
  architecture
- struct indicating the available CPU features propagated from
  AGC2 to each component; in this way
  - better control over the unit tests
  - no need to propagate individual kill switches but just
    set to false features that are turned off

Note that (i) this CL does not change the performance of the RNN VAD
and (ii) no AVX2 optimization is added yet.

Bug: webrtc:10480
Change-Id: I0e61f3311ecd140f38369cf68b6e5954f3dc1f5a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/193140
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32739}
2020-12-02 10:09:24 +00:00
Alessio Bazzica
08d2a703fc AGC2 limiter stats + config ToString missing param
Bug: webrtc:7494
Change-Id: Icb6a164882af5c15c9400eb869dccbfda20b3da7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/194324
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Jakob Ivarsson <jakobi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32653}
2020-11-20 17:03:05 +00:00
Mirko Bonadei
01719fbeb5 Reland "Rename FATAL() into RTC_FATAL()."
This is a reland of 9653d26f8e

Original change's description:
> Rename FATAL() into RTC_FATAL().
>
> No-Try: True
> Bug: webrtc:8454
> Change-Id: I9130487a92463a2128cf1493e6c5117b2fab313a
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/193703
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#32620}

No-Try: True
Bug: webrtc:8454
Change-Id: Idb80125ac31ea307d1434bc9a65f148ac2017a3c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/193864
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32635}
2020-11-18 20:49:08 +00:00
Mirko Bonadei
a4fd641f51 Revert "Rename FATAL() into RTC_FATAL()."
This reverts commit 9653d26f8e.

Reason for revert: Breaks downstream project.

Original change's description:
> Rename FATAL() into RTC_FATAL().
>
> No-Try: True
> Bug: webrtc:8454
> Change-Id: I9130487a92463a2128cf1493e6c5117b2fab313a
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/193703
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#32620}

TBR=mbonadei@webrtc.org,kwiberg@webrtc.org

Change-Id: I0ad01bcac60c87b30bd4575a9d631e7dd8f34992
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:8454
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/193863
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32627}
2020-11-18 07:03:54 +00:00
Mirko Bonadei
9653d26f8e Rename FATAL() into RTC_FATAL().
No-Try: True
Bug: webrtc:8454
Change-Id: I9130487a92463a2128cf1493e6c5117b2fab313a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/193703
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32620}
2020-11-17 16:12:40 +00:00
Gustaf Ullberg
4543697b37 Set range of GetLinearAecOutput to [-1, 1]
The output of GetLinearAecOutput is changed to have the range [-1, 1]
instead of [-2^15, 2^15] to be more similar to other Audio Processing
Module API functions.

The "--linear_aec_output" of audioproc_f has been tested for
bit-exactness.

Bug: webrtc:12185
Change-Id: Id50d93fcfaee5c239f3eb73f99d0bd3533319518
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/193062
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32604}
2020-11-13 15:01:31 +00:00
Alessio Bazzica
05f5d636e5 RNN VAD: pitch search optimizations (part 4)
Add inverted lags index to simplify the loop in
`FindBestPitchPeriod48kHz()`. Instead of looping over 294 items,
only loop over the relevant ones (up to 10) by keeping track of
the relevant indexes.

The benchmark has shown a slight improvement (about +6x).

Benchmarked as follows:
```
out/release/modules_unittests \
  --gtest_filter=*RnnVadTest.DISABLED_RnnVadPerformance* \
  --gtest_also_run_disabled_tests --logs
```

Results:

      | baseline             | this CL
------+----------------------+------------------------
run 1 | 22.8319 +/- 1.46554  | 22.1951 +/- 0.747611
      | 389.367x             | 400.539x
------+----------------------+------------------------
run 2 | 22.4286 +/- 0.726449 | 22.2718 +/- 0.963738
      | 396.369x             | 399.16x
------+----------------------+------------------------
run 2 | 22.5688 +/- 0.831341 | 22.4166 +/- 0.953362
      | 393.906x             | 396.581x

This CL also moved `PitchPseudoInterpolationInvLagAutoCorr()`
into `FindBestPitchPeriod48kHz()`.

Bug: webrtc:10480
Change-Id: Id4e6d755045c3198a80fa94a0a7463577d909b7e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/191764
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32590}
2020-11-11 15:51:52 +00:00
Alessio Bazzica
f2a2fe84b8 Reland "RNN VAD: pitch search optimizations (part 3)"
This reverts commit 57e68ee1b9.

Reason for revert: bug in ancestor CL fixed

Original change's description:
> Revert "RNN VAD: pitch search optimizations (part 3)"
>
> This reverts commit ea89f2a447.
>
> 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 3)
> >
> > `ComputeSlidingFrameSquareEnergies()` which computes the energy of a
> > sliding 20 ms frame in the pitch buffer has been switched from backward
> > to forward.
> >
> > The benchmark has shown a slight improvement (about +6x).
> >
> > This change is not bit exact but all the tolerance tests still pass
> > except for one single case in `RnnVadTest,PitchSearchWithinTolerance`
> > for which the tolerance has been slightly increased. Note that the pitch
> > estimation is still bit-exact.
> >
> > Benchmarked as follows:
> > ```
> > out/release/modules_unittests \
> >   --gtest_filter=*RnnVadTest.DISABLED_RnnVadPerformance* \
> >   --gtest_also_run_disabled_tests --logs
> > ```
> >
> > Results:
> >
> >       | baseline             | this CL
> > ------+----------------------+------------------------
> > run 1 | 22.8319 +/- 1.46554  | 22.087 +/- 0.552932
> >       | 389.367x             | 402.499x
> > ------+----------------------+------------------------
> > run 2 | 22.4286 +/- 0.726449 | 22.216 +/- 0.916222
> >       | 396.369x             | 400.162x
> > ------+----------------------+------------------------
> > run 2 | 22.5688 +/- 0.831341 | 22.4902 +/- 1.04881
> >       | 393.906x             | 395.283x
> >
> > Bug: webrtc:10480
> > Change-Id: I1fd54077a32e25e46196c8e18f003cd0ffd503e1
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/191703
> > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#32572}
>
> TBR=alessiob@webrtc.org,kwiberg@webrtc.org
>
> Change-Id: I57a8f937ade0a35e1ccf0e229c391cc3a10e7c48
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:10480
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192621
> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#32578}

TBR=alessiob@webrtc.org,kwiberg@webrtc.org

# Not skipping CQ checks because this is a reland.

Bug: webrtc:10480
Change-Id: I1d510697236255d8c0cca405e90781f5d8c6a3e6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192783
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32587}
2020-11-11 13:46:02 +00:00
Alessio Bazzica
5a37b94029 Reland "RNN VAD: pitch search optimizations (part 2)"
This reverts commit e6a731fcea.

Reason for revert: bug in parent CL fixed

Original change's description:
> Revert "RNN VAD: pitch search optimizations (part 2)"
>
> This reverts commit 2f7d1c62e2.
>
> 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 13:19:02 +00:00
Alessio Bazzica
c36f8623c0 Reland "RNN VAD: pitch search optimizations (part 1)"
This reverts commit 1b6b958a4a.

Reason for revert: Bug fix

Original change's description:
> Revert "RNN VAD: pitch search optimizations (part 1)"
>
> This reverts commit 9da3e177fd.
>
> 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:43:45 +00:00
Alessio Bazzica
1b6b958a4a Revert "RNN VAD: pitch search optimizations (part 1)"
This reverts commit 9da3e177fd.

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}
2020-11-10 20:31:28 +00:00
Alessio Bazzica
e6a731fcea Revert "RNN VAD: pitch search optimizations (part 2)"
This reverts commit 2f7d1c62e2.

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}
2020-11-10 19:44:09 +00:00
Alessio Bazzica
57e68ee1b9 Revert "RNN VAD: pitch search optimizations (part 3)"
This reverts commit ea89f2a447.

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 3)
>
> `ComputeSlidingFrameSquareEnergies()` which computes the energy of a
> sliding 20 ms frame in the pitch buffer has been switched from backward
> to forward.
>
> The benchmark has shown a slight improvement (about +6x).
>
> This change is not bit exact but all the tolerance tests still pass
> except for one single case in `RnnVadTest,PitchSearchWithinTolerance`
> for which the tolerance has been slightly increased. Note that the pitch
> estimation is still bit-exact.
>
> Benchmarked as follows:
> ```
> out/release/modules_unittests \
>   --gtest_filter=*RnnVadTest.DISABLED_RnnVadPerformance* \
>   --gtest_also_run_disabled_tests --logs
> ```
>
> Results:
>
>       | baseline             | this CL
> ------+----------------------+------------------------
> run 1 | 22.8319 +/- 1.46554  | 22.087 +/- 0.552932
>       | 389.367x             | 402.499x
> ------+----------------------+------------------------
> run 2 | 22.4286 +/- 0.726449 | 22.216 +/- 0.916222
>       | 396.369x             | 400.162x
> ------+----------------------+------------------------
> run 2 | 22.5688 +/- 0.831341 | 22.4902 +/- 1.04881
>       | 393.906x             | 395.283x
>
> Bug: webrtc:10480
> Change-Id: I1fd54077a32e25e46196c8e18f003cd0ffd503e1
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/191703
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#32572}

TBR=alessiob@webrtc.org,kwiberg@webrtc.org

Change-Id: I57a8f937ade0a35e1ccf0e229c391cc3a10e7c48
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:10480
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192621
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32578}
2020-11-10 18:43:48 +00:00