meanvalue.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /***************************************************************************\
  2. *
  3. * MPEG Layer3-Audio Decoder
  4. * © 1997-2006 by Fraunhofer IIS
  5. * All Rights Reserved
  6. *
  7. * filename: meanvalue.h
  8. * project : ---
  9. * author : Martin Sieler
  10. * date : 1998-02-14
  11. * contents/description: HEADER - calc mean value
  12. *
  13. *
  14. \***************************************************************************/
  15. /*
  16. * $Date: 2010/11/17 20:46:03 $
  17. * $Id: meanvalue.h,v 1.1 2010/11/17 20:46:03 audiodsp Exp $
  18. */
  19. #ifndef __MEANVALUE_H__
  20. #define __MEANVALUE_H__
  21. /* ------------------------ includes --------------------------------------*/
  22. /*-------------------------- defines --------------------------------------*/
  23. /*-------------------------------------------------------------------------*/
  24. class CMeanValue
  25. {
  26. public:
  27. CMeanValue() { Reset(); }
  28. void Reset();
  29. CMeanValue& operator+= (int nValue);
  30. operator int() const { return m_Count ? m_Sum/m_Count : 0; }
  31. operator float() const { return m_Count ? float(m_Sum)/float(m_Count) : 0.0f; }
  32. int GetSum() const { return m_Sum; }
  33. int GetCount() const { return m_Count; }
  34. int GetMin() const { return m_Min; }
  35. int GetMax() const { return m_Max; }
  36. bool IsFixed() const { return m_bFixed; }
  37. protected:
  38. private:
  39. int m_Count;
  40. int m_Sum;
  41. int m_FirstValue;
  42. int m_Min;
  43. int m_Max;
  44. bool m_bFixed;
  45. };
  46. /*-------------------------------------------------------------------------*/
  47. #endif