tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

random_vector.h (1328B)


      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 
     11 #ifndef MODULES_AUDIO_CODING_NETEQ_RANDOM_VECTOR_H_
     12 #define MODULES_AUDIO_CODING_NETEQ_RANDOM_VECTOR_H_
     13 
     14 #include <stddef.h>
     15 #include <stdint.h>
     16 
     17 namespace webrtc {
     18 
     19 // This class generates pseudo-random samples.
     20 class RandomVector {
     21 public:
     22  static const size_t kRandomTableSize = 256;
     23  static const int16_t kRandomTable[kRandomTableSize];
     24 
     25  RandomVector() : seed_(777), seed_increment_(1) {}
     26 
     27  RandomVector(const RandomVector&) = delete;
     28  RandomVector& operator=(const RandomVector&) = delete;
     29 
     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_;
     43 };
     44 
     45 }  // namespace webrtc
     46 #endif  // MODULES_AUDIO_CODING_NETEQ_RANDOM_VECTOR_H_