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|QC_MVHEVC_B0046 |
---|
70 | #if !QC_MVHEVC_B0046 |
---|
71 | UInt layerId = 0; |
---|
72 | #endif |
---|
73 | // TODO: fix the assumption here that the temporal structures are all equal across all layers??? |
---|
74 | m_cVPS.setMaxTLayers( m_maxTempLayer[0] ); |
---|
75 | #if QC_MVHEVC_B0046 |
---|
76 | m_cVPS.setMaxLayers( m_iNumberOfViews ); |
---|
77 | #else |
---|
78 | m_cVPS.setMaxLayers( m_iNumberOfViews * (m_bUsingDepthMaps ? 2:1) ); |
---|
79 | #endif |
---|
80 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
81 | { |
---|
82 | m_cVPS.setNumReorderPics( m_numReorderPics[0][i], i ); |
---|
83 | m_cVPS.setMaxDecPicBuffering( m_maxDecPicBuffering[0][i], i ); |
---|
84 | } |
---|
85 | #endif |
---|
86 | |
---|
87 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
88 | { |
---|
89 | m_frameRcvd.push_back(0); |
---|
90 | m_acTEncTopList.push_back(new TEncTop); |
---|
91 | m_acTVideoIOYuvInputFileList.push_back(new TVideoIOYuv); |
---|
92 | m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv); |
---|
93 | m_picYuvRec.push_back(new TComList<TComPicYuv*>) ; |
---|
94 | |
---|
95 | m_acTEncTopList[iViewIdx]->setFrameRate ( m_iFrameRate ); |
---|
96 | m_acTEncTopList[iViewIdx]->setFrameSkip ( m_FrameSkip ); |
---|
97 | m_acTEncTopList[iViewIdx]->setSourceWidth ( m_iSourceWidth ); |
---|
98 | m_acTEncTopList[iViewIdx]->setSourceHeight ( m_iSourceHeight ); |
---|
99 | m_acTEncTopList[iViewIdx]->setCroppingMode ( m_croppingMode ); |
---|
100 | m_acTEncTopList[iViewIdx]->setCropLeft ( m_cropLeft ); |
---|
101 | m_acTEncTopList[iViewIdx]->setCropRight ( m_cropRight ); |
---|
102 | m_acTEncTopList[iViewIdx]->setCropTop ( m_cropTop ); |
---|
103 | m_acTEncTopList[iViewIdx]->setCropBottom ( m_cropBottom ); |
---|
104 | m_acTEncTopList[iViewIdx]->setFrameToBeEncoded ( m_iFrameToBeEncoded ); |
---|
105 | m_acTEncTopList[iViewIdx]->setViewId ( iViewIdx ); |
---|
106 | m_acTEncTopList[iViewIdx]->setIsDepth ( false ); |
---|
107 | #if QC_MVHEVC_B0046 |
---|
108 | m_acTEncTopList[iViewIdx]->setLayerId ( iViewIdx ); |
---|
109 | m_cVPS.setViewId ( m_aiVId[ iViewIdx ], iViewIdx ); |
---|
110 | #else |
---|
111 | m_acTEncTopList[iViewIdx]->setViewOrderIdx ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] ); |
---|
112 | #if VIDYO_VPS_INTEGRATION |
---|
113 | layerId = iViewIdx * (m_bUsingDepthMaps ? 2:1); |
---|
114 | m_acTEncTopList[iViewIdx]->setLayerId ( layerId ); |
---|
115 | m_cVPS.setDepthFlag ( false, layerId ); |
---|
116 | m_cVPS.setViewId ( iViewIdx, layerId ); |
---|
117 | m_cVPS.setViewOrderIdx ( m_cCameraData.getViewOrderIndex()[ iViewIdx ], layerId ); |
---|
118 | // TODO: set correct dependentFlag and dependentLayer |
---|
119 | m_cVPS.setDependentFlag ( iViewIdx ? true:false, layerId ); |
---|
120 | m_cVPS.setDependentLayer ( layerId - (m_bUsingDepthMaps ? 2:1), layerId ); |
---|
121 | #if INTER_VIEW_VECTOR_SCALING_C0115 |
---|
122 | m_cVPS.setIVScalingFlag ( m_bUseIVS ); |
---|
123 | #endif |
---|
124 | #endif |
---|
125 | |
---|
126 | m_acTEncTopList[iViewIdx]->setCamParPrecision ( m_cCameraData.getCamParsCodedPrecision () ); |
---|
127 | m_acTEncTopList[iViewIdx]->setCamParInSliceHeader ( m_cCameraData.getVaryingCameraParameters() ); |
---|
128 | m_acTEncTopList[iViewIdx]->setCodedScale ( m_cCameraData.getCodedScale () ); |
---|
129 | m_acTEncTopList[iViewIdx]->setCodedOffset ( m_cCameraData.getCodedOffset () ); |
---|
130 | #endif |
---|
131 | |
---|
132 | //====== Coding Structure ======== |
---|
133 | m_acTEncTopList[iViewIdx]->setIntraPeriod ( m_iIntraPeriod ); |
---|
134 | m_acTEncTopList[iViewIdx]->setDecodingRefreshType ( m_iDecodingRefreshType ); |
---|
135 | m_acTEncTopList[iViewIdx]->setGOPSize ( m_iGOPSize ); |
---|
136 | m_acTEncTopList[iViewIdx]->setGopList ( m_GOPListsMvc[iViewIdx] ); |
---|
137 | m_acTEncTopList[iViewIdx]->setExtraRPSs ( m_extraRPSs[iViewIdx] ); |
---|
138 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
139 | { |
---|
140 | m_acTEncTopList[iViewIdx]->setNumReorderPics ( m_numReorderPics[iViewIdx][i], i ); |
---|
141 | m_acTEncTopList[iViewIdx]->setMaxDecPicBuffering ( m_maxDecPicBuffering[iViewIdx][i], i ); |
---|
142 | } |
---|
143 | for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop ) |
---|
144 | { |
---|
145 | m_acTEncTopList[iViewIdx]->setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] ); |
---|
146 | } |
---|
147 | m_acTEncTopList[iViewIdx]->setQP ( m_aiQP[0] ); |
---|
148 | |
---|
149 | m_acTEncTopList[iViewIdx]->setTemporalLayerQPOffset ( m_aiTLayerQPOffset ); |
---|
150 | m_acTEncTopList[iViewIdx]->setPad ( m_aiPad ); |
---|
151 | |
---|
152 | m_acTEncTopList[iViewIdx]->setMaxTempLayer ( m_maxTempLayer[iViewIdx] ); |
---|
153 | |
---|
154 | m_acTEncTopList[iViewIdx]->setDisInter4x4 ( m_bDisInter4x4); |
---|
155 | |
---|
156 | m_acTEncTopList[iViewIdx]->setUseNSQT( m_enableNSQT ); |
---|
157 | m_acTEncTopList[iViewIdx]->setUseAMP( m_enableAMP ); |
---|
158 | |
---|
159 | //===== Slice ======== |
---|
160 | |
---|
161 | //====== Loop/Deblock Filter ======== |
---|
162 | m_acTEncTopList[iViewIdx]->setLoopFilterDisable ( m_abLoopFilterDisable[0] ); |
---|
163 | m_acTEncTopList[iViewIdx]->setLoopFilterOffsetInAPS ( m_loopFilterOffsetInAPS ); |
---|
164 | m_acTEncTopList[iViewIdx]->setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 ); |
---|
165 | m_acTEncTopList[iViewIdx]->setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 ); |
---|
166 | m_acTEncTopList[iViewIdx]->setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent); |
---|
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 | #if DV_V_RESTRICTION_B0037 |
---|
173 | m_acTEncTopList[iViewIdx]->setUseDisparitySearchRangeRestriction ( m_bUseDisparitySearchRangeRestriction ); |
---|
174 | m_acTEncTopList[iViewIdx]->setVerticalDisparitySearchRange( m_iVerticalDisparitySearchRange ); |
---|
175 | #endif |
---|
176 | //====== Quality control ======== |
---|
177 | m_acTEncTopList[iViewIdx]->setMaxDeltaQP ( m_iMaxDeltaQP ); |
---|
178 | m_acTEncTopList[iViewIdx]->setMaxCuDQPDepth ( m_iMaxCuDQPDepth ); |
---|
179 | |
---|
180 | m_acTEncTopList[iViewIdx]->setChromaQpOffset ( m_iChromaQpOffset ); |
---|
181 | m_acTEncTopList[iViewIdx]->setChromaQpOffset2nd ( m_iChromaQpOffset2nd ); |
---|
182 | |
---|
183 | #if ADAPTIVE_QP_SELECTION |
---|
184 | m_acTEncTopList[iViewIdx]->setUseAdaptQpSelect ( m_bUseAdaptQpSelect ); |
---|
185 | #endif |
---|
186 | |
---|
187 | #if LOSSLESS_CODING |
---|
188 | Int lowestQP; |
---|
189 | lowestQP = - ( (Int)(6*(g_uiBitDepth + g_uiBitIncrement - 8)) ); |
---|
190 | if ((m_iMaxDeltaQP == 0 ) && (m_aiQP[0] == lowestQP) && (m_useLossless == true)) |
---|
191 | { |
---|
192 | m_bUseAdaptiveQP = false; |
---|
193 | } |
---|
194 | #endif |
---|
195 | |
---|
196 | m_acTEncTopList[iViewIdx]->setUseAdaptiveQP ( m_bUseAdaptiveQP ); |
---|
197 | m_acTEncTopList[iViewIdx]->setQPAdaptationRange ( m_iQPAdaptationRange ); |
---|
198 | |
---|
199 | #if HHI_VSO |
---|
200 | //====== VSO ========= |
---|
201 | m_acTEncTopList[iViewIdx]->setForceLambdaScaleVSO ( false ); |
---|
202 | m_acTEncTopList[iViewIdx]->setLambdaScaleVSO ( 1 ); |
---|
203 | m_acTEncTopList[iViewIdx]->setVSOMode ( 0 ); |
---|
204 | m_acTEncTopList[iViewIdx]->setUseVSO ( false ); |
---|
205 | #if SAIT_VSO_EST_A0033 |
---|
206 | m_acTEncTopList[iViewIdx]->setUseEstimatedVSD ( false ); |
---|
207 | #endif |
---|
208 | #if LGE_WVSO_A0119 |
---|
209 | m_acTEncTopList[iViewIdx]->setUseWVSO ( false ); |
---|
210 | #endif |
---|
211 | #endif |
---|
212 | |
---|
213 | #if DEPTH_MAP_GENERATION |
---|
214 | m_acTEncTopList[iViewIdx]->setPredDepthMapGeneration ( m_uiPredDepthMapGeneration ); |
---|
215 | m_acTEncTopList[iViewIdx]->setPdmPrecision ( (UInt)m_cCameraData.getPdmPrecision () ); |
---|
216 | m_acTEncTopList[iViewIdx]->setPdmScaleNomDelta ( m_cCameraData.getPdmScaleNomDelta () ); |
---|
217 | m_acTEncTopList[iViewIdx]->setPdmOffset ( m_cCameraData.getPdmOffset () ); |
---|
218 | #endif |
---|
219 | #if H3D_IVMP |
---|
220 | m_acTEncTopList[iViewIdx]->setMultiviewMvPredMode ( m_uiMultiviewMvPredMode ); |
---|
221 | m_acTEncTopList[iViewIdx]->setMultiviewMvRegMode ( iViewIdx ? m_uiMultiviewMvRegMode : 0 ); |
---|
222 | m_acTEncTopList[iViewIdx]->setMultiviewMvRegLambdaScale ( iViewIdx ? m_dMultiviewMvRegLambdaScale : 0.0 ); |
---|
223 | #endif |
---|
224 | #if H3D_IVRP |
---|
225 | #if QC_ARP_D0177 |
---|
226 | m_acTEncTopList[iViewIdx]->setUseAdvRP ( iViewIdx ? m_nUseAdvResPred : 0 ); |
---|
227 | m_acTEncTopList[iViewIdx]->setARPStepNum ( iViewIdx ? QC_ARP_WFNR : 1 ); |
---|
228 | #else |
---|
229 | m_acTEncTopList[iViewIdx]->setMultiviewResPredMode ( m_uiMultiviewResPredMode ); |
---|
230 | #endif |
---|
231 | #endif |
---|
232 | |
---|
233 | //====== Tool list ======== |
---|
234 | m_acTEncTopList[iViewIdx]->setUseSBACRD ( m_bUseSBACRD ); |
---|
235 | m_acTEncTopList[iViewIdx]->setDeltaQpRD ( m_uiDeltaQpRD ); |
---|
236 | m_acTEncTopList[iViewIdx]->setUseASR ( m_bUseASR ); |
---|
237 | m_acTEncTopList[iViewIdx]->setUseHADME ( m_bUseHADME ); |
---|
238 | m_acTEncTopList[iViewIdx]->setUseALF ( m_abUseALF[0] ); |
---|
239 | m_acTEncTopList[iViewIdx]->setALFEncodePassReduction ( m_iALFEncodePassReduction ); |
---|
240 | #if LOSSLESS_CODING |
---|
241 | m_acTEncTopList[iViewIdx]->setUseLossless ( m_useLossless ); |
---|
242 | #endif |
---|
243 | m_acTEncTopList[iViewIdx]->setALFMaxNumberFilters ( m_iALFMaxNumberFilters ) ; |
---|
244 | |
---|
245 | m_acTEncTopList[iViewIdx]->setUseLComb ( m_bUseLComb ); |
---|
246 | m_acTEncTopList[iViewIdx]->setLCMod ( m_bLCMod ); |
---|
247 | m_acTEncTopList[iViewIdx]->setdQPs ( m_aidQP ); |
---|
248 | m_acTEncTopList[iViewIdx]->setUseRDOQ ( m_abUseRDOQ[0] ); |
---|
249 | m_acTEncTopList[iViewIdx]->setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize ); |
---|
250 | m_acTEncTopList[iViewIdx]->setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize ); |
---|
251 | m_acTEncTopList[iViewIdx]->setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); |
---|
252 | m_acTEncTopList[iViewIdx]->setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); |
---|
253 | m_acTEncTopList[iViewIdx]->setUseFastEnc ( m_bUseFastEnc ); |
---|
254 | m_acTEncTopList[iViewIdx]->setUseEarlyCU ( m_bUseEarlyCU ); |
---|
255 | m_acTEncTopList[iViewIdx]->setUseFastDecisionForMerge ( m_useFastDecisionForMerge ); |
---|
256 | m_acTEncTopList[iViewIdx]->setUseCbfFastMode ( m_bUseCbfFastMode ); |
---|
257 | #if HHI_INTERVIEW_SKIP |
---|
258 | m_acTEncTopList[iViewIdx]->setInterViewSkip ( iViewIdx>0 ? m_bInterViewSkip : false ); |
---|
259 | #if HHI_INTERVIEW_SKIP_LAMBDA_SCALE |
---|
260 | m_acTEncTopList[iViewIdx]->setInterViewSkipLambdaScale ( iViewIdx>0 ? (UInt)m_dInterViewSkipLambdaScale : 1 ); |
---|
261 | #endif |
---|
262 | #endif |
---|
263 | m_acTEncTopList[iViewIdx]->setUseLMChroma ( m_bUseLMChroma ); |
---|
264 | m_acTEncTopList[iViewIdx]->setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); |
---|
265 | m_acTEncTopList[iViewIdx]->setPCMLog2MinSize ( m_uiPCMLog2MinSize); |
---|
266 | m_acTEncTopList[iViewIdx]->setUsePCM ( m_usePCM ); |
---|
267 | m_acTEncTopList[iViewIdx]->setPCMLog2MaxSize ( m_pcmLog2MaxSize); |
---|
268 | |
---|
269 | //====== Weighted Prediction ======== |
---|
270 | m_acTEncTopList[iViewIdx]->setUseWP ( m_bUseWeightPred ); |
---|
271 | m_acTEncTopList[iViewIdx]->setWPBiPredIdc ( m_uiBiPredIdc ); |
---|
272 | //====== Slice ======== |
---|
273 | m_acTEncTopList[iViewIdx]->setSliceMode ( m_iSliceMode ); |
---|
274 | m_acTEncTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument ); |
---|
275 | |
---|
276 | //====== Entropy Slice ======== |
---|
277 | m_acTEncTopList[iViewIdx]->setEntropySliceMode ( m_iEntropySliceMode ); |
---|
278 | m_acTEncTopList[iViewIdx]->setEntropySliceArgument ( m_iEntropySliceArgument ); |
---|
279 | int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1); |
---|
280 | if(m_iEntropySliceMode==SHARP_FIXED_NUMBER_OF_LCU_IN_ENTROPY_SLICE) |
---|
281 | { |
---|
282 | m_acTEncTopList[iViewIdx]->setEntropySliceArgument ( m_iEntropySliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) ); |
---|
283 | } |
---|
284 | if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE) |
---|
285 | { |
---|
286 | m_acTEncTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) ); |
---|
287 | } |
---|
288 | if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE) |
---|
289 | { |
---|
290 | m_acTEncTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument ); |
---|
291 | } |
---|
292 | m_acTEncTopList[iViewIdx]->setSliceGranularity ( m_iSliceGranularity ); |
---|
293 | if(m_iSliceMode == 0 ) |
---|
294 | { |
---|
295 | m_bLFCrossSliceBoundaryFlag = true; |
---|
296 | } |
---|
297 | m_acTEncTopList[iViewIdx]->setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
298 | m_acTEncTopList[iViewIdx]->setUseSAO ( m_abUseSAO[0] ); |
---|
299 | #if LGE_ILLUCOMP_B0045 |
---|
300 | #if LGE_ILLUCOMP_DEPTH_C0046 |
---|
301 | m_acTEncTopList[iViewIdx]->setUseIC ( m_abUseIC[0] ); |
---|
302 | #else |
---|
303 | m_acTEncTopList[iViewIdx]->setUseIC ( m_bUseIC ); |
---|
304 | #endif |
---|
305 | #endif |
---|
306 | #if INTER_VIEW_VECTOR_SCALING_C0115 |
---|
307 | m_acTEncTopList[iViewIdx]->setUseIVS ( m_bUseIVS ); |
---|
308 | #endif |
---|
309 | m_acTEncTopList[iViewIdx]->setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic); |
---|
310 | m_acTEncTopList[iViewIdx]->setSaoInterleavingFlag (m_saoInterleavingFlag); |
---|
311 | m_acTEncTopList[iViewIdx]->setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag); |
---|
312 | m_acTEncTopList[iViewIdx]->setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag); |
---|
313 | |
---|
314 | m_acTEncTopList[iViewIdx]->setPictureDigestEnabled(m_pictureDigestEnabled); |
---|
315 | |
---|
316 | m_acTEncTopList[iViewIdx]->setColumnRowInfoPresent ( m_iColumnRowInfoPresent ); |
---|
317 | m_acTEncTopList[iViewIdx]->setUniformSpacingIdr ( m_iUniformSpacingIdr ); |
---|
318 | m_acTEncTopList[iViewIdx]->setNumColumnsMinus1 ( m_iNumColumnsMinus1 ); |
---|
319 | m_acTEncTopList[iViewIdx]->setNumRowsMinus1 ( m_iNumRowsMinus1 ); |
---|
320 | if(m_iUniformSpacingIdr==0) |
---|
321 | { |
---|
322 | m_acTEncTopList[iViewIdx]->setColumnWidth ( m_pchColumnWidth ); |
---|
323 | m_acTEncTopList[iViewIdx]->setRowHeight ( m_pchRowHeight ); |
---|
324 | } |
---|
325 | m_acTEncTopList[iViewIdx]->xCheckGSParameters(); |
---|
326 | m_acTEncTopList[iViewIdx]->setTileLocationInSliceHeaderFlag ( m_iTileLocationInSliceHeaderFlag ); |
---|
327 | m_acTEncTopList[iViewIdx]->setTileMarkerFlag ( m_iTileMarkerFlag ); |
---|
328 | m_acTEncTopList[iViewIdx]->setMaxTileMarkerEntryPoints ( m_iMaxTileMarkerEntryPoints ); |
---|
329 | |
---|
330 | Int uiTilesCount = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1); |
---|
331 | m_dMaxTileMarkerOffset = ((Double)uiTilesCount) / m_iMaxTileMarkerEntryPoints; |
---|
332 | m_acTEncTopList[iViewIdx]->setMaxTileMarkerOffset ( m_dMaxTileMarkerOffset ); |
---|
333 | m_acTEncTopList[iViewIdx]->setTileBehaviorControlPresentFlag( m_iTileBehaviorControlPresentFlag ); |
---|
334 | if(uiTilesCount == 1) |
---|
335 | { |
---|
336 | m_bLFCrossTileBoundaryFlag = true; |
---|
337 | } |
---|
338 | m_acTEncTopList[iViewIdx]->setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); |
---|
339 | m_acTEncTopList[iViewIdx]->setWaveFrontSynchro ( m_iWaveFrontSynchro ); |
---|
340 | m_acTEncTopList[iViewIdx]->setWaveFrontFlush ( m_iWaveFrontFlush ); |
---|
341 | m_acTEncTopList[iViewIdx]->setWaveFrontSubstreams ( m_iWaveFrontSubstreams ); |
---|
342 | #if TMVP_DEPTH_SWITCH |
---|
343 | m_acTEncTopList[iViewIdx]->setEnableTMVP ( m_enableTMVP[0] ); |
---|
344 | #else |
---|
345 | m_acTEncTopList[iViewIdx]->setEnableTMVP ( m_enableTMVP ); |
---|
346 | #endif |
---|
347 | m_acTEncTopList[iViewIdx]->setUseScalingListId ( m_useScalingListId ); |
---|
348 | m_acTEncTopList[iViewIdx]->setScalingListFile ( m_scalingListFile ); |
---|
349 | m_acTEncTopList[iViewIdx]->setSignHideFlag(m_signHideFlag); |
---|
350 | m_acTEncTopList[iViewIdx]->setTSIG(m_signHidingThreshold); |
---|
351 | |
---|
352 | if(uiTilesCount > 1) |
---|
353 | { |
---|
354 | m_bALFParamInSlice = false; |
---|
355 | m_bALFPicBasedEncode = true; |
---|
356 | } |
---|
357 | m_acTEncTopList[iViewIdx]->setALFParamInSlice ( m_bALFParamInSlice); |
---|
358 | m_acTEncTopList[iViewIdx]->setALFPicBasedEncode ( m_bALFPicBasedEncode); |
---|
359 | |
---|
360 | //====== Depth tools ======== |
---|
361 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
362 | m_acTEncTopList[iViewIdx]->setUseDMM ( false ); |
---|
363 | #endif |
---|
364 | #if H3D_QTL |
---|
365 | m_acTEncTopList[iViewIdx]->setUseQTLPC ( false ); |
---|
366 | #endif |
---|
367 | #if HHI_MPI |
---|
368 | m_acTEncTopList[iViewIdx]->setUseMVI( false ); |
---|
369 | #endif |
---|
370 | #if RWTH_SDC_DLT_B0036 |
---|
371 | m_acTEncTopList[iViewIdx]->setUseDLT ( false ); |
---|
372 | m_acTEncTopList[iViewIdx]->setUseSDC ( false ); |
---|
373 | #endif |
---|
374 | } |
---|
375 | if( m_bUsingDepthMaps ) |
---|
376 | { |
---|
377 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
378 | { |
---|
379 | |
---|
380 | #if FLEX_CODING_ORDER_M23723 |
---|
381 | // Detect whether depth comes before than texture for this view |
---|
382 | Bool isDepthFirst = false; |
---|
383 | if ( m_b3DVFlexOrder ) |
---|
384 | { |
---|
385 | for ( Int ii=1; ii<12; ii+=2 ) |
---|
386 | { |
---|
387 | Int iViewIdxCfg = (Int)(m_pchMVCJointCodingOrder[ii]-'0'); |
---|
388 | if ( iViewIdxCfg == iViewIdx ) |
---|
389 | { |
---|
390 | if ( m_pchMVCJointCodingOrder[ii-1]=='D' ) // depth comes first for this view |
---|
391 | { |
---|
392 | isDepthFirst = true; |
---|
393 | } |
---|
394 | else |
---|
395 | { |
---|
396 | assert(m_pchMVCJointCodingOrder[ii-1]=='T'); |
---|
397 | } |
---|
398 | break; |
---|
399 | } |
---|
400 | } |
---|
401 | } |
---|
402 | #endif |
---|
403 | |
---|
404 | m_depthFrameRcvd.push_back(0); |
---|
405 | m_acTEncDepthTopList.push_back(new TEncTop); |
---|
406 | m_acTVideoIOYuvDepthInputFileList.push_back(new TVideoIOYuv); |
---|
407 | m_acTVideoIOYuvDepthReconFileList.push_back(new TVideoIOYuv); |
---|
408 | m_picYuvDepthRec.push_back(new TComList<TComPicYuv*>) ; |
---|
409 | |
---|
410 | m_acTEncDepthTopList[iViewIdx]->setFrameRate ( m_iFrameRate ); |
---|
411 | m_acTEncDepthTopList[iViewIdx]->setFrameSkip ( m_FrameSkip ); |
---|
412 | m_acTEncDepthTopList[iViewIdx]->setSourceWidth ( m_iSourceWidth ); |
---|
413 | m_acTEncDepthTopList[iViewIdx]->setSourceHeight ( m_iSourceHeight ); |
---|
414 | m_acTEncDepthTopList[iViewIdx]->setCroppingMode ( m_croppingMode ); |
---|
415 | m_acTEncDepthTopList[iViewIdx]->setCropLeft ( m_cropLeft ); |
---|
416 | m_acTEncDepthTopList[iViewIdx]->setCropRight ( m_cropRight ); |
---|
417 | m_acTEncDepthTopList[iViewIdx]->setCropTop ( m_cropTop ); |
---|
418 | m_acTEncDepthTopList[iViewIdx]->setCropBottom ( m_cropBottom ); |
---|
419 | m_acTEncDepthTopList[iViewIdx]->setFrameToBeEncoded ( m_iFrameToBeEncoded ); |
---|
420 | m_acTEncDepthTopList[iViewIdx]->setViewId ( iViewIdx ); |
---|
421 | m_acTEncDepthTopList[iViewIdx]->setIsDepth ( true ); |
---|
422 | #if QC_MVHEVC_B0046 |
---|
423 | m_acTEncDepthTopList[iViewIdx]->setLayerId ( iViewIdx ); |
---|
424 | #else |
---|
425 | m_acTEncDepthTopList[iViewIdx]->setViewOrderIdx ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] ); |
---|
426 | #endif |
---|
427 | #if VIDYO_VPS_INTEGRATION |
---|
428 | layerId = iViewIdx * 2 + 1; |
---|
429 | m_acTEncDepthTopList[iViewIdx]->setLayerId ( layerId ); |
---|
430 | m_cVPS.setDepthFlag ( true, layerId ); |
---|
431 | m_cVPS.setViewId ( iViewIdx, layerId ); |
---|
432 | m_cVPS.setViewOrderIdx ( m_cCameraData.getViewOrderIndex()[ iViewIdx ], layerId ); |
---|
433 | m_cVPS.setDependentFlag ( true, layerId ); |
---|
434 | m_cVPS.setDependentLayer ( layerId-1, layerId); |
---|
435 | #endif |
---|
436 | #if FCO_FIX_SPS_CHANGE |
---|
437 | m_acTEncDepthTopList[iViewIdx]->setCamParPrecision ( m_cCameraData.getCamParsCodedPrecision () ); |
---|
438 | m_acTEncDepthTopList[iViewIdx]->setCamParInSliceHeader ( m_cCameraData.getVaryingCameraParameters() ); |
---|
439 | m_acTEncDepthTopList[iViewIdx]->setCodedScale ( m_cCameraData.getCodedScale () ); |
---|
440 | m_acTEncDepthTopList[iViewIdx]->setCodedOffset ( m_cCameraData.getCodedOffset () ); |
---|
441 | #else |
---|
442 | m_acTEncDepthTopList[iViewIdx]->setCamParPrecision ( 0 ); |
---|
443 | m_acTEncDepthTopList[iViewIdx]->setCamParInSliceHeader ( false ); |
---|
444 | m_acTEncDepthTopList[iViewIdx]->setCodedScale ( 0 ); |
---|
445 | m_acTEncDepthTopList[iViewIdx]->setCodedOffset ( 0 ); |
---|
446 | #endif |
---|
447 | |
---|
448 | //====== Coding Structure ======== |
---|
449 | m_acTEncDepthTopList[iViewIdx]->setIntraPeriod ( m_iIntraPeriod ); |
---|
450 | m_acTEncDepthTopList[iViewIdx]->setDecodingRefreshType ( m_iDecodingRefreshType ); |
---|
451 | m_acTEncDepthTopList[iViewIdx]->setGOPSize ( m_iGOPSize ); |
---|
452 | m_acTEncDepthTopList[iViewIdx]->setGopList ( m_GOPListsMvc[iViewIdx] ); |
---|
453 | m_acTEncDepthTopList[iViewIdx]->setExtraRPSs ( m_extraRPSs[iViewIdx] ); |
---|
454 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
455 | { |
---|
456 | m_acTEncDepthTopList[iViewIdx]->setNumReorderPics ( m_numReorderPics[iViewIdx][i], i ); |
---|
457 | m_acTEncDepthTopList[iViewIdx]->setMaxDecPicBuffering ( m_maxDecPicBuffering[iViewIdx][i], i ); |
---|
458 | } |
---|
459 | for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop ) |
---|
460 | { |
---|
461 | m_acTEncDepthTopList[iViewIdx]->setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] ); |
---|
462 | } |
---|
463 | m_acTEncDepthTopList[iViewIdx]->setQP ( m_aiQP[1] ); |
---|
464 | |
---|
465 | m_acTEncDepthTopList[iViewIdx]->setTemporalLayerQPOffset ( m_aiTLayerQPOffset ); |
---|
466 | m_acTEncDepthTopList[iViewIdx]->setPad ( m_aiPad ); |
---|
467 | |
---|
468 | m_acTEncDepthTopList[iViewIdx]->setMaxTempLayer ( m_maxTempLayer[iViewIdx] ); |
---|
469 | |
---|
470 | m_acTEncDepthTopList[iViewIdx]->setDisInter4x4 ( m_bDisInter4x4); |
---|
471 | |
---|
472 | m_acTEncDepthTopList[iViewIdx]->setUseNSQT( m_enableNSQT ); |
---|
473 | m_acTEncDepthTopList[iViewIdx]->setUseAMP( m_enableAMP ); |
---|
474 | |
---|
475 | //===== Slice ======== |
---|
476 | |
---|
477 | //====== Loop/Deblock Filter ======== |
---|
478 | m_acTEncDepthTopList[iViewIdx]->setLoopFilterDisable ( m_abLoopFilterDisable[1] ); |
---|
479 | m_acTEncDepthTopList[iViewIdx]->setLoopFilterOffsetInAPS ( m_loopFilterOffsetInAPS ); |
---|
480 | m_acTEncDepthTopList[iViewIdx]->setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 ); |
---|
481 | m_acTEncDepthTopList[iViewIdx]->setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 ); |
---|
482 | m_acTEncDepthTopList[iViewIdx]->setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent); |
---|
483 | |
---|
484 | //====== Motion search ======== |
---|
485 | m_acTEncDepthTopList[iViewIdx]->setFastSearch ( m_iFastSearch ); |
---|
486 | m_acTEncDepthTopList[iViewIdx]->setSearchRange ( m_iSearchRange ); |
---|
487 | m_acTEncDepthTopList[iViewIdx]->setBipredSearchRange ( m_bipredSearchRange ); |
---|
488 | #if DV_V_RESTRICTION_B0037 |
---|
489 | m_acTEncDepthTopList[iViewIdx]->setUseDisparitySearchRangeRestriction ( m_bUseDisparitySearchRangeRestriction ); |
---|
490 | m_acTEncDepthTopList[iViewIdx]->setVerticalDisparitySearchRange( m_iVerticalDisparitySearchRange ); |
---|
491 | #endif |
---|
492 | //====== Quality control ======== |
---|
493 | m_acTEncDepthTopList[iViewIdx]->setMaxDeltaQP ( m_iMaxDeltaQP ); |
---|
494 | m_acTEncDepthTopList[iViewIdx]->setMaxCuDQPDepth ( m_iMaxCuDQPDepth ); |
---|
495 | |
---|
496 | m_acTEncDepthTopList[iViewIdx]->setChromaQpOffset ( m_iChromaQpOffset ); |
---|
497 | m_acTEncDepthTopList[iViewIdx]->setChromaQpOffset2nd ( m_iChromaQpOffset2nd ); |
---|
498 | |
---|
499 | #if ADAPTIVE_QP_SELECTION |
---|
500 | m_acTEncDepthTopList[iViewIdx]->setUseAdaptQpSelect ( m_bUseAdaptQpSelect ); |
---|
501 | #endif |
---|
502 | |
---|
503 | m_acTEncDepthTopList[iViewIdx]->setUseAdaptiveQP ( m_bUseAdaptiveQP ); |
---|
504 | m_acTEncDepthTopList[iViewIdx]->setQPAdaptationRange ( m_iQPAdaptationRange ); |
---|
505 | |
---|
506 | //====== Tool list ======== |
---|
507 | m_acTEncDepthTopList[iViewIdx]->setUseSBACRD ( m_bUseSBACRD ); |
---|
508 | m_acTEncDepthTopList[iViewIdx]->setDeltaQpRD ( m_uiDeltaQpRD ); |
---|
509 | m_acTEncDepthTopList[iViewIdx]->setUseASR ( m_bUseASR ); |
---|
510 | m_acTEncDepthTopList[iViewIdx]->setUseHADME ( m_bUseHADME ); |
---|
511 | m_acTEncDepthTopList[iViewIdx]->setUseALF ( m_abUseALF[1] ); |
---|
512 | m_acTEncDepthTopList[iViewIdx]->setALFEncodePassReduction ( m_iALFEncodePassReduction ); |
---|
513 | #if LOSSLESS_CODING |
---|
514 | m_acTEncDepthTopList[iViewIdx]->setUseLossless ( m_useLossless ); |
---|
515 | #endif |
---|
516 | m_acTEncDepthTopList[iViewIdx]->setALFMaxNumberFilters ( m_iALFMaxNumberFilters ) ; |
---|
517 | |
---|
518 | m_acTEncDepthTopList[iViewIdx]->setUseLComb ( m_bUseLComb ); |
---|
519 | m_acTEncDepthTopList[iViewIdx]->setLCMod ( m_bLCMod ); |
---|
520 | m_acTEncDepthTopList[iViewIdx]->setdQPs ( m_aidQPdepth ); |
---|
521 | m_acTEncDepthTopList[iViewIdx]->setUseRDOQ ( m_abUseRDOQ[1] ); |
---|
522 | m_acTEncDepthTopList[iViewIdx]->setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize ); |
---|
523 | m_acTEncDepthTopList[iViewIdx]->setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize ); |
---|
524 | m_acTEncDepthTopList[iViewIdx]->setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); |
---|
525 | m_acTEncDepthTopList[iViewIdx]->setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); |
---|
526 | m_acTEncDepthTopList[iViewIdx]->setUseFastEnc ( m_bUseFastEnc ); |
---|
527 | m_acTEncDepthTopList[iViewIdx]->setUseEarlyCU ( m_bUseEarlyCU ); |
---|
528 | m_acTEncDepthTopList[iViewIdx]->setUseFastDecisionForMerge ( m_useFastDecisionForMerge ); |
---|
529 | m_acTEncDepthTopList[iViewIdx]->setUseCbfFastMode ( m_bUseCbfFastMode ); |
---|
530 | #if HHI_INTERVIEW_SKIP |
---|
531 | m_acTEncDepthTopList[iViewIdx]->setInterViewSkip ( 0 ); |
---|
532 | #if HHI_INTERVIEW_SKIP_LAMBDA_SCALE |
---|
533 | m_acTEncDepthTopList[iViewIdx]->setInterViewSkipLambdaScale ( 1 ); |
---|
534 | #endif |
---|
535 | #endif |
---|
536 | m_acTEncDepthTopList[iViewIdx]->setUseLMChroma ( m_bUseLMChroma ); |
---|
537 | m_acTEncDepthTopList[iViewIdx]->setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); |
---|
538 | m_acTEncDepthTopList[iViewIdx]->setPCMLog2MinSize ( m_uiPCMLog2MinSize); |
---|
539 | m_acTEncDepthTopList[iViewIdx]->setUsePCM ( m_usePCM ); |
---|
540 | m_acTEncDepthTopList[iViewIdx]->setPCMLog2MaxSize ( m_pcmLog2MaxSize); |
---|
541 | //====== VSO ======== |
---|
542 | #if HHI_VSO |
---|
543 | m_acTEncDepthTopList[iViewIdx]->setUseVSO ( m_bUseVSO ); //GT: might be enabled/disabled later for VSO Mode 4 |
---|
544 | m_acTEncDepthTopList[iViewIdx]->setForceLambdaScaleVSO ( m_bForceLambdaScaleVSO ); |
---|
545 | m_acTEncDepthTopList[iViewIdx]->setLambdaScaleVSO ( m_dLambdaScaleVSO ); |
---|
546 | #if HHI_VSO_DIST_INT |
---|
547 | m_acTEncDepthTopList[iViewIdx]->setAllowNegDist ( m_bAllowNegDist ); |
---|
548 | #endif |
---|
549 | m_acTEncDepthTopList[iViewIdx]->setVSOMode ( m_uiVSOMode ); |
---|
550 | |
---|
551 | #if SAIT_VSO_EST_A0033 |
---|
552 | m_acTEncDepthTopList[iViewIdx]->setUseEstimatedVSD ( m_bUseEstimatedVSD ); |
---|
553 | #endif |
---|
554 | #if LGE_WVSO_A0119 |
---|
555 | m_acTEncDepthTopList[iViewIdx]->setUseWVSO ( m_bUseWVSO ); |
---|
556 | #endif |
---|
557 | #endif |
---|
558 | |
---|
559 | #if DEPTH_MAP_GENERATION |
---|
560 | m_acTEncDepthTopList[iViewIdx]->setPredDepthMapGeneration ( 0 ); |
---|
561 | #endif |
---|
562 | #if H3D_IVMP |
---|
563 | m_acTEncDepthTopList[iViewIdx]->setMultiviewMvPredMode ( 0 ); |
---|
564 | m_acTEncDepthTopList[iViewIdx]->setMultiviewMvRegMode ( 0 ); |
---|
565 | m_acTEncDepthTopList[iViewIdx]->setMultiviewMvRegLambdaScale ( 0.0 ); |
---|
566 | #endif |
---|
567 | #if H3D_IVRP |
---|
568 | #if QC_ARP_D0177 |
---|
569 | m_acTEncDepthTopList[iViewIdx]->setUseAdvRP ( 0 ); |
---|
570 | m_acTEncDepthTopList[iViewIdx]->setARPStepNum ( 1 ); |
---|
571 | #else |
---|
572 | m_acTEncDepthTopList[iViewIdx]->setMultiviewResPredMode ( 0 ); |
---|
573 | #endif |
---|
574 | #endif |
---|
575 | |
---|
576 | //====== Weighted Prediction ======== |
---|
577 | m_acTEncDepthTopList[iViewIdx]->setUseWP ( m_bUseWeightPred ); |
---|
578 | m_acTEncDepthTopList[iViewIdx]->setWPBiPredIdc ( m_uiBiPredIdc ); |
---|
579 | //====== Slice ======== |
---|
580 | m_acTEncDepthTopList[iViewIdx]->setSliceMode ( m_iSliceMode ); |
---|
581 | m_acTEncDepthTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument ); |
---|
582 | |
---|
583 | //====== Entropy Slice ======== |
---|
584 | m_acTEncDepthTopList[iViewIdx]->setEntropySliceMode ( m_iEntropySliceMode ); |
---|
585 | m_acTEncDepthTopList[iViewIdx]->setEntropySliceArgument ( m_iEntropySliceArgument ); |
---|
586 | int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1); |
---|
587 | if(m_iEntropySliceMode==SHARP_FIXED_NUMBER_OF_LCU_IN_ENTROPY_SLICE) |
---|
588 | { |
---|
589 | m_acTEncDepthTopList[iViewIdx]->setEntropySliceArgument ( m_iEntropySliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) ); |
---|
590 | } |
---|
591 | if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE) |
---|
592 | { |
---|
593 | m_acTEncDepthTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) ); |
---|
594 | } |
---|
595 | if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE) |
---|
596 | { |
---|
597 | m_acTEncDepthTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument ); |
---|
598 | } |
---|
599 | m_acTEncDepthTopList[iViewIdx]->setSliceGranularity ( m_iSliceGranularity ); |
---|
600 | if(m_iSliceMode == 0 ) |
---|
601 | { |
---|
602 | m_bLFCrossSliceBoundaryFlag = true; |
---|
603 | } |
---|
604 | m_acTEncDepthTopList[iViewIdx]->setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
605 | m_acTEncDepthTopList[iViewIdx]->setUseSAO ( m_abUseSAO[1] ); |
---|
606 | #if LGE_ILLUCOMP_B0045 |
---|
607 | #if LGE_ILLUCOMP_DEPTH_C0046 |
---|
608 | m_acTEncDepthTopList[iViewIdx]->setUseIC ( m_abUseIC[1] ); |
---|
609 | #else |
---|
610 | m_acTEncDepthTopList[iViewIdx]->setUseIC ( false ); |
---|
611 | #endif |
---|
612 | #endif |
---|
613 | #if INTER_VIEW_VECTOR_SCALING_C0115 |
---|
614 | m_acTEncDepthTopList[iViewIdx]->setUseIVS ( m_bUseIVS ); |
---|
615 | #endif |
---|
616 | m_acTEncDepthTopList[iViewIdx]->setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic); |
---|
617 | m_acTEncDepthTopList[iViewIdx]->setSaoInterleavingFlag (m_saoInterleavingFlag); |
---|
618 | m_acTEncDepthTopList[iViewIdx]->setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag); |
---|
619 | m_acTEncDepthTopList[iViewIdx]->setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag); |
---|
620 | |
---|
621 | m_acTEncDepthTopList[iViewIdx]->setPictureDigestEnabled(m_pictureDigestEnabled); |
---|
622 | |
---|
623 | m_acTEncDepthTopList[iViewIdx]->setColumnRowInfoPresent ( m_iColumnRowInfoPresent ); |
---|
624 | m_acTEncDepthTopList[iViewIdx]->setUniformSpacingIdr ( m_iUniformSpacingIdr ); |
---|
625 | m_acTEncDepthTopList[iViewIdx]->setNumColumnsMinus1 ( m_iNumColumnsMinus1 ); |
---|
626 | m_acTEncDepthTopList[iViewIdx]->setNumRowsMinus1 ( m_iNumRowsMinus1 ); |
---|
627 | if(m_iUniformSpacingIdr==0) |
---|
628 | { |
---|
629 | m_acTEncDepthTopList[iViewIdx]->setColumnWidth ( m_pchColumnWidth ); |
---|
630 | m_acTEncDepthTopList[iViewIdx]->setRowHeight ( m_pchRowHeight ); |
---|
631 | } |
---|
632 | m_acTEncDepthTopList[iViewIdx]->xCheckGSParameters(); |
---|
633 | m_acTEncDepthTopList[iViewIdx]->setTileLocationInSliceHeaderFlag ( m_iTileLocationInSliceHeaderFlag ); |
---|
634 | m_acTEncDepthTopList[iViewIdx]->setTileMarkerFlag ( m_iTileMarkerFlag ); |
---|
635 | m_acTEncDepthTopList[iViewIdx]->setMaxTileMarkerEntryPoints ( m_iMaxTileMarkerEntryPoints ); |
---|
636 | |
---|
637 | Int uiTilesCount = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1); |
---|
638 | m_dMaxTileMarkerOffset = ((Double)uiTilesCount) / m_iMaxTileMarkerEntryPoints; |
---|
639 | m_acTEncDepthTopList[iViewIdx]->setMaxTileMarkerOffset ( m_dMaxTileMarkerOffset ); |
---|
640 | m_acTEncDepthTopList[iViewIdx]->setTileBehaviorControlPresentFlag( m_iTileBehaviorControlPresentFlag ); |
---|
641 | if(uiTilesCount == 1) |
---|
642 | { |
---|
643 | m_bLFCrossTileBoundaryFlag = true; |
---|
644 | } |
---|
645 | m_acTEncDepthTopList[iViewIdx]->setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); |
---|
646 | m_acTEncDepthTopList[iViewIdx]->setWaveFrontSynchro ( m_iWaveFrontSynchro ); |
---|
647 | m_acTEncDepthTopList[iViewIdx]->setWaveFrontFlush ( m_iWaveFrontFlush ); |
---|
648 | m_acTEncDepthTopList[iViewIdx]->setWaveFrontSubstreams ( m_iWaveFrontSubstreams ); |
---|
649 | #if TMVP_DEPTH_SWITCH |
---|
650 | m_acTEncDepthTopList[iViewIdx]->setEnableTMVP ( m_enableTMVP[1] ); |
---|
651 | #else |
---|
652 | m_acTEncDepthTopList[iViewIdx]->setEnableTMVP ( m_enableTMVP ); |
---|
653 | #endif |
---|
654 | m_acTEncDepthTopList[iViewIdx]->setUseScalingListId ( m_useScalingListId ); |
---|
655 | m_acTEncDepthTopList[iViewIdx]->setScalingListFile ( m_scalingListFile ); |
---|
656 | m_acTEncDepthTopList[iViewIdx]->setSignHideFlag(m_signHideFlag); |
---|
657 | m_acTEncDepthTopList[iViewIdx]->setTSIG(m_signHidingThreshold); |
---|
658 | |
---|
659 | if(uiTilesCount > 1) |
---|
660 | { |
---|
661 | m_bALFParamInSlice = false; |
---|
662 | m_bALFPicBasedEncode = true; |
---|
663 | } |
---|
664 | m_acTEncDepthTopList[iViewIdx]->setALFParamInSlice ( m_bALFParamInSlice); |
---|
665 | m_acTEncDepthTopList[iViewIdx]->setALFPicBasedEncode ( m_bALFPicBasedEncode); |
---|
666 | |
---|
667 | //====== Depth tools ======== |
---|
668 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
669 | m_acTEncDepthTopList[iViewIdx]->setUseDMM ( m_bUseDMM ); |
---|
670 | #endif |
---|
671 | #if FLEX_CODING_ORDER_M23723 && HHI_DMM_PRED_TEX |
---|
672 | m_acTEncDepthTopList[iViewIdx]->setUseDMM34( (m_b3DVFlexOrder && isDepthFirst) ? false : m_bUseDMM ); |
---|
673 | #endif |
---|
674 | |
---|
675 | #if H3D_QTL |
---|
676 | m_acTEncDepthTopList[iViewIdx]->setUseQTLPC (m_bUseQTLPC); |
---|
677 | #endif |
---|
678 | #if HHI_MPI |
---|
679 | #if FLEX_CODING_ORDER_M23723 |
---|
680 | m_acTEncDepthTopList[iViewIdx]->setUseMVI( (m_b3DVFlexOrder && isDepthFirst) ? false : m_bUseMVI ); |
---|
681 | #else |
---|
682 | m_acTEncDepthTopList[iViewIdx]->setUseMVI( m_bUseMVI ); |
---|
683 | #endif |
---|
684 | #endif |
---|
685 | #if RWTH_SDC_DLT_B0036 |
---|
686 | m_acTEncDepthTopList[iViewIdx]->setUseDLT ( m_bUseDLT ); |
---|
687 | m_acTEncDepthTopList[iViewIdx]->setUseSDC ( m_bUseSDC ); |
---|
688 | #endif |
---|
689 | } |
---|
690 | } |
---|
691 | |
---|
692 | #if H3D_IVMP |
---|
693 | else if( m_uiMultiviewMvRegMode ) |
---|
694 | { |
---|
695 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
696 | { |
---|
697 | m_acTVideoIOYuvDepthInputFileList.push_back( new TVideoIOYuv ); |
---|
698 | } |
---|
699 | } |
---|
700 | #endif |
---|
701 | |
---|
702 | #if HHI_VSO |
---|
703 | if ( m_bUseVSO ) |
---|
704 | { |
---|
705 | if ( m_uiVSOMode == 4 ) |
---|
706 | { |
---|
707 | #if LGE_VSO_EARLY_SKIP_A0093 |
---|
708 | m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0, m_bVSOEarlySkip ); |
---|
709 | #else |
---|
710 | m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0 ); |
---|
711 | #endif |
---|
712 | |
---|
713 | for ( Int iViewNum = 0; iViewNum < m_iNumberOfViews; iViewNum++ ) |
---|
714 | { |
---|
715 | for (Int iContent = 0; iContent < 2; iContent++ ) |
---|
716 | { |
---|
717 | Int iNumOfModels = m_cRenModStrParser.getNumOfModelsForView(iViewNum, iContent); |
---|
718 | Bool bUseVSO = (iNumOfModels != 0); |
---|
719 | |
---|
720 | TEncTop* pcEncTop = ( iContent == 0 ) ? m_acTEncTopList[iViewNum] : m_acTEncDepthTopList[iViewNum]; |
---|
721 | pcEncTop->setUseVSO( bUseVSO ); |
---|
722 | pcEncTop->getRdCost()->setRenModel( bUseVSO ? &m_cRendererModel : NULL ); |
---|
723 | |
---|
724 | for (Int iCurModel = 0; iCurModel < iNumOfModels; iCurModel++ ) |
---|
725 | { |
---|
726 | Int iModelNum; Int iLeftViewNum; Int iRightViewNum; Int iDump; Int iOrgRefNum; Int iBlendMode; |
---|
727 | |
---|
728 | m_cRenModStrParser.getSingleModelData ( iViewNum, iContent, iCurModel, iModelNum, iBlendMode, iLeftViewNum, iRightViewNum, iOrgRefNum, iDump ) ; |
---|
729 | m_cRendererModel .createSingleModel ( iViewNum, iContent, iModelNum, iLeftViewNum, iRightViewNum, (iOrgRefNum != -1), iBlendMode ); |
---|
730 | } |
---|
731 | } |
---|
732 | } |
---|
733 | } |
---|
734 | else |
---|
735 | { |
---|
736 | AOT(true); |
---|
737 | } |
---|
738 | #if LGE_WVSO_A0119 |
---|
739 | for ( Int iViewNum = 0; iViewNum < m_iNumberOfViews; iViewNum++ ) |
---|
740 | { |
---|
741 | for (Int iContent = 0; iContent < 2; iContent++ ) |
---|
742 | { |
---|
743 | TEncTop* pcEncTop = ( iContent == 0 ) ? m_acTEncTopList[iViewNum] : m_acTEncDepthTopList[iViewNum]; |
---|
744 | pcEncTop->setUseWVSO ( m_bUseWVSO ); |
---|
745 | pcEncTop->setVSOWeight( m_iVSOWeight ); |
---|
746 | pcEncTop->setVSDWeight( m_iVSDWeight ); |
---|
747 | pcEncTop->setDWeight ( m_iDWeight ); |
---|
748 | } |
---|
749 | } |
---|
750 | #endif |
---|
751 | } |
---|
752 | #endif |
---|
753 | |
---|
754 | #if HHI_INTERVIEW_SKIP |
---|
755 | m_cUsedPelsRenderer.init(m_iSourceWidth, m_iSourceHeight, true, 0, LOG2_DISP_PREC_LUT, true, 0, 0, 0, 0, 0, 6, 4, 1, 0, 6 ); |
---|
756 | #endif |
---|
757 | |
---|
758 | } |
---|
759 | |
---|
760 | Void TAppEncTop::xCreateLib() |
---|
761 | { |
---|
762 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
763 | { |
---|
764 | m_acTVideoIOYuvInputFileList[iViewIdx]->open( m_pchInputFileList[iViewIdx], false, m_uiInputBitDepth, m_uiInternalBitDepth ); // read mode |
---|
765 | m_acTVideoIOYuvInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]); |
---|
766 | |
---|
767 | if (m_pchReconFileList[iViewIdx]) |
---|
768 | m_acTVideoIOYuvReconFileList[iViewIdx]->open(m_pchReconFileList[iViewIdx], true, m_uiOutputBitDepth, m_uiInternalBitDepth); // write mode |
---|
769 | m_acTEncTopList[iViewIdx]->create(); |
---|
770 | if( m_bUsingDepthMaps ) |
---|
771 | { |
---|
772 | m_acTVideoIOYuvDepthInputFileList[iViewIdx]->open( m_pchDepthInputFileList[iViewIdx], false, m_uiInputBitDepth, m_uiInternalBitDepth ); // read mode |
---|
773 | m_acTVideoIOYuvDepthInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]); |
---|
774 | |
---|
775 | if (m_pchDepthReconFileList[iViewIdx]) |
---|
776 | m_acTVideoIOYuvDepthReconFileList[iViewIdx]->open(m_pchDepthReconFileList[iViewIdx], true, m_uiOutputBitDepth, m_uiInternalBitDepth); // write mode |
---|
777 | m_acTEncDepthTopList[iViewIdx]->create(); |
---|
778 | } |
---|
779 | #if H3D_IVMP |
---|
780 | else if( m_uiMultiviewMvRegMode ) |
---|
781 | { |
---|
782 | m_acTVideoIOYuvDepthInputFileList[iViewIdx]->open( m_pchDepthInputFileList[iViewIdx], false, m_uiInputBitDepth, m_uiInternalBitDepth ); // read mode |
---|
783 | m_acTVideoIOYuvDepthInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth, m_iSourceHeight); |
---|
784 | } |
---|
785 | #endif |
---|
786 | } |
---|
787 | } |
---|
788 | |
---|
789 | Void TAppEncTop::xDestroyLib() |
---|
790 | { |
---|
791 | // Video I/O |
---|
792 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
793 | { |
---|
794 | m_acTVideoIOYuvInputFileList[iViewIdx]->close(); |
---|
795 | m_acTVideoIOYuvReconFileList[iViewIdx]->close(); |
---|
796 | delete m_acTVideoIOYuvInputFileList[iViewIdx] ; |
---|
797 | m_acTVideoIOYuvInputFileList[iViewIdx] = NULL; |
---|
798 | delete m_acTVideoIOYuvReconFileList[iViewIdx] ; |
---|
799 | m_acTVideoIOYuvReconFileList[iViewIdx] = NULL; |
---|
800 | m_acTEncTopList[iViewIdx]->deletePicBuffer(); |
---|
801 | m_acTEncTopList[iViewIdx]->destroy(); |
---|
802 | delete m_acTEncTopList[iViewIdx] ; |
---|
803 | m_acTEncTopList[iViewIdx] = NULL; |
---|
804 | delete m_picYuvRec[iViewIdx] ; |
---|
805 | m_picYuvRec[iViewIdx] = NULL; |
---|
806 | |
---|
807 | if( iViewIdx < Int( m_acTVideoIOYuvDepthInputFileList.size() ) && m_acTVideoIOYuvDepthInputFileList[iViewIdx] ) |
---|
808 | { |
---|
809 | m_acTVideoIOYuvDepthInputFileList[iViewIdx]->close( ); |
---|
810 | delete m_acTVideoIOYuvDepthInputFileList[iViewIdx]; |
---|
811 | m_acTVideoIOYuvDepthInputFileList[iViewIdx] = NULL; |
---|
812 | } |
---|
813 | if( iViewIdx < Int( m_acTVideoIOYuvDepthReconFileList.size() ) && m_acTVideoIOYuvDepthReconFileList[iViewIdx] ) |
---|
814 | { |
---|
815 | m_acTVideoIOYuvDepthReconFileList[iViewIdx]->close () ; |
---|
816 | delete m_acTVideoIOYuvDepthReconFileList[iViewIdx]; |
---|
817 | m_acTVideoIOYuvDepthReconFileList[iViewIdx] = NULL; |
---|
818 | } |
---|
819 | if( iViewIdx < Int( m_acTEncDepthTopList.size() ) && m_acTEncDepthTopList[iViewIdx] ) |
---|
820 | { |
---|
821 | m_acTEncDepthTopList[iViewIdx]->deletePicBuffer(); |
---|
822 | m_acTEncDepthTopList[iViewIdx]->destroy(); |
---|
823 | delete m_acTEncDepthTopList[iViewIdx]; |
---|
824 | m_acTEncDepthTopList[iViewIdx] = NULL; |
---|
825 | } |
---|
826 | if( iViewIdx < Int( m_picYuvDepthRec.size() ) && m_picYuvDepthRec[iViewIdx] ) |
---|
827 | { |
---|
828 | delete m_picYuvDepthRec[iViewIdx] ; |
---|
829 | m_picYuvDepthRec[iViewIdx] = NULL; |
---|
830 | } |
---|
831 | } |
---|
832 | } |
---|
833 | |
---|
834 | Void TAppEncTop::xInitLib() |
---|
835 | { |
---|
836 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
837 | { |
---|
838 | m_acTEncTopList[iViewIdx]->init( this ); |
---|
839 | #if QC_MVHEVC_B0046 |
---|
840 | //set setNumDirectRefLayer |
---|
841 | Int iNumDirectRef = m_acTEncTopList[iViewIdx]->getSPS()->getNumberOfUsableInterViewRefs(); |
---|
842 | m_acTEncTopList[iViewIdx]->getEncTop()->getVPS()->setNumDirectRefLayer(iNumDirectRef, iViewIdx); |
---|
843 | for(Int iNumIvRef = 0; iNumIvRef < iNumDirectRef; iNumIvRef ++) |
---|
844 | { |
---|
845 | Int iLayerId = m_acTEncTopList[iViewIdx]->getSPS()->getUsableInterViewRef(iNumIvRef); |
---|
846 | m_acTEncTopList[iViewIdx]->getEncTop()->getVPS()->setDirectRefLayerId( iLayerId + iViewIdx, iViewIdx, iNumIvRef); |
---|
847 | } |
---|
848 | #endif |
---|
849 | } |
---|
850 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
851 | { |
---|
852 | m_acTEncTopList[iViewIdx]->setTEncTopList( &m_acTEncTopList ); |
---|
853 | } |
---|
854 | if ( m_bUsingDepthMaps ) |
---|
855 | { |
---|
856 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
857 | { |
---|
858 | m_acTEncDepthTopList[iViewIdx]->init( this ); |
---|
859 | } |
---|
860 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
861 | { |
---|
862 | m_acTEncDepthTopList[iViewIdx]->setTEncTopList( &m_acTEncDepthTopList ); |
---|
863 | } |
---|
864 | } |
---|
865 | } |
---|
866 | |
---|
867 | // ==================================================================================================================== |
---|
868 | // Public member functions |
---|
869 | // ==================================================================================================================== |
---|
870 | |
---|
871 | /** |
---|
872 | - create internal class |
---|
873 | - initialize internal variable |
---|
874 | - until the end of input YUV file, call encoding function in TEncTop class |
---|
875 | - delete allocated buffers |
---|
876 | - destroy internal class |
---|
877 | . |
---|
878 | */ |
---|
879 | Void TAppEncTop::encode() |
---|
880 | { |
---|
881 | fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out); |
---|
882 | if (!bitstreamFile) |
---|
883 | { |
---|
884 | fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile); |
---|
885 | exit(EXIT_FAILURE); |
---|
886 | } |
---|
887 | |
---|
888 | TComPicYuv* pcPicYuvOrg = new TComPicYuv; |
---|
889 | TComPicYuv* pcDepthPicYuvOrg = new TComPicYuv; |
---|
890 | #if !QC_MVHEVC_B0046 |
---|
891 | TComPicYuv* pcPdmDepthOrg = new TComPicYuv; |
---|
892 | #endif |
---|
893 | TComPicYuv* pcPicYuvRec = NULL; |
---|
894 | TComPicYuv* pcDepthPicYuvRec = NULL; |
---|
895 | |
---|
896 | // initialize internal class & member variables |
---|
897 | xInitLibCfg(); |
---|
898 | xCreateLib(); |
---|
899 | xInitLib(); |
---|
900 | |
---|
901 | // main encoder loop |
---|
902 | Bool allEos = false; |
---|
903 | std::vector<Bool> eos ; |
---|
904 | std::vector<Bool> depthEos ; |
---|
905 | Int maxGopSize = 0; |
---|
906 | Int gopSize = 1; |
---|
907 | |
---|
908 | list<AccessUnit> outputAccessUnits; ///< list of access units to write out. is populated by the encoding process |
---|
909 | maxGopSize = (std::max)(maxGopSize, m_acTEncTopList[0]->getGOPSize()); |
---|
910 | |
---|
911 | for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) |
---|
912 | { |
---|
913 | eos.push_back( false ); |
---|
914 | depthEos.push_back( false ); |
---|
915 | |
---|
916 | #if RWTH_SDC_DLT_B0036 |
---|
917 | if( m_bUsingDepthMaps && m_bUseDLT ) |
---|
918 | xAnalyzeInputBaseDepth(iViewIdx, m_iIntraPeriod); |
---|
919 | #endif |
---|
920 | } |
---|
921 | |
---|
922 | // allocate original YUV buffer |
---|
923 | pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
924 | pcDepthPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
925 | |
---|
926 | #if H3D_IVMP |
---|
927 | if( m_uiMultiviewMvRegMode ) |
---|
928 | { |
---|
929 | pcPdmDepthOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
930 | } |
---|
931 | #endif |
---|
932 | |
---|
933 | while ( !allEos ) |
---|
934 | { |
---|
935 | for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) |
---|
936 | { |
---|
937 | Int frmCnt = 0; |
---|
938 | while ( !eos[iViewIdx] && !(frmCnt == gopSize)) |
---|
939 | { |
---|
940 | // get buffers |
---|
941 | xGetBuffer(pcPicYuvRec, iViewIdx, false); |
---|
942 | |
---|
943 | // read input YUV file |
---|
944 | m_acTVideoIOYuvInputFileList[iViewIdx]->read( pcPicYuvOrg, m_aiPad ); |
---|
945 | |
---|
946 | #if H3D_IVMP |
---|
947 | if( m_uiMultiviewMvRegMode && iViewIdx ) |
---|
948 | { |
---|
949 | m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcPdmDepthOrg, m_aiPad, m_bUsingDepthMaps ); |
---|
950 | } |
---|
951 | #endif |
---|
952 | |
---|
953 | #if H3D_IVMP |
---|
954 | m_acTEncTopList[iViewIdx]->initNewPic( pcPicYuvOrg, ( m_uiMultiviewMvRegMode && iViewIdx ? pcPdmDepthOrg : 0 ) ); |
---|
955 | #else |
---|
956 | m_acTEncTopList[iViewIdx]->initNewPic( pcPicYuvOrg ); |
---|
957 | #endif |
---|
958 | |
---|
959 | // increase number of received frames |
---|
960 | m_frameRcvd[iViewIdx]++; |
---|
961 | frmCnt++; |
---|
962 | // check end of file |
---|
963 | eos[iViewIdx] = ( m_acTVideoIOYuvInputFileList[iViewIdx]->isEof() == 1 ? true : false ); |
---|
964 | eos[iViewIdx] = ( m_frameRcvd[iViewIdx] == m_iFrameToBeEncoded ? true : eos[iViewIdx] ); |
---|
965 | allEos = allEos|eos[iViewIdx] ; |
---|
966 | } |
---|
967 | if( m_bUsingDepthMaps ) |
---|
968 | { |
---|
969 | Int frmCntDepth = 0; |
---|
970 | while ( !depthEos[iViewIdx] && !(frmCntDepth == gopSize)) |
---|
971 | { |
---|
972 | // get buffers |
---|
973 | xGetBuffer(pcDepthPicYuvRec, iViewIdx, true); |
---|
974 | |
---|
975 | // read input YUV file |
---|
976 | m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcDepthPicYuvOrg, m_aiPad ); |
---|
977 | |
---|
978 | m_acTEncDepthTopList[iViewIdx]->initNewPic( pcDepthPicYuvOrg ); |
---|
979 | |
---|
980 | // increase number of received frames |
---|
981 | m_depthFrameRcvd[iViewIdx]++; |
---|
982 | frmCntDepth++; |
---|
983 | // check end of file |
---|
984 | depthEos[iViewIdx] = ( m_acTVideoIOYuvDepthInputFileList[iViewIdx]->isEof() == 1 ? true : false ); |
---|
985 | depthEos[iViewIdx] = ( m_depthFrameRcvd[iViewIdx] == m_iFrameToBeEncoded ? true : depthEos[iViewIdx] ); |
---|
986 | allEos = allEos|depthEos[iViewIdx] ; |
---|
987 | } |
---|
988 | } |
---|
989 | } |
---|
990 | for ( Int gopId=0; gopId < gopSize; gopId++ ) |
---|
991 | { |
---|
992 | Int iNumEncoded = 0; |
---|
993 | |
---|
994 | #if !QC_MVHEVC_B0046 |
---|
995 | UInt iNextPoc = m_acTEncTopList[0] -> getFrameId( gopId ); |
---|
996 | if ( iNextPoc < m_iFrameToBeEncoded ) |
---|
997 | { |
---|
998 | m_cCameraData.update( iNextPoc ); |
---|
999 | } |
---|
1000 | #endif |
---|
1001 | |
---|
1002 | |
---|
1003 | #if FLEX_CODING_ORDER_M23723 |
---|
1004 | if (m_b3DVFlexOrder) |
---|
1005 | { |
---|
1006 | Int iNumDepthEncoded = 0; |
---|
1007 | iNumEncoded = 0; |
---|
1008 | Int i=0; |
---|
1009 | Int iViewIdx=0; |
---|
1010 | Int iNumberofDepthViews = m_bUsingDepthMaps?m_iNumberOfViews:0; |
---|
1011 | for (Int j=0; j < (m_iNumberOfViews+ iNumberofDepthViews); j++ ) |
---|
1012 | { |
---|
1013 | if (m_pchMVCJointCodingOrder[i]=='T') |
---|
1014 | { |
---|
1015 | |
---|
1016 | i++; |
---|
1017 | assert(isdigit(m_pchMVCJointCodingOrder[i])); |
---|
1018 | iViewIdx = (Int)(m_pchMVCJointCodingOrder[i]-'0'); |
---|
1019 | #if (FCO_FIX && MERL_VSP_C0152) |
---|
1020 | Int iCurPoc = m_acTEncTopList[iViewIdx]->getFrameId(gopId); |
---|
1021 | if( iCurPoc < m_acTEncTopList[iViewIdx]->getFrameToBeEncoded() && iViewIdx!=0 ) |
---|
1022 | { |
---|
1023 | TComPic* pcBaseTxtPic = getPicFromView( 0, m_acTEncTopList[iViewIdx]->getFrameId(gopId), false ); //get base view reconstructed texture |
---|
1024 | TComPic* pcBaseDepthPic = getPicFromView( 0, m_acTEncTopList[iViewIdx]->getFrameId(gopId), true ); //get base view reconstructed depth |
---|
1025 | TEncSlice* pEncSlice = m_acTEncTopList[iViewIdx]->getSliceEncoder(); |
---|
1026 | pEncSlice->setRefPicBaseTxt(pcBaseTxtPic); |
---|
1027 | pEncSlice->setRefPicBaseDepth(pcBaseDepthPic); |
---|
1028 | } |
---|
1029 | setBWVSPLUT( iViewIdx, gopId, false); |
---|
1030 | #endif |
---|
1031 | |
---|
1032 | m_acTEncTopList[iViewIdx]->encode( eos[iViewIdx], pcPicYuvOrg, *m_picYuvRec[iViewIdx], outputAccessUnits, iNumEncoded, gopId ); |
---|
1033 | xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, iViewIdx, false); |
---|
1034 | outputAccessUnits.clear(); |
---|
1035 | i++; |
---|
1036 | } |
---|
1037 | else if ( m_pchMVCJointCodingOrder[i] == 'D') |
---|
1038 | { |
---|
1039 | |
---|
1040 | i++; |
---|
1041 | if( m_bUsingDepthMaps ) |
---|
1042 | { |
---|
1043 | assert(isdigit(m_pchMVCJointCodingOrder[i])); |
---|
1044 | iViewIdx = (Int)(m_pchMVCJointCodingOrder[i]-'0'); |
---|
1045 | |
---|
1046 | #if SAIT_VSO_EST_A0033 |
---|
1047 | if( m_bUseVSO && iNextPoc < m_iFrameToBeEncoded ) |
---|
1048 | { |
---|
1049 | m_cCameraData.xSetDispCoeff( iNextPoc, iViewIdx ); |
---|
1050 | m_acTEncDepthTopList[iViewIdx]->setDispCoeff( m_cCameraData.getDispCoeff() ); |
---|
1051 | } |
---|
1052 | #endif |
---|
1053 | #if (FCO_FIX && MERL_VSP_C0152) |
---|
1054 | Int iCurPocDepth = m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId); |
---|
1055 | if( iCurPocDepth < m_acTEncDepthTopList[iViewIdx]->getFrameToBeEncoded() && iViewIdx!=0 ) |
---|
1056 | { |
---|
1057 | TComPic* pcBaseDepthPic = getPicFromView( 0, m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId), true ); |
---|
1058 | TEncSlice* pcSlice = (TEncSlice*) m_acTEncDepthTopList[iViewIdx]->getSliceEncoder(); |
---|
1059 | pcSlice->setRefPicBaseDepth(pcBaseDepthPic); |
---|
1060 | } |
---|
1061 | setBWVSPLUT( iViewIdx, gopId, true); |
---|
1062 | #endif |
---|
1063 | m_acTEncDepthTopList[iViewIdx]->encode( depthEos[iViewIdx], pcDepthPicYuvOrg, *m_picYuvDepthRec[iViewIdx], outputAccessUnits, iNumDepthEncoded, gopId ); |
---|
1064 | xWriteOutput(bitstreamFile, iNumDepthEncoded, outputAccessUnits, iViewIdx, true); |
---|
1065 | outputAccessUnits.clear(); |
---|
1066 | i++; |
---|
1067 | } |
---|
1068 | } |
---|
1069 | } |
---|
1070 | } |
---|
1071 | else |
---|
1072 | { |
---|
1073 | |
---|
1074 | #endif |
---|
1075 | for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) |
---|
1076 | { |
---|
1077 | #if SAIT_VSO_EST_A0033 |
---|
1078 | if( m_bUseVSO && iNextPoc < m_iFrameToBeEncoded ) |
---|
1079 | { |
---|
1080 | m_cCameraData.xSetDispCoeff( iNextPoc, iViewIdx ); |
---|
1081 | m_acTEncDepthTopList[iViewIdx]->setDispCoeff( m_cCameraData.getDispCoeff() ); |
---|
1082 | } |
---|
1083 | #endif |
---|
1084 | iNumEncoded = 0; |
---|
1085 | |
---|
1086 | #if MERL_VSP_C0152 |
---|
1087 | #if MERL_VSP_C0152_BugFix_ForNoDepthCase |
---|
1088 | if(m_bUsingDepthMaps) // VSP can be used only when depth is available as input |
---|
1089 | { |
---|
1090 | #endif |
---|
1091 | Int iCurPoc = m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId); |
---|
1092 | if( iCurPoc < m_acTEncDepthTopList[iViewIdx]->getFrameToBeEncoded() && iViewIdx!=0 ) |
---|
1093 | { |
---|
1094 | TComPic* pcBaseTxtPic = getPicFromView( 0, m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId), false ); //get base view reconstructed texture |
---|
1095 | TComPic* pcBaseDepthPic = getPicFromView( 0, m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId), true ); //get base view reconstructed depth |
---|
1096 | TEncSlice* pEncSlice = m_acTEncTopList[iViewIdx]->getSliceEncoder(); |
---|
1097 | pEncSlice->setRefPicBaseTxt(pcBaseTxtPic); |
---|
1098 | pEncSlice->setRefPicBaseDepth(pcBaseDepthPic); |
---|
1099 | #if MERL_VSP_NBDV_RefVId_Fix_D0166 |
---|
1100 | for (Int refViewId=0; refViewId < iViewIdx; refViewId++ ) |
---|
1101 | { |
---|
1102 | pEncSlice->setListDepthPic(m_acTEncDepthTopList[refViewId]->getListPic(), refViewId ); // The list will store only the depth pictures |
---|
1103 | setBWVSPLUT(refViewId, iViewIdx, gopId, false); |
---|
1104 | } |
---|
1105 | #endif |
---|
1106 | } |
---|
1107 | #if !MERL_VSP_NBDV_RefVId_Fix_D0166 |
---|
1108 | setBWVSPLUT( iViewIdx, gopId, false); |
---|
1109 | #endif |
---|
1110 | #endif |
---|
1111 | |
---|
1112 | #if MERL_VSP_C0152_BugFix_ForNoDepthCase |
---|
1113 | } |
---|
1114 | else |
---|
1115 | { |
---|
1116 | Int iCurPoc = m_acTEncTopList[iViewIdx]->getFrameId(gopId); |
---|
1117 | if( iCurPoc < m_acTEncTopList[iViewIdx]->getFrameToBeEncoded() && iViewIdx!=0 ) |
---|
1118 | { |
---|
1119 | TEncSlice* pEncSlice = m_acTEncTopList[iViewIdx]->getSliceEncoder(); |
---|
1120 | pEncSlice->setRefPicBaseTxt(NULL);//Initialize the base view reconstructed texture buffer |
---|
1121 | pEncSlice->setRefPicBaseDepth(NULL);//Initialize the base view reconstructed depth buffer |
---|
1122 | } |
---|
1123 | } |
---|
1124 | #endif |
---|
1125 | |
---|
1126 | // call encoding function for one frame |
---|
1127 | m_acTEncTopList[iViewIdx]->encode( eos[iViewIdx], pcPicYuvOrg, *m_picYuvRec[iViewIdx], outputAccessUnits, iNumEncoded, gopId ); |
---|
1128 | xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, iViewIdx, false); |
---|
1129 | outputAccessUnits.clear(); |
---|
1130 | if( m_bUsingDepthMaps ) |
---|
1131 | { |
---|
1132 | Int iNumDepthEncoded = 0; |
---|
1133 | #if MERL_VSP_C0152 |
---|
1134 | Int iCurPocDepth = m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId); |
---|
1135 | if( iCurPocDepth < m_acTEncDepthTopList[iViewIdx]->getFrameToBeEncoded() && iViewIdx!=0 ) |
---|
1136 | { |
---|
1137 | TComPic* pcBaseDepthPic = getPicFromView( 0, m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId), true ); |
---|
1138 | TEncSlice* pcSlice = (TEncSlice*) m_acTEncDepthTopList[iViewIdx]->getSliceEncoder(); |
---|
1139 | pcSlice->setRefPicBaseDepth(pcBaseDepthPic); |
---|
1140 | #if MERL_VSP_NBDV_RefVId_Fix_D0166 |
---|
1141 | for (Int refViewId=0; refViewId < iViewIdx; refViewId++ ) |
---|
1142 | { |
---|
1143 | pcSlice->setListDepthPic(m_acTEncDepthTopList[refViewId]->getListPic(), refViewId ); // The list will store only the depth pictures |
---|
1144 | setBWVSPLUT( refViewId, iViewIdx, gopId, true); |
---|
1145 | } |
---|
1146 | #endif |
---|
1147 | } |
---|
1148 | #if !MERL_VSP_NBDV_RefVId_Fix_D0166 |
---|
1149 | setBWVSPLUT( iViewIdx, gopId, true); |
---|
1150 | #endif |
---|
1151 | #endif |
---|
1152 | |
---|
1153 | // call encoding function for one depth frame |
---|
1154 | m_acTEncDepthTopList[iViewIdx]->encode( depthEos[iViewIdx], pcDepthPicYuvOrg, *m_picYuvDepthRec[iViewIdx], outputAccessUnits, iNumDepthEncoded, gopId ); |
---|
1155 | xWriteOutput(bitstreamFile, iNumDepthEncoded, outputAccessUnits, iViewIdx, true); |
---|
1156 | outputAccessUnits.clear(); |
---|
1157 | } |
---|
1158 | } |
---|
1159 | |
---|
1160 | #if FLEX_CODING_ORDER_M23723 |
---|
1161 | } |
---|
1162 | #endif |
---|
1163 | |
---|
1164 | #if HHI_INTERVIEW_SKIP || H3D_IVMP || H3D_IVRP |
---|
1165 | for( Int iViewIdx = 0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) |
---|
1166 | { |
---|
1167 | if( iViewIdx < (Int)m_acTEncTopList.size() && m_acTEncTopList[iViewIdx] ) |
---|
1168 | { |
---|
1169 | m_acTEncTopList[iViewIdx]->deleteExtraPicBuffers( m_acTEncTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() ); |
---|
1170 | } |
---|
1171 | if( iViewIdx < (Int)m_acTEncDepthTopList.size() && m_acTEncDepthTopList[iViewIdx] ) |
---|
1172 | { |
---|
1173 | m_acTEncDepthTopList[iViewIdx]->deleteExtraPicBuffers( m_acTEncTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() ); |
---|
1174 | } |
---|
1175 | } |
---|
1176 | #endif |
---|
1177 | for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) |
---|
1178 | { |
---|
1179 | m_acTEncTopList[iViewIdx]->compressMotion( m_acTEncTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() ); |
---|
1180 | if( m_bUsingDepthMaps ) |
---|
1181 | { |
---|
1182 | m_acTEncDepthTopList[iViewIdx]->compressMotion( m_acTEncDepthTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() ); |
---|
1183 | } |
---|
1184 | } |
---|
1185 | } |
---|
1186 | gopSize = maxGopSize; |
---|
1187 | } |
---|
1188 | // delete original YUV buffer |
---|
1189 | pcPicYuvOrg->destroy(); |
---|
1190 | delete pcPicYuvOrg; |
---|
1191 | pcPicYuvOrg = NULL; |
---|
1192 | pcDepthPicYuvOrg->destroy(); |
---|
1193 | delete pcDepthPicYuvOrg; |
---|
1194 | pcDepthPicYuvOrg = NULL; |
---|
1195 | |
---|
1196 | #if !QC_MVHEVC_B0046 |
---|
1197 | if ( pcPdmDepthOrg != NULL && m_uiMultiviewMvRegMode ) |
---|
1198 | { |
---|
1199 | pcPdmDepthOrg->destroy(); |
---|
1200 | delete pcPdmDepthOrg; |
---|
1201 | pcPdmDepthOrg = NULL; |
---|
1202 | }; |
---|
1203 | #endif |
---|
1204 | |
---|
1205 | for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) |
---|
1206 | { |
---|
1207 | m_acTEncTopList[iViewIdx]->printOutSummary(m_acTEncTopList[iViewIdx]->getNumAllPicCoded()); |
---|
1208 | if ( m_bUsingDepthMaps ) |
---|
1209 | { |
---|
1210 | m_acTEncDepthTopList[iViewIdx]->printOutSummary(m_acTEncDepthTopList[iViewIdx]->getNumAllPicCoded()); |
---|
1211 | } |
---|
1212 | } |
---|
1213 | |
---|
1214 | // delete buffers & classes |
---|
1215 | xDeleteBuffer(); |
---|
1216 | xDestroyLib(); |
---|
1217 | |
---|
1218 | return; |
---|
1219 | } |
---|
1220 | |
---|
1221 | TEncTop* TAppEncTop::getTEncTop( Int viewId, Bool isDepth ) |
---|
1222 | { |
---|
1223 | if ( isDepth ) |
---|
1224 | { |
---|
1225 | return m_acTEncDepthTopList[viewId]; |
---|
1226 | } |
---|
1227 | else |
---|
1228 | { |
---|
1229 | return m_acTEncTopList[viewId]; |
---|
1230 | } |
---|
1231 | } |
---|
1232 | |
---|
1233 | |
---|
1234 | // ==================================================================================================================== |
---|
1235 | // Protected member functions |
---|
1236 | // ==================================================================================================================== |
---|
1237 | |
---|
1238 | /** |
---|
1239 | - application has picture buffer list with size of GOP |
---|
1240 | - picture buffer list acts as ring buffer |
---|
1241 | - end of the list has the latest picture |
---|
1242 | . |
---|
1243 | */ |
---|
1244 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, Int iViewIdx, Bool isDepth) |
---|
1245 | { |
---|
1246 | assert( m_iGOPSize > 0 ); |
---|
1247 | |
---|
1248 | if( !isDepth ) |
---|
1249 | { |
---|
1250 | if ( m_picYuvRec[iViewIdx]->size() == (UInt)m_iGOPSize ) |
---|
1251 | { |
---|
1252 | rpcPicYuvRec = m_picYuvRec[iViewIdx]->popFront(); |
---|
1253 | } |
---|
1254 | else |
---|
1255 | { |
---|
1256 | rpcPicYuvRec = new TComPicYuv; |
---|
1257 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
1258 | } |
---|
1259 | m_picYuvRec[iViewIdx]->pushBack( rpcPicYuvRec ); |
---|
1260 | } |
---|
1261 | else |
---|
1262 | { |
---|
1263 | if ( m_picYuvDepthRec[iViewIdx]->size() == (UInt)m_iGOPSize ) |
---|
1264 | { |
---|
1265 | rpcPicYuvRec = m_picYuvDepthRec[iViewIdx]->popFront(); |
---|
1266 | } |
---|
1267 | else |
---|
1268 | { |
---|
1269 | rpcPicYuvRec = new TComPicYuv; |
---|
1270 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
1271 | } |
---|
1272 | m_picYuvDepthRec[iViewIdx]->pushBack( rpcPicYuvRec ); |
---|
1273 | } |
---|
1274 | } |
---|
1275 | |
---|
1276 | Void TAppEncTop::xDeleteBuffer( ) |
---|
1277 | { |
---|
1278 | for(Int iViewIdx=0; iViewIdx<m_picYuvRec.size(); iViewIdx++) |
---|
1279 | { |
---|
1280 | if(m_picYuvRec[iViewIdx]) |
---|
1281 | { |
---|
1282 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[iViewIdx]->begin(); |
---|
1283 | Int iSize = Int( m_picYuvRec[iViewIdx]->size() ); |
---|
1284 | for ( Int i = 0; i < iSize; i++ ) |
---|
1285 | { |
---|
1286 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
1287 | if(pcPicYuvRec) |
---|
1288 | { |
---|
1289 | pcPicYuvRec->destroy(); |
---|
1290 | delete pcPicYuvRec; |
---|
1291 | pcPicYuvRec = NULL; |
---|
1292 | } |
---|
1293 | } |
---|
1294 | } |
---|
1295 | } |
---|
1296 | for(Int iViewIdx=0; iViewIdx<m_picYuvDepthRec.size(); iViewIdx++) |
---|
1297 | { |
---|
1298 | if(m_picYuvDepthRec[iViewIdx]) |
---|
1299 | { |
---|
1300 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvDepthRec[iViewIdx]->begin(); |
---|
1301 | Int iSize = Int( m_picYuvDepthRec[iViewIdx]->size() ); |
---|
1302 | for ( Int i = 0; i < iSize; i++ ) |
---|
1303 | { |
---|
1304 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
1305 | if(pcPicYuvRec) |
---|
1306 | { |
---|
1307 | pcPicYuvRec->destroy(); |
---|
1308 | delete pcPicYuvRec; |
---|
1309 | pcPicYuvRec = NULL; |
---|
1310 | } |
---|
1311 | } |
---|
1312 | } |
---|
1313 | } |
---|
1314 | } |
---|
1315 | |
---|
1316 | /** \param iNumEncoded number of encoded frames |
---|
1317 | */ |
---|
1318 | Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, Int iViewIdx, Bool isDepth ) |
---|
1319 | { |
---|
1320 | Int i; |
---|
1321 | |
---|
1322 | if( iNumEncoded > 0 ) |
---|
1323 | { |
---|
1324 | TComList<TComPicYuv*>::iterator iterPicYuvRec = !isDepth ? m_picYuvRec[iViewIdx]->end() : m_picYuvDepthRec[iViewIdx]->end(); |
---|
1325 | |
---|
1326 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
1327 | { |
---|
1328 | --iterPicYuvRec; |
---|
1329 | } |
---|
1330 | |
---|
1331 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
1332 | { |
---|
1333 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
1334 | if( !isDepth ) |
---|
1335 | { |
---|
1336 | if (m_pchReconFileList[iViewIdx]) |
---|
1337 | { |
---|
1338 | m_acTVideoIOYuvReconFileList[iViewIdx]->write( pcPicYuvRec, m_cropLeft, m_cropRight, m_cropTop, m_cropBottom ); |
---|
1339 | } |
---|
1340 | } |
---|
1341 | else |
---|
1342 | { |
---|
1343 | if (m_pchDepthReconFileList[iViewIdx]) |
---|
1344 | { |
---|
1345 | m_acTVideoIOYuvDepthReconFileList[iViewIdx]->write( pcPicYuvRec, m_cropLeft, m_cropRight, m_cropTop, m_cropBottom ); |
---|
1346 | } |
---|
1347 | } |
---|
1348 | } |
---|
1349 | } |
---|
1350 | if( ! accessUnits.empty() ) |
---|
1351 | { |
---|
1352 | list<AccessUnit>::iterator aUIter; |
---|
1353 | for( aUIter = accessUnits.begin(); aUIter != accessUnits.end(); aUIter++ ) |
---|
1354 | { |
---|
1355 | const vector<unsigned>& stats = writeAnnexB(bitstreamFile, *aUIter); |
---|
1356 | rateStatsAccum(*aUIter, stats); |
---|
1357 | } |
---|
1358 | } |
---|
1359 | } |
---|
1360 | |
---|
1361 | |
---|
1362 | TComPicYuv* TAppEncTop::xGetPicYuvFromView( Int iViewIdx, Int iPoc, Bool bDepth, Bool bRecon ) |
---|
1363 | { |
---|
1364 | TComPic* pcPic = xGetPicFromView( iViewIdx, iPoc, bDepth); |
---|
1365 | TComPicYuv* pcPicYuv = NULL; |
---|
1366 | |
---|
1367 | if (pcPic != NULL) |
---|
1368 | { |
---|
1369 | if( bRecon ) |
---|
1370 | { |
---|
1371 | if ( pcPic->getReconMark() ) |
---|
1372 | { |
---|
1373 | pcPicYuv = pcPic->getPicYuvRec(); |
---|
1374 | } |
---|
1375 | } |
---|
1376 | else |
---|
1377 | { |
---|
1378 | pcPicYuv = pcPic->getPicYuvOrg(); |
---|
1379 | } |
---|
1380 | }; |
---|
1381 | |
---|
1382 | return pcPicYuv; |
---|
1383 | }; |
---|
1384 | |
---|
1385 | /** |
---|
1386 | * |
---|
1387 | */ |
---|
1388 | void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<unsigned>& annexBsizes) |
---|
1389 | { |
---|
1390 | AccessUnit::const_iterator it_au = au.begin(); |
---|
1391 | vector<unsigned>::const_iterator it_stats = annexBsizes.begin(); |
---|
1392 | |
---|
1393 | for (; it_au != au.end(); it_au++, it_stats++) |
---|
1394 | { |
---|
1395 | switch ((*it_au)->m_nalUnitType) |
---|
1396 | { |
---|
1397 | case NAL_UNIT_CODED_SLICE: |
---|
1398 | #if !QC_REM_IDV_B0046 |
---|
1399 | case NAL_UNIT_CODED_SLICE_IDV: |
---|
1400 | #endif |
---|
1401 | case NAL_UNIT_CODED_SLICE_TLA: |
---|
1402 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
1403 | case NAL_UNIT_CODED_SLICE_IDR: |
---|
1404 | case NAL_UNIT_SPS: |
---|
1405 | case NAL_UNIT_PPS: |
---|
1406 | #if VIDYO_VPS_INTEGRATION |
---|
1407 | case NAL_UNIT_VPS: |
---|
1408 | #endif |
---|
1409 | m_essentialBytes += *it_stats; |
---|
1410 | break; |
---|
1411 | default: |
---|
1412 | break; |
---|
1413 | } |
---|
1414 | |
---|
1415 | m_totalBytes += *it_stats; |
---|
1416 | } |
---|
1417 | } |
---|
1418 | |
---|
1419 | #if HHI_INTERVIEW_SKIP |
---|
1420 | Void TAppEncTop::getUsedPelsMap( Int iViewIdx, Int iPoc, TComPicYuv* pcPicYuvUsedSplsMap ) |
---|
1421 | { |
---|
1422 | AOT( iViewIdx <= 0); |
---|
1423 | AOT( iViewIdx >= m_iNumberOfViews ); |
---|
1424 | AOF( m_cCameraData.getCurFrameId() == iPoc ); |
---|
1425 | Int iViewSIdx = m_cCameraData.getBaseId2SortedId()[iViewIdx]; |
---|
1426 | Int iFirstViewSIdx = m_cCameraData.getBaseId2SortedId()[0]; |
---|
1427 | |
---|
1428 | AOT( iViewSIdx == iFirstViewSIdx ); |
---|
1429 | |
---|
1430 | Bool bFirstIsLeft = (iFirstViewSIdx < iViewSIdx); |
---|
1431 | |
---|
1432 | m_cUsedPelsRenderer.setShiftLUTs( |
---|
1433 | m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx], |
---|
1434 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
1435 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
1436 | m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx], |
---|
1437 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
1438 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
1439 | -1 |
---|
1440 | ); |
---|
1441 | |
---|
1442 | TComPicYuv* pcPicYuvDepth = xGetPicYuvFromView(0, iPoc, true, true ); |
---|
1443 | AOF( pcPicYuvDepth); |
---|
1444 | |
---|
1445 | m_cUsedPelsRenderer.getUsedSamplesMap( pcPicYuvDepth, pcPicYuvUsedSplsMap, bFirstIsLeft ); |
---|
1446 | } |
---|
1447 | #endif |
---|
1448 | #if HHI_VSO |
---|
1449 | Void TAppEncTop::setupRenModel( Int iPoc, Int iEncViewIdx, Int iEncContent, Int iHorOffset ) |
---|
1450 | { |
---|
1451 | m_cRendererModel.setupPart( iHorOffset, Min( g_uiMaxCUHeight, m_iSourceHeight - iHorOffset ) ); |
---|
1452 | Int iEncViewSIdx = m_cCameraData.getBaseId2SortedId()[ iEncViewIdx ]; |
---|
1453 | |
---|
1454 | // setup base views |
---|
1455 | Int iNumOfBV = m_cRenModStrParser.getNumOfBaseViewsForView( iEncViewSIdx, iEncContent ); |
---|
1456 | |
---|
1457 | for (Int iCurView = 0; iCurView < iNumOfBV; iCurView++ ) |
---|
1458 | { |
---|
1459 | Int iBaseViewSIdx; |
---|
1460 | Int iVideoDistMode; |
---|
1461 | Int iDepthDistMode; |
---|
1462 | |
---|
1463 | m_cRenModStrParser.getBaseViewData( iEncViewSIdx, iEncContent, iCurView, iBaseViewSIdx, iVideoDistMode, iDepthDistMode ); |
---|
1464 | |
---|
1465 | AOT( iVideoDistMode < 0 || iVideoDistMode > 2 ); |
---|
1466 | |
---|
1467 | Int iBaseViewIdx = m_cCameraData.getBaseSortedId2Id()[ iBaseViewSIdx ]; |
---|
1468 | |
---|
1469 | TComPicYuv* pcPicYuvVideoRec = xGetPicYuvFromView( iBaseViewIdx, iPoc, false, true ); |
---|
1470 | TComPicYuv* pcPicYuvDepthRec = xGetPicYuvFromView( iBaseViewIdx, iPoc, true , true ); |
---|
1471 | TComPicYuv* pcPicYuvVideoOrg = xGetPicYuvFromView( iBaseViewIdx, iPoc, false, false ); |
---|
1472 | TComPicYuv* pcPicYuvDepthOrg = xGetPicYuvFromView( iBaseViewIdx, iPoc, true , false ); |
---|
1473 | |
---|
1474 | TComPicYuv* pcPicYuvVideoRef = ( iVideoDistMode == 2 ) ? pcPicYuvVideoOrg : NULL; |
---|
1475 | TComPicYuv* pcPicYuvDepthRef = ( iDepthDistMode == 2 ) ? pcPicYuvDepthOrg : NULL; |
---|
1476 | |
---|
1477 | TComPicYuv* pcPicYuvVideoTest = ( iVideoDistMode == 0 ) ? pcPicYuvVideoOrg : pcPicYuvVideoRec; |
---|
1478 | TComPicYuv* pcPicYuvDepthTest = ( iDepthDistMode == 0 ) ? pcPicYuvDepthOrg : pcPicYuvDepthRec; |
---|
1479 | |
---|
1480 | AOT( (iVideoDistMode == 2) != (pcPicYuvVideoRef != NULL) ); |
---|
1481 | AOT( (iDepthDistMode == 2) != (pcPicYuvDepthRef != NULL) ); |
---|
1482 | AOT( pcPicYuvDepthTest == NULL ); |
---|
1483 | AOT( pcPicYuvVideoTest == NULL ); |
---|
1484 | |
---|
1485 | m_cRendererModel.setBaseView( iBaseViewSIdx, pcPicYuvVideoTest, pcPicYuvDepthTest, pcPicYuvVideoRef, pcPicYuvDepthRef ); |
---|
1486 | } |
---|
1487 | |
---|
1488 | m_cRendererModel.setErrorMode( iEncViewSIdx, iEncContent, 0 ); |
---|
1489 | // setup virtual views |
---|
1490 | Int iNumOfSV = m_cRenModStrParser.getNumOfModelsForView( iEncViewSIdx, iEncContent ); |
---|
1491 | for (Int iCurView = 0; iCurView < iNumOfSV; iCurView++ ) |
---|
1492 | { |
---|
1493 | Int iOrgRefBaseViewSIdx; |
---|
1494 | Int iLeftBaseViewSIdx; |
---|
1495 | Int iRightBaseViewSIdx; |
---|
1496 | Int iSynthViewRelNum; |
---|
1497 | Int iModelNum; |
---|
1498 | Int iBlendMode; |
---|
1499 | m_cRenModStrParser.getSingleModelData(iEncViewSIdx, iEncContent, iCurView, iModelNum, iBlendMode,iLeftBaseViewSIdx, iRightBaseViewSIdx, iOrgRefBaseViewSIdx, iSynthViewRelNum ); |
---|
1500 | |
---|
1501 | Int iLeftBaseViewIdx = -1; |
---|
1502 | Int iRightBaseViewIdx = -1; |
---|
1503 | |
---|
1504 | TComPicYuv* pcPicYuvOrgRef = NULL; |
---|
1505 | Int** ppiShiftLUTLeft = NULL; |
---|
1506 | Int** ppiShiftLUTRight = NULL; |
---|
1507 | Int** ppiBaseShiftLUTLeft = NULL; |
---|
1508 | Int** ppiBaseShiftLUTRight = NULL; |
---|
1509 | |
---|
1510 | |
---|
1511 | Int iDistToLeft = -1; |
---|
1512 | |
---|
1513 | Int iSynthViewIdx = m_cCameraData.synthRelNum2Idx( iSynthViewRelNum ); |
---|
1514 | |
---|
1515 | if ( iLeftBaseViewSIdx != -1 ) |
---|
1516 | { |
---|
1517 | iLeftBaseViewIdx = m_cCameraData.getBaseSortedId2Id() [ iLeftBaseViewSIdx ]; |
---|
1518 | ppiShiftLUTLeft = m_cCameraData.getSynthViewShiftLUTI()[ iLeftBaseViewIdx ][ iSynthViewIdx ]; |
---|
1519 | } |
---|
1520 | |
---|
1521 | if ( iRightBaseViewSIdx != -1 ) |
---|
1522 | { |
---|
1523 | iRightBaseViewIdx = m_cCameraData.getBaseSortedId2Id() [iRightBaseViewSIdx ]; |
---|
1524 | ppiShiftLUTRight = m_cCameraData.getSynthViewShiftLUTI()[ iRightBaseViewIdx ][ iSynthViewIdx ]; |
---|
1525 | } |
---|
1526 | |
---|
1527 | if ( iRightBaseViewSIdx != -1 && iLeftBaseViewSIdx != -1 ) |
---|
1528 | { |
---|
1529 | iDistToLeft = m_cCameraData.getRelDistLeft( iSynthViewIdx , iLeftBaseViewIdx, iRightBaseViewIdx); |
---|
1530 | ppiBaseShiftLUTLeft = m_cCameraData.getBaseViewShiftLUTI() [ iLeftBaseViewIdx ][ iRightBaseViewIdx ]; |
---|
1531 | ppiBaseShiftLUTRight = m_cCameraData.getBaseViewShiftLUTI() [ iRightBaseViewIdx ][ iLeftBaseViewIdx ]; |
---|
1532 | |
---|
1533 | } |
---|
1534 | |
---|
1535 | if ( iOrgRefBaseViewSIdx != -1 ) |
---|
1536 | { |
---|
1537 | pcPicYuvOrgRef = xGetPicYuvFromView( m_cCameraData.getBaseSortedId2Id()[ iOrgRefBaseViewSIdx ] , iPoc, false, false ); |
---|
1538 | AOF ( pcPicYuvOrgRef ); |
---|
1539 | } |
---|
1540 | |
---|
1541 | m_cRendererModel.setSingleModel( iModelNum, ppiShiftLUTLeft, ppiBaseShiftLUTLeft, ppiShiftLUTRight, ppiBaseShiftLUTRight, iDistToLeft, pcPicYuvOrgRef ); |
---|
1542 | } |
---|
1543 | } |
---|
1544 | #endif |
---|
1545 | |
---|
1546 | |
---|
1547 | |
---|
1548 | /* |
---|
1549 | void TAppEncTop::printRateSummary() |
---|
1550 | { |
---|
1551 | double time = (double) m_iFrameRcvd / m_iFrameRate; |
---|
1552 | printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time); |
---|
1553 | #if VERBOSE_RATE |
---|
1554 | printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time); |
---|
1555 | #endif |
---|
1556 | } |
---|
1557 | */ |
---|
1558 | |
---|
1559 | std::vector<TComPic*> TAppEncTop::getInterViewRefPics( Int viewId, Int poc, Bool isDepth, TComSPS* sps ) |
---|
1560 | { |
---|
1561 | std::vector<TComPic*> apcRefPics( sps->getNumberOfUsableInterViewRefs(), (TComPic*)NULL ); |
---|
1562 | for( Int k = 0; k < sps->getNumberOfUsableInterViewRefs(); k++ ) |
---|
1563 | { |
---|
1564 | TComPic* pcRefPic = xGetPicFromView( sps->getUsableInterViewRef( k ) + viewId, poc, isDepth ); |
---|
1565 | assert( pcRefPic != NULL ); |
---|
1566 | apcRefPics[k] = pcRefPic; |
---|
1567 | } |
---|
1568 | return apcRefPics; |
---|
1569 | } |
---|
1570 | |
---|
1571 | TComPic* TAppEncTop::xGetPicFromView( Int viewIdx, Int poc, Bool isDepth ) |
---|
1572 | { |
---|
1573 | assert( ( viewIdx >= 0 ) && ( viewIdx < m_iNumberOfViews ) ); |
---|
1574 | |
---|
1575 | TComList<TComPic*>* apcListPic = (isDepth ? m_acTEncDepthTopList[viewIdx] : m_acTEncTopList[viewIdx])->getListPic() ; |
---|
1576 | |
---|
1577 | TComPic* pcPic = NULL; |
---|
1578 | for(TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++) |
---|
1579 | { |
---|
1580 | if( (*it)->getPOC() == poc ) |
---|
1581 | { |
---|
1582 | pcPic = *it ; |
---|
1583 | break ; |
---|
1584 | } |
---|
1585 | } |
---|
1586 | |
---|
1587 | return pcPic; |
---|
1588 | }; |
---|
1589 | |
---|
1590 | #if RWTH_SDC_DLT_B0036 |
---|
1591 | Void TAppEncTop::xAnalyzeInputBaseDepth(Int iViewIdx, UInt uiNumFrames) |
---|
1592 | { |
---|
1593 | TComPicYuv* pcDepthPicYuvOrg = new TComPicYuv; |
---|
1594 | // allocate original YUV buffer |
---|
1595 | pcDepthPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
1596 | |
---|
1597 | TVideoIOYuv* depthVideoFile = new TVideoIOYuv; |
---|
1598 | |
---|
1599 | UInt uiMaxDepthValue = g_uiIBDI_MAX; |
---|
1600 | |
---|
1601 | Bool abValidDepths[256]; |
---|
1602 | |
---|
1603 | depthVideoFile->open( m_pchDepthInputFileList[iViewIdx], false, m_uiInputBitDepth, m_uiInternalBitDepth ); // read mode |
---|
1604 | |
---|
1605 | // initialize boolean array |
---|
1606 | for(Int p=0; p<=uiMaxDepthValue; p++) |
---|
1607 | abValidDepths[p] = false; |
---|
1608 | |
---|
1609 | Int iHeight = pcDepthPicYuvOrg->getHeight(); |
---|
1610 | Int iWidth = pcDepthPicYuvOrg->getWidth(); |
---|
1611 | Int iStride = pcDepthPicYuvOrg->getStride(); |
---|
1612 | |
---|
1613 | Pel* pInDM = pcDepthPicYuvOrg->getLumaAddr(); |
---|
1614 | |
---|
1615 | for(Int uiFrame=0; uiFrame < uiNumFrames; uiFrame++ ) |
---|
1616 | { |
---|
1617 | depthVideoFile->read( pcDepthPicYuvOrg, m_aiPad, false ); |
---|
1618 | |
---|
1619 | // check all pixel values |
---|
1620 | for (Int i=0; i<iHeight; i++) |
---|
1621 | { |
---|
1622 | Int rowOffset = i*iStride; |
---|
1623 | |
---|
1624 | for (Int j=0; j<iWidth; j++) |
---|
1625 | { |
---|
1626 | Pel depthValue = pInDM[rowOffset+j]; |
---|
1627 | abValidDepths[depthValue] = true; |
---|
1628 | } |
---|
1629 | } |
---|
1630 | } |
---|
1631 | |
---|
1632 | depthVideoFile->close(); |
---|
1633 | |
---|
1634 | pcDepthPicYuvOrg->destroy(); |
---|
1635 | delete pcDepthPicYuvOrg; |
---|
1636 | |
---|
1637 | // convert boolean array to idx2Depth LUT |
---|
1638 | UInt* auiIdx2DepthValue = (UInt*) calloc(uiMaxDepthValue, sizeof(UInt)); |
---|
1639 | UInt uiNumDepthValues = 0; |
---|
1640 | for(UInt p=0; p<=uiMaxDepthValue; p++) |
---|
1641 | { |
---|
1642 | if( abValidDepths[p] == true) |
---|
1643 | { |
---|
1644 | auiIdx2DepthValue[uiNumDepthValues++] = p; |
---|
1645 | } |
---|
1646 | } |
---|
1647 | |
---|
1648 | if( uiNumFrames == 0 || ceil(Log2(uiNumDepthValues)) == ceil(Log2(g_uiIBDI_MAX)) ) |
---|
1649 | { |
---|
1650 | // don't use DLT |
---|
1651 | m_acTEncDepthTopList[iViewIdx]->setUseDLT(false); |
---|
1652 | m_acTEncDepthTopList[iViewIdx]->getSPS()->setUseDLT(false); |
---|
1653 | } |
---|
1654 | |
---|
1655 | // assign LUT |
---|
1656 | if( m_acTEncDepthTopList[iViewIdx]->getUseDLT() ) |
---|
1657 | m_acTEncDepthTopList[iViewIdx]->getSPS()->setDepthLUTs(auiIdx2DepthValue, uiNumDepthValues); |
---|
1658 | else |
---|
1659 | m_acTEncDepthTopList[iViewIdx]->getSPS()->setDepthLUTs(); |
---|
1660 | |
---|
1661 | // free temporary memory |
---|
1662 | free(auiIdx2DepthValue); |
---|
1663 | } |
---|
1664 | #endif |
---|
1665 | |
---|
1666 | #if MERL_VSP_C0152 |
---|
1667 | |
---|
1668 | Void TAppEncTop::setBWVSPLUT( |
---|
1669 | #if MERL_VSP_NBDV_RefVId_Fix_D0166 |
---|
1670 | Int iNeighborViewId, |
---|
1671 | #endif |
---|
1672 | Int iCodedViewIdx, Int gopId, Bool isDepth) |
---|
1673 | { |
---|
1674 | //first view does not have VSP |
---|
1675 | if((iCodedViewIdx == 0)) return; |
---|
1676 | |
---|
1677 | AOT( iCodedViewIdx <= 0); |
---|
1678 | AOT( iCodedViewIdx >= m_iNumberOfViews ); |
---|
1679 | #if !MERL_VSP_NBDV_RefVId_Fix_D0166 |
---|
1680 | Int iNeighborViewId = 0; |
---|
1681 | #endif |
---|
1682 | //setting look-up table |
---|
1683 | Int* piShiftLUT = m_cCameraData.getBaseViewShiftLUTI()[iNeighborViewId][iCodedViewIdx][0]; |
---|
1684 | |
---|
1685 | if(isDepth) |
---|
1686 | { |
---|
1687 | TEncSlice* pcEncSlice = (TEncSlice*) m_acTEncDepthTopList[iCodedViewIdx]->getSliceEncoder(); |
---|
1688 | #if MERL_VSP_NBDV_RefVId_Fix_D0166 |
---|
1689 | pcEncSlice->setBWVSPLUTParam( piShiftLUT, LOG2_DISP_PREC_LUT, iNeighborViewId ); |
---|
1690 | #else |
---|
1691 | pcEncSlice->setBWVSPLUTParam( piShiftLUT, LOG2_DISP_PREC_LUT ); |
---|
1692 | #endif |
---|
1693 | } |
---|
1694 | else |
---|
1695 | { |
---|
1696 | TEncSlice* pcEncSlice = (TEncSlice*) m_acTEncTopList[iCodedViewIdx]->getSliceEncoder(); |
---|
1697 | #if MERL_VSP_NBDV_RefVId_Fix_D0166 |
---|
1698 | pcEncSlice->setBWVSPLUTParam( piShiftLUT, LOG2_DISP_PREC_LUT, iNeighborViewId ); |
---|
1699 | #else |
---|
1700 | pcEncSlice->setBWVSPLUTParam( piShiftLUT, LOG2_DISP_PREC_LUT ); |
---|
1701 | #endif |
---|
1702 | } |
---|
1703 | |
---|
1704 | } |
---|
1705 | #endif |
---|
1706 | |
---|
1707 | //! \} |
---|