[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / utils / BitstreamStats.h
1 #ifndef BITSTREAM_STATS__H__
2 #define BITSTREAM_STATS__H__
3
4 /*
5  *      Copyright (C) 2005-2013 Team XBMC
6  *      http://www.xbmc.org
7  *
8  *  This Program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2, or (at your option)
11  *  any later version.
12  *
13  *  This Program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with XBMC; see the file COPYING.  If not, see
20  *  <http://www.gnu.org/licenses/>.
21  *
22  */
23
24 #include <string>
25 #ifdef _LINUX
26 #include "linux/PlatformDefs.h"
27 #endif
28
29 class BitstreamStats
30 {
31 public:
32   // in order not to cause a performance hit, we should only check the clock when
33   // we reach m_nEstimatedBitrate bits.
34   // if this value is 1, we will calculate bitrate on every sample.
35   BitstreamStats(unsigned int nEstimatedBitrate=(10240*8) /*10Kbit*/);
36   virtual ~BitstreamStats();
37
38   void AddSampleBytes(unsigned int nBytes);
39   void AddSampleBits(unsigned int nBits);
40
41   inline double GetBitrate()    const { return m_dBitrate; }
42   inline double GetMaxBitrate() const { return m_dMaxBitrate; }
43   inline double GetMinBitrate() const { return m_dMinBitrate; }
44
45   void Start();
46   void CalculateBitrate();
47
48 private:
49   double m_dBitrate;
50   double m_dMaxBitrate;
51   double m_dMinBitrate;
52   unsigned int m_nBitCount;
53   unsigned int m_nEstimatedBitrate; // when we reach this amount of bits we check current bitrate.
54   int64_t m_tmStart;
55   static int64_t m_tmFreq;
56 };
57
58 #endif
59