random_vector.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #ifndef MODULES_AUDIO_CODING_NETEQ_RANDOM_VECTOR_H_
  11. #define MODULES_AUDIO_CODING_NETEQ_RANDOM_VECTOR_H_
  12. #include <stddef.h>
  13. #include <stdint.h>
  14. #include "rtc_base/constructor_magic.h"
  15. namespace webrtc {
  16. // This class generates pseudo-random samples.
  17. class RandomVector {
  18. public:
  19. static const size_t kRandomTableSize = 256;
  20. static const int16_t kRandomTable[kRandomTableSize];
  21. RandomVector() : seed_(777), seed_increment_(1) {}
  22. void Reset();
  23. void Generate(size_t length, int16_t* output);
  24. void IncreaseSeedIncrement(int16_t increase_by);
  25. // Accessors and mutators.
  26. int16_t seed_increment() { return seed_increment_; }
  27. void set_seed_increment(int16_t value) { seed_increment_ = value; }
  28. private:
  29. uint32_t seed_;
  30. int16_t seed_increment_;
  31. RTC_DISALLOW_COPY_AND_ASSIGN(RandomVector);
  32. };
  33. } // namespace webrtc
  34. #endif // MODULES_AUDIO_CODING_NETEQ_RANDOM_VECTOR_H_