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-2012, 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 | m_totalBytes = 0; |
---|
60 | m_essentialBytes = 0; |
---|
61 | } |
---|
62 | |
---|
63 | TAppEncTop::~TAppEncTop() |
---|
64 | { |
---|
65 | } |
---|
66 | |
---|
67 | Void TAppEncTop::xInitLibCfg() |
---|
68 | { |
---|
69 | #if VIDYO_VPS_INTEGRATION |
---|
70 | UInt layerId = 0; |
---|
71 | // TODO: fix the assumption here that the temporal structures are all equal across all layers??? |
---|
72 | m_cVPS.setMaxTLayers( m_maxTempLayer[0] ); |
---|
73 | m_cVPS.setMaxLayers( m_iNumberOfViews * (m_bUsingDepthMaps ? 2:1) ); |
---|
74 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
75 | { |
---|
76 | m_cVPS.setNumReorderPics( m_numReorderPics[0][i], i ); |
---|
77 | m_cVPS.setMaxDecPicBuffering( m_maxDecPicBuffering[0][i], i ); |
---|
78 | } |
---|
79 | #endif |
---|
80 | |
---|
81 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
82 | { |
---|
83 | m_frameRcvd.push_back(0); |
---|
84 | m_acTEncTopList.push_back(new TEncTop); |
---|
85 | m_acTVideoIOYuvInputFileList.push_back(new TVideoIOYuv); |
---|
86 | m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv); |
---|
87 | m_picYuvRec.push_back(new TComList<TComPicYuv*>) ; |
---|
88 | |
---|
89 | m_acTEncTopList[iViewIdx]->setFrameRate ( m_iFrameRate ); |
---|
90 | m_acTEncTopList[iViewIdx]->setFrameSkip ( m_FrameSkip ); |
---|
91 | m_acTEncTopList[iViewIdx]->setSourceWidth ( m_iSourceWidth ); |
---|
92 | m_acTEncTopList[iViewIdx]->setSourceHeight ( m_iSourceHeight ); |
---|
93 | #if PIC_CROPPING |
---|
94 | m_acTEncTopList[iViewIdx]->setCroppingMode ( m_croppingMode ); |
---|
95 | m_acTEncTopList[iViewIdx]->setCropLeft ( m_cropLeft ); |
---|
96 | m_acTEncTopList[iViewIdx]->setCropRight ( m_cropRight ); |
---|
97 | m_acTEncTopList[iViewIdx]->setCropTop ( m_cropTop ); |
---|
98 | m_acTEncTopList[iViewIdx]->setCropBottom ( m_cropBottom ); |
---|
99 | #endif |
---|
100 | m_acTEncTopList[iViewIdx]->setFrameToBeEncoded ( m_iFrameToBeEncoded ); |
---|
101 | m_acTEncTopList[iViewIdx]->setViewId ( iViewIdx ); |
---|
102 | m_acTEncTopList[iViewIdx]->setIsDepth ( false ); |
---|
103 | m_acTEncTopList[iViewIdx]->setViewOrderIdx ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] ); |
---|
104 | #if VIDYO_VPS_INTEGRATION |
---|
105 | layerId = iViewIdx * (m_bUsingDepthMaps ? 2:1); |
---|
106 | m_acTEncTopList[iViewIdx]->setLayerId ( layerId ); |
---|
107 | m_cVPS.setDepthFlag ( false, layerId ); |
---|
108 | m_cVPS.setViewId ( iViewIdx, layerId ); |
---|
109 | m_cVPS.setViewOrderIdx ( m_cCameraData.getViewOrderIndex()[ iViewIdx ], layerId ); |
---|
110 | // TODO: set correct dependentFlag and dependentLayer |
---|
111 | m_cVPS.setDependentFlag ( iViewIdx ? true:false, layerId ); |
---|
112 | m_cVPS.setDependentLayer ( layerId - (m_bUsingDepthMaps ? 2:1), layerId ); |
---|
113 | #endif |
---|
114 | |
---|
115 | m_acTEncTopList[iViewIdx]->setCamParPrecision ( m_cCameraData.getCamParsCodedPrecision () ); |
---|
116 | m_acTEncTopList[iViewIdx]->setCamParInSliceHeader ( m_cCameraData.getVaryingCameraParameters() ); |
---|
117 | m_acTEncTopList[iViewIdx]->setCodedScale ( m_cCameraData.getCodedScale () ); |
---|
118 | m_acTEncTopList[iViewIdx]->setCodedOffset ( m_cCameraData.getCodedOffset () ); |
---|
119 | |
---|
120 | //====== Coding Structure ======== |
---|
121 | m_acTEncTopList[iViewIdx]->setIntraPeriod ( m_iIntraPeriod ); |
---|
122 | m_acTEncTopList[iViewIdx]->setDecodingRefreshType ( m_iDecodingRefreshType ); |
---|
123 | m_acTEncTopList[iViewIdx]->setGOPSize ( m_iGOPSize ); |
---|
124 | m_acTEncTopList[iViewIdx]->setGopList ( m_GOPListsMvc[iViewIdx] ); |
---|
125 | m_acTEncTopList[iViewIdx]->setExtraRPSs ( m_extraRPSs[iViewIdx] ); |
---|
126 | #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
127 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
128 | { |
---|
129 | m_acTEncTopList[iViewIdx]->setNumReorderPics ( m_numReorderPics[iViewIdx][i], i ); |
---|
130 | m_acTEncTopList[iViewIdx]->setMaxDecPicBuffering ( m_maxDecPicBuffering[iViewIdx][i], i ); |
---|
131 | } |
---|
132 | #else |
---|
133 | m_acTEncTopList[iViewIdx]->setNumReorderFrames ( m_numReorderFrames ); |
---|
134 | m_acTEncTopList[iViewIdx]->setMaxNumberOfReferencePictures ( m_maxNumberOfReferencePictures ); |
---|
135 | #endif |
---|
136 | for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop ) |
---|
137 | { |
---|
138 | m_acTEncTopList[iViewIdx]->setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] ); |
---|
139 | } |
---|
140 | m_acTEncTopList[iViewIdx]->setQP ( m_aiQP[0] ); |
---|
141 | |
---|
142 | m_acTEncTopList[iViewIdx]->setTemporalLayerQPOffset ( m_aiTLayerQPOffset ); |
---|
143 | m_acTEncTopList[iViewIdx]->setPad ( m_aiPad ); |
---|
144 | |
---|
145 | #if H0566_TLA |
---|
146 | m_acTEncTopList[iViewIdx]->setMaxTempLayer ( m_maxTempLayer[iViewIdx] ); |
---|
147 | #else |
---|
148 | m_acTEncTopList[iViewIdx]->setTLayering ( m_bTLayering ); |
---|
149 | m_acTEncTopList[iViewIdx]->setTLayerSwitchingFlag ( m_abTLayerSwitchingFlag ); |
---|
150 | #endif |
---|
151 | |
---|
152 | m_acTEncTopList[iViewIdx]->setDisInter4x4 ( m_bDisInter4x4); |
---|
153 | |
---|
154 | m_acTEncTopList[iViewIdx]->setUseNSQT( m_enableNSQT ); |
---|
155 | m_acTEncTopList[iViewIdx]->setUseAMP( m_enableAMP ); |
---|
156 | |
---|
157 | //===== Slice ======== |
---|
158 | |
---|
159 | //====== Loop/Deblock Filter ======== |
---|
160 | m_acTEncTopList[iViewIdx]->setLoopFilterDisable ( m_abLoopFilterDisable[0] ); |
---|
161 | m_acTEncTopList[iViewIdx]->setLoopFilterOffsetInAPS ( m_loopFilterOffsetInAPS ); |
---|
162 | m_acTEncTopList[iViewIdx]->setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 ); |
---|
163 | m_acTEncTopList[iViewIdx]->setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 ); |
---|
164 | #if DBL_CONTROL |
---|
165 | m_acTEncTopList[iViewIdx]->setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent); |
---|
166 | #endif |
---|
167 | |
---|
168 | //====== Motion search ======== |
---|
169 | m_acTEncTopList[iViewIdx]->setFastSearch ( m_iFastSearch ); |
---|
170 | m_acTEncTopList[iViewIdx]->setSearchRange ( m_iSearchRange ); |
---|
171 | m_acTEncTopList[iViewIdx]->setBipredSearchRange ( m_bipredSearchRange ); |
---|
172 | |
---|
173 | //====== Quality control ======== |
---|
174 | m_acTEncTopList[iViewIdx]->setMaxDeltaQP ( m_iMaxDeltaQP ); |
---|
175 | m_acTEncTopList[iViewIdx]->setMaxCuDQPDepth ( m_iMaxCuDQPDepth ); |
---|
176 | |
---|
177 | m_acTEncTopList[iViewIdx]->setChromaQpOffset ( m_iChromaQpOffset ); |
---|
178 | m_acTEncTopList[iViewIdx]->setChromaQpOffset2nd ( m_iChromaQpOffset2nd ); |
---|
179 | |
---|
180 | #if ADAPTIVE_QP_SELECTION |
---|
181 | m_acTEncTopList[iViewIdx]->setUseAdaptQpSelect ( m_bUseAdaptQpSelect ); |
---|
182 | #endif |
---|
183 | |
---|
184 | #if LOSSLESS_CODING |
---|
185 | Int lowestQP; |
---|
186 | #if H0736_AVC_STYLE_QP_RANGE |
---|
187 | lowestQP = - ( (Int)(6*(g_uiBitDepth + g_uiBitIncrement - 8)) ); |
---|
188 | #else |
---|
189 | lowestQP = 0; |
---|
190 | #endif |
---|
191 | if ((m_iMaxDeltaQP == 0 ) && (m_aiQP[0] == lowestQP) && (m_useLossless == true)) |
---|
192 | { |
---|
193 | m_bUseAdaptiveQP = false; |
---|
194 | } |
---|
195 | #endif |
---|
196 | |
---|
197 | m_acTEncTopList[iViewIdx]->setUseAdaptiveQP ( m_bUseAdaptiveQP ); |
---|
198 | m_acTEncTopList[iViewIdx]->setQPAdaptationRange ( m_iQPAdaptationRange ); |
---|
199 | |
---|
200 | #if HHI_VSO |
---|
201 | //====== VSO ========= |
---|
202 | m_acTEncTopList[iViewIdx]->setForceLambdaScaleVSO ( false ); |
---|
203 | m_acTEncTopList[iViewIdx]->setLambdaScaleVSO ( 1 ); |
---|
204 | m_acTEncTopList[iViewIdx]->setVSOMode ( 0 ); |
---|
205 | m_acTEncTopList[iViewIdx]->setUseVSO ( false ); //GT: might be enabled later for VSO Mode 4 |
---|
206 | #endif |
---|
207 | |
---|
208 | #if DEPTH_MAP_GENERATION |
---|
209 | m_acTEncTopList[iViewIdx]->setPredDepthMapGeneration ( m_uiPredDepthMapGeneration ); |
---|
210 | m_acTEncTopList[iViewIdx]->setPdmPrecision ( (UInt)m_cCameraData.getPdmPrecision () ); |
---|
211 | m_acTEncTopList[iViewIdx]->setPdmScaleNomDelta ( m_cCameraData.getPdmScaleNomDelta () ); |
---|
212 | m_acTEncTopList[iViewIdx]->setPdmOffset ( m_cCameraData.getPdmOffset () ); |
---|
213 | #endif |
---|
214 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
215 | m_acTEncTopList[iViewIdx]->setMultiviewMvPredMode ( m_uiMultiviewMvPredMode ); |
---|
216 | m_acTEncTopList[iViewIdx]->setMultiviewMvRegMode ( iViewIdx ? m_uiMultiviewMvRegMode : 0 ); |
---|
217 | m_acTEncTopList[iViewIdx]->setMultiviewMvRegLambdaScale ( iViewIdx ? m_dMultiviewMvRegLambdaScale : 0.0 ); |
---|
218 | #endif |
---|
219 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
220 | m_acTEncTopList[iViewIdx]->setMultiviewResPredMode ( m_uiMultiviewResPredMode ); |
---|
221 | #endif |
---|
222 | |
---|
223 | //====== Tool list ======== |
---|
224 | m_acTEncTopList[iViewIdx]->setUseSBACRD ( m_bUseSBACRD ); |
---|
225 | m_acTEncTopList[iViewIdx]->setDeltaQpRD ( m_uiDeltaQpRD ); |
---|
226 | m_acTEncTopList[iViewIdx]->setUseASR ( m_bUseASR ); |
---|
227 | m_acTEncTopList[iViewIdx]->setUseHADME ( m_bUseHADME ); |
---|
228 | m_acTEncTopList[iViewIdx]->setUseALF ( m_abUseALF[0] ); |
---|
229 | m_acTEncTopList[iViewIdx]->setALFEncodePassReduction ( m_iALFEncodePassReduction ); |
---|
230 | #if LOSSLESS_CODING |
---|
231 | m_acTEncTopList[iViewIdx]->setUseLossless ( m_useLossless ); |
---|
232 | #endif |
---|
233 | m_acTEncTopList[iViewIdx]->setALFMaxNumberFilters ( m_iALFMaxNumberFilters ) ; |
---|
234 | |
---|
235 | m_acTEncTopList[iViewIdx]->setUseLComb ( m_bUseLComb ); |
---|
236 | m_acTEncTopList[iViewIdx]->setLCMod ( m_bLCMod ); |
---|
237 | m_acTEncTopList[iViewIdx]->setdQPs ( m_aidQP ); |
---|
238 | m_acTEncTopList[iViewIdx]->setUseRDOQ ( m_abUseRDOQ[0] ); |
---|
239 | #if !PIC_CROPPING |
---|
240 | m_acTEncTopList[iViewIdx]->setUsePAD ( m_bUsePAD ); |
---|
241 | #endif |
---|
242 | m_acTEncTopList[iViewIdx]->setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize ); |
---|
243 | m_acTEncTopList[iViewIdx]->setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize ); |
---|
244 | m_acTEncTopList[iViewIdx]->setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); |
---|
245 | m_acTEncTopList[iViewIdx]->setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); |
---|
246 | m_acTEncTopList[iViewIdx]->setUseFastEnc ( m_bUseFastEnc ); |
---|
247 | m_acTEncTopList[iViewIdx]->setUseEarlyCU ( m_bUseEarlyCU ); |
---|
248 | #if FAST_DECISION_FOR_MRG_RD_COST |
---|
249 | m_acTEncTopList[iViewIdx]->setUseFastDecisionForMerge ( m_useFastDecisionForMerge ); |
---|
250 | #endif |
---|
251 | m_acTEncTopList[iViewIdx]->setUseCbfFastMode ( m_bUseCbfFastMode ); |
---|
252 | #if HHI_INTERVIEW_SKIP |
---|
253 | m_acTEncTopList[iViewIdx]->setInterViewSkip ( iViewIdx>0 ? m_bInterViewSkip : false ); |
---|
254 | #if HHI_INTERVIEW_SKIP_LAMBDA_SCALE |
---|
255 | m_acTEncTopList[iViewIdx]->setInterViewSkipLambdaScale ( iViewIdx>0 ? (UInt)m_dInterViewSkipLambdaScale : 1 ); |
---|
256 | #endif |
---|
257 | #endif |
---|
258 | m_acTEncTopList[iViewIdx]->setUseLMChroma ( m_bUseLMChroma ); |
---|
259 | m_acTEncTopList[iViewIdx]->setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); |
---|
260 | m_acTEncTopList[iViewIdx]->setPCMLog2MinSize ( m_uiPCMLog2MinSize); |
---|
261 | m_acTEncTopList[iViewIdx]->setUsePCM ( m_usePCM ); |
---|
262 | m_acTEncTopList[iViewIdx]->setPCMLog2MaxSize ( m_pcmLog2MaxSize); |
---|
263 | |
---|
264 | //====== Weighted Prediction ======== |
---|
265 | m_acTEncTopList[iViewIdx]->setUseWP ( m_bUseWeightPred ); |
---|
266 | m_acTEncTopList[iViewIdx]->setWPBiPredIdc ( m_uiBiPredIdc ); |
---|
267 | //====== Slice ======== |
---|
268 | m_acTEncTopList[iViewIdx]->setSliceMode ( m_iSliceMode ); |
---|
269 | m_acTEncTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument ); |
---|
270 | |
---|
271 | //====== Entropy Slice ======== |
---|
272 | m_acTEncTopList[iViewIdx]->setEntropySliceMode ( m_iEntropySliceMode ); |
---|
273 | m_acTEncTopList[iViewIdx]->setEntropySliceArgument ( m_iEntropySliceArgument ); |
---|
274 | int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1); |
---|
275 | if(m_iEntropySliceMode==SHARP_FIXED_NUMBER_OF_LCU_IN_ENTROPY_SLICE) |
---|
276 | { |
---|
277 | m_acTEncTopList[iViewIdx]->setEntropySliceArgument ( m_iEntropySliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) ); |
---|
278 | } |
---|
279 | if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE) |
---|
280 | { |
---|
281 | m_acTEncTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) ); |
---|
282 | } |
---|
283 | #if FIXED_NUMBER_OF_TILES_SLICE_MODE |
---|
284 | if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE) |
---|
285 | { |
---|
286 | m_acTEncTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument ); |
---|
287 | } |
---|
288 | #endif |
---|
289 | m_acTEncTopList[iViewIdx]->setSliceGranularity ( m_iSliceGranularity ); |
---|
290 | if(m_iSliceMode == 0 ) |
---|
291 | { |
---|
292 | m_bLFCrossSliceBoundaryFlag = true; |
---|
293 | } |
---|
294 | m_acTEncTopList[iViewIdx]->setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
295 | m_acTEncTopList[iViewIdx]->setUseSAO ( m_abUseSAO[0] ); |
---|
296 | #if SAO_UNIT_INTERLEAVING |
---|
297 | m_acTEncTopList[iViewIdx]->setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic); |
---|
298 | m_acTEncTopList[iViewIdx]->setSaoInterleavingFlag (m_saoInterleavingFlag); |
---|
299 | #endif |
---|
300 | m_acTEncTopList[iViewIdx]->setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag); |
---|
301 | m_acTEncTopList[iViewIdx]->setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag); |
---|
302 | |
---|
303 | m_acTEncTopList[iViewIdx]->setPictureDigestEnabled(m_pictureDigestEnabled); |
---|
304 | |
---|
305 | m_acTEncTopList[iViewIdx]->setColumnRowInfoPresent ( m_iColumnRowInfoPresent ); |
---|
306 | m_acTEncTopList[iViewIdx]->setUniformSpacingIdr ( m_iUniformSpacingIdr ); |
---|
307 | #if !REMOVE_TILE_DEPENDENCE |
---|
308 | m_acTEncTopList[iViewIdx]->setTileBoundaryIndependenceIdr( m_iTileBoundaryIndependenceIdr ); |
---|
309 | #endif |
---|
310 | m_acTEncTopList[iViewIdx]->setNumColumnsMinus1 ( m_iNumColumnsMinus1 ); |
---|
311 | m_acTEncTopList[iViewIdx]->setNumRowsMinus1 ( m_iNumRowsMinus1 ); |
---|
312 | if(m_iUniformSpacingIdr==0) |
---|
313 | { |
---|
314 | m_acTEncTopList[iViewIdx]->setColumnWidth ( m_pchColumnWidth ); |
---|
315 | m_acTEncTopList[iViewIdx]->setRowHeight ( m_pchRowHeight ); |
---|
316 | } |
---|
317 | m_acTEncTopList[iViewIdx]->xCheckGSParameters(); |
---|
318 | m_acTEncTopList[iViewIdx]->setTileLocationInSliceHeaderFlag ( m_iTileLocationInSliceHeaderFlag ); |
---|
319 | m_acTEncTopList[iViewIdx]->setTileMarkerFlag ( m_iTileMarkerFlag ); |
---|
320 | m_acTEncTopList[iViewIdx]->setMaxTileMarkerEntryPoints ( m_iMaxTileMarkerEntryPoints ); |
---|
321 | |
---|
322 | Int uiTilesCount = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1); |
---|
323 | m_dMaxTileMarkerOffset = ((Double)uiTilesCount) / m_iMaxTileMarkerEntryPoints; |
---|
324 | m_acTEncTopList[iViewIdx]->setMaxTileMarkerOffset ( m_dMaxTileMarkerOffset ); |
---|
325 | m_acTEncTopList[iViewIdx]->setTileBehaviorControlPresentFlag( m_iTileBehaviorControlPresentFlag ); |
---|
326 | #if !REMOVE_TILE_DEPENDENCE |
---|
327 | if(m_iTileBoundaryIndependenceIdr == 0 || uiTilesCount == 1) |
---|
328 | #else |
---|
329 | if(uiTilesCount == 1) |
---|
330 | #endif |
---|
331 | { |
---|
332 | m_bLFCrossTileBoundaryFlag = true; |
---|
333 | } |
---|
334 | m_acTEncTopList[iViewIdx]->setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); |
---|
335 | m_acTEncTopList[iViewIdx]->setWaveFrontSynchro ( m_iWaveFrontSynchro ); |
---|
336 | m_acTEncTopList[iViewIdx]->setWaveFrontFlush ( m_iWaveFrontFlush ); |
---|
337 | m_acTEncTopList[iViewIdx]->setWaveFrontSubstreams ( m_iWaveFrontSubstreams ); |
---|
338 | m_acTEncTopList[iViewIdx]->setEnableTMVP ( m_enableTMVP ); |
---|
339 | m_acTEncTopList[iViewIdx]->setUseScalingListId ( m_useScalingListId ); |
---|
340 | m_acTEncTopList[iViewIdx]->setScalingListFile ( m_scalingListFile ); |
---|
341 | #if MULTIBITS_DATA_HIDING |
---|
342 | m_acTEncTopList[iViewIdx]->setSignHideFlag(m_signHideFlag); |
---|
343 | m_acTEncTopList[iViewIdx]->setTSIG(m_signHidingThreshold); |
---|
344 | #endif |
---|
345 | |
---|
346 | #if LCU_SYNTAX_ALF |
---|
347 | if(uiTilesCount > 1) |
---|
348 | { |
---|
349 | m_bALFParamInSlice = false; |
---|
350 | m_bALFPicBasedEncode = true; |
---|
351 | } |
---|
352 | m_acTEncTopList[iViewIdx]->setALFParamInSlice ( m_bALFParamInSlice); |
---|
353 | m_acTEncTopList[iViewIdx]->setALFPicBasedEncode ( m_bALFPicBasedEncode); |
---|
354 | #endif |
---|
355 | |
---|
356 | //====== Depth tools ======== |
---|
357 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
358 | m_acTEncTopList[iViewIdx]->setUseDMM ( false ); |
---|
359 | #endif |
---|
360 | #if HHI_MPI |
---|
361 | m_acTEncTopList[iViewIdx]->setUseMVI( false ); |
---|
362 | #endif |
---|
363 | } |
---|
364 | if( m_bUsingDepthMaps ) |
---|
365 | { |
---|
366 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
367 | { |
---|
368 | m_depthFrameRcvd.push_back(0); |
---|
369 | m_acTEncDepthTopList.push_back(new TEncTop); |
---|
370 | m_acTVideoIOYuvDepthInputFileList.push_back(new TVideoIOYuv); |
---|
371 | m_acTVideoIOYuvDepthReconFileList.push_back(new TVideoIOYuv); |
---|
372 | m_picYuvDepthRec.push_back(new TComList<TComPicYuv*>) ; |
---|
373 | |
---|
374 | m_acTEncDepthTopList[iViewIdx]->setFrameRate ( m_iFrameRate ); |
---|
375 | m_acTEncDepthTopList[iViewIdx]->setFrameSkip ( m_FrameSkip ); |
---|
376 | m_acTEncDepthTopList[iViewIdx]->setSourceWidth ( m_iSourceWidth ); |
---|
377 | m_acTEncDepthTopList[iViewIdx]->setSourceHeight ( m_iSourceHeight ); |
---|
378 | #if PIC_CROPPING |
---|
379 | m_acTEncDepthTopList[iViewIdx]->setCroppingMode ( m_croppingMode ); |
---|
380 | m_acTEncDepthTopList[iViewIdx]->setCropLeft ( m_cropLeft ); |
---|
381 | m_acTEncDepthTopList[iViewIdx]->setCropRight ( m_cropRight ); |
---|
382 | m_acTEncDepthTopList[iViewIdx]->setCropTop ( m_cropTop ); |
---|
383 | m_acTEncDepthTopList[iViewIdx]->setCropBottom ( m_cropBottom ); |
---|
384 | #endif |
---|
385 | m_acTEncDepthTopList[iViewIdx]->setFrameToBeEncoded ( m_iFrameToBeEncoded ); |
---|
386 | m_acTEncDepthTopList[iViewIdx]->setViewId ( iViewIdx ); |
---|
387 | m_acTEncDepthTopList[iViewIdx]->setIsDepth ( true ); |
---|
388 | m_acTEncDepthTopList[iViewIdx]->setViewOrderIdx ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] ); |
---|
389 | #if VIDYO_VPS_INTEGRATION |
---|
390 | layerId = iViewIdx * 2 + 1; |
---|
391 | m_acTEncDepthTopList[iViewIdx]->setLayerId ( layerId ); |
---|
392 | m_cVPS.setDepthFlag ( true, layerId ); |
---|
393 | m_cVPS.setViewId ( iViewIdx, layerId ); |
---|
394 | m_cVPS.setViewOrderIdx ( m_cCameraData.getViewOrderIndex()[ iViewIdx ], layerId ); |
---|
395 | m_cVPS.setDependentFlag ( true, layerId ); |
---|
396 | m_cVPS.setDependentLayer ( layerId-1, layerId); |
---|
397 | #endif |
---|
398 | m_acTEncDepthTopList[iViewIdx]->setCamParPrecision ( 0 ); |
---|
399 | m_acTEncDepthTopList[iViewIdx]->setCamParInSliceHeader ( false ); |
---|
400 | m_acTEncDepthTopList[iViewIdx]->setCodedScale ( 0 ); |
---|
401 | m_acTEncDepthTopList[iViewIdx]->setCodedOffset ( 0 ); |
---|
402 | |
---|
403 | //====== Coding Structure ======== |
---|
404 | m_acTEncDepthTopList[iViewIdx]->setIntraPeriod ( m_iIntraPeriod ); |
---|
405 | m_acTEncDepthTopList[iViewIdx]->setDecodingRefreshType ( m_iDecodingRefreshType ); |
---|
406 | m_acTEncDepthTopList[iViewIdx]->setGOPSize ( m_iGOPSize ); |
---|
407 | m_acTEncDepthTopList[iViewIdx]->setGopList ( m_GOPListsMvc[iViewIdx] ); |
---|
408 | m_acTEncDepthTopList[iViewIdx]->setExtraRPSs ( m_extraRPSs[iViewIdx] ); |
---|
409 | #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
410 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
411 | { |
---|
412 | m_acTEncDepthTopList[iViewIdx]->setNumReorderPics ( m_numReorderPics[iViewIdx][i], i ); |
---|
413 | m_acTEncDepthTopList[iViewIdx]->setMaxDecPicBuffering ( m_maxDecPicBuffering[iViewIdx][i], i ); |
---|
414 | } |
---|
415 | #else |
---|
416 | m_acTEncDepthTopList[iViewIdx]->setNumReorderFrames ( m_numReorderFrames ); |
---|
417 | m_acTEncDepthTopList[iViewIdx]->setMaxNumberOfReferencePictures ( m_maxNumberOfReferencePictures ); |
---|
418 | #endif |
---|
419 | for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop ) |
---|
420 | { |
---|
421 | m_acTEncDepthTopList[iViewIdx]->setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] ); |
---|
422 | } |
---|
423 | m_acTEncDepthTopList[iViewIdx]->setQP ( m_aiQP[1] ); |
---|
424 | |
---|
425 | m_acTEncDepthTopList[iViewIdx]->setTemporalLayerQPOffset ( m_aiTLayerQPOffset ); |
---|
426 | m_acTEncDepthTopList[iViewIdx]->setPad ( m_aiPad ); |
---|
427 | |
---|
428 | #if H0566_TLA |
---|
429 | m_acTEncDepthTopList[iViewIdx]->setMaxTempLayer ( m_maxTempLayer[iViewIdx] ); |
---|
430 | #else |
---|
431 | m_acTEncDepthTopList[iViewIdx]->setTLayering ( m_bTLayering ); |
---|
432 | m_acTEncDepthTopList[iViewIdx]->setTLayerSwitchingFlag ( m_abTLayerSwitchingFlag ); |
---|
433 | #endif |
---|
434 | |
---|
435 | m_acTEncDepthTopList[iViewIdx]->setDisInter4x4 ( m_bDisInter4x4); |
---|
436 | |
---|
437 | m_acTEncDepthTopList[iViewIdx]->setUseNSQT( m_enableNSQT ); |
---|
438 | m_acTEncDepthTopList[iViewIdx]->setUseAMP( m_enableAMP ); |
---|
439 | |
---|
440 | //===== Slice ======== |
---|
441 | |
---|
442 | //====== Loop/Deblock Filter ======== |
---|
443 | m_acTEncDepthTopList[iViewIdx]->setLoopFilterDisable ( m_abLoopFilterDisable[1] ); |
---|
444 | m_acTEncDepthTopList[iViewIdx]->setLoopFilterOffsetInAPS ( m_loopFilterOffsetInAPS ); |
---|
445 | m_acTEncDepthTopList[iViewIdx]->setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 ); |
---|
446 | m_acTEncDepthTopList[iViewIdx]->setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 ); |
---|
447 | #if DBL_CONTROL |
---|
448 | m_acTEncDepthTopList[iViewIdx]->setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent); |
---|
449 | #endif |
---|
450 | |
---|
451 | //====== Motion search ======== |
---|
452 | m_acTEncDepthTopList[iViewIdx]->setFastSearch ( m_iFastSearch ); |
---|
453 | m_acTEncDepthTopList[iViewIdx]->setSearchRange ( m_iSearchRange ); |
---|
454 | m_acTEncDepthTopList[iViewIdx]->setBipredSearchRange ( m_bipredSearchRange ); |
---|
455 | |
---|
456 | //====== Quality control ======== |
---|
457 | m_acTEncDepthTopList[iViewIdx]->setMaxDeltaQP ( m_iMaxDeltaQP ); |
---|
458 | m_acTEncDepthTopList[iViewIdx]->setMaxCuDQPDepth ( m_iMaxCuDQPDepth ); |
---|
459 | |
---|
460 | m_acTEncDepthTopList[iViewIdx]->setChromaQpOffset ( m_iChromaQpOffset ); |
---|
461 | m_acTEncDepthTopList[iViewIdx]->setChromaQpOffset2nd ( m_iChromaQpOffset2nd ); |
---|
462 | |
---|
463 | #if ADAPTIVE_QP_SELECTION |
---|
464 | m_acTEncDepthTopList[iViewIdx]->setUseAdaptQpSelect ( m_bUseAdaptQpSelect ); |
---|
465 | #endif |
---|
466 | |
---|
467 | m_acTEncDepthTopList[iViewIdx]->setUseAdaptiveQP ( m_bUseAdaptiveQP ); |
---|
468 | m_acTEncDepthTopList[iViewIdx]->setQPAdaptationRange ( m_iQPAdaptationRange ); |
---|
469 | |
---|
470 | //====== Tool list ======== |
---|
471 | m_acTEncDepthTopList[iViewIdx]->setUseSBACRD ( m_bUseSBACRD ); |
---|
472 | m_acTEncDepthTopList[iViewIdx]->setDeltaQpRD ( m_uiDeltaQpRD ); |
---|
473 | m_acTEncDepthTopList[iViewIdx]->setUseASR ( m_bUseASR ); |
---|
474 | m_acTEncDepthTopList[iViewIdx]->setUseHADME ( m_bUseHADME ); |
---|
475 | m_acTEncDepthTopList[iViewIdx]->setUseALF ( m_abUseALF[1] ); |
---|
476 | m_acTEncDepthTopList[iViewIdx]->setALFEncodePassReduction ( m_iALFEncodePassReduction ); |
---|
477 | #if LOSSLESS_CODING |
---|
478 | m_acTEncDepthTopList[iViewIdx]->setUseLossless ( m_useLossless ); |
---|
479 | #endif |
---|
480 | m_acTEncDepthTopList[iViewIdx]->setALFMaxNumberFilters ( m_iALFMaxNumberFilters ) ; |
---|
481 | |
---|
482 | m_acTEncDepthTopList[iViewIdx]->setUseLComb ( m_bUseLComb ); |
---|
483 | m_acTEncDepthTopList[iViewIdx]->setLCMod ( m_bLCMod ); |
---|
484 | m_acTEncDepthTopList[iViewIdx]->setdQPs ( m_aidQPdepth ); |
---|
485 | m_acTEncDepthTopList[iViewIdx]->setUseRDOQ ( m_abUseRDOQ[1] ); |
---|
486 | #if !PIC_CROPPING |
---|
487 | m_acTEncDepthTopList[iViewIdx]->setUsePAD ( m_bUsePAD ); |
---|
488 | #endif |
---|
489 | m_acTEncDepthTopList[iViewIdx]->setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize ); |
---|
490 | m_acTEncDepthTopList[iViewIdx]->setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize ); |
---|
491 | m_acTEncDepthTopList[iViewIdx]->setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); |
---|
492 | m_acTEncDepthTopList[iViewIdx]->setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); |
---|
493 | m_acTEncDepthTopList[iViewIdx]->setUseFastEnc ( m_bUseFastEnc ); |
---|
494 | m_acTEncDepthTopList[iViewIdx]->setUseEarlyCU ( m_bUseEarlyCU ); |
---|
495 | #if FAST_DECISION_FOR_MRG_RD_COST |
---|
496 | m_acTEncDepthTopList[iViewIdx]->setUseFastDecisionForMerge ( m_useFastDecisionForMerge ); |
---|
497 | #endif |
---|
498 | m_acTEncDepthTopList[iViewIdx]->setUseCbfFastMode ( m_bUseCbfFastMode ); |
---|
499 | #if HHI_INTERVIEW_SKIP |
---|
500 | m_acTEncDepthTopList[iViewIdx]->setInterViewSkip ( 0 ); |
---|
501 | #if HHI_INTERVIEW_SKIP_LAMBDA_SCALE |
---|
502 | m_acTEncDepthTopList[iViewIdx]->setInterViewSkipLambdaScale ( 1 ); |
---|
503 | #endif |
---|
504 | #endif |
---|
505 | m_acTEncDepthTopList[iViewIdx]->setUseLMChroma ( m_bUseLMChroma ); |
---|
506 | m_acTEncDepthTopList[iViewIdx]->setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); |
---|
507 | m_acTEncDepthTopList[iViewIdx]->setPCMLog2MinSize ( m_uiPCMLog2MinSize); |
---|
508 | m_acTEncDepthTopList[iViewIdx]->setUsePCM ( m_usePCM ); |
---|
509 | m_acTEncDepthTopList[iViewIdx]->setPCMLog2MaxSize ( m_pcmLog2MaxSize); |
---|
510 | //====== VSO ======== |
---|
511 | #if HHI_VSO |
---|
512 | m_acTEncDepthTopList[iViewIdx]->setUseVSO ( m_bUseVSO ); //GT: might be enabled/disabled later for VSO Mode 4 |
---|
513 | m_acTEncDepthTopList[iViewIdx]->setForceLambdaScaleVSO ( m_bForceLambdaScaleVSO ); |
---|
514 | m_acTEncDepthTopList[iViewIdx]->setLambdaScaleVSO ( m_dLambdaScaleVSO ); |
---|
515 | #if HHI_VSO_DIST_INT |
---|
516 | m_acTEncDepthTopList[iViewIdx]->setAllowNegDist ( m_bAllowNegDist ); |
---|
517 | #endif |
---|
518 | m_acTEncDepthTopList[iViewIdx]->setVSOMode ( m_uiVSOMode ); |
---|
519 | #endif |
---|
520 | |
---|
521 | #if DEPTH_MAP_GENERATION |
---|
522 | m_acTEncDepthTopList[iViewIdx]->setPredDepthMapGeneration ( 0 ); |
---|
523 | #endif |
---|
524 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
525 | m_acTEncDepthTopList[iViewIdx]->setMultiviewMvPredMode ( 0 ); |
---|
526 | m_acTEncDepthTopList[iViewIdx]->setMultiviewMvRegMode ( 0 ); |
---|
527 | m_acTEncDepthTopList[iViewIdx]->setMultiviewMvRegLambdaScale ( 0.0 ); |
---|
528 | #endif |
---|
529 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
530 | m_acTEncDepthTopList[iViewIdx]->setMultiviewResPredMode ( 0 ); |
---|
531 | #endif |
---|
532 | |
---|
533 | //====== Weighted Prediction ======== |
---|
534 | m_acTEncDepthTopList[iViewIdx]->setUseWP ( m_bUseWeightPred ); |
---|
535 | m_acTEncDepthTopList[iViewIdx]->setWPBiPredIdc ( m_uiBiPredIdc ); |
---|
536 | //====== Slice ======== |
---|
537 | m_acTEncDepthTopList[iViewIdx]->setSliceMode ( m_iSliceMode ); |
---|
538 | m_acTEncDepthTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument ); |
---|
539 | |
---|
540 | //====== Entropy Slice ======== |
---|
541 | m_acTEncDepthTopList[iViewIdx]->setEntropySliceMode ( m_iEntropySliceMode ); |
---|
542 | m_acTEncDepthTopList[iViewIdx]->setEntropySliceArgument ( m_iEntropySliceArgument ); |
---|
543 | int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1); |
---|
544 | if(m_iEntropySliceMode==SHARP_FIXED_NUMBER_OF_LCU_IN_ENTROPY_SLICE) |
---|
545 | { |
---|
546 | m_acTEncDepthTopList[iViewIdx]->setEntropySliceArgument ( m_iEntropySliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) ); |
---|
547 | } |
---|
548 | if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE) |
---|
549 | { |
---|
550 | m_acTEncDepthTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) ); |
---|
551 | } |
---|
552 | #if FIXED_NUMBER_OF_TILES_SLICE_MODE |
---|
553 | if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE) |
---|
554 | { |
---|
555 | m_acTEncDepthTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument ); |
---|
556 | } |
---|
557 | #endif |
---|
558 | m_acTEncDepthTopList[iViewIdx]->setSliceGranularity ( m_iSliceGranularity ); |
---|
559 | if(m_iSliceMode == 0 ) |
---|
560 | { |
---|
561 | m_bLFCrossSliceBoundaryFlag = true; |
---|
562 | } |
---|
563 | m_acTEncDepthTopList[iViewIdx]->setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
564 | m_acTEncDepthTopList[iViewIdx]->setUseSAO ( m_abUseSAO[1] ); |
---|
565 | #if SAO_UNIT_INTERLEAVING |
---|
566 | m_acTEncDepthTopList[iViewIdx]->setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic); |
---|
567 | m_acTEncDepthTopList[iViewIdx]->setSaoInterleavingFlag (m_saoInterleavingFlag); |
---|
568 | #endif |
---|
569 | m_acTEncDepthTopList[iViewIdx]->setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag); |
---|
570 | m_acTEncDepthTopList[iViewIdx]->setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag); |
---|
571 | |
---|
572 | m_acTEncDepthTopList[iViewIdx]->setPictureDigestEnabled(m_pictureDigestEnabled); |
---|
573 | |
---|
574 | m_acTEncDepthTopList[iViewIdx]->setColumnRowInfoPresent ( m_iColumnRowInfoPresent ); |
---|
575 | m_acTEncDepthTopList[iViewIdx]->setUniformSpacingIdr ( m_iUniformSpacingIdr ); |
---|
576 | #if !REMOVE_TILE_DEPENDENCE |
---|
577 | m_acTEncDepthTopList[iViewIdx]->setTileBoundaryIndependenceIdr( m_iTileBoundaryIndependenceIdr ); |
---|
578 | #endif |
---|
579 | m_acTEncDepthTopList[iViewIdx]->setNumColumnsMinus1 ( m_iNumColumnsMinus1 ); |
---|
580 | m_acTEncDepthTopList[iViewIdx]->setNumRowsMinus1 ( m_iNumRowsMinus1 ); |
---|
581 | if(m_iUniformSpacingIdr==0) |
---|
582 | { |
---|
583 | m_acTEncDepthTopList[iViewIdx]->setColumnWidth ( m_pchColumnWidth ); |
---|
584 | m_acTEncDepthTopList[iViewIdx]->setRowHeight ( m_pchRowHeight ); |
---|
585 | } |
---|
586 | m_acTEncDepthTopList[iViewIdx]->xCheckGSParameters(); |
---|
587 | m_acTEncDepthTopList[iViewIdx]->setTileLocationInSliceHeaderFlag ( m_iTileLocationInSliceHeaderFlag ); |
---|
588 | m_acTEncDepthTopList[iViewIdx]->setTileMarkerFlag ( m_iTileMarkerFlag ); |
---|
589 | m_acTEncDepthTopList[iViewIdx]->setMaxTileMarkerEntryPoints ( m_iMaxTileMarkerEntryPoints ); |
---|
590 | |
---|
591 | Int uiTilesCount = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1); |
---|
592 | m_dMaxTileMarkerOffset = ((Double)uiTilesCount) / m_iMaxTileMarkerEntryPoints; |
---|
593 | m_acTEncDepthTopList[iViewIdx]->setMaxTileMarkerOffset ( m_dMaxTileMarkerOffset ); |
---|
594 | m_acTEncDepthTopList[iViewIdx]->setTileBehaviorControlPresentFlag( m_iTileBehaviorControlPresentFlag ); |
---|
595 | #if !REMOVE_TILE_DEPENDENCE |
---|
596 | if(m_iTileBoundaryIndependenceIdr == 0 || uiTilesCount == 1) |
---|
597 | #else |
---|
598 | if(uiTilesCount == 1) |
---|
599 | #endif |
---|
600 | { |
---|
601 | m_bLFCrossTileBoundaryFlag = true; |
---|
602 | } |
---|
603 | m_acTEncDepthTopList[iViewIdx]->setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); |
---|
604 | m_acTEncDepthTopList[iViewIdx]->setWaveFrontSynchro ( m_iWaveFrontSynchro ); |
---|
605 | m_acTEncDepthTopList[iViewIdx]->setWaveFrontFlush ( m_iWaveFrontFlush ); |
---|
606 | m_acTEncDepthTopList[iViewIdx]->setWaveFrontSubstreams ( m_iWaveFrontSubstreams ); |
---|
607 | m_acTEncDepthTopList[iViewIdx]->setEnableTMVP ( m_enableTMVP ); |
---|
608 | m_acTEncDepthTopList[iViewIdx]->setUseScalingListId ( m_useScalingListId ); |
---|
609 | m_acTEncDepthTopList[iViewIdx]->setScalingListFile ( m_scalingListFile ); |
---|
610 | #if MULTIBITS_DATA_HIDING |
---|
611 | m_acTEncDepthTopList[iViewIdx]->setSignHideFlag(m_signHideFlag); |
---|
612 | m_acTEncDepthTopList[iViewIdx]->setTSIG(m_signHidingThreshold); |
---|
613 | #endif |
---|
614 | |
---|
615 | #if LCU_SYNTAX_ALF |
---|
616 | if(uiTilesCount > 1) |
---|
617 | { |
---|
618 | m_bALFParamInSlice = false; |
---|
619 | m_bALFPicBasedEncode = true; |
---|
620 | } |
---|
621 | m_acTEncDepthTopList[iViewIdx]->setALFParamInSlice ( m_bALFParamInSlice); |
---|
622 | m_acTEncDepthTopList[iViewIdx]->setALFPicBasedEncode ( m_bALFPicBasedEncode); |
---|
623 | #endif |
---|
624 | |
---|
625 | //====== Depth tools ======== |
---|
626 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
627 | m_acTEncDepthTopList[iViewIdx]->setUseDMM ( m_bUseDMM ); |
---|
628 | #endif |
---|
629 | #if HHI_MPI |
---|
630 | m_acTEncDepthTopList[iViewIdx]->setUseMVI( m_bUseMVI ); |
---|
631 | #endif |
---|
632 | } |
---|
633 | } |
---|
634 | |
---|
635 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
636 | else if( m_uiMultiviewMvRegMode ) |
---|
637 | { |
---|
638 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
639 | { |
---|
640 | m_acTVideoIOYuvDepthInputFileList.push_back( new TVideoIOYuv ); |
---|
641 | } |
---|
642 | } |
---|
643 | #endif |
---|
644 | |
---|
645 | #if HHI_VSO |
---|
646 | if ( m_bUseVSO ) |
---|
647 | { |
---|
648 | if ( m_uiVSOMode == 4 ) |
---|
649 | { |
---|
650 | m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, m_iSourceHeight, LOG2_DISP_PREC_LUT, 0 ); |
---|
651 | |
---|
652 | for ( Int iViewNum = 0; iViewNum < m_iNumberOfViews; iViewNum++ ) |
---|
653 | { |
---|
654 | for (Int iContent = 0; iContent < 2; iContent++ ) |
---|
655 | { |
---|
656 | Int iNumOfModels = m_cRenModStrParser.getNumOfModelsForView(iViewNum, iContent); |
---|
657 | Bool bUseVSO = (iNumOfModels != 0); |
---|
658 | |
---|
659 | TEncTop* pcEncTop = ( iContent == 0 ) ? m_acTEncTopList[iViewNum] : m_acTEncDepthTopList[iViewNum]; |
---|
660 | pcEncTop->setUseVSO( bUseVSO ); |
---|
661 | pcEncTop->getRdCost()->setRenModel( bUseVSO ? &m_cRendererModel : NULL ); |
---|
662 | |
---|
663 | for (Int iCurModel = 0; iCurModel < iNumOfModels; iCurModel++ ) |
---|
664 | { |
---|
665 | Int iModelNum; Int iLeftViewNum; Int iRightViewNum; Int iDump; Int iOrgRefNum; Int iBlendMode; |
---|
666 | |
---|
667 | m_cRenModStrParser.getSingleModelData ( iViewNum, iContent, iCurModel, iModelNum, iBlendMode, iLeftViewNum, iRightViewNum, iOrgRefNum, iDump ) ; |
---|
668 | m_cRendererModel .createSingleModel ( iViewNum, iContent, iModelNum, iLeftViewNum, iRightViewNum, (iOrgRefNum != -1), iBlendMode ); |
---|
669 | } |
---|
670 | } |
---|
671 | } |
---|
672 | } |
---|
673 | else |
---|
674 | { |
---|
675 | AOT(true); |
---|
676 | } |
---|
677 | } |
---|
678 | #endif |
---|
679 | |
---|
680 | #if HHI_INTERVIEW_SKIP |
---|
681 | m_cUsedPelsRenderer.init(m_iSourceWidth, m_iSourceHeight, true, 0, LOG2_DISP_PREC_LUT, true, 0, 0, 0, 0, 0, 6, 4, 1, 0, 6 ); |
---|
682 | #endif |
---|
683 | |
---|
684 | } |
---|
685 | |
---|
686 | Void TAppEncTop::xCreateLib() |
---|
687 | { |
---|
688 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
689 | { |
---|
690 | m_acTVideoIOYuvInputFileList[iViewIdx]->open( m_pchInputFileList[iViewIdx], false, m_uiInputBitDepth, m_uiInternalBitDepth ); // read mode |
---|
691 | m_acTVideoIOYuvInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]); |
---|
692 | |
---|
693 | if (m_pchReconFileList[iViewIdx]) |
---|
694 | m_acTVideoIOYuvReconFileList[iViewIdx]->open(m_pchReconFileList[iViewIdx], true, m_uiOutputBitDepth, m_uiInternalBitDepth); // write mode |
---|
695 | m_acTEncTopList[iViewIdx]->create(); |
---|
696 | if( m_bUsingDepthMaps ) |
---|
697 | { |
---|
698 | m_acTVideoIOYuvDepthInputFileList[iViewIdx]->open( m_pchDepthInputFileList[iViewIdx], false, m_uiInputBitDepth, m_uiInternalBitDepth ); // read mode |
---|
699 | m_acTVideoIOYuvDepthInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]); |
---|
700 | |
---|
701 | if (m_pchDepthReconFileList[iViewIdx]) |
---|
702 | m_acTVideoIOYuvDepthReconFileList[iViewIdx]->open(m_pchDepthReconFileList[iViewIdx], true, m_uiOutputBitDepth, m_uiInternalBitDepth); // write mode |
---|
703 | m_acTEncDepthTopList[iViewIdx]->create(); |
---|
704 | } |
---|
705 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
706 | else if( m_uiMultiviewMvRegMode ) |
---|
707 | { |
---|
708 | m_acTVideoIOYuvDepthInputFileList[iViewIdx]->open( m_pchDepthInputFileList[iViewIdx], false, m_uiInputBitDepth, m_uiInternalBitDepth ); // read mode |
---|
709 | m_acTVideoIOYuvDepthInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth, m_iSourceHeight); |
---|
710 | } |
---|
711 | #endif |
---|
712 | } |
---|
713 | } |
---|
714 | |
---|
715 | Void TAppEncTop::xDestroyLib() |
---|
716 | { |
---|
717 | // Video I/O |
---|
718 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
719 | { |
---|
720 | m_acTVideoIOYuvInputFileList[iViewIdx]->close(); |
---|
721 | m_acTVideoIOYuvReconFileList[iViewIdx]->close(); |
---|
722 | delete m_acTVideoIOYuvInputFileList[iViewIdx] ; |
---|
723 | m_acTVideoIOYuvInputFileList[iViewIdx] = NULL; |
---|
724 | delete m_acTVideoIOYuvReconFileList[iViewIdx] ; |
---|
725 | m_acTVideoIOYuvReconFileList[iViewIdx] = NULL; |
---|
726 | m_acTEncTopList[iViewIdx]->deletePicBuffer(); |
---|
727 | m_acTEncTopList[iViewIdx]->destroy(); |
---|
728 | delete m_acTEncTopList[iViewIdx] ; |
---|
729 | m_acTEncTopList[iViewIdx] = NULL; |
---|
730 | delete m_picYuvRec[iViewIdx] ; |
---|
731 | m_picYuvRec[iViewIdx] = NULL; |
---|
732 | |
---|
733 | if( iViewIdx < Int( m_acTVideoIOYuvDepthInputFileList.size() ) && m_acTVideoIOYuvDepthInputFileList[iViewIdx] ) |
---|
734 | { |
---|
735 | m_acTVideoIOYuvDepthInputFileList[iViewIdx]->close( ); |
---|
736 | delete m_acTVideoIOYuvDepthInputFileList[iViewIdx]; |
---|
737 | m_acTVideoIOYuvDepthInputFileList[iViewIdx] = NULL; |
---|
738 | } |
---|
739 | if( iViewIdx < Int( m_acTVideoIOYuvDepthReconFileList.size() ) && m_acTVideoIOYuvDepthReconFileList[iViewIdx] ) |
---|
740 | { |
---|
741 | m_acTVideoIOYuvDepthReconFileList[iViewIdx]->close () ; |
---|
742 | delete m_acTVideoIOYuvDepthReconFileList[iViewIdx]; |
---|
743 | m_acTVideoIOYuvDepthReconFileList[iViewIdx] = NULL; |
---|
744 | } |
---|
745 | if( iViewIdx < Int( m_acTEncDepthTopList.size() ) && m_acTEncDepthTopList[iViewIdx] ) |
---|
746 | { |
---|
747 | m_acTEncDepthTopList[iViewIdx]->deletePicBuffer(); |
---|
748 | m_acTEncDepthTopList[iViewIdx]->destroy(); |
---|
749 | delete m_acTEncDepthTopList[iViewIdx]; |
---|
750 | m_acTEncDepthTopList[iViewIdx] = NULL; |
---|
751 | } |
---|
752 | if( iViewIdx < Int( m_picYuvDepthRec.size() ) && m_picYuvDepthRec[iViewIdx] ) |
---|
753 | { |
---|
754 | delete m_picYuvDepthRec[iViewIdx] ; |
---|
755 | m_picYuvDepthRec[iViewIdx] = NULL; |
---|
756 | } |
---|
757 | } |
---|
758 | } |
---|
759 | |
---|
760 | Void TAppEncTop::xInitLib() |
---|
761 | { |
---|
762 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
763 | { |
---|
764 | m_acTEncTopList[iViewIdx]->init( this ); |
---|
765 | } |
---|
766 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
767 | { |
---|
768 | m_acTEncTopList[iViewIdx]->setTEncTopList( &m_acTEncTopList ); |
---|
769 | } |
---|
770 | if ( m_bUsingDepthMaps ) |
---|
771 | { |
---|
772 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
773 | { |
---|
774 | m_acTEncDepthTopList[iViewIdx]->init( this ); |
---|
775 | } |
---|
776 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
777 | { |
---|
778 | m_acTEncDepthTopList[iViewIdx]->setTEncTopList( &m_acTEncDepthTopList ); |
---|
779 | } |
---|
780 | } |
---|
781 | } |
---|
782 | |
---|
783 | // ==================================================================================================================== |
---|
784 | // Public member functions |
---|
785 | // ==================================================================================================================== |
---|
786 | |
---|
787 | /** |
---|
788 | - create internal class |
---|
789 | - initialize internal variable |
---|
790 | - until the end of input YUV file, call encoding function in TEncTop class |
---|
791 | - delete allocated buffers |
---|
792 | - destroy internal class |
---|
793 | . |
---|
794 | */ |
---|
795 | Void TAppEncTop::encode() |
---|
796 | { |
---|
797 | fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out); |
---|
798 | if (!bitstreamFile) |
---|
799 | { |
---|
800 | fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile); |
---|
801 | exit(EXIT_FAILURE); |
---|
802 | } |
---|
803 | |
---|
804 | TComPicYuv* pcPicYuvOrg = new TComPicYuv; |
---|
805 | TComPicYuv* pcDepthPicYuvOrg = new TComPicYuv; |
---|
806 | TComPicYuv* pcPdmDepthOrg = new TComPicYuv; |
---|
807 | TComPicYuv* pcPicYuvRec = NULL; |
---|
808 | TComPicYuv* pcDepthPicYuvRec = NULL; |
---|
809 | |
---|
810 | // initialize internal class & member variables |
---|
811 | xInitLibCfg(); |
---|
812 | xCreateLib(); |
---|
813 | xInitLib(); |
---|
814 | |
---|
815 | // main encoder loop |
---|
816 | Bool allEos = false; |
---|
817 | std::vector<Bool> eos ; |
---|
818 | std::vector<Bool> depthEos ; |
---|
819 | Int maxGopSize = 0; |
---|
820 | Int gopSize = 1; |
---|
821 | |
---|
822 | list<AccessUnit> outputAccessUnits; ///< list of access units to write out. is populated by the encoding process |
---|
823 | maxGopSize = (std::max)(maxGopSize, m_acTEncTopList[0]->getGOPSize()); |
---|
824 | |
---|
825 | for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) |
---|
826 | { |
---|
827 | eos.push_back( false ); |
---|
828 | depthEos.push_back( false ); |
---|
829 | } |
---|
830 | |
---|
831 | // allocate original YUV buffer |
---|
832 | pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
833 | pcDepthPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
834 | |
---|
835 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
836 | if( m_uiMultiviewMvRegMode ) |
---|
837 | { |
---|
838 | pcPdmDepthOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
839 | } |
---|
840 | #endif |
---|
841 | |
---|
842 | while ( !allEos ) |
---|
843 | { |
---|
844 | for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) |
---|
845 | { |
---|
846 | Int frmCnt = 0; |
---|
847 | while ( !eos[iViewIdx] && !(frmCnt == gopSize)) |
---|
848 | { |
---|
849 | // get buffers |
---|
850 | xGetBuffer(pcPicYuvRec, iViewIdx, false); |
---|
851 | |
---|
852 | // read input YUV file |
---|
853 | m_acTVideoIOYuvInputFileList[iViewIdx]->read( pcPicYuvOrg, m_aiPad ); |
---|
854 | |
---|
855 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
856 | if( m_uiMultiviewMvRegMode && iViewIdx ) |
---|
857 | { |
---|
858 | m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcPdmDepthOrg, m_aiPad, m_bUsingDepthMaps ); |
---|
859 | } |
---|
860 | #endif |
---|
861 | |
---|
862 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
863 | m_acTEncTopList[iViewIdx]->initNewPic( pcPicYuvOrg, ( m_uiMultiviewMvRegMode && iViewIdx ? pcPdmDepthOrg : 0 ) ); |
---|
864 | #else |
---|
865 | m_acTEncTopList[iViewIdx]->initNewPic( pcPicYuvOrg ); |
---|
866 | #endif |
---|
867 | |
---|
868 | // increase number of received frames |
---|
869 | m_frameRcvd[iViewIdx]++; |
---|
870 | frmCnt++; |
---|
871 | // check end of file |
---|
872 | eos[iViewIdx] = ( m_acTVideoIOYuvInputFileList[iViewIdx]->isEof() == 1 ? true : false ); |
---|
873 | eos[iViewIdx] = ( m_frameRcvd[iViewIdx] == m_iFrameToBeEncoded ? true : eos[iViewIdx] ); |
---|
874 | allEos = allEos|eos[iViewIdx] ; |
---|
875 | } |
---|
876 | if( m_bUsingDepthMaps ) |
---|
877 | { |
---|
878 | Int frmCntDepth = 0; |
---|
879 | while ( !depthEos[iViewIdx] && !(frmCntDepth == gopSize)) |
---|
880 | { |
---|
881 | // get buffers |
---|
882 | xGetBuffer(pcDepthPicYuvRec, iViewIdx, true); |
---|
883 | |
---|
884 | // read input YUV file |
---|
885 | m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcDepthPicYuvOrg, m_aiPad ); |
---|
886 | |
---|
887 | m_acTEncDepthTopList[iViewIdx]->initNewPic( pcDepthPicYuvOrg ); |
---|
888 | |
---|
889 | // increase number of received frames |
---|
890 | m_depthFrameRcvd[iViewIdx]++; |
---|
891 | frmCntDepth++; |
---|
892 | // check end of file |
---|
893 | depthEos[iViewIdx] = ( m_acTVideoIOYuvDepthInputFileList[iViewIdx]->isEof() == 1 ? true : false ); |
---|
894 | depthEos[iViewIdx] = ( m_depthFrameRcvd[iViewIdx] == m_iFrameToBeEncoded ? true : depthEos[iViewIdx] ); |
---|
895 | allEos = allEos|depthEos[iViewIdx] ; |
---|
896 | } |
---|
897 | } |
---|
898 | } |
---|
899 | for ( Int gopId=0; gopId < gopSize; gopId++ ) |
---|
900 | { |
---|
901 | Int iNumEncoded = 0; |
---|
902 | UInt iNextPoc = m_acTEncTopList[0] -> getFrameId( gopId ); |
---|
903 | if ( iNextPoc < m_iFrameToBeEncoded ) |
---|
904 | { |
---|
905 | m_cCameraData.update( iNextPoc ); |
---|
906 | } |
---|
907 | for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) |
---|
908 | { |
---|
909 | iNumEncoded = 0; |
---|
910 | // call encoding function for one frame |
---|
911 | m_acTEncTopList[iViewIdx]->encode( eos[iViewIdx], pcPicYuvOrg, *m_picYuvRec[iViewIdx], outputAccessUnits, iNumEncoded, gopId ); |
---|
912 | xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, iViewIdx, false); |
---|
913 | outputAccessUnits.clear(); |
---|
914 | if( m_bUsingDepthMaps ) |
---|
915 | { |
---|
916 | Int iNumDepthEncoded = 0; |
---|
917 | // call encoding function for one depth frame |
---|
918 | m_acTEncDepthTopList[iViewIdx]->encode( depthEos[iViewIdx], pcDepthPicYuvOrg, *m_picYuvDepthRec[iViewIdx], outputAccessUnits, iNumDepthEncoded, gopId ); |
---|
919 | xWriteOutput(bitstreamFile, iNumDepthEncoded, outputAccessUnits, iViewIdx, true); |
---|
920 | outputAccessUnits.clear(); |
---|
921 | } |
---|
922 | } |
---|
923 | #if HHI_INTERVIEW_SKIP || HHI_INTER_VIEW_MOTION_PRED || HHI_INTER_VIEW_RESIDUAL_PRED |
---|
924 | for( Int iViewIdx = 0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) |
---|
925 | { |
---|
926 | if( iViewIdx < (Int)m_acTEncTopList.size() && m_acTEncTopList[iViewIdx] ) |
---|
927 | { |
---|
928 | m_acTEncTopList[iViewIdx]->deleteExtraPicBuffers( m_acTEncTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() ); |
---|
929 | } |
---|
930 | if( iViewIdx < (Int)m_acTEncDepthTopList.size() && m_acTEncDepthTopList[iViewIdx] ) |
---|
931 | { |
---|
932 | m_acTEncDepthTopList[iViewIdx]->deleteExtraPicBuffers( m_acTEncTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() ); |
---|
933 | } |
---|
934 | } |
---|
935 | #endif |
---|
936 | for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) |
---|
937 | { |
---|
938 | m_acTEncTopList[iViewIdx]->compressMotion( m_acTEncTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() ); |
---|
939 | if( m_bUsingDepthMaps ) |
---|
940 | { |
---|
941 | m_acTEncDepthTopList[iViewIdx]->compressMotion( m_acTEncDepthTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() ); |
---|
942 | } |
---|
943 | } |
---|
944 | } |
---|
945 | gopSize = maxGopSize; |
---|
946 | } |
---|
947 | // delete original YUV buffer |
---|
948 | pcPicYuvOrg->destroy(); |
---|
949 | delete pcPicYuvOrg; |
---|
950 | pcPicYuvOrg = NULL; |
---|
951 | pcDepthPicYuvOrg->destroy(); |
---|
952 | delete pcDepthPicYuvOrg; |
---|
953 | pcDepthPicYuvOrg = NULL; |
---|
954 | |
---|
955 | for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) |
---|
956 | { |
---|
957 | m_acTEncTopList[iViewIdx]->printOutSummary(m_acTEncTopList[iViewIdx]->getNumAllPicCoded()); |
---|
958 | if ( m_bUsingDepthMaps ) |
---|
959 | { |
---|
960 | m_acTEncDepthTopList[iViewIdx]->printOutSummary(m_acTEncDepthTopList[iViewIdx]->getNumAllPicCoded()); |
---|
961 | } |
---|
962 | } |
---|
963 | |
---|
964 | // delete buffers & classes |
---|
965 | xDeleteBuffer(); |
---|
966 | xDestroyLib(); |
---|
967 | |
---|
968 | return; |
---|
969 | } |
---|
970 | |
---|
971 | TEncTop* TAppEncTop::getTEncTop( Int viewId, Bool isDepth ) |
---|
972 | { |
---|
973 | if ( isDepth ) |
---|
974 | { |
---|
975 | return m_acTEncDepthTopList[viewId]; |
---|
976 | } |
---|
977 | else |
---|
978 | { |
---|
979 | return m_acTEncTopList[viewId]; |
---|
980 | } |
---|
981 | } |
---|
982 | |
---|
983 | |
---|
984 | // ==================================================================================================================== |
---|
985 | // Protected member functions |
---|
986 | // ==================================================================================================================== |
---|
987 | |
---|
988 | /** |
---|
989 | - application has picture buffer list with size of GOP |
---|
990 | - picture buffer list acts as ring buffer |
---|
991 | - end of the list has the latest picture |
---|
992 | . |
---|
993 | */ |
---|
994 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, Int iViewIdx, Bool isDepth) |
---|
995 | { |
---|
996 | assert( m_iGOPSize > 0 ); |
---|
997 | |
---|
998 | if( !isDepth ) |
---|
999 | { |
---|
1000 | if ( m_picYuvRec[iViewIdx]->size() == (UInt)m_iGOPSize ) |
---|
1001 | { |
---|
1002 | rpcPicYuvRec = m_picYuvRec[iViewIdx]->popFront(); |
---|
1003 | } |
---|
1004 | else |
---|
1005 | { |
---|
1006 | rpcPicYuvRec = new TComPicYuv; |
---|
1007 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
1008 | } |
---|
1009 | m_picYuvRec[iViewIdx]->pushBack( rpcPicYuvRec ); |
---|
1010 | } |
---|
1011 | else |
---|
1012 | { |
---|
1013 | if ( m_picYuvDepthRec[iViewIdx]->size() == (UInt)m_iGOPSize ) |
---|
1014 | { |
---|
1015 | rpcPicYuvRec = m_picYuvDepthRec[iViewIdx]->popFront(); |
---|
1016 | } |
---|
1017 | else |
---|
1018 | { |
---|
1019 | rpcPicYuvRec = new TComPicYuv; |
---|
1020 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
1021 | } |
---|
1022 | m_picYuvDepthRec[iViewIdx]->pushBack( rpcPicYuvRec ); |
---|
1023 | } |
---|
1024 | } |
---|
1025 | |
---|
1026 | Void TAppEncTop::xDeleteBuffer( ) |
---|
1027 | { |
---|
1028 | for(Int iViewIdx=0; iViewIdx<m_picYuvRec.size(); iViewIdx++) |
---|
1029 | { |
---|
1030 | if(m_picYuvRec[iViewIdx]) |
---|
1031 | { |
---|
1032 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[iViewIdx]->begin(); |
---|
1033 | Int iSize = Int( m_picYuvRec[iViewIdx]->size() ); |
---|
1034 | for ( Int i = 0; i < iSize; i++ ) |
---|
1035 | { |
---|
1036 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
1037 | if(pcPicYuvRec) |
---|
1038 | { |
---|
1039 | pcPicYuvRec->destroy(); |
---|
1040 | delete pcPicYuvRec; |
---|
1041 | pcPicYuvRec = NULL; |
---|
1042 | } |
---|
1043 | } |
---|
1044 | } |
---|
1045 | } |
---|
1046 | for(Int iViewIdx=0; iViewIdx<m_picYuvDepthRec.size(); iViewIdx++) |
---|
1047 | { |
---|
1048 | if(m_picYuvDepthRec[iViewIdx]) |
---|
1049 | { |
---|
1050 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvDepthRec[iViewIdx]->begin(); |
---|
1051 | Int iSize = Int( m_picYuvDepthRec[iViewIdx]->size() ); |
---|
1052 | for ( Int i = 0; i < iSize; i++ ) |
---|
1053 | { |
---|
1054 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
1055 | if(pcPicYuvRec) |
---|
1056 | { |
---|
1057 | pcPicYuvRec->destroy(); |
---|
1058 | delete pcPicYuvRec; |
---|
1059 | pcPicYuvRec = NULL; |
---|
1060 | } |
---|
1061 | } |
---|
1062 | } |
---|
1063 | } |
---|
1064 | } |
---|
1065 | |
---|
1066 | /** \param iNumEncoded number of encoded frames |
---|
1067 | */ |
---|
1068 | Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, Int iViewIdx, Bool isDepth ) |
---|
1069 | { |
---|
1070 | Int i; |
---|
1071 | |
---|
1072 | if( iNumEncoded > 0 ) |
---|
1073 | { |
---|
1074 | TComList<TComPicYuv*>::iterator iterPicYuvRec = !isDepth ? m_picYuvRec[iViewIdx]->end() : m_picYuvDepthRec[iViewIdx]->end(); |
---|
1075 | |
---|
1076 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
1077 | { |
---|
1078 | --iterPicYuvRec; |
---|
1079 | } |
---|
1080 | |
---|
1081 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
1082 | { |
---|
1083 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
1084 | if( !isDepth ) |
---|
1085 | { |
---|
1086 | if (m_pchReconFileList[iViewIdx]) |
---|
1087 | { |
---|
1088 | #if PIC_CROPPING |
---|
1089 | m_acTVideoIOYuvReconFileList[iViewIdx]->write( pcPicYuvRec, m_cropLeft, m_cropRight, m_cropTop, m_cropBottom ); |
---|
1090 | #else |
---|
1091 | m_acTVideoIOYuvReconFileList[iViewIdx]->write( pcPicYuvRec, m_aiPad ); |
---|
1092 | #endif |
---|
1093 | } |
---|
1094 | } |
---|
1095 | else |
---|
1096 | { |
---|
1097 | if (m_pchDepthReconFileList[iViewIdx]) |
---|
1098 | { |
---|
1099 | #if PIC_CROPPING |
---|
1100 | m_acTVideoIOYuvDepthReconFileList[iViewIdx]->write( pcPicYuvRec, m_cropLeft, m_cropRight, m_cropTop, m_cropBottom ); |
---|
1101 | #else |
---|
1102 | m_acTVideoIOYuvDepthReconFileList[iViewIdx]->write( pcPicYuvRec, m_aiPad ); |
---|
1103 | #endif |
---|
1104 | } |
---|
1105 | } |
---|
1106 | } |
---|
1107 | } |
---|
1108 | if( ! accessUnits.empty() ) |
---|
1109 | { |
---|
1110 | list<AccessUnit>::iterator aUIter; |
---|
1111 | for( aUIter = accessUnits.begin(); aUIter != accessUnits.end(); aUIter++ ) |
---|
1112 | { |
---|
1113 | const vector<unsigned>& stats = writeAnnexB(bitstreamFile, *aUIter); |
---|
1114 | rateStatsAccum(*aUIter, stats); |
---|
1115 | } |
---|
1116 | } |
---|
1117 | } |
---|
1118 | |
---|
1119 | |
---|
1120 | TComPicYuv* TAppEncTop::xGetPicYuvFromView( Int iViewIdx, Int iPoc, Bool bDepth, Bool bRecon ) |
---|
1121 | { |
---|
1122 | TComPic* pcPic = xGetPicFromView( iViewIdx, iPoc, bDepth); |
---|
1123 | TComPicYuv* pcPicYuv = NULL; |
---|
1124 | |
---|
1125 | if (pcPic != NULL) |
---|
1126 | { |
---|
1127 | if( bRecon ) |
---|
1128 | { |
---|
1129 | if ( pcPic->getReconMark() ) |
---|
1130 | { |
---|
1131 | pcPicYuv = pcPic->getPicYuvRec(); |
---|
1132 | } |
---|
1133 | } |
---|
1134 | else |
---|
1135 | { |
---|
1136 | pcPicYuv = pcPic->getPicYuvOrg(); |
---|
1137 | } |
---|
1138 | }; |
---|
1139 | |
---|
1140 | return pcPicYuv; |
---|
1141 | }; |
---|
1142 | |
---|
1143 | /** |
---|
1144 | * |
---|
1145 | */ |
---|
1146 | void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<unsigned>& annexBsizes) |
---|
1147 | { |
---|
1148 | AccessUnit::const_iterator it_au = au.begin(); |
---|
1149 | vector<unsigned>::const_iterator it_stats = annexBsizes.begin(); |
---|
1150 | |
---|
1151 | for (; it_au != au.end(); it_au++, it_stats++) |
---|
1152 | { |
---|
1153 | switch ((*it_au)->m_nalUnitType) |
---|
1154 | { |
---|
1155 | case NAL_UNIT_CODED_SLICE: |
---|
1156 | #if H0566_TLA |
---|
1157 | case NAL_UNIT_CODED_SLICE_IDV: |
---|
1158 | case NAL_UNIT_CODED_SLICE_TLA: |
---|
1159 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
1160 | #else |
---|
1161 | case NAL_UNIT_CODED_SLICE_DATAPART_A: |
---|
1162 | case NAL_UNIT_CODED_SLICE_DATAPART_B: |
---|
1163 | case NAL_UNIT_CODED_SLICE_CDR: |
---|
1164 | #endif |
---|
1165 | case NAL_UNIT_CODED_SLICE_IDR: |
---|
1166 | case NAL_UNIT_SPS: |
---|
1167 | case NAL_UNIT_PPS: |
---|
1168 | #if VIDYO_VPS_INTEGRATION |
---|
1169 | case NAL_UNIT_VPS: |
---|
1170 | #endif |
---|
1171 | m_essentialBytes += *it_stats; |
---|
1172 | break; |
---|
1173 | default: |
---|
1174 | break; |
---|
1175 | } |
---|
1176 | |
---|
1177 | m_totalBytes += *it_stats; |
---|
1178 | } |
---|
1179 | } |
---|
1180 | |
---|
1181 | #if HHI_INTERVIEW_SKIP |
---|
1182 | Void TAppEncTop::getUsedPelsMap( Int iViewIdx, Int iPoc, TComPicYuv* pcPicYuvUsedSplsMap ) |
---|
1183 | { |
---|
1184 | AOT( iViewIdx <= 0); |
---|
1185 | AOT( iViewIdx >= m_iNumberOfViews ); |
---|
1186 | AOF( m_cCameraData.getCurFrameId() == iPoc ); |
---|
1187 | Int iViewSIdx = m_cCameraData.getBaseId2SortedId()[iViewIdx]; |
---|
1188 | Int iFirstViewSIdx = m_cCameraData.getBaseId2SortedId()[0]; |
---|
1189 | |
---|
1190 | AOT( iViewSIdx == iFirstViewSIdx ); |
---|
1191 | |
---|
1192 | Bool bFirstIsLeft = (iFirstViewSIdx < iViewSIdx); |
---|
1193 | |
---|
1194 | m_cUsedPelsRenderer.setShiftLUTs( |
---|
1195 | m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx], |
---|
1196 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
1197 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
1198 | m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx], |
---|
1199 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
1200 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
1201 | -1 |
---|
1202 | ); |
---|
1203 | |
---|
1204 | TComPicYuv* pcPicYuvDepth = xGetPicYuvFromView(0, iPoc, true, true ); |
---|
1205 | AOF( pcPicYuvDepth); |
---|
1206 | |
---|
1207 | m_cUsedPelsRenderer.getUsedSamplesMap( pcPicYuvDepth, pcPicYuvUsedSplsMap, bFirstIsLeft ); |
---|
1208 | } |
---|
1209 | #endif |
---|
1210 | #if HHI_VSO |
---|
1211 | Void TAppEncTop::setupRenModel( Int iPoc, Int iEncViewIdx, Int iEncContent ) |
---|
1212 | { |
---|
1213 | Int iEncViewSIdx = m_cCameraData.getBaseId2SortedId()[ iEncViewIdx ]; |
---|
1214 | |
---|
1215 | // setup base views |
---|
1216 | Int iNumOfBV = m_cRenModStrParser.getNumOfBaseViewsForView( iEncViewSIdx, iEncContent ); |
---|
1217 | |
---|
1218 | for (Int iCurView = 0; iCurView < iNumOfBV; iCurView++ ) |
---|
1219 | { |
---|
1220 | Int iBaseViewSIdx; |
---|
1221 | Int iVideoDistMode; |
---|
1222 | Int iDepthDistMode; |
---|
1223 | |
---|
1224 | m_cRenModStrParser.getBaseViewData( iEncViewSIdx, iEncContent, iCurView, iBaseViewSIdx, iVideoDistMode, iDepthDistMode ); |
---|
1225 | |
---|
1226 | AOT( iVideoDistMode < 0 || iVideoDistMode > 2 ); |
---|
1227 | |
---|
1228 | Int iBaseViewIdx = m_cCameraData.getBaseSortedId2Id()[ iBaseViewSIdx ]; |
---|
1229 | |
---|
1230 | TComPicYuv* pcPicYuvVideoRec = xGetPicYuvFromView( iBaseViewIdx, iPoc, false, true ); |
---|
1231 | TComPicYuv* pcPicYuvDepthRec = xGetPicYuvFromView( iBaseViewIdx, iPoc, true , true ); |
---|
1232 | TComPicYuv* pcPicYuvVideoOrg = xGetPicYuvFromView( iBaseViewIdx, iPoc, false, false ); |
---|
1233 | TComPicYuv* pcPicYuvDepthOrg = xGetPicYuvFromView( iBaseViewIdx, iPoc, true , false ); |
---|
1234 | |
---|
1235 | TComPicYuv* pcPicYuvVideoRef = ( iVideoDistMode == 2 ) ? pcPicYuvVideoOrg : NULL; |
---|
1236 | TComPicYuv* pcPicYuvDepthRef = ( iDepthDistMode == 2 ) ? pcPicYuvDepthOrg : NULL; |
---|
1237 | |
---|
1238 | TComPicYuv* pcPicYuvVideoTest = ( iVideoDistMode == 0 ) ? pcPicYuvVideoOrg : pcPicYuvVideoRec; |
---|
1239 | TComPicYuv* pcPicYuvDepthTest = ( iDepthDistMode == 0 ) ? pcPicYuvDepthOrg : pcPicYuvDepthRec; |
---|
1240 | |
---|
1241 | AOT( (iVideoDistMode == 2) != (pcPicYuvVideoRef != NULL) ); |
---|
1242 | AOT( (iDepthDistMode == 2) != (pcPicYuvDepthRef != NULL) ); |
---|
1243 | AOT( pcPicYuvDepthTest == NULL ); |
---|
1244 | AOT( pcPicYuvVideoTest == NULL ); |
---|
1245 | |
---|
1246 | m_cRendererModel.setBaseView( iBaseViewSIdx, pcPicYuvVideoTest, pcPicYuvDepthTest, pcPicYuvVideoRef, pcPicYuvDepthRef ); |
---|
1247 | } |
---|
1248 | |
---|
1249 | m_cRendererModel.setErrorMode( iEncViewSIdx, iEncContent, 0 ); |
---|
1250 | // setup virtual views |
---|
1251 | Int iNumOfSV = m_cRenModStrParser.getNumOfModelsForView( iEncViewSIdx, iEncContent ); |
---|
1252 | for (Int iCurView = 0; iCurView < iNumOfSV; iCurView++ ) |
---|
1253 | { |
---|
1254 | Int iOrgRefBaseViewSIdx; |
---|
1255 | Int iLeftBaseViewSIdx; |
---|
1256 | Int iRightBaseViewSIdx; |
---|
1257 | Int iSynthViewRelNum; |
---|
1258 | Int iModelNum; |
---|
1259 | Int iBlendMode; |
---|
1260 | m_cRenModStrParser.getSingleModelData(iEncViewSIdx, iEncContent, iCurView, iModelNum, iBlendMode,iLeftBaseViewSIdx, iRightBaseViewSIdx, iOrgRefBaseViewSIdx, iSynthViewRelNum ); |
---|
1261 | |
---|
1262 | Int iLeftBaseViewIdx = -1; |
---|
1263 | Int iRightBaseViewIdx = -1; |
---|
1264 | |
---|
1265 | TComPicYuv* pcPicYuvOrgRef = NULL; |
---|
1266 | Int** ppiShiftLUTLeft = NULL; |
---|
1267 | Int** ppiShiftLUTRight = NULL; |
---|
1268 | Int** ppiBaseShiftLUTLeft = NULL; |
---|
1269 | Int** ppiBaseShiftLUTRight = NULL; |
---|
1270 | |
---|
1271 | |
---|
1272 | Int iDistToLeft = -1; |
---|
1273 | |
---|
1274 | Int iSynthViewIdx = m_cCameraData.synthRelNum2Idx( iSynthViewRelNum ); |
---|
1275 | |
---|
1276 | if ( iLeftBaseViewSIdx != -1 ) |
---|
1277 | { |
---|
1278 | iLeftBaseViewIdx = m_cCameraData.getBaseSortedId2Id() [ iLeftBaseViewSIdx ]; |
---|
1279 | ppiShiftLUTLeft = m_cCameraData.getSynthViewShiftLUTI()[ iLeftBaseViewIdx ][ iSynthViewIdx ]; |
---|
1280 | } |
---|
1281 | |
---|
1282 | if ( iRightBaseViewSIdx != -1 ) |
---|
1283 | { |
---|
1284 | iRightBaseViewIdx = m_cCameraData.getBaseSortedId2Id() [iRightBaseViewSIdx ]; |
---|
1285 | ppiShiftLUTRight = m_cCameraData.getSynthViewShiftLUTI()[ iRightBaseViewIdx ][ iSynthViewIdx ]; |
---|
1286 | } |
---|
1287 | |
---|
1288 | if ( iRightBaseViewSIdx != -1 && iLeftBaseViewSIdx != -1 ) |
---|
1289 | { |
---|
1290 | iDistToLeft = m_cCameraData.getRelDistLeft( iSynthViewIdx , iLeftBaseViewIdx, iRightBaseViewIdx); |
---|
1291 | ppiBaseShiftLUTLeft = m_cCameraData.getBaseViewShiftLUTI() [ iLeftBaseViewIdx ][ iRightBaseViewIdx ]; |
---|
1292 | ppiBaseShiftLUTRight = m_cCameraData.getBaseViewShiftLUTI() [ iRightBaseViewIdx ][ iLeftBaseViewIdx ]; |
---|
1293 | |
---|
1294 | } |
---|
1295 | |
---|
1296 | if ( iOrgRefBaseViewSIdx != -1 ) |
---|
1297 | { |
---|
1298 | pcPicYuvOrgRef = xGetPicYuvFromView( m_cCameraData.getBaseSortedId2Id()[ iOrgRefBaseViewSIdx ] , iPoc, false, false ); |
---|
1299 | AOF ( pcPicYuvOrgRef ); |
---|
1300 | } |
---|
1301 | |
---|
1302 | m_cRendererModel.setSingleModel( iModelNum, ppiShiftLUTLeft, ppiBaseShiftLUTLeft, ppiShiftLUTRight, ppiBaseShiftLUTRight, iDistToLeft, pcPicYuvOrgRef ); |
---|
1303 | } |
---|
1304 | } |
---|
1305 | #endif |
---|
1306 | |
---|
1307 | |
---|
1308 | |
---|
1309 | /* |
---|
1310 | void TAppEncTop::printRateSummary() |
---|
1311 | { |
---|
1312 | double time = (double) m_iFrameRcvd / m_iFrameRate; |
---|
1313 | printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time); |
---|
1314 | #if VERBOSE_RATE |
---|
1315 | printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time); |
---|
1316 | #endif |
---|
1317 | } |
---|
1318 | */ |
---|
1319 | |
---|
1320 | std::vector<TComPic*> TAppEncTop::getInterViewRefPics( Int viewId, Int poc, Bool isDepth, TComSPS* sps ) |
---|
1321 | { |
---|
1322 | std::vector<TComPic*> apcRefPics( sps->getNumberOfUsableInterViewRefs(), (TComPic*)NULL ); |
---|
1323 | for( Int k = 0; k < sps->getNumberOfUsableInterViewRefs(); k++ ) |
---|
1324 | { |
---|
1325 | TComPic* pcRefPic = xGetPicFromView( sps->getUsableInterViewRef( k ) + viewId, poc, isDepth ); |
---|
1326 | assert( pcRefPic != NULL ); |
---|
1327 | apcRefPics[k] = pcRefPic; |
---|
1328 | } |
---|
1329 | return apcRefPics; |
---|
1330 | } |
---|
1331 | |
---|
1332 | TComPic* TAppEncTop::xGetPicFromView( Int viewIdx, Int poc, Bool isDepth ) |
---|
1333 | { |
---|
1334 | assert( ( viewIdx >= 0 ) && ( viewIdx < m_iNumberOfViews ) ); |
---|
1335 | |
---|
1336 | TComList<TComPic*>* apcListPic = (isDepth ? m_acTEncDepthTopList[viewIdx] : m_acTEncTopList[viewIdx])->getListPic() ; |
---|
1337 | |
---|
1338 | TComPic* pcPic = NULL; |
---|
1339 | for(TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++) |
---|
1340 | { |
---|
1341 | if( (*it)->getPOC() == poc ) |
---|
1342 | { |
---|
1343 | pcPic = *it ; |
---|
1344 | break ; |
---|
1345 | } |
---|
1346 | } |
---|
1347 | |
---|
1348 | return pcPic; |
---|
1349 | }; |
---|
1350 | |
---|
1351 | //! \} |
---|