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 | } |
---|
1100 | setBWVSPLUT( iViewIdx, gopId, false); |
---|
1101 | #if MERL_VSP_C0152_BugFix_ForNoDepthCase |
---|
1102 | } |
---|
1103 | else |
---|
1104 | { |
---|
1105 | Int iCurPoc = m_acTEncTopList[iViewIdx]->getFrameId(gopId); |
---|
1106 | if( iCurPoc < m_acTEncTopList[iViewIdx]->getFrameToBeEncoded() && iViewIdx!=0 ) |
---|
1107 | { |
---|
1108 | TEncSlice* pEncSlice = m_acTEncTopList[iViewIdx]->getSliceEncoder(); |
---|
1109 | pEncSlice->setRefPicBaseTxt(NULL);//Initialize the base view reconstructed texture buffer |
---|
1110 | pEncSlice->setRefPicBaseDepth(NULL);//Initialize the base view reconstructed depth buffer |
---|
1111 | } |
---|
1112 | } |
---|
1113 | #endif |
---|
1114 | |
---|
1115 | #endif |
---|
1116 | // call encoding function for one frame |
---|
1117 | m_acTEncTopList[iViewIdx]->encode( eos[iViewIdx], pcPicYuvOrg, *m_picYuvRec[iViewIdx], outputAccessUnits, iNumEncoded, gopId ); |
---|
1118 | xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, iViewIdx, false); |
---|
1119 | outputAccessUnits.clear(); |
---|
1120 | if( m_bUsingDepthMaps ) |
---|
1121 | { |
---|
1122 | Int iNumDepthEncoded = 0; |
---|
1123 | #if MERL_VSP_C0152 |
---|
1124 | Int iCurPocDepth = m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId); |
---|
1125 | if( iCurPocDepth < m_acTEncDepthTopList[iViewIdx]->getFrameToBeEncoded() && iViewIdx!=0 ) |
---|
1126 | { |
---|
1127 | TComPic* pcBaseDepthPic = getPicFromView( 0, m_acTEncDepthTopList[iViewIdx]->getFrameId(gopId), true ); |
---|
1128 | TEncSlice* pcSlice = (TEncSlice*) m_acTEncDepthTopList[iViewIdx]->getSliceEncoder(); |
---|
1129 | pcSlice->setRefPicBaseDepth(pcBaseDepthPic); |
---|
1130 | } |
---|
1131 | setBWVSPLUT( iViewIdx, gopId, true); |
---|
1132 | #endif |
---|
1133 | |
---|
1134 | // call encoding function for one depth frame |
---|
1135 | m_acTEncDepthTopList[iViewIdx]->encode( depthEos[iViewIdx], pcDepthPicYuvOrg, *m_picYuvDepthRec[iViewIdx], outputAccessUnits, iNumDepthEncoded, gopId ); |
---|
1136 | xWriteOutput(bitstreamFile, iNumDepthEncoded, outputAccessUnits, iViewIdx, true); |
---|
1137 | outputAccessUnits.clear(); |
---|
1138 | } |
---|
1139 | } |
---|
1140 | |
---|
1141 | #if FLEX_CODING_ORDER_M23723 |
---|
1142 | } |
---|
1143 | #endif |
---|
1144 | |
---|
1145 | #if HHI_INTERVIEW_SKIP || H3D_IVMP || H3D_IVRP |
---|
1146 | for( Int iViewIdx = 0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) |
---|
1147 | { |
---|
1148 | if( iViewIdx < (Int)m_acTEncTopList.size() && m_acTEncTopList[iViewIdx] ) |
---|
1149 | { |
---|
1150 | m_acTEncTopList[iViewIdx]->deleteExtraPicBuffers( m_acTEncTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() ); |
---|
1151 | } |
---|
1152 | if( iViewIdx < (Int)m_acTEncDepthTopList.size() && m_acTEncDepthTopList[iViewIdx] ) |
---|
1153 | { |
---|
1154 | m_acTEncDepthTopList[iViewIdx]->deleteExtraPicBuffers( m_acTEncTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() ); |
---|
1155 | } |
---|
1156 | } |
---|
1157 | #endif |
---|
1158 | for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) |
---|
1159 | { |
---|
1160 | m_acTEncTopList[iViewIdx]->compressMotion( m_acTEncTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() ); |
---|
1161 | if( m_bUsingDepthMaps ) |
---|
1162 | { |
---|
1163 | m_acTEncDepthTopList[iViewIdx]->compressMotion( m_acTEncDepthTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() ); |
---|
1164 | } |
---|
1165 | } |
---|
1166 | } |
---|
1167 | gopSize = maxGopSize; |
---|
1168 | } |
---|
1169 | // delete original YUV buffer |
---|
1170 | pcPicYuvOrg->destroy(); |
---|
1171 | delete pcPicYuvOrg; |
---|
1172 | pcPicYuvOrg = NULL; |
---|
1173 | pcDepthPicYuvOrg->destroy(); |
---|
1174 | delete pcDepthPicYuvOrg; |
---|
1175 | pcDepthPicYuvOrg = NULL; |
---|
1176 | |
---|
1177 | #if !QC_MVHEVC_B0046 |
---|
1178 | if ( pcPdmDepthOrg != NULL && m_uiMultiviewMvRegMode ) |
---|
1179 | { |
---|
1180 | pcPdmDepthOrg->destroy(); |
---|
1181 | delete pcPdmDepthOrg; |
---|
1182 | pcPdmDepthOrg = NULL; |
---|
1183 | }; |
---|
1184 | #endif |
---|
1185 | |
---|
1186 | for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) |
---|
1187 | { |
---|
1188 | m_acTEncTopList[iViewIdx]->printOutSummary(m_acTEncTopList[iViewIdx]->getNumAllPicCoded()); |
---|
1189 | if ( m_bUsingDepthMaps ) |
---|
1190 | { |
---|
1191 | m_acTEncDepthTopList[iViewIdx]->printOutSummary(m_acTEncDepthTopList[iViewIdx]->getNumAllPicCoded()); |
---|
1192 | } |
---|
1193 | } |
---|
1194 | |
---|
1195 | // delete buffers & classes |
---|
1196 | xDeleteBuffer(); |
---|
1197 | xDestroyLib(); |
---|
1198 | |
---|
1199 | return; |
---|
1200 | } |
---|
1201 | |
---|
1202 | TEncTop* TAppEncTop::getTEncTop( Int viewId, Bool isDepth ) |
---|
1203 | { |
---|
1204 | if ( isDepth ) |
---|
1205 | { |
---|
1206 | return m_acTEncDepthTopList[viewId]; |
---|
1207 | } |
---|
1208 | else |
---|
1209 | { |
---|
1210 | return m_acTEncTopList[viewId]; |
---|
1211 | } |
---|
1212 | } |
---|
1213 | |
---|
1214 | |
---|
1215 | // ==================================================================================================================== |
---|
1216 | // Protected member functions |
---|
1217 | // ==================================================================================================================== |
---|
1218 | |
---|
1219 | /** |
---|
1220 | - application has picture buffer list with size of GOP |
---|
1221 | - picture buffer list acts as ring buffer |
---|
1222 | - end of the list has the latest picture |
---|
1223 | . |
---|
1224 | */ |
---|
1225 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, Int iViewIdx, Bool isDepth) |
---|
1226 | { |
---|
1227 | assert( m_iGOPSize > 0 ); |
---|
1228 | |
---|
1229 | if( !isDepth ) |
---|
1230 | { |
---|
1231 | if ( m_picYuvRec[iViewIdx]->size() == (UInt)m_iGOPSize ) |
---|
1232 | { |
---|
1233 | rpcPicYuvRec = m_picYuvRec[iViewIdx]->popFront(); |
---|
1234 | } |
---|
1235 | else |
---|
1236 | { |
---|
1237 | rpcPicYuvRec = new TComPicYuv; |
---|
1238 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
1239 | } |
---|
1240 | m_picYuvRec[iViewIdx]->pushBack( rpcPicYuvRec ); |
---|
1241 | } |
---|
1242 | else |
---|
1243 | { |
---|
1244 | if ( m_picYuvDepthRec[iViewIdx]->size() == (UInt)m_iGOPSize ) |
---|
1245 | { |
---|
1246 | rpcPicYuvRec = m_picYuvDepthRec[iViewIdx]->popFront(); |
---|
1247 | } |
---|
1248 | else |
---|
1249 | { |
---|
1250 | rpcPicYuvRec = new TComPicYuv; |
---|
1251 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
1252 | } |
---|
1253 | m_picYuvDepthRec[iViewIdx]->pushBack( rpcPicYuvRec ); |
---|
1254 | } |
---|
1255 | } |
---|
1256 | |
---|
1257 | Void TAppEncTop::xDeleteBuffer( ) |
---|
1258 | { |
---|
1259 | for(Int iViewIdx=0; iViewIdx<m_picYuvRec.size(); iViewIdx++) |
---|
1260 | { |
---|
1261 | if(m_picYuvRec[iViewIdx]) |
---|
1262 | { |
---|
1263 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[iViewIdx]->begin(); |
---|
1264 | Int iSize = Int( m_picYuvRec[iViewIdx]->size() ); |
---|
1265 | for ( Int i = 0; i < iSize; i++ ) |
---|
1266 | { |
---|
1267 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
1268 | if(pcPicYuvRec) |
---|
1269 | { |
---|
1270 | pcPicYuvRec->destroy(); |
---|
1271 | delete pcPicYuvRec; |
---|
1272 | pcPicYuvRec = NULL; |
---|
1273 | } |
---|
1274 | } |
---|
1275 | } |
---|
1276 | } |
---|
1277 | for(Int iViewIdx=0; iViewIdx<m_picYuvDepthRec.size(); iViewIdx++) |
---|
1278 | { |
---|
1279 | if(m_picYuvDepthRec[iViewIdx]) |
---|
1280 | { |
---|
1281 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvDepthRec[iViewIdx]->begin(); |
---|
1282 | Int iSize = Int( m_picYuvDepthRec[iViewIdx]->size() ); |
---|
1283 | for ( Int i = 0; i < iSize; i++ ) |
---|
1284 | { |
---|
1285 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
1286 | if(pcPicYuvRec) |
---|
1287 | { |
---|
1288 | pcPicYuvRec->destroy(); |
---|
1289 | delete pcPicYuvRec; |
---|
1290 | pcPicYuvRec = NULL; |
---|
1291 | } |
---|
1292 | } |
---|
1293 | } |
---|
1294 | } |
---|
1295 | } |
---|
1296 | |
---|
1297 | /** \param iNumEncoded number of encoded frames |
---|
1298 | */ |
---|
1299 | Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, Int iViewIdx, Bool isDepth ) |
---|
1300 | { |
---|
1301 | Int i; |
---|
1302 | |
---|
1303 | if( iNumEncoded > 0 ) |
---|
1304 | { |
---|
1305 | TComList<TComPicYuv*>::iterator iterPicYuvRec = !isDepth ? m_picYuvRec[iViewIdx]->end() : m_picYuvDepthRec[iViewIdx]->end(); |
---|
1306 | |
---|
1307 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
1308 | { |
---|
1309 | --iterPicYuvRec; |
---|
1310 | } |
---|
1311 | |
---|
1312 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
1313 | { |
---|
1314 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
1315 | if( !isDepth ) |
---|
1316 | { |
---|
1317 | if (m_pchReconFileList[iViewIdx]) |
---|
1318 | { |
---|
1319 | m_acTVideoIOYuvReconFileList[iViewIdx]->write( pcPicYuvRec, m_cropLeft, m_cropRight, m_cropTop, m_cropBottom ); |
---|
1320 | } |
---|
1321 | } |
---|
1322 | else |
---|
1323 | { |
---|
1324 | if (m_pchDepthReconFileList[iViewIdx]) |
---|
1325 | { |
---|
1326 | m_acTVideoIOYuvDepthReconFileList[iViewIdx]->write( pcPicYuvRec, m_cropLeft, m_cropRight, m_cropTop, m_cropBottom ); |
---|
1327 | } |
---|
1328 | } |
---|
1329 | } |
---|
1330 | } |
---|
1331 | if( ! accessUnits.empty() ) |
---|
1332 | { |
---|
1333 | list<AccessUnit>::iterator aUIter; |
---|
1334 | for( aUIter = accessUnits.begin(); aUIter != accessUnits.end(); aUIter++ ) |
---|
1335 | { |
---|
1336 | const vector<unsigned>& stats = writeAnnexB(bitstreamFile, *aUIter); |
---|
1337 | rateStatsAccum(*aUIter, stats); |
---|
1338 | } |
---|
1339 | } |
---|
1340 | } |
---|
1341 | |
---|
1342 | |
---|
1343 | TComPicYuv* TAppEncTop::xGetPicYuvFromView( Int iViewIdx, Int iPoc, Bool bDepth, Bool bRecon ) |
---|
1344 | { |
---|
1345 | TComPic* pcPic = xGetPicFromView( iViewIdx, iPoc, bDepth); |
---|
1346 | TComPicYuv* pcPicYuv = NULL; |
---|
1347 | |
---|
1348 | if (pcPic != NULL) |
---|
1349 | { |
---|
1350 | if( bRecon ) |
---|
1351 | { |
---|
1352 | if ( pcPic->getReconMark() ) |
---|
1353 | { |
---|
1354 | pcPicYuv = pcPic->getPicYuvRec(); |
---|
1355 | } |
---|
1356 | } |
---|
1357 | else |
---|
1358 | { |
---|
1359 | pcPicYuv = pcPic->getPicYuvOrg(); |
---|
1360 | } |
---|
1361 | }; |
---|
1362 | |
---|
1363 | return pcPicYuv; |
---|
1364 | }; |
---|
1365 | |
---|
1366 | /** |
---|
1367 | * |
---|
1368 | */ |
---|
1369 | void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<unsigned>& annexBsizes) |
---|
1370 | { |
---|
1371 | AccessUnit::const_iterator it_au = au.begin(); |
---|
1372 | vector<unsigned>::const_iterator it_stats = annexBsizes.begin(); |
---|
1373 | |
---|
1374 | for (; it_au != au.end(); it_au++, it_stats++) |
---|
1375 | { |
---|
1376 | switch ((*it_au)->m_nalUnitType) |
---|
1377 | { |
---|
1378 | case NAL_UNIT_CODED_SLICE: |
---|
1379 | #if !QC_REM_IDV_B0046 |
---|
1380 | case NAL_UNIT_CODED_SLICE_IDV: |
---|
1381 | #endif |
---|
1382 | case NAL_UNIT_CODED_SLICE_TLA: |
---|
1383 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
1384 | case NAL_UNIT_CODED_SLICE_IDR: |
---|
1385 | case NAL_UNIT_SPS: |
---|
1386 | case NAL_UNIT_PPS: |
---|
1387 | #if VIDYO_VPS_INTEGRATION |
---|
1388 | case NAL_UNIT_VPS: |
---|
1389 | #endif |
---|
1390 | m_essentialBytes += *it_stats; |
---|
1391 | break; |
---|
1392 | default: |
---|
1393 | break; |
---|
1394 | } |
---|
1395 | |
---|
1396 | m_totalBytes += *it_stats; |
---|
1397 | } |
---|
1398 | } |
---|
1399 | |
---|
1400 | #if HHI_INTERVIEW_SKIP |
---|
1401 | Void TAppEncTop::getUsedPelsMap( Int iViewIdx, Int iPoc, TComPicYuv* pcPicYuvUsedSplsMap ) |
---|
1402 | { |
---|
1403 | AOT( iViewIdx <= 0); |
---|
1404 | AOT( iViewIdx >= m_iNumberOfViews ); |
---|
1405 | AOF( m_cCameraData.getCurFrameId() == iPoc ); |
---|
1406 | Int iViewSIdx = m_cCameraData.getBaseId2SortedId()[iViewIdx]; |
---|
1407 | Int iFirstViewSIdx = m_cCameraData.getBaseId2SortedId()[0]; |
---|
1408 | |
---|
1409 | AOT( iViewSIdx == iFirstViewSIdx ); |
---|
1410 | |
---|
1411 | Bool bFirstIsLeft = (iFirstViewSIdx < iViewSIdx); |
---|
1412 | |
---|
1413 | m_cUsedPelsRenderer.setShiftLUTs( |
---|
1414 | m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx], |
---|
1415 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
1416 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
1417 | m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx], |
---|
1418 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
1419 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
1420 | -1 |
---|
1421 | ); |
---|
1422 | |
---|
1423 | TComPicYuv* pcPicYuvDepth = xGetPicYuvFromView(0, iPoc, true, true ); |
---|
1424 | AOF( pcPicYuvDepth); |
---|
1425 | |
---|
1426 | m_cUsedPelsRenderer.getUsedSamplesMap( pcPicYuvDepth, pcPicYuvUsedSplsMap, bFirstIsLeft ); |
---|
1427 | } |
---|
1428 | #endif |
---|
1429 | #if HHI_VSO |
---|
1430 | Void TAppEncTop::setupRenModel( Int iPoc, Int iEncViewIdx, Int iEncContent, Int iHorOffset ) |
---|
1431 | { |
---|
1432 | m_cRendererModel.setupPart( iHorOffset, Min( g_uiMaxCUHeight, m_iSourceHeight - iHorOffset ) ); |
---|
1433 | Int iEncViewSIdx = m_cCameraData.getBaseId2SortedId()[ iEncViewIdx ]; |
---|
1434 | |
---|
1435 | // setup base views |
---|
1436 | Int iNumOfBV = m_cRenModStrParser.getNumOfBaseViewsForView( iEncViewSIdx, iEncContent ); |
---|
1437 | |
---|
1438 | for (Int iCurView = 0; iCurView < iNumOfBV; iCurView++ ) |
---|
1439 | { |
---|
1440 | Int iBaseViewSIdx; |
---|
1441 | Int iVideoDistMode; |
---|
1442 | Int iDepthDistMode; |
---|
1443 | |
---|
1444 | m_cRenModStrParser.getBaseViewData( iEncViewSIdx, iEncContent, iCurView, iBaseViewSIdx, iVideoDistMode, iDepthDistMode ); |
---|
1445 | |
---|
1446 | AOT( iVideoDistMode < 0 || iVideoDistMode > 2 ); |
---|
1447 | |
---|
1448 | Int iBaseViewIdx = m_cCameraData.getBaseSortedId2Id()[ iBaseViewSIdx ]; |
---|
1449 | |
---|
1450 | TComPicYuv* pcPicYuvVideoRec = xGetPicYuvFromView( iBaseViewIdx, iPoc, false, true ); |
---|
1451 | TComPicYuv* pcPicYuvDepthRec = xGetPicYuvFromView( iBaseViewIdx, iPoc, true , true ); |
---|
1452 | TComPicYuv* pcPicYuvVideoOrg = xGetPicYuvFromView( iBaseViewIdx, iPoc, false, false ); |
---|
1453 | TComPicYuv* pcPicYuvDepthOrg = xGetPicYuvFromView( iBaseViewIdx, iPoc, true , false ); |
---|
1454 | |
---|
1455 | TComPicYuv* pcPicYuvVideoRef = ( iVideoDistMode == 2 ) ? pcPicYuvVideoOrg : NULL; |
---|
1456 | TComPicYuv* pcPicYuvDepthRef = ( iDepthDistMode == 2 ) ? pcPicYuvDepthOrg : NULL; |
---|
1457 | |
---|
1458 | TComPicYuv* pcPicYuvVideoTest = ( iVideoDistMode == 0 ) ? pcPicYuvVideoOrg : pcPicYuvVideoRec; |
---|
1459 | TComPicYuv* pcPicYuvDepthTest = ( iDepthDistMode == 0 ) ? pcPicYuvDepthOrg : pcPicYuvDepthRec; |
---|
1460 | |
---|
1461 | AOT( (iVideoDistMode == 2) != (pcPicYuvVideoRef != NULL) ); |
---|
1462 | AOT( (iDepthDistMode == 2) != (pcPicYuvDepthRef != NULL) ); |
---|
1463 | AOT( pcPicYuvDepthTest == NULL ); |
---|
1464 | AOT( pcPicYuvVideoTest == NULL ); |
---|
1465 | |
---|
1466 | m_cRendererModel.setBaseView( iBaseViewSIdx, pcPicYuvVideoTest, pcPicYuvDepthTest, pcPicYuvVideoRef, pcPicYuvDepthRef ); |
---|
1467 | } |
---|
1468 | |
---|
1469 | m_cRendererModel.setErrorMode( iEncViewSIdx, iEncContent, 0 ); |
---|
1470 | // setup virtual views |
---|
1471 | Int iNumOfSV = m_cRenModStrParser.getNumOfModelsForView( iEncViewSIdx, iEncContent ); |
---|
1472 | for (Int iCurView = 0; iCurView < iNumOfSV; iCurView++ ) |
---|
1473 | { |
---|
1474 | Int iOrgRefBaseViewSIdx; |
---|
1475 | Int iLeftBaseViewSIdx; |
---|
1476 | Int iRightBaseViewSIdx; |
---|
1477 | Int iSynthViewRelNum; |
---|
1478 | Int iModelNum; |
---|
1479 | Int iBlendMode; |
---|
1480 | m_cRenModStrParser.getSingleModelData(iEncViewSIdx, iEncContent, iCurView, iModelNum, iBlendMode,iLeftBaseViewSIdx, iRightBaseViewSIdx, iOrgRefBaseViewSIdx, iSynthViewRelNum ); |
---|
1481 | |
---|
1482 | Int iLeftBaseViewIdx = -1; |
---|
1483 | Int iRightBaseViewIdx = -1; |
---|
1484 | |
---|
1485 | TComPicYuv* pcPicYuvOrgRef = NULL; |
---|
1486 | Int** ppiShiftLUTLeft = NULL; |
---|
1487 | Int** ppiShiftLUTRight = NULL; |
---|
1488 | Int** ppiBaseShiftLUTLeft = NULL; |
---|
1489 | Int** ppiBaseShiftLUTRight = NULL; |
---|
1490 | |
---|
1491 | |
---|
1492 | Int iDistToLeft = -1; |
---|
1493 | |
---|
1494 | Int iSynthViewIdx = m_cCameraData.synthRelNum2Idx( iSynthViewRelNum ); |
---|
1495 | |
---|
1496 | if ( iLeftBaseViewSIdx != -1 ) |
---|
1497 | { |
---|
1498 | iLeftBaseViewIdx = m_cCameraData.getBaseSortedId2Id() [ iLeftBaseViewSIdx ]; |
---|
1499 | ppiShiftLUTLeft = m_cCameraData.getSynthViewShiftLUTI()[ iLeftBaseViewIdx ][ iSynthViewIdx ]; |
---|
1500 | } |
---|
1501 | |
---|
1502 | if ( iRightBaseViewSIdx != -1 ) |
---|
1503 | { |
---|
1504 | iRightBaseViewIdx = m_cCameraData.getBaseSortedId2Id() [iRightBaseViewSIdx ]; |
---|
1505 | ppiShiftLUTRight = m_cCameraData.getSynthViewShiftLUTI()[ iRightBaseViewIdx ][ iSynthViewIdx ]; |
---|
1506 | } |
---|
1507 | |
---|
1508 | if ( iRightBaseViewSIdx != -1 && iLeftBaseViewSIdx != -1 ) |
---|
1509 | { |
---|
1510 | iDistToLeft = m_cCameraData.getRelDistLeft( iSynthViewIdx , iLeftBaseViewIdx, iRightBaseViewIdx); |
---|
1511 | ppiBaseShiftLUTLeft = m_cCameraData.getBaseViewShiftLUTI() [ iLeftBaseViewIdx ][ iRightBaseViewIdx ]; |
---|
1512 | ppiBaseShiftLUTRight = m_cCameraData.getBaseViewShiftLUTI() [ iRightBaseViewIdx ][ iLeftBaseViewIdx ]; |
---|
1513 | |
---|
1514 | } |
---|
1515 | |
---|
1516 | if ( iOrgRefBaseViewSIdx != -1 ) |
---|
1517 | { |
---|
1518 | pcPicYuvOrgRef = xGetPicYuvFromView( m_cCameraData.getBaseSortedId2Id()[ iOrgRefBaseViewSIdx ] , iPoc, false, false ); |
---|
1519 | AOF ( pcPicYuvOrgRef ); |
---|
1520 | } |
---|
1521 | |
---|
1522 | m_cRendererModel.setSingleModel( iModelNum, ppiShiftLUTLeft, ppiBaseShiftLUTLeft, ppiShiftLUTRight, ppiBaseShiftLUTRight, iDistToLeft, pcPicYuvOrgRef ); |
---|
1523 | } |
---|
1524 | } |
---|
1525 | #endif |
---|
1526 | |
---|
1527 | |
---|
1528 | |
---|
1529 | /* |
---|
1530 | void TAppEncTop::printRateSummary() |
---|
1531 | { |
---|
1532 | double time = (double) m_iFrameRcvd / m_iFrameRate; |
---|
1533 | printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time); |
---|
1534 | #if VERBOSE_RATE |
---|
1535 | printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time); |
---|
1536 | #endif |
---|
1537 | } |
---|
1538 | */ |
---|
1539 | |
---|
1540 | std::vector<TComPic*> TAppEncTop::getInterViewRefPics( Int viewId, Int poc, Bool isDepth, TComSPS* sps ) |
---|
1541 | { |
---|
1542 | std::vector<TComPic*> apcRefPics( sps->getNumberOfUsableInterViewRefs(), (TComPic*)NULL ); |
---|
1543 | for( Int k = 0; k < sps->getNumberOfUsableInterViewRefs(); k++ ) |
---|
1544 | { |
---|
1545 | TComPic* pcRefPic = xGetPicFromView( sps->getUsableInterViewRef( k ) + viewId, poc, isDepth ); |
---|
1546 | assert( pcRefPic != NULL ); |
---|
1547 | apcRefPics[k] = pcRefPic; |
---|
1548 | } |
---|
1549 | return apcRefPics; |
---|
1550 | } |
---|
1551 | |
---|
1552 | TComPic* TAppEncTop::xGetPicFromView( Int viewIdx, Int poc, Bool isDepth ) |
---|
1553 | { |
---|
1554 | assert( ( viewIdx >= 0 ) && ( viewIdx < m_iNumberOfViews ) ); |
---|
1555 | |
---|
1556 | TComList<TComPic*>* apcListPic = (isDepth ? m_acTEncDepthTopList[viewIdx] : m_acTEncTopList[viewIdx])->getListPic() ; |
---|
1557 | |
---|
1558 | TComPic* pcPic = NULL; |
---|
1559 | for(TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++) |
---|
1560 | { |
---|
1561 | if( (*it)->getPOC() == poc ) |
---|
1562 | { |
---|
1563 | pcPic = *it ; |
---|
1564 | break ; |
---|
1565 | } |
---|
1566 | } |
---|
1567 | |
---|
1568 | return pcPic; |
---|
1569 | }; |
---|
1570 | |
---|
1571 | #if RWTH_SDC_DLT_B0036 |
---|
1572 | Void TAppEncTop::xAnalyzeInputBaseDepth(Int iViewIdx, UInt uiNumFrames) |
---|
1573 | { |
---|
1574 | TComPicYuv* pcDepthPicYuvOrg = new TComPicYuv; |
---|
1575 | // allocate original YUV buffer |
---|
1576 | pcDepthPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
1577 | |
---|
1578 | TVideoIOYuv* depthVideoFile = new TVideoIOYuv; |
---|
1579 | |
---|
1580 | UInt uiMaxDepthValue = g_uiIBDI_MAX; |
---|
1581 | |
---|
1582 | Bool abValidDepths[256]; |
---|
1583 | |
---|
1584 | depthVideoFile->open( m_pchDepthInputFileList[iViewIdx], false, m_uiInputBitDepth, m_uiInternalBitDepth ); // read mode |
---|
1585 | |
---|
1586 | // initialize boolean array |
---|
1587 | for(Int p=0; p<=uiMaxDepthValue; p++) |
---|
1588 | abValidDepths[p] = false; |
---|
1589 | |
---|
1590 | Int iHeight = pcDepthPicYuvOrg->getHeight(); |
---|
1591 | Int iWidth = pcDepthPicYuvOrg->getWidth(); |
---|
1592 | Int iStride = pcDepthPicYuvOrg->getStride(); |
---|
1593 | |
---|
1594 | Pel* pInDM = pcDepthPicYuvOrg->getLumaAddr(); |
---|
1595 | |
---|
1596 | for(Int uiFrame=0; uiFrame < uiNumFrames; uiFrame++ ) |
---|
1597 | { |
---|
1598 | depthVideoFile->read( pcDepthPicYuvOrg, m_aiPad, false ); |
---|
1599 | |
---|
1600 | // check all pixel values |
---|
1601 | for (Int i=0; i<iHeight; i++) |
---|
1602 | { |
---|
1603 | Int rowOffset = i*iStride; |
---|
1604 | |
---|
1605 | for (Int j=0; j<iWidth; j++) |
---|
1606 | { |
---|
1607 | Pel depthValue = pInDM[rowOffset+j]; |
---|
1608 | abValidDepths[depthValue] = true; |
---|
1609 | } |
---|
1610 | } |
---|
1611 | } |
---|
1612 | |
---|
1613 | depthVideoFile->close(); |
---|
1614 | |
---|
1615 | pcDepthPicYuvOrg->destroy(); |
---|
1616 | delete pcDepthPicYuvOrg; |
---|
1617 | |
---|
1618 | // convert boolean array to idx2Depth LUT |
---|
1619 | UInt* auiIdx2DepthValue = (UInt*) calloc(uiMaxDepthValue, sizeof(UInt)); |
---|
1620 | UInt uiNumDepthValues = 0; |
---|
1621 | for(UInt p=0; p<=uiMaxDepthValue; p++) |
---|
1622 | { |
---|
1623 | if( abValidDepths[p] == true) |
---|
1624 | { |
---|
1625 | auiIdx2DepthValue[uiNumDepthValues++] = p; |
---|
1626 | } |
---|
1627 | } |
---|
1628 | |
---|
1629 | if( uiNumFrames == 0 || ceil(Log2(uiNumDepthValues)) == ceil(Log2(g_uiIBDI_MAX)) ) |
---|
1630 | { |
---|
1631 | // don't use DLT |
---|
1632 | m_acTEncDepthTopList[iViewIdx]->setUseDLT(false); |
---|
1633 | m_acTEncDepthTopList[iViewIdx]->getSPS()->setUseDLT(false); |
---|
1634 | } |
---|
1635 | |
---|
1636 | // assign LUT |
---|
1637 | if( m_acTEncDepthTopList[iViewIdx]->getUseDLT() ) |
---|
1638 | m_acTEncDepthTopList[iViewIdx]->getSPS()->setDepthLUTs(auiIdx2DepthValue, uiNumDepthValues); |
---|
1639 | else |
---|
1640 | m_acTEncDepthTopList[iViewIdx]->getSPS()->setDepthLUTs(); |
---|
1641 | |
---|
1642 | // free temporary memory |
---|
1643 | free(auiIdx2DepthValue); |
---|
1644 | } |
---|
1645 | #endif |
---|
1646 | |
---|
1647 | #if MERL_VSP_C0152 |
---|
1648 | Void TAppEncTop::setBWVSPLUT(Int iCodedViewIdx, Int gopId, Bool isDepth) |
---|
1649 | { |
---|
1650 | //first view does not have VSP |
---|
1651 | if((iCodedViewIdx == 0)) return; |
---|
1652 | |
---|
1653 | AOT( iCodedViewIdx <= 0); |
---|
1654 | AOT( iCodedViewIdx >= m_iNumberOfViews ); |
---|
1655 | |
---|
1656 | Int iNeighborViewId = 0; |
---|
1657 | //setting look-up table |
---|
1658 | Int* piShiftLUT = m_cCameraData.getBaseViewShiftLUTI()[iNeighborViewId][iCodedViewIdx][0]; |
---|
1659 | |
---|
1660 | if(isDepth) |
---|
1661 | { |
---|
1662 | TEncSlice* pcEncSlice = (TEncSlice*) m_acTEncDepthTopList[iCodedViewIdx]->getSliceEncoder(); |
---|
1663 | pcEncSlice->setBWVSPLUTParam( piShiftLUT, LOG2_DISP_PREC_LUT ); |
---|
1664 | } |
---|
1665 | else |
---|
1666 | { |
---|
1667 | TEncSlice* pcEncSlice = (TEncSlice*) m_acTEncTopList[iCodedViewIdx]->getSliceEncoder(); |
---|
1668 | pcEncSlice->setBWVSPLUTParam( piShiftLUT, LOG2_DISP_PREC_LUT ); |
---|
1669 | } |
---|
1670 | |
---|
1671 | } |
---|
1672 | #endif |
---|
1673 | |
---|
1674 | //! \} |
---|