[313] | 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 | } |
---|
[431] | 133 | |
---|
| 134 | Void printOutInterlaced ( Char cDelim, Double bits ) |
---|
| 135 | { |
---|
| 136 | Double dFps = m_dFrmRate; //--CFG_KDY |
---|
| 137 | Double dScale = dFps / 1000 / (Double)m_uiNumPic; |
---|
| 138 | |
---|
| 139 | printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); |
---|
| 140 | //printf( "\t------------ " " ----------" " -------- " " -------- " " --------\n" ); |
---|
| 141 | printf( "\t %8d %c" "%12.4lf " "%8.4lf " "%8.4lf " "%8.4lf\n", |
---|
| 142 | getNumPic(), cDelim, |
---|
| 143 | bits * dScale, |
---|
| 144 | getPsnrY() / (Double)getNumPic(), |
---|
| 145 | getPsnrU() / (Double)getNumPic(), |
---|
| 146 | getPsnrV() / (Double)getNumPic() ); |
---|
| 147 | } |
---|
[313] | 148 | |
---|
[431] | 149 | Void printSummaryOutInterlaced (Int bits) |
---|
| 150 | { |
---|
| 151 | FILE* pFile = fopen ("summaryTotal.txt", "at"); |
---|
| 152 | Double dFps = m_dFrmRate; //--CFG_KDY |
---|
| 153 | Double dScale = dFps / 1000 / (Double)m_uiNumPic; |
---|
| 154 | |
---|
| 155 | fprintf(pFile, "%f\t %f\t %f\t %f\n", bits * dScale, |
---|
| 156 | getPsnrY() / (Double)getNumPic(), |
---|
| 157 | getPsnrU() / (Double)getNumPic(), |
---|
| 158 | getPsnrV() / (Double)getNumPic() ); |
---|
| 159 | fclose(pFile); |
---|
| 160 | } |
---|
| 161 | |
---|
[313] | 162 | Void printSummary(Char ch) |
---|
| 163 | { |
---|
| 164 | FILE* pFile = NULL; |
---|
| 165 | |
---|
| 166 | switch( ch ) |
---|
| 167 | { |
---|
| 168 | case 'I': |
---|
| 169 | pFile = fopen ("summary_I.txt", "at"); |
---|
| 170 | break; |
---|
| 171 | case 'P': |
---|
| 172 | pFile = fopen ("summary_P.txt", "at"); |
---|
| 173 | break; |
---|
| 174 | case 'B': |
---|
| 175 | pFile = fopen ("summary_B.txt", "at"); |
---|
| 176 | break; |
---|
| 177 | default: |
---|
| 178 | assert(0); |
---|
| 179 | return; |
---|
| 180 | break; |
---|
| 181 | } |
---|
| 182 | |
---|
| 183 | Double dFps = m_dFrmRate; //--CFG_KDY |
---|
| 184 | Double dScale = dFps / 1000 / (Double)m_uiNumPic; |
---|
| 185 | |
---|
| 186 | fprintf(pFile, "%f\t %f\t %f\t %f\n", |
---|
| 187 | getBits() * dScale, |
---|
| 188 | getPsnrY() / (Double)getNumPic(), |
---|
| 189 | getPsnrU() / (Double)getNumPic(), |
---|
| 190 | getPsnrV() / (Double)getNumPic() ); |
---|
| 191 | |
---|
| 192 | fclose(pFile); |
---|
| 193 | } |
---|
| 194 | }; |
---|
| 195 | |
---|
| 196 | #if SVC_EXTENSION |
---|
| 197 | extern TEncAnalyze m_gcAnalyzeAll [MAX_LAYERS]; |
---|
| 198 | extern TEncAnalyze m_gcAnalyzeI [MAX_LAYERS]; |
---|
| 199 | extern TEncAnalyze m_gcAnalyzeP [MAX_LAYERS]; |
---|
| 200 | extern TEncAnalyze m_gcAnalyzeB [MAX_LAYERS]; |
---|
| 201 | #else |
---|
| 202 | extern TEncAnalyze m_gcAnalyzeAll; |
---|
| 203 | extern TEncAnalyze m_gcAnalyzeI; |
---|
| 204 | extern TEncAnalyze m_gcAnalyzeP; |
---|
| 205 | extern TEncAnalyze m_gcAnalyzeB; |
---|
| 206 | #endif |
---|
| 207 | |
---|
[431] | 208 | extern TEncAnalyze m_gcAnalyzeAll_in; |
---|
[313] | 209 | //! \} |
---|
| 210 | |
---|
| 211 | #endif // !defined(AFX_TENCANALYZE_H__C79BCAA2_6AC8_4175_A0FE_CF02F5829233__INCLUDED_) |
---|