[191] | 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-2013, 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 |
---|
| 58 | class TEncAnalyze |
---|
| 59 | { |
---|
| 60 | private: |
---|
| 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 | |
---|
| 68 | public: |
---|
| 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 | #if SVC_EXTENSION |
---|
| 91 | Void printOut ( Char cDelim, UInt layer ) |
---|
| 92 | { |
---|
| 93 | Double dFps = m_dFrmRate; //--CFG_KDY |
---|
| 94 | Double dScale = dFps / 1000 / (Double)m_uiNumPic; |
---|
| 95 | |
---|
| 96 | printf( " L%d\t %8d %c" "%12.4lf " "%8.4lf " "%8.4lf " "%8.4lf\n", |
---|
| 97 | layer, |
---|
| 98 | getNumPic(), cDelim, |
---|
| 99 | getBits() * dScale, |
---|
| 100 | getPsnrY() / (Double)getNumPic(), |
---|
| 101 | getPsnrU() / (Double)getNumPic(), |
---|
| 102 | getPsnrV() / (Double)getNumPic() ); |
---|
| 103 | } |
---|
| 104 | #else |
---|
| 105 | Void printOut ( Char cDelim ) |
---|
| 106 | { |
---|
| 107 | Double dFps = m_dFrmRate; //--CFG_KDY |
---|
| 108 | Double dScale = dFps / 1000 / (Double)m_uiNumPic; |
---|
| 109 | |
---|
| 110 | printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); |
---|
| 111 | //printf( "\t------------ " " ----------" " -------- " " -------- " " --------\n" ); |
---|
| 112 | printf( "\t %8d %c" "%12.4lf " "%8.4lf " "%8.4lf " "%8.4lf\n", |
---|
| 113 | getNumPic(), cDelim, |
---|
| 114 | getBits() * dScale, |
---|
| 115 | getPsnrY() / (Double)getNumPic(), |
---|
| 116 | getPsnrU() / (Double)getNumPic(), |
---|
| 117 | getPsnrV() / (Double)getNumPic() ); |
---|
| 118 | } |
---|
| 119 | #endif |
---|
| 120 | |
---|
| 121 | Void printSummaryOut () |
---|
| 122 | { |
---|
| 123 | FILE* pFile = fopen ("summaryTotal.txt", "at"); |
---|
| 124 | Double dFps = m_dFrmRate; //--CFG_KDY |
---|
| 125 | Double dScale = dFps / 1000 / (Double)m_uiNumPic; |
---|
| 126 | |
---|
| 127 | fprintf(pFile, "%f\t %f\t %f\t %f\n", getBits() * dScale, |
---|
| 128 | getPsnrY() / (Double)getNumPic(), |
---|
| 129 | getPsnrU() / (Double)getNumPic(), |
---|
| 130 | getPsnrV() / (Double)getNumPic() ); |
---|
| 131 | fclose(pFile); |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | Void printSummary(Char ch) |
---|
| 135 | { |
---|
| 136 | FILE* pFile = NULL; |
---|
| 137 | |
---|
| 138 | switch( ch ) |
---|
| 139 | { |
---|
| 140 | case 'I': |
---|
| 141 | pFile = fopen ("summary_I.txt", "at"); |
---|
| 142 | break; |
---|
| 143 | case 'P': |
---|
| 144 | pFile = fopen ("summary_P.txt", "at"); |
---|
| 145 | break; |
---|
| 146 | case 'B': |
---|
| 147 | pFile = fopen ("summary_B.txt", "at"); |
---|
| 148 | break; |
---|
| 149 | default: |
---|
| 150 | assert(0); |
---|
| 151 | return; |
---|
| 152 | break; |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | Double dFps = m_dFrmRate; //--CFG_KDY |
---|
| 156 | Double dScale = dFps / 1000 / (Double)m_uiNumPic; |
---|
| 157 | |
---|
| 158 | fprintf(pFile, "%f\t %f\t %f\t %f\n", |
---|
| 159 | getBits() * dScale, |
---|
| 160 | getPsnrY() / (Double)getNumPic(), |
---|
| 161 | getPsnrU() / (Double)getNumPic(), |
---|
| 162 | getPsnrV() / (Double)getNumPic() ); |
---|
| 163 | |
---|
| 164 | fclose(pFile); |
---|
| 165 | } |
---|
| 166 | }; |
---|
| 167 | |
---|
| 168 | #if SVC_EXTENSION |
---|
| 169 | extern TEncAnalyze m_gcAnalyzeAll [MAX_LAYERS]; |
---|
| 170 | extern TEncAnalyze m_gcAnalyzeI [MAX_LAYERS]; |
---|
| 171 | extern TEncAnalyze m_gcAnalyzeP [MAX_LAYERS]; |
---|
| 172 | extern TEncAnalyze m_gcAnalyzeB [MAX_LAYERS]; |
---|
| 173 | #else |
---|
| 174 | extern TEncAnalyze m_gcAnalyzeAll; |
---|
| 175 | extern TEncAnalyze m_gcAnalyzeI; |
---|
| 176 | extern TEncAnalyze m_gcAnalyzeP; |
---|
| 177 | extern TEncAnalyze m_gcAnalyzeB; |
---|
| 178 | #endif |
---|
| 179 | |
---|
| 180 | //! \} |
---|
| 181 | |
---|
| 182 | #endif // !defined(AFX_TENCANALYZE_H__C79BCAA2_6AC8_4175_A0FE_CF02F5829233__INCLUDED_) |
---|