/xbmc/utils/BitstreamStats.h

http://github.com/xbmc/xbmc · C Header · 40 lines · 22 code · 8 blank · 10 comment · 0 complexity · 810c2d2dcb78995969283a96ea642947 MD5 · raw file

  1. /*
  2. * Copyright (C) 2005-2018 Team Kodi
  3. * This file is part of Kodi - https://kodi.tv
  4. *
  5. * SPDX-License-Identifier: GPL-2.0-or-later
  6. * See LICENSES/README.md for more information.
  7. */
  8. #pragma once
  9. #include <stdint.h>
  10. class BitstreamStats final
  11. {
  12. public:
  13. // in order not to cause a performance hit, we should only check the clock when
  14. // we reach m_nEstimatedBitrate bits.
  15. // if this value is 1, we will calculate bitrate on every sample.
  16. explicit BitstreamStats(unsigned int nEstimatedBitrate=(10240*8) /*10Kbit*/);
  17. void AddSampleBytes(unsigned int nBytes);
  18. void AddSampleBits(unsigned int nBits);
  19. inline double GetBitrate() const { return m_dBitrate; }
  20. inline double GetMaxBitrate() const { return m_dMaxBitrate; }
  21. inline double GetMinBitrate() const { return m_dMinBitrate; }
  22. void Start();
  23. void CalculateBitrate();
  24. private:
  25. double m_dBitrate;
  26. double m_dMaxBitrate;
  27. double m_dMinBitrate;
  28. unsigned int m_nBitCount;
  29. unsigned int m_nEstimatedBitrate; // when we reach this amount of bits we check current bitrate.
  30. int64_t m_tmStart;
  31. static int64_t m_tmFreq;
  32. };