source: 3DVCSoftware/branches/0.1-poznan-univ/source/Lib/TLibEncoder/TEncAnalyze.h @ 83

Last change on this file since 83 was 2, checked in by hhi, 13 years ago

inital import

  • Property svn:eol-style set to native
File size: 3.3 KB
Line 
1
2
3/** \file     TEncAnalyze.h
4    \brief    encoder analyzer class (header)
5*/
6
7#ifndef __TENCANALYZE__
8#define __TENCANALYZE__
9
10#if _MSC_VER > 1000
11#pragma once
12#endif // _MSC_VER > 1000
13
14#include <stdio.h>
15#include <memory.h>
16#include <assert.h>
17#include "../TLibCommon/CommonDef.h"
18
19// ====================================================================================================================
20// Class definition
21// ====================================================================================================================
22
23/// encoder analyzer class
24class TEncAnalyze
25{
26private:
27  Double    m_dPSNRSumY;
28  Double    m_dPSNRSumU;
29  Double    m_dPSNRSumV;
30  Double    m_dAddBits;
31  UInt      m_uiNumPic;
32  Double    m_dFrmRate; //--CFG_KDY
33 
34public:
35  TEncAnalyze() { m_dPSNRSumY = m_dPSNRSumU = m_dPSNRSumV = m_dAddBits = m_uiNumPic = 0;  }
36  virtual ~TEncAnalyze()  {}
37 
38  Void  addResult( Double psnrY, Double psnrU, Double psnrV, Double bits)
39  {
40    m_dPSNRSumY += psnrY;
41    m_dPSNRSumU += psnrU;
42    m_dPSNRSumV += psnrV;
43    m_dAddBits  += bits;
44   
45    m_uiNumPic++;
46  }
47 
48  Double  getPsnrY()  { return  m_dPSNRSumY;  }
49  Double  getPsnrU()  { return  m_dPSNRSumU;  }
50  Double  getPsnrV()  { return  m_dPSNRSumV;  }
51  Double  getBits()   { return  m_dAddBits;   }
52  UInt    getNumPic() { return  m_uiNumPic;   }
53 
54  Void    setFrmRate  (Double dFrameRate) { m_dFrmRate = dFrameRate; } //--CFG_KDY
55  Void    clear() { m_dPSNRSumY = m_dPSNRSumU = m_dPSNRSumV = m_dAddBits = m_uiNumPic = 0;  }
56  Void    printOut ( Char cDelim )
57  {
58    Double dFps     =   m_dFrmRate; //--CFG_KDY
59    Double dScale   = dFps / 1000 / (Double)m_uiNumPic;
60   
61    printf( "\tTotal Frames |  "   "Bitrate    "  "Y-PSNR    "  "U-PSNR    "  "V-PSNR \n" );
62    //printf( "\t------------ "  " ----------"   " -------- "  " -------- "  " --------\n" );
63    printf( "\t %8d    %c"          "%12.4lf  "    "%8.4lf  "   "%8.4lf  "    "%8.4lf\n",
64           getNumPic(), cDelim,
65           getBits() * dScale,
66           getPsnrY() / (Double)getNumPic(),
67           getPsnrU() / (Double)getNumPic(),
68           getPsnrV() / (Double)getNumPic() );
69  }
70 
71  Void    printSummaryOut ()
72  {
73    FILE* pFile = fopen ("summaryTotal.txt", "at");
74    Double dFps     =   m_dFrmRate; //--CFG_KDY
75    Double dScale   = dFps / 1000 / (Double)m_uiNumPic;
76   
77    fprintf(pFile, "%f\t %f\t %f\t %f\n", getBits() * dScale,
78            getPsnrY() / (Double)getNumPic(),
79            getPsnrU() / (Double)getNumPic(),
80            getPsnrV() / (Double)getNumPic() );
81    fclose(pFile);
82  }
83 
84  Void    printSummary(Char ch)
85  {
86    FILE* pFile = NULL;
87   
88    switch( ch ) 
89    {
90      case 'I':
91        pFile = fopen ("summary_I.txt", "at");
92        break;
93      case 'P':
94        pFile = fopen ("summary_P.txt", "at");
95        break;
96      case 'B':
97        pFile = fopen ("summary_B.txt", "at");
98        break;
99      default:
100        assert(0);
101        return;
102        break;
103    }
104   
105    Double dFps     =   m_dFrmRate; //--CFG_KDY
106    Double dScale   = dFps / 1000 / (Double)m_uiNumPic;
107   
108    fprintf(pFile, "%f\t %f\t %f\t %f\n",
109            getBits() * dScale,
110            getPsnrY() / (Double)getNumPic(),
111            getPsnrU() / (Double)getNumPic(),
112            getPsnrV() / (Double)getNumPic() );
113   
114    fclose(pFile);
115  }
116};
117
118#endif // !defined(AFX_TENCANALYZE_H__C79BCAA2_6AC8_4175_A0FE_CF02F5829233__INCLUDED_)
119
Note: See TracBrowser for help on using the repository browser.