henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_CODING_NETEQ_RANDOM_VECTOR_H_ |
| 12 | #define MODULES_AUDIO_CODING_NETEQ_RANDOM_VECTOR_H_ |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 13 | |
Niels Möller | a12c42a | 2018-07-25 16:05:48 +0200 | [diff] [blame] | 14 | #include <stddef.h> |
| 15 | #include <stdint.h> |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 16 | |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 17 | namespace webrtc { |
| 18 | |
| 19 | // This class generates pseudo-random samples. |
| 20 | class RandomVector { |
| 21 | public: |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 22 | static const size_t kRandomTableSize = 256; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 23 | static const int16_t kRandomTable[kRandomTableSize]; |
| 24 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 25 | RandomVector() : seed_(777), seed_increment_(1) {} |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 26 | |
Byoungchan Lee | 604fd2f | 2022-01-21 09:49:39 +0900 | [diff] [blame] | 27 | RandomVector(const RandomVector&) = delete; |
| 28 | RandomVector& operator=(const RandomVector&) = delete; |
| 29 | |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 30 | void Reset(); |
| 31 | |
| 32 | void Generate(size_t length, int16_t* output); |
| 33 | |
| 34 | void IncreaseSeedIncrement(int16_t increase_by); |
| 35 | |
| 36 | // Accessors and mutators. |
| 37 | int16_t seed_increment() { return seed_increment_; } |
| 38 | void set_seed_increment(int16_t value) { seed_increment_ = value; } |
| 39 | |
| 40 | private: |
| 41 | uint32_t seed_; |
| 42 | int16_t seed_increment_; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | } // namespace webrtc |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 46 | #endif // MODULES_AUDIO_CODING_NETEQ_RANDOM_VECTOR_H_ |