This CL adds #includes to header files in order to make them
self contained after the preprocessor pass.
Bug: b/251890128
Change-Id: I81c3ba38fb8ab8a2bbd151ba99aa871fae9f1b1b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/278422
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38327}
This CL changes so that the AGC legacy C code is built as C++.
The CL also
-removes #defines from the header files.
-adds namespaces
-removes unused code.
To simplify the review, the CL is partitioned into different patchsets
where each comprising of one step in the modification of the code
(e.g., patch set 1 performs the renaming of the .c files to .cc).
Bug: webrtc:5298
Change-Id: I362b17bde91142b2f2166acba4f2f888efd50fa1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/171064
Commit-Queue: Per Åhgren <peah@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30847}
Beyond making the digital AGC1 code properly support
multichannel, this CL also
-Removes deprecated debug logging code.
-Converts the gain application to be fully in floating point
which
--Is less computationally complex.
--Does not quantize the samples to 16 bit before applying the
gains.
Bug: webrtc:10859
Change-Id: I6020ba8ae7e311dfc93a72783a2bb68d935f90c5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/159861
Commit-Queue: Per Åhgren <peah@webrtc.org>
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29886}
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}
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}
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}
An energy value is calculated by summing squares of processed audio
samples. The expression 'out*out >> 6' could overflow. In this CL we
change it to 'out*(out>>6) + out*(out*(out%(1<<6))>>6)'.
The which is verified and proven to be equal, but doesn't
overflow. The change also passes our change-detection tests in
GainControlBitExactnessTest.*
We verified with Godbolt that the modulo and divisions are converted
into branch-free bitwise operations.
NOTRY=True # changing comment, tests just passed.
Bug: chromium:780638, chromium:780376
Change-Id: I415535193433a2fbc275c643fb4e4026ba3e0bdd
Reviewed-on: https://webrtc-review.googlesource.com/20867
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20589}
This CL replaces one 'int32_t' with 'uint32_t'. The value is a
non-negative energy, and the number of leading zeros is
computed. During computation, a shift can cause it to overflow.
Issue was found by the Audio Processing fuzzer.
Bug: chromium:778939, chromium:778921, chromium:778919
Change-Id: I3d7e0b547e6b0edcd9995903517ea851142a08c1
Reviewed-on: https://webrtc-review.googlesource.com/16433
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20470}
This CL replaces 5 left shifts where the shifted value may be
negative. The shifts are replaced with equivalent multiplications.
Bug: chromium:777231, chromium:776719, chromium:776624, chromium:776286
Change-Id: Ifb27d5506eac779e60f238432bdf9e4bc5b2da4c
Reviewed-on: https://webrtc-review.googlesource.com/14800
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20430}
In the legacy C part of AGC, an audio level 'cur_level' is represented as
(1+frac) * 2^(31 - zeros)
The 'zeros' exponent part is used for looking up a gain value in a
table, and 'frac' is used for interpolating between two nearby table
values. Code snippet below:
zeros = WebRtcSpl_NormU32((uint32_t)cur_level);
tmp32 = (cur_level << zeros) & 0x7FFFFFFF;
frac = (int16_t)(tmp32 >> 19);
In the second line, 'cur_level' is shifted upwards so that the leading
bit is '1', after which the leading bit is cleared. The result is
'frac' in Q31.
The compiler type of 'cur_level << zeros' is 'int32_t'. This is a
fuzzer error 'Left shift cannot be represented in int32_t',
because the leading sign bit is 1. This CL changes the compiler type to
uint32_t.
Bug: chromium:776286
Change-Id: Ie29552b75e690057bd76fc88e747841b531e3802
Reviewed-on: https://webrtc-review.googlesource.com/14841
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20405}
Now that we have moved WebRTC from src/webrtc to src/, common_types.h
and typedefs.h are triggering a cpplint error.
The cpplint complaint is:
Include the directory when naming .h files [build/include] [4]
This CL disables the error but we have to remove these two headers
from the root directory.
NOPRESUBMIT=true
Bug: webrtc:5876
Change-Id: I08e1b69aadcc4b28ab83bf25e3819d135d41d333
Reviewed-on: https://webrtc-review.googlesource.com/1577
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Henrik Kjellander <kjellander@google.com>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#19859}
In https://webrtc-review.googlesource.com/c/src/+/1560 we moved WebRTC
from src/webrtc to src/ (in order to preserve an healthy git history).
This CL takes care of fixing header guards, #include paths, etc...
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
TBR=tommi@webrtc.org
Bug: chromium:611808
Change-Id: Iea91618212bee0af16aa3f05071eab8f93706578
Reviewed-on: https://webrtc-review.googlesource.com/1561
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Henrik Kjellander <kjellander@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#19846}
In order to eliminate the WebRTC Subtree mirror in Chromium,
WebRTC is moving the content of the src/webrtc directory up
to the src/ directory.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
TBR=tommi@webrtc.org
Bug: chromium:611808
Change-Id: Iac59c5b51b950f174119565bac87955a7994bc38
Reviewed-on: https://webrtc-review.googlesource.com/1560
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Henrik Kjellander <kjellander@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#19845}