Commit graph

1345 commits

Author SHA1 Message Date
Harald Alvestrand
78f905e5cc Move some users to use webrtc::RefCountInterface
Bug: webrtc:15622
Change-Id: I2d4c20c726af1a052e161b7689a73d1e5e3eb191
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/325526
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41067}
2023-11-02 14:45:57 +00:00
Björn Terelius
efeeba0864 Try removing RTC_PUSH_IGNORING_WUNDEF() around proto includes
Bug: webrtc:15623
Change-Id: Ia184993769f74d51e68a5a536d5fdde26890bcfd
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/325481
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41058}
2023-11-01 08:21:05 +00:00
Sam Zackrisson
2e1f16d55c Make AEC3 json parsing code testonly
Reasons:
- the code is no longer used in Chrome
- it is conceptually weird for WebRTC to have JSON parsing in its API
- there are concerns around the reliability of the underlying JSON library

Additionally, this CL removes the rtc_json "poisonous" attribute: the scheme is incompatible and redundant with testonly.

Bug: webrtc:1493351
Change-Id: I0b621b0e3f183df7315919d9c89242fbe387928f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/325062
Reviewed-by: Per Åhgren <peah@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41014}
2023-10-26 12:03:02 +00:00
Michael Froman
90fb11e806 Fix improper buffer size in call to rtc::strcpyn
rtc::strcpyn second param should be the size of the destination buffer,
not the size of the source string.  The result is that the final character
(usually a trailing directory path separator) is lost during the copy.
This has been masked because FormFileName helpfully adds a trailing path
separator if one is missing.

BUG=webrtc:15441

Change-Id: I992e69cad86a7e8bc2057ec629063f34c75fe75f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/317502
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40736}
2023-09-12 11:40:07 +00:00
Jesús de Vicente Peña
1a4cf30047 Avoiding to increase an iterator when the result can be larger than their container end.
Bug: webrtc:15438
Change-Id: I0d75436bc845590c76466bde7007e921f842a9d4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/317320
Commit-Queue: Jesus de Vicente Pena <devicentepena@webrtc.org>
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40605}
2023-08-23 08:11:33 +00:00
Li-Yu Yu
758f26852d Fix downstream review comments for C++20
This CL addresses the review comments for
https://webrtc-review.googlesource.com/c/src/+/261221
in the downstream cherry-pick: https://crrev.com/c/4660950.

*   Always use size_t{} for casting.
*   Remove unneeded size_t casts.
*   Avoid using __x as it is reserved for the compiler.

Bug: b:217226507
Change-Id: I13c57cb69d7db066ac9a6dbd15b7f6de54abb613
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/311360
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Li-Yu Yu <aaronyu@google.com>
Cr-Commit-Position: refs/heads/main@{#40395}
2023-07-04 09:06:07 +00:00
Jesús de Vicente Peña
f80cf81435 Changing the pre echo configuration default.
Bug: webrtc:14205
Change-Id: I17add3bf19c599f170ffe98d0da0a561794591c1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/309481
Commit-Queue: Jesus de Vicente Pena <devicentepena@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40319}
2023-06-20 14:46:44 +00:00
Li-Yu Yu
b84fae66db Use sinf instead of std::sinf to improve libstdc++ compatibility
libstdc++ does not define std::sinf in <cmath>.
See also: https://stackoverflow.com/a/56420862.

BUG=b:235200394

Change-Id: Idfb80ac6f54fbf57a20425391b0c4165b7945b2f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/306681
Commit-Queue: Li-Yu Yu <aaronyu@google.com>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40183}
2023-05-30 20:16:31 +00:00
Jesús de Vicente Peña
766f703fe3 Making WebRTC-Aec3PenalyzeHighDelaysInitialPhase default to true.
Bug: webrtc:14919
Change-Id: Id7509b9ef4730b4d09259bdd7ed13411238eabd3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/304164
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Commit-Queue: Jesus de Vicente Pena <devicentepena@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39986}
2023-05-04 17:25:33 +00:00
Jared Siskin
c018bae807 Format /modules
git ls-files | grep -e  "\(\.h\|\.cc\)$" | grep -e  "^modules/" | xargs clang-format -i ; git cl format
after landing: add to .git-blame-ignore-revs

Bug: webrtc:15082
Change-Id: I2c3cd28740062794f8c10e39d8406aadb9e9a35a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/301620
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Auto-Submit: Jared Siskin <jtsiskin@meta.com>
Cr-Commit-Position: refs/heads/main@{#39901}
2023-04-20 02:02:45 +00:00
Alan Zhao
6cf8b486eb Fix missing libc++ includes in webrtc
Several files refer to symbols declared in headers not explicitly
included. This compiles now because libc++ tranitively includes these
headers via other libc++ headers; however, these transitive includes are
not guaranteed to exist and in Chrome, will no longer exist once libc++
is compiled with modules.

Bug: chromium:543704
Change-Id: I638bb02df3d050a48345248e80aebd2dd60956c1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/295762
Auto-Submit: Alan Zhao <ayzhao@google.com>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39448}
2023-03-02 10:14:51 +00:00
Emil Lundmark
4e86aa0870 Remove mentions of already deleted field trials
- WebRTC-Audio-Agc2ForceExtraSaturationMargin
- WebRTC-Audio-Agc2ForceInitialSaturationMargin
- WebRTC-Audio-BitrateAdaptation
- WebRTC-Audio-TransientSuppressorVadMode
- WebRTC-FrameBuffer3
- WebRTC-IntelVP8
- WebRTC-UseActiveIceController

Bug: None
Change-Id: I3545727c09f761867f2f4c2bb5c400012ce146d2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/295723
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Auto-Submit: Emil Lundmark <lndmrk@webrtc.org>
Commit-Queue: Emil Lundmark <lndmrk@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39444}
2023-03-01 15:53:37 +00:00
Jesús de Vicente Peña
e7478182ac Penalization of large delays on the initial phase.
Bug: webrtc:14919
Change-Id: Iba00b2782b7e7c3dbd345a94aba541fad8c979ee
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/294289
Commit-Queue: Jesus de Vicente Pena <devicentepena@webrtc.org>
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39364}
2023-02-22 07:11:58 +00:00
Sam Zackrisson
56c67555f1 AEC3: Delete render delay buffer alignment killswitch
The code has been running in Chrome since 2020 and ChromeOS since 2022 (https://crrev.com/c/3452884) without issues.

Bug: webrtc:11803
Change-Id: I0c572d362b1f52b4591c7790e11a87c1a1ad1a79
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/293342
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39316}
2023-02-15 12:57:04 +00:00
Artem Titov
a617867a45 Reland "Migrate WebRTC documentation to new renderer"
This reverts commit 0f2ce5cc1c.

Reason for revert: Downstream infrastructure should be ready now

Original change's description:
> Revert "Migrate WebRTC documentation to new renderer"
>
> This reverts commit 3eceaf4669.
>
> Reason for revert:
>
> Original change's description:
> > Migrate WebRTC documentation to new renderer
> >
> > Bug: b/258408932
> > Change-Id: Ib96f39fe0c3912f9746bcc09d079097a145d6115
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/290987
> > Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> > Commit-Queue: Artem Titov <titovartem@webrtc.org>
> > Cr-Commit-Position: refs/heads/main@{#39205}
>
> Bug: b/258408932
> Change-Id: I16cb4088bee3fc15c2bb88bd692c592b3a7db9fe
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/291560
> Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
> Owners-Override: Artem Titov <titovartem@webrtc.org>
> Commit-Queue: Artem Titov <titovartem@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#39209}

Bug: b/258408932
Change-Id: Ia172e4a6ad1cc7953b48eed08776e9d1e44eb074
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/291660
Owners-Override: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39231}
2023-01-31 09:30:04 +00:00
Artem Titov
0f2ce5cc1c Revert "Migrate WebRTC documentation to new renderer"
This reverts commit 3eceaf4669.

Reason for revert: 

Original change's description:
> Migrate WebRTC documentation to new renderer
>
> Bug: b/258408932
> Change-Id: Ib96f39fe0c3912f9746bcc09d079097a145d6115
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/290987
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Commit-Queue: Artem Titov <titovartem@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#39205}

Bug: b/258408932
Change-Id: I16cb4088bee3fc15c2bb88bd692c592b3a7db9fe
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/291560
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Owners-Override: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39209}
2023-01-26 20:19:12 +00:00
Artem Titov
3eceaf4669 Migrate WebRTC documentation to new renderer
Bug: b/258408932
Change-Id: Ib96f39fe0c3912f9746bcc09d079097a145d6115
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/290987
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39205}
2023-01-26 14:58:00 +00:00
Jesús de Vicente Peña
5b55b2750a Version 3: Various changes on the pre-echo delay estimator:
- Lowering the energy threshold for updating the accumulated error.
- Not using the pre-echo estimate in the initial frames when the matched filters have been recently initialized.
- Slight speed up for the increases in the accumulated error.
- Not periodically resetting the accumulated error.

Bug: webrtc:14205
Change-Id: Ic337332e263b27d7a3aba0ab4b371517780f9c90
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/291320
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Commit-Queue: Jesus de Vicente Pena <devicentepena@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39175}
2023-01-23 15:10:48 +00:00
Alessio Bazzica
eeb223557f Retune AGC2 input volume controller speech ratio threshold
Based on offline testing; needed to allow input volume adaptations
more frequently. Note that if the estimated speech level falls in
the target range, the recommended input volume won't change and
hence the new lower threshold won't necessarily increase the
number of adjustments.

Bug: webrtc:7494
Change-Id: Iabb501c188da238ea7b7137175bcfe09239c90a2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/291110
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39161}
2023-01-20 14:03:58 +00:00
Alessio Bazzica
40b5bd72d0 APM: fix TS initialization bugs with WebRTC-Audio-GainController2
When the `WebRTC-Audio-GainController2` field trial is used, the
initial APM configuration is adjusted depending on its original
values and the field trial parameters.

This CL fixes two cases when the code crashes:
1. when, in the initial APM config, AGC1 is enabled, AGC2 is
   disabled and TS is enabled
2. when the initial APM sample rate is different from the
   capture one and the VAD APM sub-module is not re-initialized

This CL also improves the unit tests coverage and it has been
tested offline to check that the VAD sub-module is created only
when expected and that AGC2 uses its internal VAD when expected.
The tests ran on a few Wav files with different sample rates and
one AEC dump and on 16 different APM and field trial
configurations.

Bug: chromium:1407341, b/265112132
Change-Id: I7cc267ea81cb02be92c1f37f273b7ae93b6e4634
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/290988
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Olga Sharonova <olka@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39118}
2023-01-16 20:30:12 +00:00
Florent Castelli
a6b9924988 Remove all usage of //rtc_base target
Bug: webrtc:9838
Change-Id: If813dbb426b4dc848185b64c0349d03fa9c059f2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/290986
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Auto-Submit: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39116}
2023-01-16 14:36:06 +00:00
Alessio Bazzica
54cf754dac APM: remove denormal disabler field trial
Always use the denormal disabler

Bug: chromium:1227566
Change-Id: I915567aac683a8cd23d6d09b75536c81fd4ee2a6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/288680
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38936}
2022-12-21 11:27:02 +00:00
Alessio Bazzica
4f26c25b62 APM input volume controller tests
- Test behavior with no input volume controller
- Test behavior with startup volume higher than the minimum
  input volume

Bug: webrtc:7494
Change-Id: I36d48e2bd277b8a71eb6fbb0272c26c7176b3d5e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/286380
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38932}
2022-12-20 15:03:35 +00:00
Alessio Bazzica
6b7834c14f Add generic input volume controller test for both AGC1 and AGC2
Make sure that the input volume controller implementations exhibit
the adaptive behavior regardless of the sample rate and the number
of channels. The newly added tests check that:
- a downward adjustment takes place with clipping input
- an upward adjustment takes place with a too low speech level
- a downward adjustment takes place with a too high speech level

Bug: webrtc:14761
Change-Id: I1795e74c5f219e15107e928ebaca2bfa75214526
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/287301
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38930}
2022-12-20 14:41:31 +00:00
Hanna Silen
18fccfc477 InputVolumeController: Add startup min input volume unit tests
Bug: webrtc:7494
Change-Id: I434046e170ba99d82ff61f763f7ef66654299fa1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/288081
Commit-Queue: Hanna Silen <silen@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38896}
2022-12-15 10:15:51 +00:00
Alessio Bazzica
3b51cd328e Unify AGC2 experiment field trials into one
In order to experiment with AGC2 and TS at the same time, 3 field
trials are removed and merged into `WebRTC-Audio-GainController2`,
which is existing.

New parameters for the `WebRTC-Audio-GainController2` field trial:
- `switch_to_agc2`: true by default; when true, the gain control
  switches to AGC2 (both for the input volume and for the adaptive
  digital gain);
- `min_input_volume`: minimum input volume enforced by the input
  volume controller when the applied input volume is not zero;
- `disallow_transient_suppressor_usage`: when true, TS is never
  created.

Removed field trials:
- `WebRTC-Audio-Agc2-MinInputVolume`: now a parameter of
  `WebRTC-Audio-GainController2`;
- `WebRTC-ApmTransientSuppressorKillSwitch`: now a parameter of
  `WebRTC-Audio-GainController2`;
- `WebRTC-Audio-TransientSuppressorVadMode`: automatically inferred
  from `WebRTC-Audio-GainController2`.

Bug: webrtc:7494
Change-Id: I452798c0862d71f9adae6d163fe841df05ca44d6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/287861
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38890}
2022-12-14 16:40:41 +00:00
Hanna Silen
597a2ba41a AGC2: Return the recommended volume from RecommendInputVolume()
In InputVolumeController, rename AnalyzePreProcess() and Process() to
reflect their use and replace the use of the getter
recommended_input_volume() with an optional return value from the
latter one. The added return value carries the recommended input
volume if the call sequence follows the API contract. Make the member
applied_input_volume_ optional. Restrict the use of the getter
recommended_input_volume() for test use. Add a method
capture_output_used() for test use.

In GainController2, store the output of InputVolumeController::Process()
in a new member variable that's updated in Analyze() and Process(). Use
a trivial getter to read the value in APM.

Bug: webrtc:7494
Change-Id: Ifcfb466c4f558be560eb6d2f45410d04adb7e2ad
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/287862
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38889}
2022-12-14 13:05:37 +00:00
Hanna Silen
cdee165646 InputVolumeController: Restrict the application of min input volume
Only allow the application of min input volume if the applied input
volume is above zero. To implement this, add a member variable to
store the applied input volume. Rename the related setter to reflect
its new functionality.

Bug: webrtc:7494
Change-Id: Ia70d5cb4dfd972aad9ef2663a81884f3e5cb0758
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/287680
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38878}
2022-12-13 09:23:03 +00:00
Alessio Bazzica
a106095333 Fix WebRTC.Audio.Apm.RecommendedInputVolume.OnChangeToMatchTarget tests
- Reset the tested metrics to avoid interactions between tests that
  depend on the execution order
- Address the comment in [1] by adding a function to log the same
  histogram in two different places

[1] https://chromium-review.googlesource.com/c/chromium/src/+/4087426/4/tools/metrics/histograms/metadata/web_rtc/histograms.xml#179

Bug: webrtc:7494
Change-Id: Ia4d339b03c8078eb63626c91579f8a9547f087f7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/287681
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38873}
2022-12-12 19:26:01 +00:00
Alessio Bazzica
2bfa767245 Fix APM AGC2 initialization: pass the correct number of channels
Pass the correct number of channels needed by the AGC2 input volume
controller. This change doesn't affect the adaptive digital
controller which reads the number of channel from the passed audio
buffer instance for each processed frame.

Note that the `AdaptiveDigitalGainController::Initialize()` impl
was removed in [1], but that CL didn't remove the declaration (done
in this CL).

[1] https://webrtc-review.googlesource.com/c/src/+/287222/5/modules/audio_processing/agc2/adaptive_digital_gain_controller.cc#105

Bug: webrtc:7494
Change-Id: I07369ab4025a251b25c716cf618e4222fdb60fc8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/287320
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38863}
2022-12-09 15:02:20 +00:00
Alessio Bazzica
dfba28e30e AGC2 adaptive digital controller config clean-up
- Remove dry-run option
- Hard-code `adjacent_speech_frames_threshold` and
  `vad_reset_period_ms`
- Expose `initial_gain_db` via field trial

Tested: adaptive digital controller bit-exactness verified

Bug: webrtc:7494
Change-Id: I6166611f91320b6c37de3f8e553c06c2ed95b772
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/287222
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38862}
2022-12-09 13:07:34 +00:00
Alessio Bazzica
f72bc5f1e2 AGC2: rename AdaptiveDigitalGainApplier -> AdaptiveDigitalGainController
Bug: webrtc:7494
Change-Id: Id45495d1742f7d2027429c97a3b286468da99b1b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/287220
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38857}
2022-12-09 10:31:34 +00:00
Hanna Silen
ca6535593f APM: Add field trial parameters and rename
Add AGC2 digital adaptive config parameters in the field trial
"WebRTC-Audio-InputVolumeControllerExperiment". Rename it as
"WebRTC-Audio-GainController2" to reflect that the override now adjusts
the parameters for both input volume controller and adaptive digital
controller.

Bug: webrtc:7494
Change-Id: Ifbc1b8be76cf23b0b6b74b22b5167a45972cab38
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/286880
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38855}
2022-12-08 18:26:05 +00:00
Hanna Silen
6ebf5e3379 InputVolumeController: Rename variables
Rename MonoInputVolumeController member input_volume_ to reflect its
use to store the most recent input volume recommendation.

Rename the remaining variables named as manager in the unit tests.

Bug: webrtc:7494
Change-Id: I31ffdc131c98061ef2b36f98b685c5182b3c6861
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/287123
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38854}
2022-12-08 16:37:01 +00:00
Alessio Bazzica
da964d7559 InputVolumeStatsReporter: replace WebRTC.Audio.AgcSetLevel
The `WebRTC.Audio.AgcSetLevel` name is misleading and the histogram
is logged for each channel - but the input volume is one for all the
channels.

Changes:
- `WebRTC.Audio.Apm.RecommendedInputVolume.OnChangeToMatchTarget`
  is the new name
- Now available not only in `AgcManagerDirect` (AGC1), but also in
  `InputVolumeController` (AGC2)
- Logged once and not for each channel
- Also add the following AGC implementation agnostic histograms
  - `WebRTC.Audio.Apm.AppliedInputVolume.OnChange`
  - `WebRTC.Audio.Apm.RecommendedInputVolume.OnChange`
- Fix `SpeechSamplesReader::Feed()` in the unit tests, which did
  not set the applied input volume and apply the recommended one

The histogram definitions are updated in crrev.com/c/4087426.

Bug: webrtc:7494
Change-Id: I03c5dfb08165805215ca2c4bb6509b16de8d68da
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/287081
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38852}
2022-12-08 15:44:43 +00:00
Alessio Bazzica
17e14fdf34 APM AGC2: consolidate GainController2
Now that `InputVolumeController` is finalized, it's time to
consolidate AGC2.

Main changes:
- Remove `AdaptiveDigitalGainController`: it's too simple to justify
  a dedicated class and some components of it are also used by
  `InputVolumeController`
- Remove unwanted temporal dependency: make `InputVolumeController`
  adapt the volume based on the current speech level estimation and
  not on the estimation from the previous frame

Tested: AGC2 adaptive digital bit-exactness verified

Bug: webrtc:7494
Change-Id: I175c2741cafc52be81794219c996a3824c3bbf5e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/280560
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38841}
2022-12-07 21:47:45 +00:00
Alessio Bazzica
352f38c7a8 APM: add field trial to disable TransientSuppressor
Regardless of the APM config, the transient suppressor (TS) submodule
won't be created if the `WebRTC-ApmTransientSuppressorKillSwitch`
field trial, disabled by default, is enabled.

Bug: webrtc:13663
Change-Id: Ic1ef9aa57c728296d671d4ef253630c581a86610
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/286382
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38839}
2022-12-07 16:30:47 +00:00
Alessio Bazzica
0524319a9d AGC2 NoiseLevelEstimator: DCHECK pointer
Bug: webrtc:7494
Change-Id: Iaac36bade3da4cfa55e8de99cfd3836df75dffa3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/286423
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38828}
2022-12-06 15:14:04 +00:00
Hanna Silen
fcbf3724eb InputVolumeController: Remove two unit test helper functions
Remove deprecated unit test helper functions CallPreProcessAudioBuffer()
and CallPreProcForChangingAudio(). Replace the use of these functions
with CallAgcSequence(). Remove a duplicate unit test using one of these
functions. The new calls follow the API contract.

Bug: webrtc:7494
Change-Id: Idc033cb48f4fab1814c4c6e0f23edc4a6a9faa64
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/285960
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38826}
2022-12-06 13:23:03 +00:00
Alessio Bazzica
38a6002548 AGC2 SpeechLevelEstimator: make IsConfident() a trivial getter
Bug: webrtc:7494
Change-Id: If2a38801d8fc9dc09838904149262a6d83bbe037
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/286421
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38825}
2022-12-06 12:43:51 +00:00
Alessio Bazzica
4366c5469f AGC2: move fixed digital controller before limiter
Currently the fixed digital gain is applied after the input volume
controller and before the adaptive digital one. This CL moves its
application after the adaptive digital controller and before the
limiter.

Reasons:
- This change is safe: no production config where both adaptive and
  fixed digital controllers are jointly used
- More predictable behavior: when the fixed digital controller is
  used after the adaptive digital controller it is easier to describe
  the overall behavior - i.e., the fixed digital combined with the
  limiter can be used for digital compression
- Allow to remove an unwanted temporal dependency: in a follow-up CL
  the input volume controller will use the latest speech level
  estimation instead of that from the previously analyzed frame; this
  CL makes that change easier.

Bug: webrtc:7494
Change-Id: I2e9869081e0eba1e4f30f11ea93a973ca7fea28c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/286340
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38813}
2022-12-05 16:21:33 +00:00
Alessio Bazzica
a422e93d7b APM AGC2 InputVolumeController test: rename manager|agc -> controller
Bug: webrtc:7494
Change-Id: Iaa8144c07541042a543e48b2e726e2d4e20edb7c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/286001
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38810}
2022-12-05 10:16:13 +00:00
Alessio Bazzica
8b4a81fb55 APM: Prepare to remove AdaptiveDigitalGainController wrapper
Isolates the build targets for the `AdaptiveDigitalGainController`
dependencies that will be moved into `GainController2`.

`AdaptiveDigitalGainController` will be removed because the wrapper
itself adds little - that's the reason why it has no unit tests.

Bug: webrtc:7494
Change-Id: I2ca41f9255c8faefe4b2cb4ec1f8db536e582f39
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/280482
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38799}
2022-12-02 14:47:33 +00:00
Alessio Bazzica
e001474407 InputVolumeController: readability improvements
- use the new naming convention 'input volume'
- fix Yoda-style expressions in the unit tests
- clarify how the gain map values are generated

Bug: webrtc:7494
Change-Id: I4d6ee897a93cdefa6735733b053c57326d01a528
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/285467
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38795}
2022-12-02 12:49:04 +00:00
Alessio Bazzica
504bd59422 Expose APM pipeline parameter to select downmixing method
Bug: b/257289030
Change-Id: I03a666a15752d7a1125af2f8d3edae530493618c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/285473
Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38789}
2022-12-01 15:30:13 +00:00
Henrik Lundin
8754a3c945 Update some audio modules with new OWNERS
Bug: b/260832909
Change-Id: I3d2ebad978988eabf228475c3fc46708e12cf5d2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/285780
Auto-Submit: Henrik Lundin <henrik.lundin@webrtc.org>
Reviewed-by: Christoffer Jansson <jansson@webrtc.org>
Commit-Queue: Christoffer Jansson <jansson@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38788}
2022-12-01 14:55:38 +00:00
Hanna Silen
a6574909e9 APM: Add a field trial for input volume controller
Add a field trial WebRTC-Audio-InputVolumeControllerExperiment and
a mechanism to adjust the config accordingly. Pass the additional
input volume controller config to GainController2.

Bug: webrtc:7494
Change-Id: I3dd624df1f4774cb533417747627995e1f60aa68
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/284101
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38780}
2022-11-30 17:26:45 +00:00
Christoffer Jansson
b00f88179e Remove xooglers from WATCHLISTS and OWNERS
Bug: b/260832909
Change-Id: I683c714da35c21c23404d4b1c6500da28d680ed5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/285470
Commit-Queue: Christoffer Jansson <jansson@google.com>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38777}
2022-11-30 15:33:25 +00:00
Hanna Silen
d4dbe4527d AudioProcessingImpl: Add the use of AGC2 InputVolumeController
The integration relies on GainController2 methods Process() and
GetRecommendedInputVolume() to internally take into account whether
the input volume controller is enabled in the ctor or not. These
methods are called for every frame processed if GainController2 is
enabled. Analyze() is called if the input volume controller is
enabled.

The functionality can be enabled from the APM config and is not
enabled by default. If multiple input volume controllers are enabled,
an error is logged.

Tested: Bitexact on a large number of aecdumps if not enabled
Bug: webrtc:7494
Change-Id: I9105483be34eb95fab3c46afbbd368802e956fad
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/282720
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38776}
2022-11-30 15:32:23 +00:00
Alessio Bazzica
03bccbe62d AGC2 Input Volume Controller: min input volume field trial update
Always enforce the minimum input volume, not only if overridden.
The only exception is when the applied input volume is zero: in that
case zero is still recommended.

This CL also adapts the unit tests and replaces "mic level" with
the "input volume".

Bug: webrtc:7494
Change-Id: I20c14624fbd357ab91ea05521c3723ec1045a8db
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/285462
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38769}
2022-11-29 22:19:31 +00:00