source: 3DVCSoftware/branches/HTM-11.2-dev3-HHI/source/Lib/TLibEncoder/TEncAnalyze.h

Last change on this file was 872, checked in by tech, 11 years ago

Merged HTM-10.0-dev0@871. (MV-HEVC 7 HLS)

  • Property svn:eol-style set to native
File size: 6.5 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license. 
5 *
6* Copyright (c) 2010-2014, ITU/ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/** \file     TEncAnalyze.h
35    \brief    encoder analyzer class (header)
36*/
37
38#ifndef __TENCANALYZE__
39#define __TENCANALYZE__
40
41#if _MSC_VER > 1000
42#pragma once
43#endif // _MSC_VER > 1000
44
45#include <stdio.h>
46#include <memory.h>
47#include <assert.h>
48#include "TLibCommon/CommonDef.h"
49
50//! \ingroup TLibEncoder
51//! \{
52
53// ====================================================================================================================
54// Class definition
55// ====================================================================================================================
56
57/// encoder analyzer class
58class TEncAnalyze
59{
60private:
61  Double    m_dPSNRSumY;
62  Double    m_dPSNRSumU;
63  Double    m_dPSNRSumV;
64  Double    m_dAddBits;
65  UInt      m_uiNumPic;
66  Double    m_dFrmRate; //--CFG_KDY
67 
68public:
69  TEncAnalyze() { m_dPSNRSumY = m_dPSNRSumU = m_dPSNRSumV = m_dAddBits = m_uiNumPic = 0;  }
70  virtual ~TEncAnalyze()  {}
71 
72  Void  addResult( Double psnrY, Double psnrU, Double psnrV, Double bits)
73  {
74    m_dPSNRSumY += psnrY;
75    m_dPSNRSumU += psnrU;
76    m_dPSNRSumV += psnrV;
77    m_dAddBits  += bits;
78   
79    m_uiNumPic++;
80  }
81 
82  Double  getPsnrY()  { return  m_dPSNRSumY;  }
83  Double  getPsnrU()  { return  m_dPSNRSumU;  }
84  Double  getPsnrV()  { return  m_dPSNRSumV;  }
85  Double  getBits()   { return  m_dAddBits;   }
86  UInt    getNumPic() { return  m_uiNumPic;   }
87 
88  Void    setFrmRate  (Double dFrameRate) { m_dFrmRate = dFrameRate; } //--CFG_KDY
89  Void    clear() { m_dPSNRSumY = m_dPSNRSumU = m_dPSNRSumV = m_dAddBits = m_uiNumPic = 0;  }
90  Void    printOut ( Char cDelim )
91  {
92    Double dFps     =   m_dFrmRate; //--CFG_KDY
93    Double dScale   = dFps / 1000 / (Double)m_uiNumPic;
94   
95    printf( "\tTotal Frames |  "   "Bitrate    "  "Y-PSNR    "  "U-PSNR    "  "V-PSNR \n" );
96    //printf( "\t------------ "  " ----------"   " -------- "  " -------- "  " --------\n" );
97    printf( "\t %8d    %c"          "%12.4lf  "    "%8.4lf  "   "%8.4lf  "    "%8.4lf\n",
98           getNumPic(), cDelim,
99           getBits() * dScale,
100           getPsnrY() / (Double)getNumPic(),
101           getPsnrU() / (Double)getNumPic(),
102           getPsnrV() / (Double)getNumPic() );
103  }
104 
105  Void    printSummaryOut ()
106  {
107    FILE* pFile = fopen ("summaryTotal.txt", "at");
108    Double dFps     =   m_dFrmRate; //--CFG_KDY
109    Double dScale   = dFps / 1000 / (Double)m_uiNumPic;
110   
111    fprintf(pFile, "%f\t %f\t %f\t %f\n", getBits() * dScale,
112            getPsnrY() / (Double)getNumPic(),
113            getPsnrU() / (Double)getNumPic(),
114            getPsnrV() / (Double)getNumPic() );
115    fclose(pFile);
116  }
117 
118  Void    printOutInterlaced ( Char cDelim, Double bits )
119  {
120    Double dFps     =   m_dFrmRate; //--CFG_KDY
121    Double dScale   = dFps / 1000 / (Double)m_uiNumPic;
122   
123    printf( "\tTotal Frames |  "   "Bitrate    "  "Y-PSNR    "  "U-PSNR    "  "V-PSNR \n" );
124    //printf( "\t------------ "  " ----------"   " -------- "  " -------- "  " --------\n" );
125    printf( "\t %8d    %c"          "%12.4lf  "    "%8.4lf  "   "%8.4lf  "    "%8.4lf\n",
126           getNumPic(), cDelim,
127           bits * dScale,
128           getPsnrY() / (Double)getNumPic(),
129           getPsnrU() / (Double)getNumPic(),
130           getPsnrV() / (Double)getNumPic() );
131  }
132 
133  Void    printSummaryOutInterlaced (Int bits)
134  {
135    FILE* pFile = fopen ("summaryTotal.txt", "at");
136    Double dFps     =   m_dFrmRate; //--CFG_KDY
137    Double dScale   = dFps / 1000 / (Double)m_uiNumPic;
138   
139    fprintf(pFile, "%f\t %f\t %f\t %f\n", bits * dScale,
140            getPsnrY() / (Double)getNumPic(),
141            getPsnrU() / (Double)getNumPic(),
142            getPsnrV() / (Double)getNumPic() );
143    fclose(pFile);
144  }
145 
146 
147  Void    printSummary(Char ch)
148  {
149    FILE* pFile = NULL;
150   
151    switch( ch ) 
152    {
153      case 'I':
154        pFile = fopen ("summary_I.txt", "at");
155        break;
156      case 'P':
157        pFile = fopen ("summary_P.txt", "at");
158        break;
159      case 'B':
160        pFile = fopen ("summary_B.txt", "at");
161        break;
162      default:
163        assert(0);
164        return;
165        break;
166    }
167   
168    Double dFps     =   m_dFrmRate; //--CFG_KDY
169    Double dScale   = dFps / 1000 / (Double)m_uiNumPic;
170   
171    fprintf(pFile, "%f\t %f\t %f\t %f\n",
172            getBits() * dScale,
173            getPsnrY() / (Double)getNumPic(),
174            getPsnrU() / (Double)getNumPic(),
175            getPsnrV() / (Double)getNumPic() );
176   
177    fclose(pFile);
178  }
179};
180
181#if !H_MV
182extern TEncAnalyze             m_gcAnalyzeAll;
183extern TEncAnalyze             m_gcAnalyzeI;
184extern TEncAnalyze             m_gcAnalyzeP;
185extern TEncAnalyze             m_gcAnalyzeB;
186
187extern TEncAnalyze             m_gcAnalyzeAll_in;
188#endif
189
190//! \}
191
192#endif // !defined(AFX_TENCANALYZE_H__C79BCAA2_6AC8_4175_A0FE_CF02F5829233__INCLUDED_)
Note: See TracBrowser for help on using the repository browser.