| 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 TAppEncTop.cpp |
|---|
| 35 | \brief Encoder application class |
|---|
| 36 | */ |
|---|
| 37 | |
|---|
| 38 | #include <list> |
|---|
| 39 | #include <fstream> |
|---|
| 40 | #include <stdlib.h> |
|---|
| 41 | #include <stdio.h> |
|---|
| 42 | #include <fcntl.h> |
|---|
| 43 | #include <assert.h> |
|---|
| 44 | |
|---|
| 45 | #include "TAppEncTop.h" |
|---|
| 46 | #include "TLibEncoder/AnnexBwrite.h" |
|---|
| 47 | |
|---|
| 48 | using namespace std; |
|---|
| 49 | |
|---|
| 50 | //! \ingroup TAppEncoder |
|---|
| 51 | //! \{ |
|---|
| 52 | |
|---|
| 53 | // ==================================================================================================================== |
|---|
| 54 | // Constructor / destructor / initialization / destroy |
|---|
| 55 | // ==================================================================================================================== |
|---|
| 56 | |
|---|
| 57 | TAppEncTop::TAppEncTop() |
|---|
| 58 | { |
|---|
| 59 | #if !H_MV |
|---|
| 60 | m_iFrameRcvd = 0; |
|---|
| 61 | #endif |
|---|
| 62 | m_totalBytes = 0; |
|---|
| 63 | m_essentialBytes = 0; |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | TAppEncTop::~TAppEncTop() |
|---|
| 67 | { |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | Void TAppEncTop::xInitLibCfg() |
|---|
| 71 | { |
|---|
| 72 | #if H_MV |
|---|
| 73 | TComVPS& vps = m_vps; |
|---|
| 74 | #else |
|---|
| 75 | TComVPS vps; |
|---|
| 76 | #endif |
|---|
| 77 | |
|---|
| 78 | #if CAM_HLS_F0136_F0045_F0082 |
|---|
| 79 | vps.createCamPars(m_iNumberOfViews); |
|---|
| 80 | #endif |
|---|
| 81 | |
|---|
| 82 | #if DLT_DIFF_CODING_IN_PPS |
|---|
| 83 | TComDLT& dlt = m_dlt; |
|---|
| 84 | #endif |
|---|
| 85 | |
|---|
| 86 | #if H_MV |
|---|
| 87 | Int maxTempLayer = -1; |
|---|
| 88 | for (Int j = 0; j < m_numberOfLayers; j++) |
|---|
| 89 | { |
|---|
| 90 | maxTempLayer = max( m_maxTempLayerMvc[ j ], maxTempLayer ); |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | vps.setMaxTLayers ( maxTempLayer ); |
|---|
| 94 | if ( maxTempLayer ) |
|---|
| 95 | { |
|---|
| 96 | vps.setTemporalNestingFlag(true); |
|---|
| 97 | } |
|---|
| 98 | vps.setMaxLayersMinus1( m_numberOfLayers - 1); |
|---|
| 99 | for(Int i = 0; i < MAX_TLAYER; i++) |
|---|
| 100 | { |
|---|
| 101 | Int maxNumReOrderPics = 0; |
|---|
| 102 | Int maxDecPicBuffering = 0; |
|---|
| 103 | for (Int j = 0; j < m_numberOfLayers; j++) |
|---|
| 104 | { |
|---|
| 105 | maxNumReOrderPics = max( maxNumReOrderPics, m_numReorderPicsMvc [ j ][ i ] ); |
|---|
| 106 | maxDecPicBuffering = max( maxDecPicBuffering, m_maxDecPicBufferingMvc[ j ][ i ] ); |
|---|
| 107 | } |
|---|
| 108 | |
|---|
| 109 | vps.setNumReorderPics ( maxNumReOrderPics ,i ); |
|---|
| 110 | vps.setMaxDecPicBuffering ( maxDecPicBuffering ,i ); |
|---|
| 111 | } |
|---|
| 112 | #else |
|---|
| 113 | vps.setMaxTLayers ( m_maxTempLayer ); |
|---|
| 114 | if (m_maxTempLayer == 1) |
|---|
| 115 | { |
|---|
| 116 | vps.setTemporalNestingFlag(true); |
|---|
| 117 | } |
|---|
| 118 | vps.setMaxLayers ( 1 ); |
|---|
| 119 | for(Int i = 0; i < MAX_TLAYER; i++) |
|---|
| 120 | { |
|---|
| 121 | vps.setNumReorderPics ( m_numReorderPics[i], i ); |
|---|
| 122 | vps.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
|---|
| 123 | } |
|---|
| 124 | #endif |
|---|
| 125 | #if H_MV |
|---|
| 126 | xSetLayerIds ( vps ); |
|---|
| 127 | xSetDimensionIdAndLength ( vps ); |
|---|
| 128 | xSetDependencies( vps ); |
|---|
| 129 | xSetProfileTierLevel ( vps ); |
|---|
| 130 | xSetRepFormat ( vps ); |
|---|
| 131 | xSetLayerSets ( vps ); |
|---|
| 132 | xSetVPSVUI ( vps ); |
|---|
| 133 | #if H_3D |
|---|
| 134 | xSetVPSExtension2 ( vps ); |
|---|
| 135 | m_ivPicLists.setVPS ( &vps ); |
|---|
| 136 | #if DLT_DIFF_CODING_IN_PPS |
|---|
| 137 | xDeriveDltArray ( vps, dlt ); |
|---|
| 138 | #endif |
|---|
| 139 | #endif |
|---|
| 140 | |
|---|
| 141 | |
|---|
| 142 | for(Int layerIdInVps = 0; layerIdInVps < m_numberOfLayers; layerIdInVps++) |
|---|
| 143 | { |
|---|
| 144 | m_frameRcvd .push_back(0); |
|---|
| 145 | m_acTEncTopList .push_back(new TEncTop); |
|---|
| 146 | m_acTVideoIOYuvInputFileList.push_back(new TVideoIOYuv); |
|---|
| 147 | m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv); |
|---|
| 148 | m_picYuvRec .push_back(new TComList<TComPicYuv*>) ; |
|---|
| 149 | m_ivPicLists.push_back( m_acTEncTopList[ layerIdInVps ]->getListPic() ); |
|---|
| 150 | TEncTop& m_cTEncTop = *m_acTEncTopList[ layerIdInVps ]; // It is not a member, but this name helps avoiding code duplication !!! |
|---|
| 151 | |
|---|
| 152 | Int layerId = vps.getLayerIdInNuh( layerIdInVps ); |
|---|
| 153 | m_cTEncTop.setLayerIdInVps ( layerIdInVps ); |
|---|
| 154 | m_cTEncTop.setLayerId ( layerId ); |
|---|
| 155 | m_cTEncTop.setViewId ( vps.getViewId ( layerId ) ); |
|---|
| 156 | m_cTEncTop.setViewIndex ( vps.getViewIndex ( layerId ) ); |
|---|
| 157 | #if H_3D |
|---|
| 158 | Bool isDepth = ( vps.getDepthId ( layerId ) != 0 ) ; |
|---|
| 159 | m_cTEncTop.setIsDepth ( isDepth ); |
|---|
| 160 | //====== Camera Parameters ========= |
|---|
| 161 | m_cTEncTop.setCameraParameters ( &m_cCameraData ); |
|---|
| 162 | m_cTEncTop.setCamParPrecision ( m_cCameraData.getCamParsCodedPrecision () ); |
|---|
| 163 | m_cTEncTop.setCamParInSliceHeader ( m_cCameraData.getVaryingCameraParameters() ); |
|---|
| 164 | m_cTEncTop.setCodedScale ( m_cCameraData.getCodedScale () ); |
|---|
| 165 | m_cTEncTop.setCodedOffset ( m_cCameraData.getCodedOffset () ); |
|---|
| 166 | #if H_3D_VSO |
|---|
| 167 | //====== VSO ========= |
|---|
| 168 | m_cTEncTop.setRenderModelParameters ( &m_cRenModStrParser ); |
|---|
| 169 | m_cTEncTop.setForceLambdaScaleVSO ( isDepth ? m_bForceLambdaScaleVSO : false ); |
|---|
| 170 | m_cTEncTop.setLambdaScaleVSO ( isDepth ? m_dLambdaScaleVSO : 1 ); |
|---|
| 171 | m_cTEncTop.setVSOMode ( isDepth ? m_uiVSOMode : 0 ); |
|---|
| 172 | |
|---|
| 173 | m_cTEncTop.setAllowNegDist ( isDepth ? m_bAllowNegDist : false ); |
|---|
| 174 | |
|---|
| 175 | // SAIT_VSO_EST_A0033 |
|---|
| 176 | m_cTEncTop.setUseEstimatedVSD ( isDepth ? m_bUseEstimatedVSD : false ); |
|---|
| 177 | |
|---|
| 178 | // LGE_WVSO_A0119 |
|---|
| 179 | m_cTEncTop.setUseWVSO ( isDepth ? m_bUseWVSO : false ); |
|---|
| 180 | m_cTEncTop.setVSOWeight ( isDepth ? m_iVSOWeight : 0 ); |
|---|
| 181 | m_cTEncTop.setVSDWeight ( isDepth ? m_iVSDWeight : 0 ); |
|---|
| 182 | m_cTEncTop.setDWeight ( isDepth ? m_iDWeight : 0 ); |
|---|
| 183 | #endif // H_3D_VSO |
|---|
| 184 | #if H_3D_ARP |
|---|
| 185 | //====== Advanced Inter-view Residual Prediction ========= |
|---|
| 186 | m_cTEncTop.setUseAdvRP ( ( isDepth || 0==layerIdInVps ) ? 0 : m_uiUseAdvResPred ); |
|---|
| 187 | m_cTEncTop.setARPStepNum ( ( isDepth || 0==layerIdInVps ) ? 1 : H_3D_ARP_WFNR ); |
|---|
| 188 | #endif |
|---|
| 189 | #if H_3D_SPIVMP |
|---|
| 190 | m_cTEncTop.setSubPULog2Size (( isDepth || 0==layerIdInVps ) ? 0 : m_iSubPULog2Size ); |
|---|
| 191 | #endif |
|---|
| 192 | #if H_3D_IC |
|---|
| 193 | m_cTEncTop.setUseIC ( vps.getViewIndex( layerId ) == 0 || isDepth ? false : m_abUseIC ); |
|---|
| 194 | #endif |
|---|
| 195 | //========== Depth intra modes ========== |
|---|
| 196 | #if H_3D_DIM |
|---|
| 197 | m_cTEncTop.setUseDMM ( isDepth ? m_useDMM : false ); |
|---|
| 198 | m_cTEncTop.setUseSDC ( isDepth ? m_useSDC : false ); |
|---|
| 199 | m_cTEncTop.setUseDLT ( isDepth ? m_useDLT : false ); |
|---|
| 200 | #endif |
|---|
| 201 | #if H_3D_QTLPC |
|---|
| 202 | m_cTEncTop.setUseQTL ( isDepth ? m_bUseQTL : false ); |
|---|
| 203 | m_cTEncTop.setUsePC ( isDepth ? m_bUsePC : false ); |
|---|
| 204 | #endif |
|---|
| 205 | //====== Depth Inter SDC ========= |
|---|
| 206 | #if H_3D_INTER_SDC |
|---|
| 207 | m_cTEncTop.setInterSDCEnable ( isDepth ? m_bDepthInterSDCFlag : false ); |
|---|
| 208 | #endif |
|---|
| 209 | #if H_3D_IV_MERGE |
|---|
| 210 | m_cTEncTop.setUseMPI ( isDepth ? m_bMPIFlag : false ); |
|---|
| 211 | #endif |
|---|
| 212 | #endif // H_3D |
|---|
| 213 | |
|---|
| 214 | m_cTEncTop.setIvPicLists ( &m_ivPicLists ); |
|---|
| 215 | // H_MV |
|---|
| 216 | m_cTEncTop.setVPS(&vps); |
|---|
| 217 | |
|---|
| 218 | #if DLT_DIFF_CODING_IN_PPS |
|---|
| 219 | m_cTEncTop.setDLT(&dlt); |
|---|
| 220 | #endif |
|---|
| 221 | |
|---|
| 222 | m_cTEncTop.setProfile(m_profile); |
|---|
| 223 | m_cTEncTop.setLevel(m_levelTier, m_level); |
|---|
| 224 | m_cTEncTop.setProgressiveSourceFlag(m_progressiveSourceFlag); |
|---|
| 225 | m_cTEncTop.setInterlacedSourceFlag(m_interlacedSourceFlag); |
|---|
| 226 | m_cTEncTop.setNonPackedConstraintFlag(m_nonPackedConstraintFlag); |
|---|
| 227 | m_cTEncTop.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag); |
|---|
| 228 | |
|---|
| 229 | m_cTEncTop.setFrameRate ( m_iFrameRate ); |
|---|
| 230 | m_cTEncTop.setFrameSkip ( m_FrameSkip ); |
|---|
| 231 | m_cTEncTop.setSourceWidth ( m_iSourceWidth ); |
|---|
| 232 | m_cTEncTop.setSourceHeight ( m_iSourceHeight ); |
|---|
| 233 | m_cTEncTop.setConformanceWindow ( m_confLeft, m_confRight, m_confTop, m_confBottom ); |
|---|
| 234 | m_cTEncTop.setFramesToBeEncoded ( m_framesToBeEncoded ); |
|---|
| 235 | |
|---|
| 236 | //====== Coding Structure ======== |
|---|
| 237 | m_cTEncTop.setIntraPeriod ( m_iIntraPeriod[ layerIdInVps ] ); |
|---|
| 238 | m_cTEncTop.setDecodingRefreshType ( m_iDecodingRefreshType ); |
|---|
| 239 | m_cTEncTop.setGOPSize ( m_iGOPSize ); |
|---|
| 240 | #if H_MV |
|---|
| 241 | m_cTEncTop.setGopList ( m_GOPListMvc[layerIdInVps] ); |
|---|
| 242 | m_cTEncTop.setExtraRPSs ( m_extraRPSsMvc[layerIdInVps] ); |
|---|
| 243 | for(Int i = 0; i < MAX_TLAYER; i++) |
|---|
| 244 | { |
|---|
| 245 | m_cTEncTop.setNumReorderPics ( m_numReorderPicsMvc[layerIdInVps][i], i ); |
|---|
| 246 | m_cTEncTop.setMaxDecPicBuffering ( m_maxDecPicBufferingMvc[layerIdInVps][i], i ); |
|---|
| 247 | } |
|---|
| 248 | #else |
|---|
| 249 | m_cTEncTop.setGopList ( m_GOPList ); |
|---|
| 250 | m_cTEncTop.setExtraRPSs ( m_extraRPSs ); |
|---|
| 251 | for(Int i = 0; i < MAX_TLAYER; i++) |
|---|
| 252 | { |
|---|
| 253 | m_cTEncTop.setNumReorderPics ( m_numReorderPics[i], i ); |
|---|
| 254 | m_cTEncTop.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
|---|
| 255 | } |
|---|
| 256 | #endif |
|---|
| 257 | for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop ) |
|---|
| 258 | { |
|---|
| 259 | m_cTEncTop.setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] ); |
|---|
| 260 | } |
|---|
| 261 | #if H_MV |
|---|
| 262 | m_cTEncTop.setQP ( m_iQP[layerIdInVps] ); |
|---|
| 263 | #else |
|---|
| 264 | m_cTEncTop.setQP ( m_iQP ); |
|---|
| 265 | #endif |
|---|
| 266 | |
|---|
| 267 | m_cTEncTop.setPad ( m_aiPad ); |
|---|
| 268 | |
|---|
| 269 | #if H_MV |
|---|
| 270 | m_cTEncTop.setMaxTempLayer ( m_maxTempLayerMvc[layerIdInVps] ); |
|---|
| 271 | #else |
|---|
| 272 | m_cTEncTop.setMaxTempLayer ( m_maxTempLayer ); |
|---|
| 273 | #endif |
|---|
| 274 | m_cTEncTop.setUseAMP( m_enableAMP ); |
|---|
| 275 | |
|---|
| 276 | //===== Slice ======== |
|---|
| 277 | |
|---|
| 278 | //====== Loop/Deblock Filter ======== |
|---|
| 279 | #if H_MV |
|---|
| 280 | m_cTEncTop.setLoopFilterDisable ( m_bLoopFilterDisable[layerIdInVps]); |
|---|
| 281 | #else |
|---|
| 282 | m_cTEncTop.setLoopFilterDisable ( m_bLoopFilterDisable ); |
|---|
| 283 | #endif |
|---|
| 284 | m_cTEncTop.setLoopFilterOffsetInPPS ( m_loopFilterOffsetInPPS ); |
|---|
| 285 | m_cTEncTop.setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 ); |
|---|
| 286 | m_cTEncTop.setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 ); |
|---|
| 287 | m_cTEncTop.setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent); |
|---|
| 288 | m_cTEncTop.setDeblockingFilterMetric ( m_DeblockingFilterMetric ); |
|---|
| 289 | |
|---|
| 290 | //====== Motion search ======== |
|---|
| 291 | m_cTEncTop.setFastSearch ( m_iFastSearch ); |
|---|
| 292 | m_cTEncTop.setSearchRange ( m_iSearchRange ); |
|---|
| 293 | m_cTEncTop.setBipredSearchRange ( m_bipredSearchRange ); |
|---|
| 294 | |
|---|
| 295 | //====== Quality control ======== |
|---|
| 296 | m_cTEncTop.setMaxDeltaQP ( m_iMaxDeltaQP ); |
|---|
| 297 | m_cTEncTop.setMaxCuDQPDepth ( m_iMaxCuDQPDepth ); |
|---|
| 298 | |
|---|
| 299 | m_cTEncTop.setChromaCbQpOffset ( m_cbQpOffset ); |
|---|
| 300 | m_cTEncTop.setChromaCrQpOffset ( m_crQpOffset ); |
|---|
| 301 | |
|---|
| 302 | #if ADAPTIVE_QP_SELECTION |
|---|
| 303 | m_cTEncTop.setUseAdaptQpSelect ( m_bUseAdaptQpSelect ); |
|---|
| 304 | #endif |
|---|
| 305 | |
|---|
| 306 | Int lowestQP; |
|---|
| 307 | lowestQP = - 6*(g_bitDepthY - 8); // XXX: check |
|---|
| 308 | |
|---|
| 309 | #if H_MV |
|---|
| 310 | if ((m_iMaxDeltaQP == 0 ) && (m_iQP[layerIdInVps] == lowestQP) && (m_useLossless == true)) |
|---|
| 311 | #else |
|---|
| 312 | if ((m_iMaxDeltaQP == 0 ) && (m_iQP == lowestQP) && (m_useLossless == true)) |
|---|
| 313 | #endif |
|---|
| 314 | { |
|---|
| 315 | m_bUseAdaptiveQP = false; |
|---|
| 316 | } |
|---|
| 317 | m_cTEncTop.setUseAdaptiveQP ( m_bUseAdaptiveQP ); |
|---|
| 318 | m_cTEncTop.setQPAdaptationRange ( m_iQPAdaptationRange ); |
|---|
| 319 | |
|---|
| 320 | //====== Tool list ======== |
|---|
| 321 | m_cTEncTop.setUseSBACRD ( m_bUseSBACRD ); |
|---|
| 322 | m_cTEncTop.setDeltaQpRD ( m_uiDeltaQpRD ); |
|---|
| 323 | m_cTEncTop.setUseASR ( m_bUseASR ); |
|---|
| 324 | m_cTEncTop.setUseHADME ( m_bUseHADME ); |
|---|
| 325 | m_cTEncTop.setUseLossless ( m_useLossless ); |
|---|
| 326 | #if H_MV |
|---|
| 327 | m_cTEncTop.setdQPs ( m_aidQP[layerIdInVps] ); |
|---|
| 328 | #else |
|---|
| 329 | m_cTEncTop.setdQPs ( m_aidQP ); |
|---|
| 330 | #endif |
|---|
| 331 | m_cTEncTop.setUseRDOQ ( m_useRDOQ ); |
|---|
| 332 | m_cTEncTop.setUseRDOQTS ( m_useRDOQTS ); |
|---|
| 333 | m_cTEncTop.setRDpenalty ( m_rdPenalty ); |
|---|
| 334 | m_cTEncTop.setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize ); |
|---|
| 335 | m_cTEncTop.setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize ); |
|---|
| 336 | m_cTEncTop.setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); |
|---|
| 337 | m_cTEncTop.setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); |
|---|
| 338 | m_cTEncTop.setUseFastEnc ( m_bUseFastEnc ); |
|---|
| 339 | m_cTEncTop.setUseEarlyCU ( m_bUseEarlyCU ); |
|---|
| 340 | m_cTEncTop.setUseFastDecisionForMerge ( m_useFastDecisionForMerge ); |
|---|
| 341 | m_cTEncTop.setUseCbfFastMode ( m_bUseCbfFastMode ); |
|---|
| 342 | m_cTEncTop.setUseEarlySkipDetection ( m_useEarlySkipDetection ); |
|---|
| 343 | |
|---|
| 344 | m_cTEncTop.setUseTransformSkip ( m_useTransformSkip ); |
|---|
| 345 | m_cTEncTop.setUseTransformSkipFast ( m_useTransformSkipFast ); |
|---|
| 346 | m_cTEncTop.setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); |
|---|
| 347 | m_cTEncTop.setPCMLog2MinSize ( m_uiPCMLog2MinSize); |
|---|
| 348 | m_cTEncTop.setUsePCM ( m_usePCM ); |
|---|
| 349 | m_cTEncTop.setPCMLog2MaxSize ( m_pcmLog2MaxSize); |
|---|
| 350 | m_cTEncTop.setMaxNumMergeCand ( m_maxNumMergeCand ); |
|---|
| 351 | |
|---|
| 352 | |
|---|
| 353 | //====== Weighted Prediction ======== |
|---|
| 354 | m_cTEncTop.setUseWP ( m_useWeightedPred ); |
|---|
| 355 | m_cTEncTop.setWPBiPred ( m_useWeightedBiPred ); |
|---|
| 356 | //====== Parallel Merge Estimation ======== |
|---|
| 357 | m_cTEncTop.setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 ); |
|---|
| 358 | |
|---|
| 359 | //====== Slice ======== |
|---|
| 360 | m_cTEncTop.setSliceMode ( m_sliceMode ); |
|---|
| 361 | m_cTEncTop.setSliceArgument ( m_sliceArgument ); |
|---|
| 362 | |
|---|
| 363 | //====== Dependent Slice ======== |
|---|
| 364 | m_cTEncTop.setSliceSegmentMode ( m_sliceSegmentMode ); |
|---|
| 365 | m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument ); |
|---|
| 366 | Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1); |
|---|
| 367 | if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU) |
|---|
| 368 | { |
|---|
| 369 | m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU ); |
|---|
| 370 | } |
|---|
| 371 | if(m_sliceMode==FIXED_NUMBER_OF_LCU) |
|---|
| 372 | { |
|---|
| 373 | m_cTEncTop.setSliceArgument ( m_sliceArgument * iNumPartInCU ); |
|---|
| 374 | } |
|---|
| 375 | if(m_sliceMode==FIXED_NUMBER_OF_TILES) |
|---|
| 376 | { |
|---|
| 377 | m_cTEncTop.setSliceArgument ( m_sliceArgument ); |
|---|
| 378 | } |
|---|
| 379 | |
|---|
| 380 | if(m_sliceMode == 0 ) |
|---|
| 381 | { |
|---|
| 382 | m_bLFCrossSliceBoundaryFlag = true; |
|---|
| 383 | } |
|---|
| 384 | m_cTEncTop.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); |
|---|
| 385 | #if H_MV |
|---|
| 386 | m_cTEncTop.setUseSAO ( m_bUseSAO[layerIdInVps] ); |
|---|
| 387 | #else |
|---|
| 388 | m_cTEncTop.setUseSAO ( m_bUseSAO ); |
|---|
| 389 | #endif |
|---|
| 390 | m_cTEncTop.setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic); |
|---|
| 391 | |
|---|
| 392 | m_cTEncTop.setSaoLcuBoundary (m_saoLcuBoundary); |
|---|
| 393 | m_cTEncTop.setSaoLcuBasedOptimization (m_saoLcuBasedOptimization); |
|---|
| 394 | m_cTEncTop.setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag); |
|---|
| 395 | m_cTEncTop.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag); |
|---|
| 396 | |
|---|
| 397 | m_cTEncTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); |
|---|
| 398 | m_cTEncTop.setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled ); |
|---|
| 399 | m_cTEncTop.setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled ); |
|---|
| 400 | m_cTEncTop.setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled ); |
|---|
| 401 | m_cTEncTop.setToneMappingInfoSEIEnabled ( m_toneMappingInfoSEIEnabled ); |
|---|
| 402 | m_cTEncTop.setTMISEIToneMapId ( m_toneMapId ); |
|---|
| 403 | m_cTEncTop.setTMISEIToneMapCancelFlag ( m_toneMapCancelFlag ); |
|---|
| 404 | m_cTEncTop.setTMISEIToneMapPersistenceFlag ( m_toneMapPersistenceFlag ); |
|---|
| 405 | m_cTEncTop.setTMISEICodedDataBitDepth ( m_toneMapCodedDataBitDepth ); |
|---|
| 406 | m_cTEncTop.setTMISEITargetBitDepth ( m_toneMapTargetBitDepth ); |
|---|
| 407 | m_cTEncTop.setTMISEIModelID ( m_toneMapModelId ); |
|---|
| 408 | m_cTEncTop.setTMISEIMinValue ( m_toneMapMinValue ); |
|---|
| 409 | m_cTEncTop.setTMISEIMaxValue ( m_toneMapMaxValue ); |
|---|
| 410 | m_cTEncTop.setTMISEISigmoidMidpoint ( m_sigmoidMidpoint ); |
|---|
| 411 | m_cTEncTop.setTMISEISigmoidWidth ( m_sigmoidWidth ); |
|---|
| 412 | m_cTEncTop.setTMISEIStartOfCodedInterva ( m_startOfCodedInterval ); |
|---|
| 413 | m_cTEncTop.setTMISEINumPivots ( m_numPivots ); |
|---|
| 414 | m_cTEncTop.setTMISEICodedPivotValue ( m_codedPivotValue ); |
|---|
| 415 | m_cTEncTop.setTMISEITargetPivotValue ( m_targetPivotValue ); |
|---|
| 416 | m_cTEncTop.setTMISEICameraIsoSpeedIdc ( m_cameraIsoSpeedIdc ); |
|---|
| 417 | m_cTEncTop.setTMISEICameraIsoSpeedValue ( m_cameraIsoSpeedValue ); |
|---|
| 418 | m_cTEncTop.setTMISEIExposureCompensationValueSignFlag ( m_exposureCompensationValueSignFlag ); |
|---|
| 419 | m_cTEncTop.setTMISEIExposureCompensationValueNumerator ( m_exposureCompensationValueNumerator ); |
|---|
| 420 | m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc ( m_exposureCompensationValueDenomIdc ); |
|---|
| 421 | m_cTEncTop.setTMISEIRefScreenLuminanceWhite ( m_refScreenLuminanceWhite ); |
|---|
| 422 | m_cTEncTop.setTMISEIExtendedRangeWhiteLevel ( m_extendedRangeWhiteLevel ); |
|---|
| 423 | m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue ( m_nominalBlackLevelLumaCodeValue ); |
|---|
| 424 | m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue ( m_nominalWhiteLevelLumaCodeValue ); |
|---|
| 425 | m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue ( m_extendedWhiteLevelLumaCodeValue ); |
|---|
| 426 | m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled ); |
|---|
| 427 | m_cTEncTop.setFramePackingArrangementSEIType( m_framePackingSEIType ); |
|---|
| 428 | m_cTEncTop.setFramePackingArrangementSEIId( m_framePackingSEIId ); |
|---|
| 429 | m_cTEncTop.setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx ); |
|---|
| 430 | m_cTEncTop.setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation ); |
|---|
| 431 | m_cTEncTop.setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle ); |
|---|
| 432 | m_cTEncTop.setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled ); |
|---|
| 433 | m_cTEncTop.setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled ); |
|---|
| 434 | m_cTEncTop.setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled ); |
|---|
| 435 | m_cTEncTop.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled ); |
|---|
| 436 | m_cTEncTop.setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled ); |
|---|
| 437 | m_cTEncTop.setUniformSpacingIdr ( m_iUniformSpacingIdr ); |
|---|
| 438 | m_cTEncTop.setNumColumnsMinus1 ( m_iNumColumnsMinus1 ); |
|---|
| 439 | m_cTEncTop.setNumRowsMinus1 ( m_iNumRowsMinus1 ); |
|---|
| 440 | if(m_iUniformSpacingIdr==0) |
|---|
| 441 | { |
|---|
| 442 | m_cTEncTop.setColumnWidth ( m_pColumnWidth ); |
|---|
| 443 | m_cTEncTop.setRowHeight ( m_pRowHeight ); |
|---|
| 444 | } |
|---|
| 445 | m_cTEncTop.xCheckGSParameters(); |
|---|
| 446 | Int uiTilesCount = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1); |
|---|
| 447 | if(uiTilesCount == 1) |
|---|
| 448 | { |
|---|
| 449 | m_bLFCrossTileBoundaryFlag = true; |
|---|
| 450 | } |
|---|
| 451 | m_cTEncTop.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); |
|---|
| 452 | m_cTEncTop.setWaveFrontSynchro ( m_iWaveFrontSynchro ); |
|---|
| 453 | m_cTEncTop.setWaveFrontSubstreams ( m_iWaveFrontSubstreams ); |
|---|
| 454 | m_cTEncTop.setTMVPModeId ( m_TMVPModeId ); |
|---|
| 455 | m_cTEncTop.setUseScalingListId ( m_useScalingListId ); |
|---|
| 456 | m_cTEncTop.setScalingListFile ( m_scalingListFile ); |
|---|
| 457 | m_cTEncTop.setSignHideFlag(m_signHideFlag); |
|---|
| 458 | #if RATE_CONTROL_LAMBDA_DOMAIN |
|---|
| 459 | #if KWU_RC_VIEWRC_E0227 || KWU_RC_MADPRED_E0227 |
|---|
| 460 | if(!m_cTEncTop.getIsDepth()) //only for texture |
|---|
| 461 | { |
|---|
| 462 | m_cTEncTop.setUseRateCtrl ( m_RCEnableRateControl ); |
|---|
| 463 | } |
|---|
| 464 | else |
|---|
| 465 | { |
|---|
| 466 | m_cTEncTop.setUseRateCtrl ( 0 ); |
|---|
| 467 | } |
|---|
| 468 | #else |
|---|
| 469 | m_cTEncTop.setUseRateCtrl ( m_RCEnableRateControl ); |
|---|
| 470 | #endif |
|---|
| 471 | #if !KWU_RC_VIEWRC_E0227 |
|---|
| 472 | m_cTEncTop.setTargetBitrate ( m_RCTargetBitrate ); |
|---|
| 473 | #endif |
|---|
| 474 | m_cTEncTop.setKeepHierBit ( m_RCKeepHierarchicalBit ); |
|---|
| 475 | m_cTEncTop.setLCULevelRC ( m_RCLCULevelRC ); |
|---|
| 476 | m_cTEncTop.setUseLCUSeparateModel ( m_RCUseLCUSeparateModel ); |
|---|
| 477 | m_cTEncTop.setInitialQP ( m_RCInitialQP ); |
|---|
| 478 | m_cTEncTop.setForceIntraQP ( m_RCForceIntraQP ); |
|---|
| 479 | |
|---|
| 480 | #if KWU_RC_MADPRED_E0227 |
|---|
| 481 | if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth()) |
|---|
| 482 | { |
|---|
| 483 | m_cTEncTop.setUseDepthMADPred(layerIdInVps ? m_depthMADPred : 0); |
|---|
| 484 | |
|---|
| 485 | if(m_cTEncTop.getUseDepthMADPred()) |
|---|
| 486 | { |
|---|
| 487 | m_cTEncTop.setCamParam(&m_cCameraData); |
|---|
| 488 | } |
|---|
| 489 | } |
|---|
| 490 | #endif |
|---|
| 491 | #if KWU_RC_VIEWRC_E0227 |
|---|
| 492 | if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth()) |
|---|
| 493 | { |
|---|
| 494 | m_cTEncTop.setUseViewWiseRateCtrl(m_viewWiseRateCtrl); |
|---|
| 495 | |
|---|
| 496 | if(m_iNumberOfViews == 1) |
|---|
| 497 | { |
|---|
| 498 | if(m_viewWiseRateCtrl) |
|---|
| 499 | { |
|---|
| 500 | m_cTEncTop.setTargetBitrate(m_viewTargetBits[layerIdInVps>>1]); |
|---|
| 501 | } |
|---|
| 502 | else |
|---|
| 503 | { |
|---|
| 504 | m_cTEncTop.setTargetBitrate ( m_RCTargetBitrate ); |
|---|
| 505 | } |
|---|
| 506 | } |
|---|
| 507 | else |
|---|
| 508 | { |
|---|
| 509 | if(m_viewWiseRateCtrl) |
|---|
| 510 | { |
|---|
| 511 | m_cTEncTop.setTargetBitrate(m_viewTargetBits[layerIdInVps>>1]); |
|---|
| 512 | } |
|---|
| 513 | else |
|---|
| 514 | { |
|---|
| 515 | if(m_iNumberOfViews == 2) |
|---|
| 516 | { |
|---|
| 517 | if(m_cTEncTop.getViewId() == 0) |
|---|
| 518 | { |
|---|
| 519 | m_cTEncTop.setTargetBitrate ( (m_RCTargetBitrate*80)/100 ); |
|---|
| 520 | } |
|---|
| 521 | else if(m_cTEncTop.getViewId() == 1) |
|---|
| 522 | { |
|---|
| 523 | m_cTEncTop.setTargetBitrate ( (m_RCTargetBitrate*20)/100 ); |
|---|
| 524 | } |
|---|
| 525 | } |
|---|
| 526 | else if(m_iNumberOfViews == 3) |
|---|
| 527 | { |
|---|
| 528 | if(m_cTEncTop.getViewId() == 0) |
|---|
| 529 | { |
|---|
| 530 | m_cTEncTop.setTargetBitrate ( (m_RCTargetBitrate*66)/100 ); |
|---|
| 531 | } |
|---|
| 532 | else if(m_cTEncTop.getViewId() == 1) |
|---|
| 533 | { |
|---|
| 534 | m_cTEncTop.setTargetBitrate ( (m_RCTargetBitrate*17)/100 ); |
|---|
| 535 | } |
|---|
| 536 | else if(m_cTEncTop.getViewId() == 2) |
|---|
| 537 | { |
|---|
| 538 | m_cTEncTop.setTargetBitrate ( (m_RCTargetBitrate*17)/100 ); |
|---|
| 539 | } |
|---|
| 540 | } |
|---|
| 541 | else |
|---|
| 542 | { |
|---|
| 543 | m_cTEncTop.setTargetBitrate ( m_RCTargetBitrate ); |
|---|
| 544 | } |
|---|
| 545 | } |
|---|
| 546 | } |
|---|
| 547 | } |
|---|
| 548 | #endif |
|---|
| 549 | #else |
|---|
| 550 | #if KWU_RC_VIEWRC_E0227 || KWU_RC_MADPRED_E0227 |
|---|
| 551 | if(!m_cTEncTop.getIsDepth()) //only for texture |
|---|
| 552 | { |
|---|
| 553 | m_cTEncTop.setUseRateCtrl ( m_enableRateCtrl ); |
|---|
| 554 | m_cTEncTop.setTargetBitrate ( m_targetBitrate ); |
|---|
| 555 | m_cTEncTop.setNumLCUInUnit ( m_numLCUInUnit); |
|---|
| 556 | } |
|---|
| 557 | else |
|---|
| 558 | { |
|---|
| 559 | m_cTEncTop.setUseRateCtrl ( 0 ); |
|---|
| 560 | } |
|---|
| 561 | #else |
|---|
| 562 | m_cTEncTop.setUseRateCtrl ( m_enableRateCtrl ); |
|---|
| 563 | m_cTEncTop.setTargetBitrate ( m_targetBitrate ); |
|---|
| 564 | m_cTEncTop.setNumLCUInUnit ( m_numLCUInUnit); |
|---|
| 565 | #endif |
|---|
| 566 | |
|---|
| 567 | |
|---|
| 568 | #if KWU_RC_MADPRED_E0227 |
|---|
| 569 | if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth()) |
|---|
| 570 | { |
|---|
| 571 | m_cTEncTop.setUseDepthMADPred(layerIdInVps ? m_depthMADPred : 0); |
|---|
| 572 | |
|---|
| 573 | if(m_cTEncTop.getUseDepthMADPred()) |
|---|
| 574 | { |
|---|
| 575 | m_cTEncTop.setCamParam(&m_cCameraData); |
|---|
| 576 | } |
|---|
| 577 | } |
|---|
| 578 | #endif |
|---|
| 579 | |
|---|
| 580 | #if KWU_RC_VIEWRC_E0227 |
|---|
| 581 | if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth()) |
|---|
| 582 | { |
|---|
| 583 | m_cTEncTop.setUseViewWiseRateCtrl(m_viewWiseRateCtrl); |
|---|
| 584 | if(m_iNumberOfViews == 1) |
|---|
| 585 | { |
|---|
| 586 | if(m_viewWiseRateCtrl) |
|---|
| 587 | { |
|---|
| 588 | m_cTEncTop.setTargetBitrate(m_viewTargetBits[layerIdInVps>>1]); |
|---|
| 589 | } |
|---|
| 590 | else |
|---|
| 591 | { |
|---|
| 592 | m_cTEncTop.setTargetBitrate ( m_targetBitrate ); |
|---|
| 593 | } |
|---|
| 594 | } |
|---|
| 595 | else |
|---|
| 596 | { |
|---|
| 597 | if(m_viewWiseRateCtrl) |
|---|
| 598 | { |
|---|
| 599 | m_cTEncTop.setTargetBitrate(m_viewTargetBits[layerIdInVps>>1]); |
|---|
| 600 | } |
|---|
| 601 | else |
|---|
| 602 | { |
|---|
| 603 | if(m_iNumberOfViews == 2) |
|---|
| 604 | { |
|---|
| 605 | if(m_cTEncTop.getViewId() == 0) |
|---|
| 606 | { |
|---|
| 607 | m_cTEncTop.setTargetBitrate ( (m_targetBitrate*80)/100 ); |
|---|
| 608 | } |
|---|
| 609 | else if(m_cTEncTop.getViewId() == 1) |
|---|
| 610 | { |
|---|
| 611 | m_cTEncTop.setTargetBitrate ( (m_targetBitrate*20)/100 ); |
|---|
| 612 | } |
|---|
| 613 | } |
|---|
| 614 | else if(m_iNumberOfViews == 3) |
|---|
| 615 | { |
|---|
| 616 | if(m_cTEncTop.getViewId() == 0) |
|---|
| 617 | { |
|---|
| 618 | m_cTEncTop.setTargetBitrate ( (m_targetBitrate*66)/100 ); |
|---|
| 619 | } |
|---|
| 620 | else if(m_cTEncTop.getViewId() == 1) |
|---|
| 621 | { |
|---|
| 622 | m_cTEncTop.setTargetBitrate ( (m_targetBitrate*17)/100 ); |
|---|
| 623 | } |
|---|
| 624 | else if(m_cTEncTop.getViewId() == 2) |
|---|
| 625 | { |
|---|
| 626 | m_cTEncTop.setTargetBitrate ( (m_targetBitrate*17)/100 ); |
|---|
| 627 | } |
|---|
| 628 | } |
|---|
| 629 | else |
|---|
| 630 | { |
|---|
| 631 | m_cTEncTop.setTargetBitrate ( m_targetBitrate ); |
|---|
| 632 | } |
|---|
| 633 | } |
|---|
| 634 | } |
|---|
| 635 | } |
|---|
| 636 | #endif |
|---|
| 637 | #endif |
|---|
| 638 | m_cTEncTop.setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag); |
|---|
| 639 | m_cTEncTop.setCUTransquantBypassFlagValue(m_CUTransquantBypassFlagValue); |
|---|
| 640 | m_cTEncTop.setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda ); |
|---|
| 641 | m_cTEncTop.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing ); |
|---|
| 642 | m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); |
|---|
| 643 | m_cTEncTop.setVuiParametersPresentFlag( m_vuiParametersPresentFlag ); |
|---|
| 644 | m_cTEncTop.setAspectRatioIdc( m_aspectRatioIdc ); |
|---|
| 645 | m_cTEncTop.setSarWidth( m_sarWidth ); |
|---|
| 646 | m_cTEncTop.setSarHeight( m_sarHeight ); |
|---|
| 647 | m_cTEncTop.setOverscanInfoPresentFlag( m_overscanInfoPresentFlag ); |
|---|
| 648 | m_cTEncTop.setOverscanAppropriateFlag( m_overscanAppropriateFlag ); |
|---|
| 649 | m_cTEncTop.setVideoSignalTypePresentFlag( m_videoSignalTypePresentFlag ); |
|---|
| 650 | m_cTEncTop.setVideoFormat( m_videoFormat ); |
|---|
| 651 | m_cTEncTop.setVideoFullRangeFlag( m_videoFullRangeFlag ); |
|---|
| 652 | m_cTEncTop.setColourDescriptionPresentFlag( m_colourDescriptionPresentFlag ); |
|---|
| 653 | m_cTEncTop.setColourPrimaries( m_colourPrimaries ); |
|---|
| 654 | m_cTEncTop.setTransferCharacteristics( m_transferCharacteristics ); |
|---|
| 655 | m_cTEncTop.setMatrixCoefficients( m_matrixCoefficients ); |
|---|
| 656 | m_cTEncTop.setChromaLocInfoPresentFlag( m_chromaLocInfoPresentFlag ); |
|---|
| 657 | m_cTEncTop.setChromaSampleLocTypeTopField( m_chromaSampleLocTypeTopField ); |
|---|
| 658 | m_cTEncTop.setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField ); |
|---|
| 659 | m_cTEncTop.setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag ); |
|---|
| 660 | m_cTEncTop.setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset ); |
|---|
| 661 | m_cTEncTop.setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag ); |
|---|
| 662 | m_cTEncTop.setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag ); |
|---|
| 663 | m_cTEncTop.setNumTicksPocDiffOneMinus1 ( m_numTicksPocDiffOneMinus1 ); |
|---|
| 664 | m_cTEncTop.setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag ); |
|---|
| 665 | m_cTEncTop.setTilesFixedStructureFlag( m_tilesFixedStructureFlag ); |
|---|
| 666 | m_cTEncTop.setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag ); |
|---|
| 667 | m_cTEncTop.setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc ); |
|---|
| 668 | m_cTEncTop.setMaxBytesPerPicDenom( m_maxBytesPerPicDenom ); |
|---|
| 669 | m_cTEncTop.setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom ); |
|---|
| 670 | m_cTEncTop.setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal ); |
|---|
| 671 | m_cTEncTop.setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical ); |
|---|
| 672 | #if H_MV |
|---|
| 673 | } |
|---|
| 674 | #endif |
|---|
| 675 | #if H_3D_VSO |
|---|
| 676 | if ( m_bUseVSO ) |
|---|
| 677 | { |
|---|
| 678 | if ( m_uiVSOMode == 4 ) |
|---|
| 679 | { |
|---|
| 680 | #if H_3D_VSO_EARLY_SKIP |
|---|
| 681 | m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0, m_bVSOEarlySkip ); |
|---|
| 682 | #else |
|---|
| 683 | m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0 ); |
|---|
| 684 | #endif |
|---|
| 685 | for ( Int layer = 0; layer < m_numberOfLayers ; layer++ ) |
|---|
| 686 | { |
|---|
| 687 | TEncTop* pcEncTop = m_acTEncTopList[ layer ]; |
|---|
| 688 | Int iViewNum = pcEncTop->getViewIndex(); |
|---|
| 689 | Int iContent = pcEncTop->getIsDepth() ? 1 : 0; |
|---|
| 690 | Int iNumOfModels = m_cRenModStrParser.getNumOfModelsForView(iViewNum, iContent); |
|---|
| 691 | |
|---|
| 692 | Bool bUseVSO = (iNumOfModels != 0); |
|---|
| 693 | |
|---|
| 694 | pcEncTop->setUseVSO( bUseVSO ); |
|---|
| 695 | pcEncTop->getRdCost()->setRenModel( bUseVSO ? &m_cRendererModel : NULL ); |
|---|
| 696 | |
|---|
| 697 | for (Int iCurModel = 0; iCurModel < iNumOfModels; iCurModel++ ) |
|---|
| 698 | { |
|---|
| 699 | Int iModelNum; Int iLeftViewNum; Int iRightViewNum; Int iDump; Int iOrgRefNum; Int iBlendMode; |
|---|
| 700 | |
|---|
| 701 | m_cRenModStrParser.getSingleModelData ( iViewNum, iContent, iCurModel, iModelNum, iBlendMode, iLeftViewNum, iRightViewNum, iOrgRefNum, iDump ) ; |
|---|
| 702 | m_cRendererModel .createSingleModel ( iViewNum, iContent, iModelNum, iLeftViewNum, iRightViewNum, (iOrgRefNum != -1), iBlendMode ); |
|---|
| 703 | } |
|---|
| 704 | } |
|---|
| 705 | } |
|---|
| 706 | else |
|---|
| 707 | { |
|---|
| 708 | AOT(true); |
|---|
| 709 | } |
|---|
| 710 | } |
|---|
| 711 | #endif |
|---|
| 712 | } |
|---|
| 713 | |
|---|
| 714 | Void TAppEncTop::xCreateLib() |
|---|
| 715 | { |
|---|
| 716 | #if H_MV |
|---|
| 717 | // initialize global variables |
|---|
| 718 | initROM(); |
|---|
| 719 | #if H_3D_DIM_DMM |
|---|
| 720 | initWedgeLists( true ); |
|---|
| 721 | #endif |
|---|
| 722 | |
|---|
| 723 | for( Int layer=0; layer < m_numberOfLayers; layer++) |
|---|
| 724 | { |
|---|
| 725 | m_acTVideoIOYuvInputFileList[layer]->open( m_pchInputFileList[layer], false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // read mode |
|---|
| 726 | m_acTVideoIOYuvInputFileList[layer]->skipFrames( m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]); |
|---|
| 727 | |
|---|
| 728 | if (m_pchReconFileList[layer]) |
|---|
| 729 | { |
|---|
| 730 | m_acTVideoIOYuvReconFileList[layer]->open( m_pchReconFileList[layer], true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC); // write mode |
|---|
| 731 | } |
|---|
| 732 | m_acTEncTopList[layer]->create(); |
|---|
| 733 | } |
|---|
| 734 | #else |
|---|
| 735 | // Video I/O |
|---|
| 736 | m_cTVideoIOYuvInputFile.open( m_pchInputFile, false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // read mode |
|---|
| 737 | m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]); |
|---|
| 738 | |
|---|
| 739 | if (m_pchReconFile) |
|---|
| 740 | m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC); // write mode |
|---|
| 741 | |
|---|
| 742 | // Neo Decoder |
|---|
| 743 | m_cTEncTop.create(); |
|---|
| 744 | #endif |
|---|
| 745 | } |
|---|
| 746 | |
|---|
| 747 | Void TAppEncTop::xDestroyLib() |
|---|
| 748 | { |
|---|
| 749 | #if H_MV |
|---|
| 750 | // destroy ROM |
|---|
| 751 | destroyROM(); |
|---|
| 752 | |
|---|
| 753 | for(Int layer=0; layer<m_numberOfLayers; layer++) |
|---|
| 754 | { |
|---|
| 755 | m_acTVideoIOYuvInputFileList[layer]->close(); |
|---|
| 756 | m_acTVideoIOYuvReconFileList[layer]->close(); |
|---|
| 757 | delete m_acTVideoIOYuvInputFileList[layer] ; |
|---|
| 758 | m_acTVideoIOYuvInputFileList[layer] = NULL; |
|---|
| 759 | delete m_acTVideoIOYuvReconFileList[layer] ; |
|---|
| 760 | m_acTVideoIOYuvReconFileList[layer] = NULL; |
|---|
| 761 | m_acTEncTopList[layer]->deletePicBuffer(); |
|---|
| 762 | m_acTEncTopList[layer]->destroy(); |
|---|
| 763 | delete m_acTEncTopList[layer] ; |
|---|
| 764 | m_acTEncTopList[layer] = NULL; |
|---|
| 765 | delete m_picYuvRec[layer] ; |
|---|
| 766 | m_picYuvRec[layer] = NULL; |
|---|
| 767 | } |
|---|
| 768 | #else |
|---|
| 769 | // Video I/O |
|---|
| 770 | m_cTVideoIOYuvInputFile.close(); |
|---|
| 771 | m_cTVideoIOYuvReconFile.close(); |
|---|
| 772 | |
|---|
| 773 | // Neo Decoder |
|---|
| 774 | m_cTEncTop.destroy(); |
|---|
| 775 | #endif |
|---|
| 776 | } |
|---|
| 777 | |
|---|
| 778 | Void TAppEncTop::xInitLib(Bool isFieldCoding) |
|---|
| 779 | { |
|---|
| 780 | #if CAM_HLS_F0136_F0045_F0082 |
|---|
| 781 | for ( Int viewIndex = 0; viewIndex < m_vps.getNumViews(); viewIndex++ ) |
|---|
| 782 | { |
|---|
| 783 | m_vps.initCamParaVPS( viewIndex, true, m_cCameraData.getCamParsCodedPrecision(), |
|---|
| 784 | m_cCameraData.getVaryingCameraParameters(), m_cCameraData.getCodedScale(), m_cCameraData.getCodedOffset() ); |
|---|
| 785 | } |
|---|
| 786 | #endif |
|---|
| 787 | |
|---|
| 788 | #if H_MV |
|---|
| 789 | for(Int layer=0; layer<m_numberOfLayers; layer++) |
|---|
| 790 | { |
|---|
| 791 | #if KWU_RC_MADPRED_E0227 |
|---|
| 792 | m_acTEncTopList[layer]->init( isFieldCoding, this ); |
|---|
| 793 | #else |
|---|
| 794 | m_acTEncTopList[layer]->init( isFieldCoding ); |
|---|
| 795 | #endif |
|---|
| 796 | } |
|---|
| 797 | #else |
|---|
| 798 | m_cTEncTop.init( isFieldCoding ); |
|---|
| 799 | #endif |
|---|
| 800 | } |
|---|
| 801 | |
|---|
| 802 | // ==================================================================================================================== |
|---|
| 803 | // Public member functions |
|---|
| 804 | // ==================================================================================================================== |
|---|
| 805 | |
|---|
| 806 | /** |
|---|
| 807 | - create internal class |
|---|
| 808 | - initialize internal variable |
|---|
| 809 | - until the end of input YUV file, call encoding function in TEncTop class |
|---|
| 810 | - delete allocated buffers |
|---|
| 811 | - destroy internal class |
|---|
| 812 | . |
|---|
| 813 | */ |
|---|
| 814 | Void TAppEncTop::encode() |
|---|
| 815 | { |
|---|
| 816 | fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out); |
|---|
| 817 | if (!bitstreamFile) |
|---|
| 818 | { |
|---|
| 819 | fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile); |
|---|
| 820 | exit(EXIT_FAILURE); |
|---|
| 821 | } |
|---|
| 822 | |
|---|
| 823 | TComPicYuv* pcPicYuvOrg = new TComPicYuv; |
|---|
| 824 | TComPicYuv* pcPicYuvRec = NULL; |
|---|
| 825 | |
|---|
| 826 | // initialize internal class & member variables |
|---|
| 827 | xInitLibCfg(); |
|---|
| 828 | xCreateLib(); |
|---|
| 829 | xInitLib(m_isField); |
|---|
| 830 | |
|---|
| 831 | // main encoder loop |
|---|
| 832 | #if H_MV |
|---|
| 833 | Bool allEos = false; |
|---|
| 834 | std::vector<Bool> eos ; |
|---|
| 835 | std::vector<Bool> flush ; |
|---|
| 836 | |
|---|
| 837 | Int gopSize = 1; |
|---|
| 838 | Int maxGopSize = 0; |
|---|
| 839 | maxGopSize = (std::max)(maxGopSize, m_acTEncTopList[0]->getGOPSize()); |
|---|
| 840 | |
|---|
| 841 | for(Int layer=0; layer < m_numberOfLayers; layer++ ) |
|---|
| 842 | { |
|---|
| 843 | eos .push_back( false ); |
|---|
| 844 | flush.push_back( false ); |
|---|
| 845 | } |
|---|
| 846 | #else |
|---|
| 847 | Int iNumEncoded = 0; |
|---|
| 848 | Bool bEos = false; |
|---|
| 849 | #endif |
|---|
| 850 | |
|---|
| 851 | list<AccessUnit> outputAccessUnits; ///< list of access units to write out. is populated by the encoding process |
|---|
| 852 | |
|---|
| 853 | // allocate original YUV buffer |
|---|
| 854 | if( m_isField ) |
|---|
| 855 | { |
|---|
| 856 | pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeightOrg, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
|---|
| 857 | } |
|---|
| 858 | else |
|---|
| 859 | { |
|---|
| 860 | pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
|---|
| 861 | } |
|---|
| 862 | |
|---|
| 863 | #if H_MV |
|---|
| 864 | while ( !allEos ) |
|---|
| 865 | { |
|---|
| 866 | for(Int layer=0; layer < m_numberOfLayers; layer++ ) |
|---|
| 867 | { |
|---|
| 868 | Int frmCnt = 0; |
|---|
| 869 | while ( !eos[layer] && !(frmCnt == gopSize)) |
|---|
| 870 | { |
|---|
| 871 | // get buffers |
|---|
| 872 | xGetBuffer(pcPicYuvRec, layer); |
|---|
| 873 | |
|---|
| 874 | // read input YUV file |
|---|
| 875 | m_acTVideoIOYuvInputFileList[layer]->read ( pcPicYuvOrg, m_aiPad ); |
|---|
| 876 | m_acTEncTopList [layer]->initNewPic( pcPicYuvOrg ); |
|---|
| 877 | |
|---|
| 878 | // increase number of received frames |
|---|
| 879 | m_frameRcvd[layer]++; |
|---|
| 880 | |
|---|
| 881 | frmCnt++; |
|---|
| 882 | |
|---|
| 883 | eos[layer] = (m_frameRcvd[layer] == m_framesToBeEncoded); |
|---|
| 884 | allEos = allEos||eos[layer]; |
|---|
| 885 | |
|---|
| 886 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
|---|
| 887 | if (m_acTVideoIOYuvInputFileList[layer]->isEof()) |
|---|
| 888 | { |
|---|
| 889 | flush [layer] = true; |
|---|
| 890 | eos [layer] = true; |
|---|
| 891 | m_frameRcvd [layer]--; |
|---|
| 892 | m_acTEncTopList[layer]->setFramesToBeEncoded(m_frameRcvd[layer]); |
|---|
| 893 | } |
|---|
| 894 | } |
|---|
| 895 | } |
|---|
| 896 | for ( Int gopId=0; gopId < gopSize; gopId++ ) |
|---|
| 897 | { |
|---|
| 898 | #if H_3D |
|---|
| 899 | UInt iNextPoc = m_acTEncTopList[0] -> getFrameId( gopId ); |
|---|
| 900 | if ( iNextPoc < m_framesToBeEncoded ) |
|---|
| 901 | { |
|---|
| 902 | m_cCameraData.update( iNextPoc ); |
|---|
| 903 | } |
|---|
| 904 | #endif |
|---|
| 905 | for(Int layer=0; layer < m_numberOfLayers; layer++ ) |
|---|
| 906 | { |
|---|
| 907 | #if H_3D_VSO |
|---|
| 908 | if( m_bUseVSO && m_bUseEstimatedVSD && iNextPoc < m_framesToBeEncoded ) |
|---|
| 909 | { |
|---|
| 910 | m_cCameraData.setDispCoeff( iNextPoc, m_acTEncTopList[layer]->getViewIndex() ); |
|---|
| 911 | m_acTEncTopList[layer] ->setDispCoeff( m_cCameraData.getDispCoeff() ); |
|---|
| 912 | } |
|---|
| 913 | #endif |
|---|
| 914 | Int iNumEncoded = 0; |
|---|
| 915 | |
|---|
| 916 | // call encoding function for one frame |
|---|
| 917 | m_acTEncTopList[layer]->encode( eos[layer], flush[layer] ? 0 : pcPicYuvOrg, *m_picYuvRec[layer], outputAccessUnits, iNumEncoded, gopId ); |
|---|
| 918 | xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, layer); |
|---|
| 919 | outputAccessUnits.clear(); |
|---|
| 920 | } |
|---|
| 921 | } |
|---|
| 922 | |
|---|
| 923 | #if !RATE_CONTROL_LAMBDA_DOMAIN && KWU_FIX_URQ |
|---|
| 924 | for(Int layer=0; layer < m_numberOfLayers; layer++ ) |
|---|
| 925 | { |
|---|
| 926 | if(m_acTEncTopList[layer]->getUseRateCtrl() && !m_acTEncTopList[layer]->getIsDepth()) |
|---|
| 927 | { |
|---|
| 928 | m_acTEncTopList[layer]->getRateCtrl()->updateRCGOPStatus(); |
|---|
| 929 | } |
|---|
| 930 | } |
|---|
| 931 | #endif |
|---|
| 932 | |
|---|
| 933 | gopSize = maxGopSize; |
|---|
| 934 | } |
|---|
| 935 | for(Int layer=0; layer < m_numberOfLayers; layer++ ) |
|---|
| 936 | { |
|---|
| 937 | m_acTEncTopList[layer]->printSummary( m_acTEncTopList[layer]->getNumAllPicCoded(), m_isField ); |
|---|
| 938 | } |
|---|
| 939 | #else |
|---|
| 940 | while ( !bEos ) |
|---|
| 941 | { |
|---|
| 942 | // get buffers |
|---|
| 943 | xGetBuffer(pcPicYuvRec); |
|---|
| 944 | |
|---|
| 945 | // read input YUV file |
|---|
| 946 | m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, m_aiPad ); |
|---|
| 947 | |
|---|
| 948 | // increase number of received frames |
|---|
| 949 | m_iFrameRcvd++; |
|---|
| 950 | |
|---|
| 951 | bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) ); |
|---|
| 952 | |
|---|
| 953 | Bool flush = 0; |
|---|
| 954 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
|---|
| 955 | if (m_cTVideoIOYuvInputFile.isEof()) |
|---|
| 956 | { |
|---|
| 957 | flush = true; |
|---|
| 958 | bEos = true; |
|---|
| 959 | m_iFrameRcvd--; |
|---|
| 960 | m_cTEncTop.setFramesToBeEncoded(m_iFrameRcvd); |
|---|
| 961 | } |
|---|
| 962 | |
|---|
| 963 | // call encoding function for one frame |
|---|
| 964 | if ( m_isField ) |
|---|
| 965 | { |
|---|
| 966 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst); |
|---|
| 967 | } |
|---|
| 968 | else |
|---|
| 969 | { |
|---|
| 970 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded ); |
|---|
| 971 | } |
|---|
| 972 | |
|---|
| 973 | // write bistream to file if necessary |
|---|
| 974 | if ( iNumEncoded > 0 ) |
|---|
| 975 | { |
|---|
| 976 | xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits); |
|---|
| 977 | outputAccessUnits.clear(); |
|---|
| 978 | } |
|---|
| 979 | } |
|---|
| 980 | |
|---|
| 981 | m_cTEncTop.printSummary(m_isField); |
|---|
| 982 | #endif |
|---|
| 983 | |
|---|
| 984 | // delete original YUV buffer |
|---|
| 985 | pcPicYuvOrg->destroy(); |
|---|
| 986 | delete pcPicYuvOrg; |
|---|
| 987 | pcPicYuvOrg = NULL; |
|---|
| 988 | |
|---|
| 989 | #if !H_MV |
|---|
| 990 | // delete used buffers in encoder class |
|---|
| 991 | m_cTEncTop.deletePicBuffer(); |
|---|
| 992 | #endif |
|---|
| 993 | |
|---|
| 994 | // delete buffers & classes |
|---|
| 995 | xDeleteBuffer(); |
|---|
| 996 | xDestroyLib(); |
|---|
| 997 | |
|---|
| 998 | printRateSummary(); |
|---|
| 999 | |
|---|
| 1000 | #if H_3D_REN_MAX_DEV_OUT |
|---|
| 1001 | Double dMaxDispDiff = m_cCameraData.getMaxShiftDeviation(); |
|---|
| 1002 | |
|---|
| 1003 | if ( !(dMaxDispDiff < 0) ) |
|---|
| 1004 | { |
|---|
| 1005 | printf("\n Max. possible shift error: %12.3f samples.\n", dMaxDispDiff ); |
|---|
| 1006 | } |
|---|
| 1007 | #endif |
|---|
| 1008 | |
|---|
| 1009 | return; |
|---|
| 1010 | } |
|---|
| 1011 | |
|---|
| 1012 | // ==================================================================================================================== |
|---|
| 1013 | // Protected member functions |
|---|
| 1014 | // ==================================================================================================================== |
|---|
| 1015 | |
|---|
| 1016 | /** |
|---|
| 1017 | - application has picture buffer list with size of GOP |
|---|
| 1018 | - picture buffer list acts as ring buffer |
|---|
| 1019 | - end of the list has the latest picture |
|---|
| 1020 | . |
|---|
| 1021 | */ |
|---|
| 1022 | #if H_MV |
|---|
| 1023 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer) |
|---|
| 1024 | #else |
|---|
| 1025 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec) |
|---|
| 1026 | #endif |
|---|
| 1027 | { |
|---|
| 1028 | assert( m_iGOPSize > 0 ); |
|---|
| 1029 | |
|---|
| 1030 | // org. buffer |
|---|
| 1031 | #if H_MV |
|---|
| 1032 | if ( m_picYuvRec[layer]->size() == (UInt)m_iGOPSize ) |
|---|
| 1033 | { |
|---|
| 1034 | rpcPicYuvRec = m_picYuvRec[layer]->popFront(); |
|---|
| 1035 | #else |
|---|
| 1036 | if ( m_cListPicYuvRec.size() == (UInt)m_iGOPSize ) |
|---|
| 1037 | { |
|---|
| 1038 | rpcPicYuvRec = m_cListPicYuvRec.popFront(); |
|---|
| 1039 | #endif |
|---|
| 1040 | |
|---|
| 1041 | } |
|---|
| 1042 | else |
|---|
| 1043 | { |
|---|
| 1044 | rpcPicYuvRec = new TComPicYuv; |
|---|
| 1045 | |
|---|
| 1046 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
|---|
| 1047 | |
|---|
| 1048 | } |
|---|
| 1049 | #if H_MV |
|---|
| 1050 | m_picYuvRec[layer]->pushBack( rpcPicYuvRec ); |
|---|
| 1051 | #else |
|---|
| 1052 | m_cListPicYuvRec.pushBack( rpcPicYuvRec ); |
|---|
| 1053 | #endif |
|---|
| 1054 | } |
|---|
| 1055 | |
|---|
| 1056 | Void TAppEncTop::xDeleteBuffer( ) |
|---|
| 1057 | { |
|---|
| 1058 | #if H_MV |
|---|
| 1059 | for(Int layer=0; layer<m_picYuvRec.size(); layer++) |
|---|
| 1060 | { |
|---|
| 1061 | if(m_picYuvRec[layer]) |
|---|
| 1062 | { |
|---|
| 1063 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layer]->begin(); |
|---|
| 1064 | Int iSize = Int( m_picYuvRec[layer]->size() ); |
|---|
| 1065 | #else |
|---|
| 1066 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.begin(); |
|---|
| 1067 | |
|---|
| 1068 | Int iSize = Int( m_cListPicYuvRec.size() ); |
|---|
| 1069 | #endif |
|---|
| 1070 | |
|---|
| 1071 | for ( Int i = 0; i < iSize; i++ ) |
|---|
| 1072 | { |
|---|
| 1073 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
|---|
| 1074 | pcPicYuvRec->destroy(); |
|---|
| 1075 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
|---|
| 1076 | } |
|---|
| 1077 | |
|---|
| 1078 | #if H_MV |
|---|
| 1079 | } |
|---|
| 1080 | } |
|---|
| 1081 | #endif |
|---|
| 1082 | } |
|---|
| 1083 | |
|---|
| 1084 | /** \param iNumEncoded number of encoded frames |
|---|
| 1085 | */ |
|---|
| 1086 | #if H_MV |
|---|
| 1087 | Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, UInt layerId) |
|---|
| 1088 | #else |
|---|
| 1089 | Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) |
|---|
| 1090 | #endif |
|---|
| 1091 | { |
|---|
| 1092 | if (m_isField) |
|---|
| 1093 | { |
|---|
| 1094 | //Reinterlace fields |
|---|
| 1095 | Int i; |
|---|
| 1096 | #if H_MV |
|---|
| 1097 | if( iNumEncoded > 0 ) |
|---|
| 1098 | { |
|---|
| 1099 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layerId]->end(); |
|---|
| 1100 | #else |
|---|
| 1101 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
|---|
| 1102 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
|---|
| 1103 | #endif |
|---|
| 1104 | |
|---|
| 1105 | for ( i = 0; i < iNumEncoded; i++ ) |
|---|
| 1106 | { |
|---|
| 1107 | --iterPicYuvRec; |
|---|
| 1108 | } |
|---|
| 1109 | |
|---|
| 1110 | for ( i = 0; i < iNumEncoded/2; i++ ) |
|---|
| 1111 | { |
|---|
| 1112 | TComPicYuv* pcPicYuvRecTop = *(iterPicYuvRec++); |
|---|
| 1113 | TComPicYuv* pcPicYuvRecBottom = *(iterPicYuvRec++); |
|---|
| 1114 | |
|---|
| 1115 | #if H_MV |
|---|
| 1116 | if (m_pchReconFileList[layerId]) |
|---|
| 1117 | { |
|---|
| 1118 | m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confLeft, m_confRight, m_confTop, m_confBottom, m_isTopFieldFirst ); |
|---|
| 1119 | } |
|---|
| 1120 | } |
|---|
| 1121 | } |
|---|
| 1122 | |
|---|
| 1123 | if( ! accessUnits.empty() ) |
|---|
| 1124 | { |
|---|
| 1125 | list<AccessUnit>::iterator aUIter; |
|---|
| 1126 | for( aUIter = accessUnits.begin(); aUIter != accessUnits.end(); aUIter++ ) |
|---|
| 1127 | { |
|---|
| 1128 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, *aUIter); |
|---|
| 1129 | rateStatsAccum(*aUIter, stats); |
|---|
| 1130 | } |
|---|
| 1131 | } |
|---|
| 1132 | #else |
|---|
| 1133 | if (m_pchReconFile) |
|---|
| 1134 | { |
|---|
| 1135 | m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confLeft, m_confRight, m_confTop, m_confBottom, m_isTopFieldFirst ); |
|---|
| 1136 | } |
|---|
| 1137 | |
|---|
| 1138 | const AccessUnit& auTop = *(iterBitstream++); |
|---|
| 1139 | const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop); |
|---|
| 1140 | rateStatsAccum(auTop, statsTop); |
|---|
| 1141 | |
|---|
| 1142 | const AccessUnit& auBottom = *(iterBitstream++); |
|---|
| 1143 | const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom); |
|---|
| 1144 | rateStatsAccum(auBottom, statsBottom); |
|---|
| 1145 | } |
|---|
| 1146 | #endif |
|---|
| 1147 | } |
|---|
| 1148 | else |
|---|
| 1149 | { |
|---|
| 1150 | Int i; |
|---|
| 1151 | #if H_MV |
|---|
| 1152 | if( iNumEncoded > 0 ) |
|---|
| 1153 | { |
|---|
| 1154 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layerId]->end(); |
|---|
| 1155 | #else |
|---|
| 1156 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
|---|
| 1157 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
|---|
| 1158 | #endif |
|---|
| 1159 | |
|---|
| 1160 | for ( i = 0; i < iNumEncoded; i++ ) |
|---|
| 1161 | { |
|---|
| 1162 | --iterPicYuvRec; |
|---|
| 1163 | } |
|---|
| 1164 | |
|---|
| 1165 | for ( i = 0; i < iNumEncoded; i++ ) |
|---|
| 1166 | { |
|---|
| 1167 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
|---|
| 1168 | #if H_MV |
|---|
| 1169 | if (m_pchReconFileList[layerId]) |
|---|
| 1170 | { |
|---|
| 1171 | m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom ); |
|---|
| 1172 | } |
|---|
| 1173 | } |
|---|
| 1174 | } |
|---|
| 1175 | if( ! accessUnits.empty() ) |
|---|
| 1176 | { |
|---|
| 1177 | list<AccessUnit>::iterator aUIter; |
|---|
| 1178 | for( aUIter = accessUnits.begin(); aUIter != accessUnits.end(); aUIter++ ) |
|---|
| 1179 | { |
|---|
| 1180 | const vector<unsigned>& stats = writeAnnexB(bitstreamFile, *aUIter); |
|---|
| 1181 | rateStatsAccum(*aUIter, stats); |
|---|
| 1182 | } |
|---|
| 1183 | } |
|---|
| 1184 | #else |
|---|
| 1185 | if (m_pchReconFile) |
|---|
| 1186 | { |
|---|
| 1187 | m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom ); |
|---|
| 1188 | } |
|---|
| 1189 | |
|---|
| 1190 | const AccessUnit& au = *(iterBitstream++); |
|---|
| 1191 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); |
|---|
| 1192 | rateStatsAccum(au, stats); |
|---|
| 1193 | } |
|---|
| 1194 | #endif |
|---|
| 1195 | } |
|---|
| 1196 | } |
|---|
| 1197 | |
|---|
| 1198 | /** |
|---|
| 1199 | * |
|---|
| 1200 | */ |
|---|
| 1201 | void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes) |
|---|
| 1202 | { |
|---|
| 1203 | AccessUnit::const_iterator it_au = au.begin(); |
|---|
| 1204 | vector<UInt>::const_iterator it_stats = annexBsizes.begin(); |
|---|
| 1205 | |
|---|
| 1206 | for (; it_au != au.end(); it_au++, it_stats++) |
|---|
| 1207 | { |
|---|
| 1208 | switch ((*it_au)->m_nalUnitType) |
|---|
| 1209 | { |
|---|
| 1210 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
|---|
| 1211 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
|---|
| 1212 | case NAL_UNIT_CODED_SLICE_TLA_R: |
|---|
| 1213 | case NAL_UNIT_CODED_SLICE_TSA_N: |
|---|
| 1214 | case NAL_UNIT_CODED_SLICE_STSA_R: |
|---|
| 1215 | case NAL_UNIT_CODED_SLICE_STSA_N: |
|---|
| 1216 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
|---|
| 1217 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
|---|
| 1218 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
|---|
| 1219 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
|---|
| 1220 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
|---|
| 1221 | case NAL_UNIT_CODED_SLICE_CRA: |
|---|
| 1222 | case NAL_UNIT_CODED_SLICE_RADL_N: |
|---|
| 1223 | case NAL_UNIT_CODED_SLICE_RADL_R: |
|---|
| 1224 | case NAL_UNIT_CODED_SLICE_RASL_N: |
|---|
| 1225 | case NAL_UNIT_CODED_SLICE_RASL_R: |
|---|
| 1226 | case NAL_UNIT_VPS: |
|---|
| 1227 | case NAL_UNIT_SPS: |
|---|
| 1228 | case NAL_UNIT_PPS: |
|---|
| 1229 | m_essentialBytes += *it_stats; |
|---|
| 1230 | break; |
|---|
| 1231 | default: |
|---|
| 1232 | break; |
|---|
| 1233 | } |
|---|
| 1234 | |
|---|
| 1235 | m_totalBytes += *it_stats; |
|---|
| 1236 | } |
|---|
| 1237 | } |
|---|
| 1238 | |
|---|
| 1239 | void TAppEncTop::printRateSummary() |
|---|
| 1240 | { |
|---|
| 1241 | #if H_MV |
|---|
| 1242 | Double time = (Double) m_frameRcvd[0] / m_iFrameRate; |
|---|
| 1243 | printf("\n"); |
|---|
| 1244 | #else |
|---|
| 1245 | Double time = (Double) m_iFrameRcvd / m_iFrameRate; |
|---|
| 1246 | #endif |
|---|
| 1247 | printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time); |
|---|
| 1248 | #if VERBOSE_RATE |
|---|
| 1249 | printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time); |
|---|
| 1250 | #endif |
|---|
| 1251 | } |
|---|
| 1252 | |
|---|
| 1253 | #if H_3D_DIM_DLT |
|---|
| 1254 | #if DLT_DIFF_CODING_IN_PPS |
|---|
| 1255 | Void TAppEncTop::xAnalyzeInputBaseDepth(UInt layer, UInt uiNumFrames, TComVPS* vps, TComDLT* dlt) |
|---|
| 1256 | #else |
|---|
| 1257 | Void TAppEncTop::xAnalyzeInputBaseDepth(UInt layer, UInt uiNumFrames, TComVPS* vps) |
|---|
| 1258 | #endif |
|---|
| 1259 | { |
|---|
| 1260 | TComPicYuv* pcDepthPicYuvOrg = new TComPicYuv; |
|---|
| 1261 | // allocate original YUV buffer |
|---|
| 1262 | pcDepthPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
|---|
| 1263 | |
|---|
| 1264 | TVideoIOYuv* depthVideoFile = new TVideoIOYuv; |
|---|
| 1265 | |
|---|
| 1266 | UInt uiMaxDepthValue = ((1 << g_bitDepthY)-1); |
|---|
| 1267 | |
|---|
| 1268 | Bool abValidDepths[256]; |
|---|
| 1269 | |
|---|
| 1270 | depthVideoFile->open( m_pchInputFileList[layer], false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // read mode |
|---|
| 1271 | |
|---|
| 1272 | // initialize boolean array |
|---|
| 1273 | for(Int p=0; p<=uiMaxDepthValue; p++) |
|---|
| 1274 | abValidDepths[p] = false; |
|---|
| 1275 | |
|---|
| 1276 | Int iHeight = pcDepthPicYuvOrg->getHeight(); |
|---|
| 1277 | Int iWidth = pcDepthPicYuvOrg->getWidth(); |
|---|
| 1278 | Int iStride = pcDepthPicYuvOrg->getStride(); |
|---|
| 1279 | |
|---|
| 1280 | Pel* pInDM = pcDepthPicYuvOrg->getLumaAddr(); |
|---|
| 1281 | |
|---|
| 1282 | for(Int uiFrame=0; uiFrame < uiNumFrames; uiFrame++ ) |
|---|
| 1283 | { |
|---|
| 1284 | depthVideoFile->read( pcDepthPicYuvOrg, m_aiPad ); |
|---|
| 1285 | |
|---|
| 1286 | // check all pixel values |
|---|
| 1287 | for (Int i=0; i<iHeight; i++) |
|---|
| 1288 | { |
|---|
| 1289 | Int rowOffset = i*iStride; |
|---|
| 1290 | |
|---|
| 1291 | for (Int j=0; j<iWidth; j++) |
|---|
| 1292 | { |
|---|
| 1293 | Pel depthValue = pInDM[rowOffset+j]; |
|---|
| 1294 | abValidDepths[depthValue] = true; |
|---|
| 1295 | } |
|---|
| 1296 | } |
|---|
| 1297 | } |
|---|
| 1298 | |
|---|
| 1299 | depthVideoFile->close(); |
|---|
| 1300 | delete depthVideoFile; |
|---|
| 1301 | |
|---|
| 1302 | pcDepthPicYuvOrg->destroy(); |
|---|
| 1303 | delete pcDepthPicYuvOrg; |
|---|
| 1304 | |
|---|
| 1305 | // convert boolean array to idx2Depth LUT |
|---|
| 1306 | Int* aiIdx2DepthValue = (Int*) calloc(uiMaxDepthValue, sizeof(Int)); |
|---|
| 1307 | Int iNumDepthValues = 0; |
|---|
| 1308 | for(Int p=0; p<=uiMaxDepthValue; p++) |
|---|
| 1309 | { |
|---|
| 1310 | if( abValidDepths[p] == true) |
|---|
| 1311 | { |
|---|
| 1312 | aiIdx2DepthValue[iNumDepthValues++] = p; |
|---|
| 1313 | } |
|---|
| 1314 | } |
|---|
| 1315 | |
|---|
| 1316 | if( uiNumFrames == 0 || numBitsForValue(iNumDepthValues) == g_bitDepthY ) |
|---|
| 1317 | { |
|---|
| 1318 | #if DLT_DIFF_CODING_IN_PPS |
|---|
| 1319 | dlt->setUseDLTFlag(layer, false); |
|---|
| 1320 | #else |
|---|
| 1321 | // don't use DLT |
|---|
| 1322 | vps->setUseDLTFlag(layer, false); |
|---|
| 1323 | #endif |
|---|
| 1324 | } |
|---|
| 1325 | |
|---|
| 1326 | // assign LUT |
|---|
| 1327 | #if DLT_DIFF_CODING_IN_PPS |
|---|
| 1328 | if( dlt->getUseDLTFlag(layer) ) |
|---|
| 1329 | dlt->setDepthLUTs(layer, aiIdx2DepthValue, iNumDepthValues); |
|---|
| 1330 | #else |
|---|
| 1331 | if( vps->getUseDLTFlag(layer) ) |
|---|
| 1332 | vps->setDepthLUTs(layer, aiIdx2DepthValue, iNumDepthValues); |
|---|
| 1333 | #endif |
|---|
| 1334 | |
|---|
| 1335 | // free temporary memory |
|---|
| 1336 | free(aiIdx2DepthValue); |
|---|
| 1337 | } |
|---|
| 1338 | #endif |
|---|
| 1339 | |
|---|
| 1340 | #if H_MV |
|---|
| 1341 | Void TAppEncTop::xSetDimensionIdAndLength( TComVPS& vps ) |
|---|
| 1342 | { |
|---|
| 1343 | vps.setScalabilityMaskFlag( m_scalabilityMask ); |
|---|
| 1344 | for( Int dim = 0; dim < m_dimIds.size(); dim++ ) |
|---|
| 1345 | { |
|---|
| 1346 | vps.setDimensionIdLen( dim, m_dimensionIdLen[ dim ] ); |
|---|
| 1347 | for( Int layer = 0; layer <= vps.getMaxLayersMinus1(); layer++ ) |
|---|
| 1348 | |
|---|
| 1349 | { |
|---|
| 1350 | vps.setDimensionId( layer, dim, m_dimIds[ dim ][ layer ] ); |
|---|
| 1351 | } |
|---|
| 1352 | } |
|---|
| 1353 | |
|---|
| 1354 | Int maxViewId = xGetMax( m_viewId ); |
|---|
| 1355 | |
|---|
| 1356 | Int viewIdLen = gCeilLog2( maxViewId + 1 ); |
|---|
| 1357 | const Int maxViewIdLen = ( 1 << 4 ) - 1; |
|---|
| 1358 | assert( viewIdLen <= maxViewIdLen ); |
|---|
| 1359 | vps.setViewIdLen( viewIdLen ); |
|---|
| 1360 | for (Int i = 0; i < m_iNumberOfViews; i++) |
|---|
| 1361 | { |
|---|
| 1362 | vps.setViewIdVal( i, m_viewId[ i] ); |
|---|
| 1363 | } |
|---|
| 1364 | |
|---|
| 1365 | assert( m_iNumberOfViews == vps.getNumViews() ); |
|---|
| 1366 | } |
|---|
| 1367 | |
|---|
| 1368 | Void TAppEncTop::xSetDependencies( TComVPS& vps ) |
|---|
| 1369 | { |
|---|
| 1370 | // Direct dependency flags + dependency types |
|---|
| 1371 | for( Int depLayer = 1; depLayer < MAX_NUM_LAYERS; depLayer++ ) |
|---|
| 1372 | { |
|---|
| 1373 | for( Int refLayer = 0; refLayer < MAX_NUM_LAYERS; refLayer++ ) |
|---|
| 1374 | { |
|---|
| 1375 | vps.setDirectDependencyFlag( depLayer, refLayer, false); |
|---|
| 1376 | vps.setDirectDependencyType( depLayer, refLayer, -1 ); |
|---|
| 1377 | } |
|---|
| 1378 | } |
|---|
| 1379 | |
|---|
| 1380 | Int defaultDirectDependencyType = -1; |
|---|
| 1381 | Bool defaultDirectDependencyFlag = true; |
|---|
| 1382 | for( Int depLayer = 1; depLayer < m_numberOfLayers; depLayer++ ) |
|---|
| 1383 | { |
|---|
| 1384 | Int numRefLayers = (Int) m_directRefLayers[depLayer].size(); |
|---|
| 1385 | assert( numRefLayers == (Int) m_dependencyTypes[depLayer].size() ); |
|---|
| 1386 | for( Int i = 0; i < numRefLayers; i++ ) |
|---|
| 1387 | { |
|---|
| 1388 | Int refLayer = m_directRefLayers[depLayer][i]; |
|---|
| 1389 | vps.setDirectDependencyFlag( depLayer, refLayer, true); |
|---|
| 1390 | Int curDirectDependencyType = m_dependencyTypes[depLayer][i]; |
|---|
| 1391 | |
|---|
| 1392 | if ( defaultDirectDependencyType != -1 ) |
|---|
| 1393 | { |
|---|
| 1394 | defaultDirectDependencyFlag = defaultDirectDependencyFlag && (curDirectDependencyType == defaultDirectDependencyType ); |
|---|
| 1395 | } |
|---|
| 1396 | else |
|---|
| 1397 | { |
|---|
| 1398 | defaultDirectDependencyType = curDirectDependencyType; |
|---|
| 1399 | } |
|---|
| 1400 | |
|---|
| 1401 | vps.setDirectDependencyType( depLayer, refLayer, curDirectDependencyType); |
|---|
| 1402 | } |
|---|
| 1403 | } |
|---|
| 1404 | |
|---|
| 1405 | vps.setDefaultDirectDependencyFlag( defaultDirectDependencyFlag ); |
|---|
| 1406 | vps.setDefaultDirectDependencyType( defaultDirectDependencyFlag ? defaultDirectDependencyType : -1 ); |
|---|
| 1407 | |
|---|
| 1408 | // Max sub layers, + presence flag |
|---|
| 1409 | Bool subLayersMaxMinus1PresentFlag = false; |
|---|
| 1410 | Int subLayersMaxMinus1 = -1; |
|---|
| 1411 | for (Int curLayerIdInVps = 0; curLayerIdInVps < m_numberOfLayers; curLayerIdInVps++ ) |
|---|
| 1412 | { |
|---|
| 1413 | Int curSubLayersMaxMinus1 = -1; |
|---|
| 1414 | for( Int i = 0; i < getGOPSize(); i++ ) |
|---|
| 1415 | { |
|---|
| 1416 | GOPEntry geCur = m_GOPListMvc[curLayerIdInVps][i]; |
|---|
| 1417 | curSubLayersMaxMinus1 = std::max( curSubLayersMaxMinus1, geCur.m_temporalId ); |
|---|
| 1418 | } |
|---|
| 1419 | |
|---|
| 1420 | vps.setSubLayersVpsMaxMinus1( curLayerIdInVps, curSubLayersMaxMinus1 ); |
|---|
| 1421 | if ( subLayersMaxMinus1 == -1 ) |
|---|
| 1422 | { |
|---|
| 1423 | subLayersMaxMinus1 = curSubLayersMaxMinus1; |
|---|
| 1424 | } |
|---|
| 1425 | else |
|---|
| 1426 | { |
|---|
| 1427 | subLayersMaxMinus1PresentFlag = subLayersMaxMinus1PresentFlag || ( curSubLayersMaxMinus1 != subLayersMaxMinus1 ); |
|---|
| 1428 | } |
|---|
| 1429 | } |
|---|
| 1430 | |
|---|
| 1431 | vps.setVpsSubLayersMaxMinus1PresentFlag( subLayersMaxMinus1PresentFlag ); |
|---|
| 1432 | |
|---|
| 1433 | |
|---|
| 1434 | // Max temporal id for inter layer reference pictures + presence flag |
|---|
| 1435 | Bool maxTidRefPresentFlag = false; |
|---|
| 1436 | for ( Int refLayerIdInVps = 0; refLayerIdInVps < m_numberOfLayers; refLayerIdInVps++) |
|---|
| 1437 | { |
|---|
| 1438 | for ( Int curLayerIdInVps = 1; curLayerIdInVps < m_numberOfLayers; curLayerIdInVps++) |
|---|
| 1439 | { |
|---|
| 1440 | Int maxTid = -1; |
|---|
| 1441 | for( Int i = 0; i < getGOPSize(); i++ ) |
|---|
| 1442 | { |
|---|
| 1443 | GOPEntry geCur = m_GOPListMvc[curLayerIdInVps][i]; |
|---|
| 1444 | GOPEntry geRef = m_GOPListMvc[refLayerIdInVps][i]; |
|---|
| 1445 | |
|---|
| 1446 | for (Int j = 0; j < geCur.m_numActiveRefLayerPics; j++) |
|---|
| 1447 | { |
|---|
| 1448 | if ( m_directRefLayers[ curLayerIdInVps ][ geCur.m_interLayerPredLayerIdc[ j ]] == refLayerIdInVps ) |
|---|
| 1449 | { |
|---|
| 1450 | maxTid = std::max( maxTid, geRef.m_temporalId ); |
|---|
| 1451 | } |
|---|
| 1452 | } |
|---|
| 1453 | } |
|---|
| 1454 | vps.setMaxTidIlRefPicsPlus1( refLayerIdInVps, curLayerIdInVps, maxTid + 1 ); |
|---|
| 1455 | maxTidRefPresentFlag = maxTidRefPresentFlag || ( maxTid != 6 ); |
|---|
| 1456 | } |
|---|
| 1457 | } |
|---|
| 1458 | |
|---|
| 1459 | vps.setMaxTidRefPresentFlag( maxTidRefPresentFlag ); |
|---|
| 1460 | // Max one active ref layer flag |
|---|
| 1461 | Bool maxOneActiveRefLayerFlag = true; |
|---|
| 1462 | for ( Int layerIdInVps = 1; layerIdInVps < m_numberOfLayers && maxOneActiveRefLayerFlag; layerIdInVps++) |
|---|
| 1463 | { |
|---|
| 1464 | for( Int i = 0; i < ( getGOPSize() + 1) && maxOneActiveRefLayerFlag; i++ ) |
|---|
| 1465 | { |
|---|
| 1466 | GOPEntry ge = m_GOPListMvc[layerIdInVps][ ( i < getGOPSize() ? i : MAX_GOP ) ]; |
|---|
| 1467 | maxOneActiveRefLayerFlag = maxOneActiveRefLayerFlag && (ge.m_numActiveRefLayerPics <= 1); |
|---|
| 1468 | } |
|---|
| 1469 | } |
|---|
| 1470 | |
|---|
| 1471 | vps.setMaxOneActiveRefLayerFlag( maxOneActiveRefLayerFlag ); |
|---|
| 1472 | |
|---|
| 1473 | // Poc Lsb Not Present Flag |
|---|
| 1474 | for ( Int layerIdInVps = 1; layerIdInVps < m_numberOfLayers; layerIdInVps++) |
|---|
| 1475 | { |
|---|
| 1476 | if ( m_directRefLayers[ layerIdInVps ].size() == 0 ) |
|---|
| 1477 | { |
|---|
| 1478 | vps.setPocLsbNotPresentFlag( layerIdInVps, true ); |
|---|
| 1479 | } |
|---|
| 1480 | } |
|---|
| 1481 | |
|---|
| 1482 | // All Ref layers active flag |
|---|
| 1483 | Bool allRefLayersActiveFlag = true; |
|---|
| 1484 | for ( Int layerIdInVps = 1; layerIdInVps < m_numberOfLayers && allRefLayersActiveFlag; layerIdInVps++) |
|---|
| 1485 | { |
|---|
| 1486 | for( Int i = 0; i < ( getGOPSize() + 1) && allRefLayersActiveFlag; i++ ) |
|---|
| 1487 | { |
|---|
| 1488 | GOPEntry ge = m_GOPListMvc[layerIdInVps][ ( i < getGOPSize() ? i : MAX_GOP ) ]; |
|---|
| 1489 | Int tId = ge.m_temporalId; // Should be equal for all layers. |
|---|
| 1490 | |
|---|
| 1491 | // check if all reference layers when allRefLayerActiveFlag is equal to 1 are reference layer pictures specified in the gop entry |
|---|
| 1492 | for (Int k = 0; k < m_directRefLayers[ layerIdInVps].size() && allRefLayersActiveFlag; k++ ) |
|---|
| 1493 | { |
|---|
| 1494 | Int refLayerIdInVps = vps.getLayerIdInVps( m_directRefLayers[ layerIdInVps ][ k ] ); |
|---|
| 1495 | if ( vps.getMaxTidIlRefPicsPlus1(refLayerIdInVps,layerIdInVps) > tId && vps.getSubLayersVpsMaxMinus1(refLayerIdInVps) >= tId ) |
|---|
| 1496 | { |
|---|
| 1497 | Bool gopEntryFoundFlag = false; |
|---|
| 1498 | for( Int l = 0; l < ge.m_numActiveRefLayerPics && !gopEntryFoundFlag; l++ ) |
|---|
| 1499 | { |
|---|
| 1500 | gopEntryFoundFlag = gopEntryFoundFlag || ( ge.m_interLayerPredLayerIdc[l] == k ); |
|---|
| 1501 | } |
|---|
| 1502 | allRefLayersActiveFlag = allRefLayersActiveFlag && gopEntryFoundFlag; |
|---|
| 1503 | } |
|---|
| 1504 | } |
|---|
| 1505 | |
|---|
| 1506 | // check if all inter layer reference pictures specified in the gop entry are valid reference layer pictures when allRefLayerActiveFlag is equal to 1 |
|---|
| 1507 | // (Should actually always be true) |
|---|
| 1508 | Bool maxTidIlRefAndSubLayerMaxVaildFlag = true; |
|---|
| 1509 | for( Int l = 0; l < ge.m_numActiveRefLayerPics; l++ ) |
|---|
| 1510 | { |
|---|
| 1511 | Bool referenceLayerFoundFlag = false; |
|---|
| 1512 | for (Int k = 0; k < m_directRefLayers[ layerIdInVps].size(); k++ ) |
|---|
| 1513 | { |
|---|
| 1514 | Int refLayerIdInVps = vps.getLayerIdInVps( m_directRefLayers[ layerIdInVps ][ k ] ); |
|---|
| 1515 | |
|---|
| 1516 | if ( vps.getMaxTidIlRefPicsPlus1(refLayerIdInVps,layerIdInVps) > tId && vps.getSubLayersVpsMaxMinus1(refLayerIdInVps) >= tId ) |
|---|
| 1517 | { |
|---|
| 1518 | referenceLayerFoundFlag = referenceLayerFoundFlag || ( ge.m_interLayerPredLayerIdc[l] == k ); |
|---|
| 1519 | } |
|---|
| 1520 | } |
|---|
| 1521 | maxTidIlRefAndSubLayerMaxVaildFlag = maxTidIlRefAndSubLayerMaxVaildFlag && referenceLayerFoundFlag; |
|---|
| 1522 | } |
|---|
| 1523 | assert ( maxTidIlRefAndSubLayerMaxVaildFlag ); // Something wrong with MaxTidIlRefPicsPlus1 or SubLayersVpsMaxMinus1 |
|---|
| 1524 | } |
|---|
| 1525 | } |
|---|
| 1526 | |
|---|
| 1527 | vps.setAllRefLayersActiveFlag( allRefLayersActiveFlag ); |
|---|
| 1528 | |
|---|
| 1529 | vps.setRefLayers(); |
|---|
| 1530 | }; |
|---|
| 1531 | |
|---|
| 1532 | GOPEntry* TAppEncTop::xGetGopEntry( Int layerIdInVps, Int poc ) |
|---|
| 1533 | { |
|---|
| 1534 | GOPEntry* geFound = NULL; |
|---|
| 1535 | for( Int i = 0; i < ( getGOPSize() + 1) && geFound == NULL ; i++ ) |
|---|
| 1536 | { |
|---|
| 1537 | GOPEntry* ge = &(m_GOPListMvc[layerIdInVps][ ( i < getGOPSize() ? i : MAX_GOP ) ]); |
|---|
| 1538 | if ( ge->m_POC == poc ) |
|---|
| 1539 | { |
|---|
| 1540 | geFound = ge; |
|---|
| 1541 | } |
|---|
| 1542 | } |
|---|
| 1543 | assert( geFound != NULL ); |
|---|
| 1544 | return geFound; |
|---|
| 1545 | } |
|---|
| 1546 | |
|---|
| 1547 | Void TAppEncTop::xSetLayerIds( TComVPS& vps ) |
|---|
| 1548 | { |
|---|
| 1549 | vps.setSplittingFlag ( m_splittingFlag ); |
|---|
| 1550 | |
|---|
| 1551 | Bool nuhLayerIdPresentFlag = !( m_layerIdInNuh.size() == 1 ); |
|---|
| 1552 | Int maxNuhLayerId = nuhLayerIdPresentFlag ? xGetMax( m_layerIdInNuh ) : ( m_numberOfLayers - 1 ) ; |
|---|
| 1553 | |
|---|
| 1554 | vps.setVpsMaxLayerId( maxNuhLayerId ); |
|---|
| 1555 | vps.setVpsNuhLayerIdPresentFlag( nuhLayerIdPresentFlag ); |
|---|
| 1556 | |
|---|
| 1557 | for (Int layer = 0; layer < m_numberOfLayers; layer++ ) |
|---|
| 1558 | { |
|---|
| 1559 | vps.setLayerIdInNuh( layer, nuhLayerIdPresentFlag ? m_layerIdInNuh[ layer ] : layer ); |
|---|
| 1560 | vps.setLayerIdInVps( vps.getLayerIdInNuh( layer ), layer ); |
|---|
| 1561 | } |
|---|
| 1562 | } |
|---|
| 1563 | |
|---|
| 1564 | Int TAppEncTop::xGetMax( std::vector<Int>& vec ) |
|---|
| 1565 | { |
|---|
| 1566 | Int maxVec = 0; |
|---|
| 1567 | for ( Int i = 0; i < vec.size(); i++) |
|---|
| 1568 | { |
|---|
| 1569 | maxVec = max( vec[i], maxVec ); |
|---|
| 1570 | } |
|---|
| 1571 | return maxVec; |
|---|
| 1572 | } |
|---|
| 1573 | |
|---|
| 1574 | Void TAppEncTop::xSetProfileTierLevel( TComVPS& vps ) |
|---|
| 1575 | { |
|---|
| 1576 | const Int vpsNumProfileTierLevelMinus1 = 0; //TBD |
|---|
| 1577 | vps.setVpsNumProfileTierLevelMinus1( vpsNumProfileTierLevelMinus1 ); |
|---|
| 1578 | |
|---|
| 1579 | for (Int i = 0; i <= vps.getVpsNumProfileTierLevelMinus1(); i++ ) |
|---|
| 1580 | { |
|---|
| 1581 | vps.setVpsProfilePresentFlag( i, true ); |
|---|
| 1582 | } |
|---|
| 1583 | } |
|---|
| 1584 | |
|---|
| 1585 | |
|---|
| 1586 | Void TAppEncTop::xSetRepFormat( TComVPS& vps ) |
|---|
| 1587 | { |
|---|
| 1588 | vps.setRepFormatIdxPresentFlag( true ); |
|---|
| 1589 | vps.setVpsNumRepFormatsMinus1 ( 0 ); |
|---|
| 1590 | |
|---|
| 1591 | TComRepFormat* repFormat = new TComRepFormat; |
|---|
| 1592 | |
|---|
| 1593 | repFormat->setBitDepthVpsChromaMinus8 ( g_bitDepthC - 8 ); |
|---|
| 1594 | repFormat->setBitDepthVpsLumaMinus8 ( g_bitDepthY - 8 ); |
|---|
| 1595 | repFormat->setChromaFormatVpsIdc ( CHROMA_420 ); |
|---|
| 1596 | repFormat->setPicHeightVpsInLumaSamples ( m_iSourceHeight ); |
|---|
| 1597 | repFormat->setPicWidthVpsInLumaSamples ( m_iSourceWidth ); |
|---|
| 1598 | repFormat->setChromaAndBitDepthVpsPresentFlag( true ); |
|---|
| 1599 | // ToDo not supported yet. |
|---|
| 1600 | //repFormat->setSeparateColourPlaneVpsFlag( ); |
|---|
| 1601 | |
|---|
| 1602 | assert( vps.getRepFormat( 0 ) == NULL ); |
|---|
| 1603 | vps.setRepFormat( 0 , repFormat ); |
|---|
| 1604 | |
|---|
| 1605 | for(Int i = 0; i <= vps.getMaxLayersMinus1(); i++ ) |
|---|
| 1606 | { |
|---|
| 1607 | vps.setVpsRepFormatIdx( i , 0 ); |
|---|
| 1608 | } |
|---|
| 1609 | } |
|---|
| 1610 | |
|---|
| 1611 | Void TAppEncTop::xSetDpbSize ( TComVPS& vps ) |
|---|
| 1612 | { |
|---|
| 1613 | // These settings need to be verified |
|---|
| 1614 | |
|---|
| 1615 | TComDpbSize* dpbSize = vps.getDpbSize(); |
|---|
| 1616 | |
|---|
| 1617 | assert ( dpbSize != 0 ); |
|---|
| 1618 | |
|---|
| 1619 | for( Int i = 1; i < vps.getNumOutputLayerSets(); i++ ) |
|---|
| 1620 | { |
|---|
| 1621 | std::vector<Int> targetDecLayerIdList = vps.getTargetDecLayerIdList( i ); |
|---|
| 1622 | dpbSize->setSubLayerFlagInfoPresentFlag( i, m_subLayerFlagInfoPresentFlag ); |
|---|
| 1623 | |
|---|
| 1624 | if ( dpbSize->getSubLayerFlagInfoPresentFlag( i ) ) |
|---|
| 1625 | { |
|---|
| 1626 | for( Int j = 0; j <= vps.getMaxTLayers() - 1 ; j++ ) |
|---|
| 1627 | { |
|---|
| 1628 | Int maxNumReorderPics = MIN_INT; |
|---|
| 1629 | Int maxDecPicBuffering = MIN_INT; |
|---|
| 1630 | Int maxLatencyIncrease = MIN_INT; |
|---|
| 1631 | |
|---|
| 1632 | Int prevMaxNumReorderPics = MIN_INT; |
|---|
| 1633 | Int prevMaxDecPicBuffering = MIN_INT; |
|---|
| 1634 | Int prevMaxLatencyIncrease = MIN_INT; |
|---|
| 1635 | |
|---|
| 1636 | assert( vps.getNumSubDpbs( vps.getOutputLayerSetIdxMinus1( i ) + 1 ) == targetDecLayerIdList.size() ); |
|---|
| 1637 | for( Int k = 0; k < vps.getNumSubDpbs( vps.getOutputLayerSetIdxMinus1( i ) + 1 ); k++ ) |
|---|
| 1638 | { |
|---|
| 1639 | Int layerIdInVps = vps.getLayerIdInVps( targetDecLayerIdList[k] ); |
|---|
| 1640 | dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, m_maxDecPicBufferingMvc[ layerIdInVps ][ j ] - 1 ); |
|---|
| 1641 | } |
|---|
| 1642 | |
|---|
| 1643 | for ( Int idx = 0; idx < targetDecLayerIdList.size(); idx++ ) |
|---|
| 1644 | { |
|---|
| 1645 | Int layerIdInVps = vps.getLayerIdInVps( targetDecLayerIdList[ idx ] ); |
|---|
| 1646 | maxNumReorderPics = std::max( maxNumReorderPics, m_numReorderPicsMvc[ layerIdInVps ][ j ] ); |
|---|
| 1647 | } |
|---|
| 1648 | assert( maxNumReorderPics != MIN_INT ); |
|---|
| 1649 | dpbSize->setMaxVpsNumReorderPics( i, j, maxNumReorderPics ); |
|---|
| 1650 | |
|---|
| 1651 | // To Be Done ! |
|---|
| 1652 | // dpbSize->setMaxVpsLatencyIncreasePlus1( i, j, uiCode ); |
|---|
| 1653 | |
|---|
| 1654 | if( j > 0 ) |
|---|
| 1655 | { |
|---|
| 1656 | dpbSize->setSubLayerDpbInfoPresentFlag( i, j, prevMaxDecPicBuffering == maxDecPicBuffering && prevMaxLatencyIncrease == maxLatencyIncrease && prevMaxNumReorderPics == maxNumReorderPics ); |
|---|
| 1657 | } |
|---|
| 1658 | |
|---|
| 1659 | prevMaxNumReorderPics = maxNumReorderPics; |
|---|
| 1660 | prevMaxDecPicBuffering = maxDecPicBuffering; |
|---|
| 1661 | prevMaxLatencyIncrease = maxLatencyIncrease; |
|---|
| 1662 | } |
|---|
| 1663 | } |
|---|
| 1664 | } |
|---|
| 1665 | } |
|---|
| 1666 | |
|---|
| 1667 | |
|---|
| 1668 | Void TAppEncTop::xSetLayerSets( TComVPS& vps ) |
|---|
| 1669 | { |
|---|
| 1670 | // Layer sets |
|---|
| 1671 | vps.setVpsNumLayerSetsMinus1 ( m_vpsNumLayerSets - 1 ); |
|---|
| 1672 | vps.setVpsNumberLayerSetsMinus1( vps.getVpsNumLayerSetsMinus1() ); |
|---|
| 1673 | |
|---|
| 1674 | for (Int lsIdx = 0; lsIdx < m_vpsNumLayerSets; lsIdx++ ) |
|---|
| 1675 | { |
|---|
| 1676 | for( Int layerId = 0; layerId < MAX_NUM_LAYER_IDS; layerId++ ) |
|---|
| 1677 | { |
|---|
| 1678 | vps.setLayerIdIncludedFlag( false, lsIdx, layerId ); |
|---|
| 1679 | } |
|---|
| 1680 | for ( Int i = 0; i < m_layerIdsInSets[lsIdx].size(); i++) |
|---|
| 1681 | { |
|---|
| 1682 | vps.setLayerIdIncludedFlag( true, lsIdx, vps.getLayerIdInNuh( m_layerIdsInSets[lsIdx][i] ) ); |
|---|
| 1683 | } |
|---|
| 1684 | } |
|---|
| 1685 | vps.deriveLayerSetLayerIdList(); |
|---|
| 1686 | |
|---|
| 1687 | Int numAddOuputLayerSets = (Int) m_outputLayerSetIdx.size(); |
|---|
| 1688 | // Additional output layer sets + profileLevelTierIdx |
|---|
| 1689 | vps.setDefaultOneTargetOutputLayerIdc ( m_defaultOneTargetOutputLayerIdc ); |
|---|
| 1690 | vps.setMoreOutputLayerSetsThanDefaultFlag( numAddOuputLayerSets != 0 ); |
|---|
| 1691 | vps.setNumAddOutputLayerSetsMinus1 ( numAddOuputLayerSets - 1 ); |
|---|
| 1692 | |
|---|
| 1693 | |
|---|
| 1694 | |
|---|
| 1695 | for (Int lsIdx = 0; lsIdx < m_vpsNumLayerSets; lsIdx++) |
|---|
| 1696 | { |
|---|
| 1697 | if ( lsIdx > 0 ) |
|---|
| 1698 | { |
|---|
| 1699 | vps.setProfileLevelTierIdx( lsIdx, m_profileLevelTierIdx[ lsIdx ] ); |
|---|
| 1700 | } |
|---|
| 1701 | |
|---|
| 1702 | vps.setOutputLayerSetIdxMinus1( lsIdx, lsIdx - 1 ); |
|---|
| 1703 | |
|---|
| 1704 | for (Int i = 0; i < m_layerIdsInSets[ lsIdx ].size(); i++ ) |
|---|
| 1705 | { |
|---|
| 1706 | vps.setOutputLayerFlag( lsIdx, i, vps.inferOutputLayerFlag( lsIdx, i )); |
|---|
| 1707 | } |
|---|
| 1708 | } |
|---|
| 1709 | |
|---|
| 1710 | for (Int addOutLs = 0; addOutLs < numAddOuputLayerSets; addOutLs++ ) |
|---|
| 1711 | { |
|---|
| 1712 | vps.setProfileLevelTierIdx( m_vpsNumLayerSets + addOutLs, m_profileLevelTierIdx[ addOutLs ] ); |
|---|
| 1713 | |
|---|
| 1714 | Int refLayerSetIdx = m_outputLayerSetIdx[ addOutLs ]; |
|---|
| 1715 | vps.setOutputLayerSetIdxMinus1( m_vpsNumLayerSets + addOutLs, refLayerSetIdx - 1 ); |
|---|
| 1716 | |
|---|
| 1717 | for (Int i = 0; i < m_layerIdsInSets[ refLayerSetIdx].size(); i++ ) |
|---|
| 1718 | { |
|---|
| 1719 | Bool outputLayerFlag = false; |
|---|
| 1720 | for (Int j = 0; j < m_layerIdsInAddOutputLayerSet[ addOutLs ].size(); j++ ) |
|---|
| 1721 | { |
|---|
| 1722 | if ( m_layerIdsInAddOutputLayerSet[addOutLs][ j ] == m_layerIdsInSets[ refLayerSetIdx][ i ] ) |
|---|
| 1723 | { |
|---|
| 1724 | outputLayerFlag = true; |
|---|
| 1725 | break; |
|---|
| 1726 | } |
|---|
| 1727 | } |
|---|
| 1728 | vps.setOutputLayerFlag( m_vpsNumLayerSets + addOutLs, i, outputLayerFlag ); |
|---|
| 1729 | } |
|---|
| 1730 | } |
|---|
| 1731 | vps.deriveTargetLayerIdLists(); |
|---|
| 1732 | } |
|---|
| 1733 | |
|---|
| 1734 | Void TAppEncTop::xSetVPSVUI( TComVPS& vps ) |
|---|
| 1735 | { |
|---|
| 1736 | vps.setVpsVuiPresentFlag( m_vpsVuiPresentFlag ); |
|---|
| 1737 | |
|---|
| 1738 | if ( m_vpsVuiPresentFlag ) |
|---|
| 1739 | { |
|---|
| 1740 | TComVPSVUI* pcVPSVUI = vps.getVPSVUI( ); |
|---|
| 1741 | |
|---|
| 1742 | assert( pcVPSVUI ); |
|---|
| 1743 | |
|---|
| 1744 | |
|---|
| 1745 | // All this stuff could actually be derived by the encoder, |
|---|
| 1746 | // however preliminary setting it from input parameters |
|---|
| 1747 | |
|---|
| 1748 | pcVPSVUI->setCrossLayerPicTypeAlignedFlag( m_crossLayerPicTypeAlignedFlag ); |
|---|
| 1749 | pcVPSVUI->setCrossLayerIrapAlignedFlag ( m_crossLayerIrapAlignedFlag ); |
|---|
| 1750 | |
|---|
| 1751 | pcVPSVUI->setBitRatePresentVpsFlag( m_bitRatePresentVpsFlag ); |
|---|
| 1752 | pcVPSVUI->setPicRatePresentVpsFlag( m_picRatePresentVpsFlag ); |
|---|
| 1753 | |
|---|
| 1754 | if( pcVPSVUI->getBitRatePresentVpsFlag( ) || pcVPSVUI->getPicRatePresentVpsFlag( ) ) |
|---|
| 1755 | { |
|---|
| 1756 | for( Int i = 0; i <= vps.getVpsNumberLayerSetsMinus1(); i++ ) |
|---|
| 1757 | { |
|---|
| 1758 | for( Int j = 0; j <= vps.getMaxTLayers(); j++ ) |
|---|
| 1759 | { |
|---|
| 1760 | if( pcVPSVUI->getBitRatePresentVpsFlag( ) && m_bitRatePresentFlag[i].size() > j ) |
|---|
| 1761 | { |
|---|
| 1762 | pcVPSVUI->setBitRatePresentFlag( i, j, m_bitRatePresentFlag[i][j] ); |
|---|
| 1763 | } |
|---|
| 1764 | if( pcVPSVUI->getPicRatePresentVpsFlag( ) && m_picRatePresentFlag[i].size() > j ) |
|---|
| 1765 | { |
|---|
| 1766 | pcVPSVUI->setPicRatePresentFlag( i, j, m_picRatePresentFlag[i][j] ); |
|---|
| 1767 | } |
|---|
| 1768 | if( pcVPSVUI->getBitRatePresentFlag( i, j ) && m_avgBitRate[i].size() > j ) |
|---|
| 1769 | { |
|---|
| 1770 | pcVPSVUI->setAvgBitRate( i, j, m_avgBitRate[i][j] ); |
|---|
| 1771 | } |
|---|
| 1772 | if( pcVPSVUI->getBitRatePresentFlag( i, j ) && m_maxBitRate[i].size() > j ) |
|---|
| 1773 | { |
|---|
| 1774 | pcVPSVUI->setMaxBitRate( i, j, m_maxBitRate[i][j] ); |
|---|
| 1775 | } |
|---|
| 1776 | if( pcVPSVUI->getPicRatePresentFlag( i, j ) && m_constantPicRateIdc[i].size() > j ) |
|---|
| 1777 | { |
|---|
| 1778 | pcVPSVUI->setConstantPicRateIdc( i, j, m_constantPicRateIdc[i][j] ); |
|---|
| 1779 | } |
|---|
| 1780 | if( pcVPSVUI->getPicRatePresentFlag( i, j ) && m_avgPicRate[i].size() > j ) |
|---|
| 1781 | { |
|---|
| 1782 | pcVPSVUI->setAvgPicRate( i, j, m_avgPicRate[i][j] ); |
|---|
| 1783 | } |
|---|
| 1784 | } |
|---|
| 1785 | } |
|---|
| 1786 | } |
|---|
| 1787 | |
|---|
| 1788 | pcVPSVUI->setTilesNotInUseFlag( m_tilesNotInUseFlag ); |
|---|
| 1789 | |
|---|
| 1790 | if( !pcVPSVUI->getTilesNotInUseFlag() ) |
|---|
| 1791 | { |
|---|
| 1792 | for( Int i = 0; i <= vps.getMaxLayersMinus1(); i++ ) |
|---|
| 1793 | { |
|---|
| 1794 | pcVPSVUI->setTilesInUseFlag( i, m_tilesInUseFlag[ i ] ); |
|---|
| 1795 | if( pcVPSVUI->getTilesInUseFlag( i ) ) |
|---|
| 1796 | { |
|---|
| 1797 | pcVPSVUI->setLoopFilterNotAcrossTilesFlag( i, m_loopFilterNotAcrossTilesFlag[ i ] ); |
|---|
| 1798 | } |
|---|
| 1799 | } |
|---|
| 1800 | |
|---|
| 1801 | for( Int i = 1; i <= vps.getMaxLayersMinus1(); i++ ) |
|---|
| 1802 | { |
|---|
| 1803 | for( Int j = 0; j < vps.getNumDirectRefLayers( vps.getLayerIdInNuh( i ) ) ; j++ ) |
|---|
| 1804 | { |
|---|
| 1805 | Int layerIdx = vps.getLayerIdInVps( vps.getRefLayerId(vps.getLayerIdInNuh( i ) , j )); |
|---|
| 1806 | if( pcVPSVUI->getTilesInUseFlag( i ) && pcVPSVUI->getTilesInUseFlag( layerIdx ) ) |
|---|
| 1807 | { |
|---|
| 1808 | pcVPSVUI->setTileBoundariesAlignedFlag( i, j, m_tileBoundariesAlignedFlag[i][j] ); |
|---|
| 1809 | } |
|---|
| 1810 | } |
|---|
| 1811 | } |
|---|
| 1812 | } |
|---|
| 1813 | |
|---|
| 1814 | pcVPSVUI->setWppNotInUseFlag( m_wppNotInUseFlag ); |
|---|
| 1815 | |
|---|
| 1816 | if( !pcVPSVUI->getWppNotInUseFlag( ) ) |
|---|
| 1817 | { |
|---|
| 1818 | for( Int i = 1; i <= vps.getMaxLayersMinus1(); i++ ) |
|---|
| 1819 | { |
|---|
| 1820 | pcVPSVUI->setWppInUseFlag( i, m_wppInUseFlag[ i ]); |
|---|
| 1821 | } |
|---|
| 1822 | } |
|---|
| 1823 | |
|---|
| 1824 | pcVPSVUI->setIlpRestrictedRefLayersFlag( m_ilpRestrictedRefLayersFlag ); |
|---|
| 1825 | |
|---|
| 1826 | if( pcVPSVUI->getIlpRestrictedRefLayersFlag( ) ) |
|---|
| 1827 | { |
|---|
| 1828 | for( Int i = 1; i <= vps.getMaxLayersMinus1(); i++ ) |
|---|
| 1829 | { |
|---|
| 1830 | for( Int j = 0; j < vps.getNumDirectRefLayers( vps.getLayerIdInNuh( i ) ); j++ ) |
|---|
| 1831 | { |
|---|
| 1832 | if ( m_minSpatialSegmentOffsetPlus1[i].size() > j ) |
|---|
| 1833 | { |
|---|
| 1834 | pcVPSVUI->setMinSpatialSegmentOffsetPlus1( i, j, m_minSpatialSegmentOffsetPlus1[i][j] ); |
|---|
| 1835 | } |
|---|
| 1836 | if( pcVPSVUI->getMinSpatialSegmentOffsetPlus1( i, j ) > 0 ) |
|---|
| 1837 | { |
|---|
| 1838 | if ( m_ctuBasedOffsetEnabledFlag[i].size() > j ) |
|---|
| 1839 | { |
|---|
| 1840 | pcVPSVUI->setCtuBasedOffsetEnabledFlag( i, j, m_ctuBasedOffsetEnabledFlag[i][j] ); |
|---|
| 1841 | } |
|---|
| 1842 | if( pcVPSVUI->getCtuBasedOffsetEnabledFlag( i, j ) ) |
|---|
| 1843 | { |
|---|
| 1844 | if ( m_minHorizontalCtuOffsetPlus1[i].size() > j ) |
|---|
| 1845 | { |
|---|
| 1846 | pcVPSVUI->setMinHorizontalCtuOffsetPlus1( i, j, m_minHorizontalCtuOffsetPlus1[i][j] ); |
|---|
| 1847 | } |
|---|
| 1848 | } |
|---|
| 1849 | } |
|---|
| 1850 | } |
|---|
| 1851 | } |
|---|
| 1852 | } |
|---|
| 1853 | pcVPSVUI->setVideoSignalInfoIdxPresentFlag( true ); |
|---|
| 1854 | pcVPSVUI->setVpsNumVideoSignalInfoMinus1 ( 0 ); |
|---|
| 1855 | |
|---|
| 1856 | assert ( pcVPSVUI->getVideoSignalInfo( 0 ) == NULL ); |
|---|
| 1857 | |
|---|
| 1858 | TComVideoSignalInfo* videoSignalInfo = new TComVideoSignalInfo; |
|---|
| 1859 | |
|---|
| 1860 | videoSignalInfo->setColourPrimariesVps ( m_colourPrimaries ); |
|---|
| 1861 | videoSignalInfo->setMatrixCoeffsVps ( m_matrixCoefficients ); |
|---|
| 1862 | videoSignalInfo->setTransferCharacteristicsVps( m_transferCharacteristics ); |
|---|
| 1863 | videoSignalInfo->setVideoVpsFormat ( m_videoFormat ); |
|---|
| 1864 | videoSignalInfo->setVideoFullRangeVpsFlag ( m_videoFullRangeFlag ); |
|---|
| 1865 | |
|---|
| 1866 | pcVPSVUI->setVideoSignalInfo( 0, videoSignalInfo ); |
|---|
| 1867 | |
|---|
| 1868 | for (Int i = 0; i < m_numberOfLayers; i++) |
|---|
| 1869 | { |
|---|
| 1870 | pcVPSVUI->setVpsVideoSignalInfoIdx( i, 0 ); |
|---|
| 1871 | } |
|---|
| 1872 | pcVPSVUI->setVpsVuiBspHrdPresentFlag( false ); // TBD |
|---|
| 1873 | } |
|---|
| 1874 | } |
|---|
| 1875 | #endif |
|---|
| 1876 | #if H_3D |
|---|
| 1877 | Void TAppEncTop::xSetVPSExtension2( TComVPS& vps ) |
|---|
| 1878 | { |
|---|
| 1879 | |
|---|
| 1880 | for ( Int layer = 0; layer <= vps.getMaxLayersMinus1(); layer++ ) |
|---|
| 1881 | { |
|---|
| 1882 | Bool isDepth = ( vps.getDepthId( layer ) == 1 ) ; |
|---|
| 1883 | Bool isLayerZero = ( layer == 0 ); |
|---|
| 1884 | |
|---|
| 1885 | #if H_3D_ARP |
|---|
| 1886 | vps.setUseAdvRP ( layer, ( isDepth || isLayerZero ) ? 0 : m_uiUseAdvResPred ); |
|---|
| 1887 | vps.setARPStepNum ( layer, ( isDepth || isLayerZero ) ? 1 : H_3D_ARP_WFNR ); |
|---|
| 1888 | #endif |
|---|
| 1889 | #if H_3D_SPIVMP |
|---|
| 1890 | if( isDepth ) |
|---|
| 1891 | { |
|---|
| 1892 | vps.setSubPULog2Size ( layer, (layer != 1) ? 6: 0 ); |
|---|
| 1893 | } |
|---|
| 1894 | else |
|---|
| 1895 | { |
|---|
| 1896 | vps.setSubPULog2Size ( layer, (!isLayerZero) ? m_iSubPULog2Size: 0 ); |
|---|
| 1897 | } |
|---|
| 1898 | #endif |
|---|
| 1899 | |
|---|
| 1900 | #if H_3D_DIM |
|---|
| 1901 | vps.setVpsDepthModesFlag( layer, isDepth && !isLayerZero && (m_useDMM || m_useSDC || m_useDLT ) ); |
|---|
| 1902 | #if H_3D_DIM_DLT |
|---|
| 1903 | #if !DLT_DIFF_CODING_IN_PPS |
|---|
| 1904 | vps.setUseDLTFlag( layer , isDepth && m_useDLT ); |
|---|
| 1905 | if( vps.getUseDLTFlag( layer ) ) |
|---|
| 1906 | { |
|---|
| 1907 | xAnalyzeInputBaseDepth(layer, max( m_iIntraPeriod[layer], 24), &vps); |
|---|
| 1908 | } |
|---|
| 1909 | #endif |
|---|
| 1910 | #endif |
|---|
| 1911 | #endif |
|---|
| 1912 | |
|---|
| 1913 | #if H_3D_IV_MERGE |
|---|
| 1914 | if( isDepth ) |
|---|
| 1915 | { |
|---|
| 1916 | vps.setIvMvPredFlag ( layer, (layer != 1) && m_ivMvPredFlag[1] ); |
|---|
| 1917 | } |
|---|
| 1918 | else |
|---|
| 1919 | { |
|---|
| 1920 | vps.setIvMvPredFlag ( layer, !isLayerZero && m_ivMvPredFlag[0] ); |
|---|
| 1921 | } |
|---|
| 1922 | #endif |
|---|
| 1923 | #if H_3D_NBDV_REF |
|---|
| 1924 | vps.setDepthRefinementFlag ( layer, !isLayerZero && !isDepth && m_depthRefinementFlag ); |
|---|
| 1925 | #endif |
|---|
| 1926 | #if H_3D_VSP |
|---|
| 1927 | vps.setViewSynthesisPredFlag( layer, !isLayerZero && !isDepth && m_viewSynthesisPredFlag ); |
|---|
| 1928 | #endif |
|---|
| 1929 | #if H_3D_INTER_SDC |
|---|
| 1930 | vps.setInterSDCFlag( layer, !isLayerZero && isDepth && m_bDepthInterSDCFlag ); |
|---|
| 1931 | #endif |
|---|
| 1932 | #if H_3D_IV_MERGE |
|---|
| 1933 | vps.setMPIFlag( layer, !isLayerZero && isDepth && m_bMPIFlag ); |
|---|
| 1934 | #endif |
|---|
| 1935 | } |
|---|
| 1936 | #if H_3D |
|---|
| 1937 | vps.setIvMvScalingFlag( m_ivMvScalingFlag ); |
|---|
| 1938 | #endif |
|---|
| 1939 | } |
|---|
| 1940 | #endif |
|---|
| 1941 | |
|---|
| 1942 | #if DLT_DIFF_CODING_IN_PPS |
|---|
| 1943 | Void TAppEncTop::xDeriveDltArray( TComVPS& vps, TComDLT& dlt ) |
|---|
| 1944 | { |
|---|
| 1945 | Int iNumDepthViews = 0; |
|---|
| 1946 | Bool bDltPresentFlag = false; |
|---|
| 1947 | |
|---|
| 1948 | for ( Int layer = 0; layer <= vps.getMaxLayersMinus1(); layer++ ) |
|---|
| 1949 | { |
|---|
| 1950 | Bool isDepth = ( vps.getDepthId( layer ) == 1 ); |
|---|
| 1951 | |
|---|
| 1952 | if ( isDepth ) |
|---|
| 1953 | { |
|---|
| 1954 | iNumDepthViews++; |
|---|
| 1955 | } |
|---|
| 1956 | |
|---|
| 1957 | dlt.setUseDLTFlag( layer , isDepth && m_useDLT ); |
|---|
| 1958 | if( dlt.getUseDLTFlag( layer ) ) |
|---|
| 1959 | { |
|---|
| 1960 | xAnalyzeInputBaseDepth(layer, max(m_iIntraPeriod[layer], 24), &vps, &dlt); |
|---|
| 1961 | bDltPresentFlag = bDltPresentFlag || dlt.getUseDLTFlag(layer); |
|---|
| 1962 | #if H_3D_DELTA_DLT |
|---|
| 1963 | dlt.setInterViewDltPredEnableFlag(layer, (dlt.getUseDLTFlag(layer) && (layer>1))); |
|---|
| 1964 | #endif |
|---|
| 1965 | } |
|---|
| 1966 | } |
|---|
| 1967 | |
|---|
| 1968 | dlt.setDltPresentFlag( bDltPresentFlag ); |
|---|
| 1969 | dlt.setNumDepthViews ( iNumDepthViews ); |
|---|
| 1970 | } |
|---|
| 1971 | #endif |
|---|
| 1972 | #endif |
|---|
| 1973 | //! \} |
|---|