Commit graph

13 commits

Author SHA1 Message Date
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
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
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
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
Sam Zackrisson
762289ed13 Fix overflow in digital AGC1
Bug: chromium:855900
Change-Id: I966d5d977cee2862f7c0dd07e35561e475269d20
Reviewed-on: https://webrtc-review.googlesource.com/85368
Reviewed-by: Alex Loiko <aleloi@google.com>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23737}
2018-06-26 10:31:09 +00:00
Mirko Bonadei
d7573563a4 Fixing -Wstrict-prototypes warnings.
Bug: webrtc:8984
Change-Id: I9a7ffb0038f341bfec055f021fc203c7d45d72fa
Reviewed-on: https://webrtc-review.googlesource.com/60903
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22501}
2018-03-19 16:57:21 +00:00
Alex Loiko
7cfbf3a0ff Make energy calculation in AGC not overflow.
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}
2017-11-07 15:37:55 +00:00
Alex Loiko
c7b18fef19 Shifted value doesn't fit in 'int32_t'.
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}
2017-10-28 10:22:32 +00:00
Alex Loiko
b9f536167c Removing undefined left shifts in AudioProcessing
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}
2017-10-25 13:35:36 +00:00
Alex Loiko
c531af77c3 Fix 'Left shift cannot be represented in int32_t'.
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}
2017-10-24 09:56:08 +00:00
Mirko Bonadei
7120742701 Adding NOLINT for typedefs.h and common_types.h
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}
2017-09-15 13:03:51 +00:00
Mirko Bonadei
92ea95e34a Fixing WebRTC after moving from src/webrtc to src/
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}
2017-09-15 05:02:56 +00:00
Mirko Bonadei
bb547203bf Moving src/webrtc into src/.
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}
2017-09-15 04:25:06 +00:00