Commit graph

418 commits

Author SHA1 Message Date
Per Åhgren
78026754a7 AEC3: Utilize shadow filter output to respond to audio path changes
This CL adds functionality to use the shadow filter output instead
of the main filter output for cases when the former is better than
the latter. One case when that happens is when there have been an
echo path change, either in the acoustic path, in the audio buffers
or due to some active audio processing effects being applied on
the device.

The CL causes less echo leaks, in particular on devices with
active render processing.

Bug: webrtc:9581,chromium:869821
Change-Id: Icb8df1b94141598da82dc188051ac59e43338938
Reviewed-on: https://webrtc-review.googlesource.com/91820
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24166}
2018-08-01 15:20:33 +00:00
Oleh Prypin
d2f4e8bd90 Explicitly add -mfpu=neon to all targets that use NEON
Remove obsolete comment about Chromium not defining NEON for Android.

Semi-related fix: don't use `rtc_remove_configs` directly, `suppressed_configs` is the "public interface".

Bug: webrtc:9579
Change-Id: I512628feb462a29432f1356cfef00efe1ddaf84f
Reviewed-on: https://webrtc-review.googlesource.com/91761
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Oleh Prypin <oprypin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24165}
2018-08-01 13:15:42 +00:00
Alessio Bazzica
55bf92adf4 RNN VAD: more specific build target names.
Bug: webrtc:9076
Change-Id: Ie35ce0f864318a1ddc552285a5535fe411168202
Reviewed-on: https://webrtc-review.googlesource.com/91760
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24162}
2018-08-01 09:07:26 +00:00
Alessio Bazzica
2a99c0bf67 Fix MovingMoments::CalculateMoments.
Protect from negative second moments, which are unexpected in TransientDetector::Detect
and may lead to invalid results.

Bug: chromium:866925
Change-Id: Id1d5b2ebb51e54d9d332b869c6f63dcd03cc461c
Reviewed-on: https://webrtc-review.googlesource.com/91164
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24153}
2018-07-31 15:08:12 +00:00
Per Åhgren
ef5d5af3a0 AEC3: Increasing the accuracy of the detection for early reverb
This CL introduces an adaptive estimation of the early reverb
in the estimation for the room reverberation. The benefits of
this is that for room with long early reflections there is
a lower risk of underestimating the reverberation.

This CL is for a landing the code in
https://webrtc-review.googlesource.com/c/src/+/87420,
and the review of the code was done in that CL. The author of
code is devicentepena@webrtc.org

Bug: webrtc:9479, chromium:865397
Change-Id: Id6f57e2a684664aef96e8c502e66775f37da59da
Reviewed-on: https://webrtc-review.googlesource.com/91162
Commit-Queue: Per Åhgren <peah@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24146}
2018-07-30 22:34:19 +00:00
Sam Zackrisson
0b0f3596bd Remove old temporary webrtc::PostProcessing typedef
Related bug closed since half a year back.

Bug: webrtc:8665
Change-Id: I77007caaa97b5db04f5cf144323cac7a576a7fde
Reviewed-on: https://webrtc-review.googlesource.com/90872
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24135}
2018-07-27 15:43:57 +00:00
Per Åhgren
f954ba5c11 AEC3: Increasing the transparency during call startup
This CL increases the AEC3 transparency during call
startup and after echo path delay changes in 3 ways:
1. The exit requirements for the initial mode is
made less strict.
2. The requirements for using the linear echo model
are made less strict.
3. The duplicated reverb modelling in the linear mode
removed.


Bug: webrtc:9572,chromium:868329
Change-Id: I79ea0796ed26408e35576bb39eaae4e4848b4f83
Reviewed-on: https://webrtc-review.googlesource.com/90868
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24132}
2018-07-27 14:18:42 +00:00
Sam Zackrisson
8b5d2cc93e Add unused AEC toggling config to API
This will be the one way of toggling AEC. The EchoControlMobile and
EchoCancellation interfaces will be removed.

The settings introduced here are not used yet, to allow for smooth
downstream fixes.

Bug: webrtc:9535
Change-Id: I3b1a524a0ab7daf63419d7e5ed47417b9282dbf6
Reviewed-on: https://webrtc-review.googlesource.com/90864
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24129}
2018-07-27 12:57:45 +00:00
Per Åhgren
e4db6a1518 AEC3: Improved the accuracy of the adaptive filter
This CL adds a functionality that jump-starts the
AEC3 shadow filter whenever it performs consistently
worse than the main filter.
The jump-start is done such that the shadow filter
is re-initialized using the main filter coefficients.

The effects of this is a significantly more accurate
main linear filter which leads to less echo leakage
and better transparency

Bug: webrtc:9565, chromium:867873
Change-Id: Ie0b23cd536adc7ce96fc3ed2a7db112aec7437f1
Reviewed-on: https://webrtc-review.googlesource.com/90413
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24117}
2018-07-26 14:51:32 +00:00
Artem Titov
333a50562c Move fft4g to proper third_party directory
Bug: webrtc:8366
Change-Id: I98d3ae56a1d14b3ecacd85a4b3d234e215c8bc58
Reviewed-on: https://webrtc-review.googlesource.com/85642
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Niklas Enbom <niklas.enbom@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24103}
2018-07-25 15:44:53 +00:00
Per Åhgren
7f5175a455 AEC3: Corrected the filter adjustment during analog gain changes
This CL corrects the way that the echo subtractor output is
adjusted during the adjustment of the adaptive filter when the
analog AGC gain changes.

The CL also ensures that the main adaptive filter is not updated
when this occurs.

Bug: webrtc:9561,chromium:867373
Change-Id: I636f936128f7d9f0d82ca4140b59f148eb35d6a4
Reviewed-on: https://webrtc-review.googlesource.com/90401
Commit-Queue: Per Åhgren <peah@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24101}
2018-07-25 15:00:33 +00:00
Niels Möller
a12c42a6b2 Delete root header file typedef.h.
Usage replaced with stdint.h, rtc_base/system/arch.h and
rtc_base/system/unused.h, as appropriate.

Bug: webrtc:6854
Change-Id: I97225465d14b969903d92979e2df3c3c05d35f18
Reviewed-on: https://webrtc-review.googlesource.com/90249
Reviewed-by: Niklas Enbom <niklas.enbom@webrtc.org>
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24100}
2018-07-25 14:59:26 +00:00
Sam Zackrisson
e507b0ce8e Turn off comfort noise generation by default in AECM
All clients who do not own their own APM turn it off by default
(in WebrtcVoiceEngine). AECM with comfort noise is a little-exercised
code path. Configurability of this setting is going away, so we're
better off disabling it by default.

Bug: webrtc:9535
Change-Id: Iba839aa18e79ae29ff20bdf6e30de77870ba4143
Reviewed-on: https://webrtc-review.googlesource.com/89583
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24078}
2018-07-24 08:52:36 +00:00
Artem Titov
5d7a4c6692 Fixing py lint errors
Bug: webrtc:9548
Change-Id: I0daf8dc06fdaac1637c32994ef6ad542ed52202a
Reviewed-on: https://webrtc-review.googlesource.com/90045
Reviewed-by: Oleh Prypin <oprypin@webrtc.org>
Reviewed-by: Niklas Enbom <niklas.enbom@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24068}
2018-07-23 15:28:48 +00:00
Sam Zackrisson
2a959d96c9 Revert "Add one-stop-shop for built-in AEC toggling in APM"
This reverts commit 771b50ca0b.

Reason for revert: Introduces error-prone config.

Original change's description:
> Add one-stop-shop for built-in AEC toggling in APM
> 
> This does not change what AEC functionality is available.
> However, a client that only uses this interface - and not the submodule
> pointer accessors - gets simpler code, and is guaranteed not to run any
> two AECs in tandem.
> 
> The submodule interface EchoControlMobile is being deprecated in
> https://webrtc-review.googlesource.com/c/src/+/89392
> 
> Bug: webrtc:9535
> Change-Id: Id9326074e566be6d8768010fc421c457beff402c
> Reviewed-on: https://webrtc-review.googlesource.com/89386
> Commit-Queue: Sam Zackrisson <saza@webrtc.org>
> Reviewed-by: Per Åhgren <peah@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#24066}

TBR=saza@webrtc.org,peah@webrtc.org

Change-Id: I43283a1b22538a4caa77313499989146b2ce67f1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:9535
Reviewed-on: https://webrtc-review.googlesource.com/90060
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24067}
2018-07-23 14:48:17 +00:00
Sam Zackrisson
771b50ca0b Add one-stop-shop for built-in AEC toggling in APM
This does not change what AEC functionality is available.
However, a client that only uses this interface - and not the submodule
pointer accessors - gets simpler code, and is guaranteed not to run any
two AECs in tandem.

The submodule interface EchoControlMobile is being deprecated in
https://webrtc-review.googlesource.com/c/src/+/89392

Bug: webrtc:9535
Change-Id: Id9326074e566be6d8768010fc421c457beff402c
Reviewed-on: https://webrtc-review.googlesource.com/89386
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24066}
2018-07-23 14:12:26 +00:00
Per Åhgren
71ebf99768 AEC3: Added dumping to wav files for the filter outputs
Bug: webrtc:8671
Change-Id: I9b16ec2fca73894ec26b1cb2b88354ea8d947bf5
Reviewed-on: https://webrtc-review.googlesource.com/88760
Commit-Queue: Per Åhgren <peah@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24064}
2018-07-23 10:43:23 +00:00
Alex Loiko
99f1e0d008 Reset level estimator when analog gain changes.
In AgcManagerDirect::UpdateGain(), Agc::GetRmsErrorDb() is
called. Depending on the result of that call, the analog gain may be
changed. After an analog gain change, the Agc should be reset, because
it's memory contains now invalid loudness levels.

The Agc in modules/audio_processing/agc/agc.cc resets itself at every
successful Agc::GetRmsErrorDb call. The AdaptiveModeLevelEstimatorAgc
does not. This change makes sure all Agcs are reset from
AgcManagerDirect.

It will cause some Agcs to be reset twice. This is fine, because
Agc::Reset() is cheap and idempotent.

Bug: webrtc:7494
Change-Id: Iee7495d699cbdb9d69b2ae0cb07034c6e2761e22
Reviewed-on: https://webrtc-review.googlesource.com/89040
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24054}
2018-07-20 14:18:38 +00:00
Alex Loiko
e714ed6427 Fuzzer finds fixedpoint failure.
A 32-bit number overflows. It's then capped to compute a 16-bit value.
This CL introduces a 64-bit variable on which equivalent operations are
performed instead.

Bug: chromium:864883
Change-Id: I371af869c6586256b900356491f467bed357e11d
Reviewed-on: https://webrtc-review.googlesource.com/89584
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24041}
2018-07-19 12:11:22 +00:00
Oleh Prypin
dd21474da5 Replace accidental usages of source_set with rtc_source_set
Bug: None
Change-Id: I80c5ad9e1e9942eb51ace014cd7b9127959d601b
Reviewed-on: https://webrtc-review.googlesource.com/89061
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Oleh Prypin <oprypin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24004}
2018-07-17 12:40:17 +00:00
Alex Loiko
684b401016 Division by zero in RNN-VAD.
Bug: webrtc:9450, chromium:861557
Change-Id: I00ddda1fe0e088b983707420acf1b9a6763a3535
Reviewed-on: https://webrtc-review.googlesource.com/87841
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23999}
2018-07-17 09:03:05 +00:00
Mirko Bonadei
a6c544d08d Enabling clang::find_bad_constructs for AEC3.
This CL removes //build/config/clang:find_bad_constructs from the
suppressed_configs list, which means that clang:find_bad_constructs
is now enabled on these translation units.

Bug: webrtc:9251
Change-Id: Ibdafc0bb08de1be7189af7053a67a24e3a26bd6b
Reviewed-on: https://webrtc-review.googlesource.com/89001
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23997}
2018-07-17 08:49:15 +00:00
Per Åhgren
88cf0501f3 AEC3: Adding explicit handling of microphone gain changes
This CL re-activates the explicit handling of microphone
gain changes in the AEC3 code. The implementation is done
beneath a kill-switch so that when that switch is active
the changes in this CL are bitexact.


Bug: webrtc:9526,chromium:863826
Change-Id: I58e93d8bc0bce7bec91e102de9891ad48ebc55d8
Reviewed-on: https://webrtc-review.googlesource.com/88620
Commit-Queue: Per Åhgren <peah@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23986}
2018-07-16 16:02:07 +00:00
Per Åhgren
b20b93796f AEC3: Refactor the code for analyzing filter convergence
This CL refactors the code in AEC3 that analyzes how
well the adaptive filter performs. The purpose of this
is both to simplify code that is more complex than needed
and also to pave the wave for the upcoming CLs that
softens the echo suppression during doubletalk.

The main changes are that:
-The shadow adaptive filter is now never analyzed. This
turned out to never affect the output in the recordings
it was tested on.
-The convergence analysis was moved to the aec state
code.

The changes are bitexact on all testcases where they
have been tested on.

Bug: webrtc:8671
Change-Id: If76b669565325c8eb4d11d1178a7e20306da9a26
Reviewed-on: https://webrtc-review.googlesource.com/87430
Commit-Queue: Per Åhgren <peah@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23958}
2018-07-12 23:13:08 +00:00
Sam Zackrisson
3f84f498e4 Remove useless import of arm.gni
Bug: None
Change-Id: I439410d9edf306b664ef21157216870d6e1c8207
Reviewed-on: https://webrtc-review.googlesource.com/87436
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23953}
2018-07-12 14:39:00 +00:00
Alessio Bazzica
9cb5d5f9de Reland "IWYU: Add <cmath> for fabsf() and powf(), switch to C++ versions"
This reverts commit d39ce8d45b.

Reason for revert: downstream project fix

Original change's description:
> Revert "IWYU: Add <cmath> for fabsf() and powf(), switch to C++ versions"
> 
> This reverts commit e90879097c.
> 
> Reason for revert: breaking downstream projects
> 
> Original change's description:
> > IWYU: Add <cmath> for fabsf() and powf(), switch to C++ versions
> > 
> > Fix the build with libstdc++ after 496cedfe5 ("AEC3: Reverberation model:
> > Changes on the decay estimation") by including the missing header:
> > 
> >     ../../modules/audio_processing/aec3/reverb_model_estimator.cc: In constructor ‘webrtc::ReverbModelEstimator::ReverbModelEstimator(const webrtc::EchoCanceller3Config&)’:
> >     ../../modules/audio_processing/aec3/reverb_model_estimator.cc:61:21: error: ‘fabsf’ was not declared in this scope
> >            reverb_decay_(fabsf(config.ep_strength.default_len)),
> >                          ^~~~~
> >     ../../modules/audio_processing/aec3/reverb_model_estimator.cc:61:21: note: suggested alternative: ‘labs’
> >            reverb_decay_(fabsf(config.ep_strength.default_len)),
> >                          ^~~~~
> >                          labs
> >     ../../modules/audio_processing/aec3/reverb_model_estimator.cc: In member function ‘void webrtc::ReverbModelEstimator::UpdateReverbDecay(const std::vector<float>&)’:
> >     ../../modules/audio_processing/aec3/reverb_model_estimator.cc:206:15: error: ‘powf’ was not declared in this scope
> >            decay = powf(2.0f, -exp_candidate * kFftLengthBy2);
> >                    ^~~~
> > 
> > While here, also switch to the C++ versions of those functions: std::fabs()
> > and std::pow() respectively.
> > 
> > Spotted by Jose Dapena Paz <jose.dapena@lge.com>.
> > 
> > Bug: chromium:819294
> > Change-Id: Id803243be8dd17eac95c70a88a37ee2fe1505a5a
> > Reviewed-on: https://webrtc-review.googlesource.com/87421
> > Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
> > Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
> > Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#23870}
> 
> TBR=gustaf@webrtc.org,alessiob@webrtc.org,raphael.kubo.da.costa@intel.com,devicentepena@webrtc.org
> 
> Change-Id: I22423a2d4201183f70ae084e0e21930367824f1c
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:819294
> Reviewed-on: https://webrtc-review.googlesource.com/87401
> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#23871}

TBR=gustaf@webrtc.org,alessiob@webrtc.org,raphael.kubo.da.costa@intel.com,devicentepena@webrtc.org

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

Bug: chromium:819294
Change-Id: I09e07d59961d3e2ecc617244287a821cb8b04578
Reviewed-on: https://webrtc-review.googlesource.com/87900
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23910}
2018-07-10 15:01:50 +00:00
Sam Zackrisson
71729eb0a8 Fix fuzzer-found flow-over in AGC1
This CL changes a constant from an approximately correct limit
of 2^25.5.

The new limit is the largest x such that z = 10 satisfies:
((x >> z) + 1)^2 <= 2^31 - 1.
If gains[k + 1] > x, then z >= 11 and needs to be computed.

Bug: chromium:860638
Change-Id: If17f257dacd94806e59e4f32b345a5fb15b4e32b
Reviewed-on: https://webrtc-review.googlesource.com/87583
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23908}
2018-07-10 14:02:49 +00:00
Sam Zackrisson
7219d053d5 Split aec and aecm into separate build targets
This clarifies dependencies and makes it easier to customize builds
for different binaries.

Also adds BUILD files in aec/ and aecm/.

Moves unit tests to their own target, which subjects them to Chromium
Clang style checks.
The CL contains a fix for a thusly induced warning.

Bug: webrtc:9488
Change-Id: I77b680b42a4dccc5f025005e0890f60b4eaf2961
Reviewed-on: https://webrtc-review.googlesource.com/87304
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23887}
2018-07-09 14:48:06 +00:00
Alex Loiko
2ffafa8244 Allow AGC2 level estimation in AgcManagerDirect.
This CL does the following:

1. Adds a new AdaptiveModeLevelEstimatorAgc implementation of the Agc
  interface. The new implementation differs from webrtc::Agc by
   1. using the AGC2 speech level estimator in
      GetRmsErrorDb. webrtc::Agc implements its own with help of
      webrtc::LoudnessHistogram.
   2. Doesn't forget its past at every GetRmsErrorDb call.
2. Makes AgcManagerDirect use AdaptiveModeLevelEstimatorAgc instead of
   webrtc::Agc if the use_agc2_level_estimation flag is set.

Bug: webrtc:7494
Change-Id: I8df3f52e322d433eb5ce5297f4236af2f1877b04
Reviewed-on: https://webrtc-review.googlesource.com/86603
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23875}
2018-07-06 14:18:18 +00:00
Alex Loiko
ed8ff64ef7 Break out Agc code from audio_processing.
Splits 'modules/audio_processing:audio_processing' target. The files
in modules/audio_processing/agc now are in targets in that folder.

Reason for doing this was to include
modules/audio_processing/agc/agc.h from another target in the
dependent CL https://webrtc-review.googlesource.com/c/src/+/86603

This could help reducing the binary size in the future.

Bug: webrtc:7494
Change-Id: I61f50ab6d5ce24d19f4097e0f3fa8b0170010887
Reviewed-on: https://webrtc-review.googlesource.com/87422
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23873}
2018-07-06 13:29:43 +00:00
Alessio Bazzica
d39ce8d45b Revert "IWYU: Add <cmath> for fabsf() and powf(), switch to C++ versions"
This reverts commit e90879097c.

Reason for revert: breaking downstream projects

Original change's description:
> IWYU: Add <cmath> for fabsf() and powf(), switch to C++ versions
> 
> Fix the build with libstdc++ after 496cedfe5 ("AEC3: Reverberation model:
> Changes on the decay estimation") by including the missing header:
> 
>     ../../modules/audio_processing/aec3/reverb_model_estimator.cc: In constructor ‘webrtc::ReverbModelEstimator::ReverbModelEstimator(const webrtc::EchoCanceller3Config&)’:
>     ../../modules/audio_processing/aec3/reverb_model_estimator.cc:61:21: error: ‘fabsf’ was not declared in this scope
>            reverb_decay_(fabsf(config.ep_strength.default_len)),
>                          ^~~~~
>     ../../modules/audio_processing/aec3/reverb_model_estimator.cc:61:21: note: suggested alternative: ‘labs’
>            reverb_decay_(fabsf(config.ep_strength.default_len)),
>                          ^~~~~
>                          labs
>     ../../modules/audio_processing/aec3/reverb_model_estimator.cc: In member function ‘void webrtc::ReverbModelEstimator::UpdateReverbDecay(const std::vector<float>&)’:
>     ../../modules/audio_processing/aec3/reverb_model_estimator.cc:206:15: error: ‘powf’ was not declared in this scope
>            decay = powf(2.0f, -exp_candidate * kFftLengthBy2);
>                    ^~~~
> 
> While here, also switch to the C++ versions of those functions: std::fabs()
> and std::pow() respectively.
> 
> Spotted by Jose Dapena Paz <jose.dapena@lge.com>.
> 
> Bug: chromium:819294
> Change-Id: Id803243be8dd17eac95c70a88a37ee2fe1505a5a
> Reviewed-on: https://webrtc-review.googlesource.com/87421
> Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
> Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
> Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#23870}

TBR=gustaf@webrtc.org,alessiob@webrtc.org,raphael.kubo.da.costa@intel.com,devicentepena@webrtc.org

Change-Id: I22423a2d4201183f70ae084e0e21930367824f1c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:819294
Reviewed-on: https://webrtc-review.googlesource.com/87401
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23871}
2018-07-06 11:37:15 +00:00
Raphael Kubo da Costa
e90879097c IWYU: Add <cmath> for fabsf() and powf(), switch to C++ versions
Fix the build with libstdc++ after 496cedfe5 ("AEC3: Reverberation model:
Changes on the decay estimation") by including the missing header:

    ../../modules/audio_processing/aec3/reverb_model_estimator.cc: In constructor ‘webrtc::ReverbModelEstimator::ReverbModelEstimator(const webrtc::EchoCanceller3Config&)’:
    ../../modules/audio_processing/aec3/reverb_model_estimator.cc:61:21: error: ‘fabsf’ was not declared in this scope
           reverb_decay_(fabsf(config.ep_strength.default_len)),
                         ^~~~~
    ../../modules/audio_processing/aec3/reverb_model_estimator.cc:61:21: note: suggested alternative: ‘labs’
           reverb_decay_(fabsf(config.ep_strength.default_len)),
                         ^~~~~
                         labs
    ../../modules/audio_processing/aec3/reverb_model_estimator.cc: In member function ‘void webrtc::ReverbModelEstimator::UpdateReverbDecay(const std::vector<float>&)’:
    ../../modules/audio_processing/aec3/reverb_model_estimator.cc:206:15: error: ‘powf’ was not declared in this scope
           decay = powf(2.0f, -exp_candidate * kFftLengthBy2);
                   ^~~~

While here, also switch to the C++ versions of those functions: std::fabs()
and std::pow() respectively.

Spotted by Jose Dapena Paz <jose.dapena@lge.com>.

Bug: chromium:819294
Change-Id: Id803243be8dd17eac95c70a88a37ee2fe1505a5a
Reviewed-on: https://webrtc-review.googlesource.com/87421
Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23870}
2018-07-06 11:03:41 +00:00
Alessio Bazzica
282dad1943 Revert "IWYU: Add <math.h> for fabsf() and powf()"
This reverts commit 7d47525e8b.

Reason for revert: breaking downstream projects

Original change's description:
> IWYU: Add <math.h> for fabsf() and powf()
> 
> Fix the build with libstdc++ after 496cedfe5 ("AEC3: Reverberation model:
> Changes on the decay estimation") by including the missing header:
> 
>     ../../modules/audio_processing/aec3/reverb_model_estimator.cc: In constructor ‘webrtc::ReverbModelEstimator::ReverbModelEstimator(const webrtc::EchoCanceller3Config&)’:
>     ../../modules/audio_processing/aec3/reverb_model_estimator.cc:61:21: error: ‘fabsf’ was not declared in this scope
>            reverb_decay_(fabsf(config.ep_strength.default_len)),
>                          ^~~~~
>     ../../modules/audio_processing/aec3/reverb_model_estimator.cc:61:21: note: suggested alternative: ‘labs’
>            reverb_decay_(fabsf(config.ep_strength.default_len)),
>                          ^~~~~
>                          labs
>     ../../modules/audio_processing/aec3/reverb_model_estimator.cc: In member function ‘void webrtc::ReverbModelEstimator::UpdateReverbDecay(const std::vector<float>&)’:
>     ../../modules/audio_processing/aec3/reverb_model_estimator.cc:206:15: error: ‘powf’ was not declared in this scope
>            decay = powf(2.0f, -exp_candidate * kFftLengthBy2);
>                    ^~~~
> 
> Spotted by Jose Dapena Paz <jose.dapena@lge.com>.
> 
> Bug: chromium:819294
> Change-Id: If992e5e473b9d4d0c1b3c1006c3816b7c4eee296
> Reviewed-on: https://webrtc-review.googlesource.com/87241
> Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
> Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
> Commit-Queue: Raphael Kubo da Costa (rakuco) <raphael.kubo.da.costa@intel.com>
> Cr-Commit-Position: refs/heads/master@{#23863}

TBR=gustaf@webrtc.org,alessiob@webrtc.org,raphael.kubo.da.costa@intel.com,devicentepena@webrtc.org

Change-Id: I8adcec57d67de2efcbf0ebef0cdb700fcc21689a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:819294
Reviewed-on: https://webrtc-review.googlesource.com/87400
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23864}
2018-07-06 09:18:22 +00:00
Raphael Kubo da Costa
7d47525e8b IWYU: Add <math.h> for fabsf() and powf()
Fix the build with libstdc++ after 496cedfe5 ("AEC3: Reverberation model:
Changes on the decay estimation") by including the missing header:

    ../../modules/audio_processing/aec3/reverb_model_estimator.cc: In constructor ‘webrtc::ReverbModelEstimator::ReverbModelEstimator(const webrtc::EchoCanceller3Config&)’:
    ../../modules/audio_processing/aec3/reverb_model_estimator.cc:61:21: error: ‘fabsf’ was not declared in this scope
           reverb_decay_(fabsf(config.ep_strength.default_len)),
                         ^~~~~
    ../../modules/audio_processing/aec3/reverb_model_estimator.cc:61:21: note: suggested alternative: ‘labs’
           reverb_decay_(fabsf(config.ep_strength.default_len)),
                         ^~~~~
                         labs
    ../../modules/audio_processing/aec3/reverb_model_estimator.cc: In member function ‘void webrtc::ReverbModelEstimator::UpdateReverbDecay(const std::vector<float>&)’:
    ../../modules/audio_processing/aec3/reverb_model_estimator.cc:206:15: error: ‘powf’ was not declared in this scope
           decay = powf(2.0f, -exp_candidate * kFftLengthBy2);
                   ^~~~

Spotted by Jose Dapena Paz <jose.dapena@lge.com>.

Bug: chromium:819294
Change-Id: If992e5e473b9d4d0c1b3c1006c3816b7c4eee296
Reviewed-on: https://webrtc-review.googlesource.com/87241
Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Commit-Queue: Raphael Kubo da Costa (rakuco) <raphael.kubo.da.costa@intel.com>
Cr-Commit-Position: refs/heads/master@{#23863}
2018-07-06 08:34:21 +00:00
Mirko Bonadei
5abfb00bf2 Removing useless import of arm.gni
Bug: None
Change-Id: I2915890f72051e1d4f042735f952d36bda6a4141
Reviewed-on: https://webrtc-review.googlesource.com/87382
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23862}
2018-07-06 08:27:41 +00:00
Sam Zackrisson
b2e176522e Create separate build targets for utility/ in APM
This clarifies the dependencies of utility/ a lot (spoiler:
there are very few) and makes it easier to separate the build
targets for aecm and aec2.

Bug: webrtc:9488
Change-Id: If916f86e80c19d1b650d0908fbe8343ea7c47bd7
Reviewed-on: https://webrtc-review.googlesource.com/87141
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23860}
2018-07-05 15:46:28 +00:00
Gustaf Ullberg
51f4014acd AEC3: Slower adaptation of main filter
The main filter is adapted at a lower rate which reduces the risk of
diverging during double talk. The change yields notable transparency
improvements.

Bug: webrtc:9497
Change-Id: Ib23b7a4055d313dede535d2b65dc7e023a2db042
Reviewed-on: https://webrtc-review.googlesource.com/87300
Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23858}
2018-07-05 14:37:27 +00:00
Karl Wiberg
918f50c5d1 Use absl::make_unique and absl::WrapUnique directly
Instead of going through our wrappers in ptr_util.h.

This CL was generated by the following script:

  git grep -l ptr_util | xargs perl -pi -e 's,#include "rtc_base/ptr_util.h",#include "absl/memory/memory.h",'
  git grep -l MakeUnique | xargs perl -pi -e 's,\b(rtc::)?MakeUnique\b,absl::make_unique,g'
  git grep -l WrapUnique | xargs perl -pi -e 's,\b(rtc::)?WrapUnique\b,absl::WrapUnique,g'
  git checkout -- rtc_base/ptr_util{.h,_unittest.cc}
  git cl format

Followed by manually adding dependencies on
//third_party/abseil-cpp/absl/memory until `gn check` stopped
complaining.

Bug: webrtc:9473
Change-Id: I89ccd363f070479b8c431eb2c3d404a46eaacc1c
Reviewed-on: https://webrtc-review.googlesource.com/86600
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23850}
2018-07-05 10:59:49 +00:00
Jesús de Vicente Peña
496cedfe56 AEC3: Reverberation model: Changes on the decay estimation.
In this CL we have introduced changes on the estimation of the decay involved in the exponential modeling of the reverberation. Specifically, the instantaneous ERLE has been tracked and used for adapting faster in the regions when the linear filter is performing well. Furthermore, the adaptation is just perform during render activity.


Change-Id: I974fd60e4e1a40a879660efaa24457ed940f77b4
Bug: webrtc:9479
Reviewed-on: https://webrtc-review.googlesource.com/86680
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Commit-Queue: Jesus de Vicente Pena <devicentepena@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23836}
2018-07-04 10:04:32 +00:00
Gustaf Ullberg
ec64217e56 AEC3: Simplified suppression gain calculation
This change simplifies the calculation of the suppression gains.
It also contains a new tuning of the suppressor.

The suppressor behavior is tuned by setting echo-to-nearend ratios
for when the suppressor is to be fully transparent and for when to
fully suppress. An echo-to-masker value determines when the signal
is masked by noise. These three values are specified for low and
high frequencies.

Change-Id: I108e83c8f2a35462085a3fabaebcc02fa3103607
Bug: webrtc:9482
Reviewed-on: https://webrtc-review.googlesource.com/86021
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23830}
2018-07-04 07:07:55 +00:00
Sam Zackrisson
46f858a626 Fix fuzzer-found overflow in AGC1
Much like https://bugs.chromium.org/p/chromium/issues/detail?id=855900,
the int32 gain table isn't always small enough for plain multiplication
with an int16.

This appears fixable through regular fixed-point arithmetic (multiply
out[i][n] by integer and fractional part of gain separately), but it's
less readable.

Bug: chromium:858989
Change-Id: Ie5aac25fd0cca4e51858cba69bde06c54a5d31bf
Reviewed-on: https://webrtc-review.googlesource.com/86602
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23815}
2018-07-03 09:56:34 +00:00
Alex Loiko
4d01146f16 Prepare AGC2 for analog gain changes.
1. Adds support for Reset calls in AGC2. The AGC will be reset during
   analog gain changes.
2. Allows AdaptiveModeLevelEstimator to return estimates > 0. This can
   happen if the signal gain is too high. It's needed for letting the
   analog AGC know that the gain is too high.

Bug: webrtc:7494
Change-Id: I38def17c21cc01c36aaea79a2401d8c2f289407b
Reviewed-on: https://webrtc-review.googlesource.com/79360
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23805}
2018-07-02 15:25:49 +00:00
Alex Loiko
64cb83bbd9 Flags and settings for AGC2 in AgcManagerDirect.
This CL adds two flags to audioproc_f. The flags control
AgcManagerDirect. The flags are
'--experimental_agc_agc2_level_estimator' and
'--experimental_agc_agc2_digital_adaptive'.

After this CL, the flags are be applied to AgcManagerDirect. The flags
have no effect in release-mode. They cause a crash in debug-mode.

In an upcoming CL, '--experimental_agc_agc2_level_estimator 1' will
replace the speech level estimation in ExperimentalAgc with that of
AGC2.

'--experimental_agc_agc2_digital_adaptive 1' will replace the digital
gain selection and application with that of AGC2.

These audioproc_f will activate both new settings:

./out/Target/audioproc_f --agc 1 --experimental_agc 1
--experimental_agc_agc2_digital_adaptive 1
--experimental_agc_agc2_level_estimator 1 --simulate_mic_gain 1
--simulated_mic_kind 2

See also https://webrtc-review.googlesource.com/c/src/+/79360

Bug: webrtc:7494
Change-Id: If0e65893dffdddb312e553787b8cedaf9a334323
Reviewed-on: https://webrtc-review.googlesource.com/86548
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23802}
2018-07-02 13:20:39 +00:00
Alex Loiko
5c71e74331 Add AGC1-compliant fake recording device.
The AGC submodule of APM changes analog gain. These gain changes are
typically ignored by the test tool audioproc_f.

There is an option of the test tool to take action on the gain
changes.  It's the '--simulate_mic_gain' option. The option converts
the analog gain to a digital gain. The digital gain is applied to the
capture stream.

This change adds a new simulated microphone kind. The new microphone
has a gain curve defined by
modules/audio_processing/agc/gain_map_internal.h. That gain curve
defines how AGC1 expects a microphone to behave.

Bug: webrtc:7494
Change-Id: Ifb3f54a8c6f8c001a711fa977f39f32413069780
Reviewed-on: https://webrtc-review.googlesource.com/86128
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23801}
2018-07-02 12:29:36 +00:00
Alex Loiko
c167673c4d Add more ApmDataDumper dumps to AGC.
We dump the compression level from AgcManagerDirect.

We use the same names and structure as in
GainControlForExperimentalAgc.

This is to get Apm dump file names to match in the upcoming AGC
changes: https://webrtc-review.googlesource.com/c/src/+/79360

TBR: alessiob@webrtc.org
Bug: webrtc:7494
Change-Id: I1e6260ea48ffc43f709e4b0c97f843ad9c3d1824
Reviewed-on: https://webrtc-review.googlesource.com/86546
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23800}
2018-07-02 11:00:13 +00:00
Alessio Bazzica
e0eda662ef Adding alessiob@ and minyue@ as owners of APM.
NOTRY=True

Bug: None
Change-Id: I690140661cf09e505a4e9e874912f05d83f14dcd
Reviewed-on: https://webrtc-review.googlesource.com/85284
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23797}
2018-07-02 07:45:31 +00:00
Jesús de Vicente Peña
2e79d2b398 AEC3: Misadjustment estimator of the linear filter.
In this work the performance of the linear filter is
estimated. The estimation aims at capture situations when the linear
filter is largely over-estimating the echo. In those circumstances,
the linear filter is scaled with the purpose of accelerating its
convergence.

Change-Id: I05ea3739d82838a6f08673432da92125c47943e0
Bug: webrtc:9466,chromium:857426
Reviewed-on: https://webrtc-review.googlesource.com/86133
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Commit-Queue: Jesus de Vicente Pena <devicentepena@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23789}
2018-06-29 15:05:14 +00:00
Per Åhgren
fc63c9e273 AEC3: Allow filter adaptation even though the estimated echo is saturated
This CL removes the constraint that freezes the filter adaptation
whenever the estimated echo or the prediction error is saturated. This
allows for much more rapid filter recovery in cases where the echo path
gain for some reason changes, such as when the analog AGC gain is
adjusted or the loudspeaker volume is changed.

TBR: devicentepena@webrtc.org
Bug: webrtc:9466,chromium:857426
Change-Id: Ic0b3b03f41f12e9a607aaadd2ee91cbaa16cac52
Reviewed-on: https://webrtc-review.googlesource.com/86124
Commit-Queue: Per Åhgren <peah@webrtc.org>
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23775}
2018-06-28 22:45:18 +00:00
Gustaf Ullberg
6c618c7002 AEC3: Avoid entering non-linear mode when the filter is slightly diverged
This CL changes the behavior when the main filter diverges.
Instead of entering non-linear mode, the AEC continues to operate in
linear mode but estimates the residual echo differently. R2 is S2
scaled by a factor of 10.

Bug: chromium:857018,webrtc:9462
Change-Id: I41212efe164ad319cf38a163cdf9d3ea151e0997
Reviewed-on: https://webrtc-review.googlesource.com/85981
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23772}
2018-06-28 13:35:18 +00:00
Artem Titov
81f5197512 Fix pylint presubmit errors and warnings from untouched modules.
BUG=None

Change-Id: I619dab14875e19477beb8bfb566ed1f34009c025
Reviewed-on: https://webrtc-review.googlesource.com/85960
Reviewed-by: Oleh Prypin <oprypin@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23754}
2018-06-27 09:31:29 +00:00