blob: 4a782f111604321e9997f450dfd8d5b08d8ee83d [file] [log] [blame]
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +00001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_AUDIO_CODING_NETEQ_RANDOM_VECTOR_H_
12#define MODULES_AUDIO_CODING_NETEQ_RANDOM_VECTOR_H_
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000013
Niels Möllera12c42a2018-07-25 16:05:48 +020014#include <stddef.h>
15#include <stdint.h>
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000016
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000017namespace webrtc {
18
19// This class generates pseudo-random samples.
20class RandomVector {
21 public:
Peter Kastingdce40cf2015-08-24 14:52:23 -070022 static const size_t kRandomTableSize = 256;
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000023 static const int16_t kRandomTable[kRandomTableSize];
24
Yves Gerey665174f2018-06-19 15:03:05 +020025 RandomVector() : seed_(777), seed_increment_(1) {}
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000026
Byoungchan Lee604fd2f2022-01-21 09:49:39 +090027 RandomVector(const RandomVector&) = delete;
28 RandomVector& operator=(const RandomVector&) = delete;
29
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000030 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.orgd94659d2013-01-29 12:09:21 +000043};
44
45} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020046#endif // MODULES_AUDIO_CODING_NETEQ_RANDOM_VECTOR_H_