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-2011, 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 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 | |
---|
35 | |
---|
36 | /** \file TAppDecTop.cpp |
---|
37 | \brief Decoder application class |
---|
38 | */ |
---|
39 | |
---|
40 | #include <list> |
---|
41 | #include <stdio.h> |
---|
42 | #include <fcntl.h> |
---|
43 | #include <assert.h> |
---|
44 | |
---|
45 | #include "TAppDecTop.h" |
---|
46 | |
---|
47 | // ==================================================================================================================== |
---|
48 | // Local constants |
---|
49 | // ==================================================================================================================== |
---|
50 | |
---|
51 | /// initial bitstream buffer size |
---|
52 | /// should be large enough for parsing SPS |
---|
53 | /// resized as a function of picture size after parsing SPS |
---|
54 | #define BITS_BUF_SIZE 65536 |
---|
55 | |
---|
56 | // ==================================================================================================================== |
---|
57 | // Constructor / destructor / initialization / destroy |
---|
58 | // ==================================================================================================================== |
---|
59 | |
---|
60 | TAppDecTop::TAppDecTop() |
---|
61 | { |
---|
62 | ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag)); |
---|
63 | m_bUsingDepth = false; |
---|
64 | // m_iPOCLastDisplay = -1; |
---|
65 | m_pScaleOffsetFile = 0; |
---|
66 | } |
---|
67 | |
---|
68 | Void TAppDecTop::create() |
---|
69 | { |
---|
70 | m_apcBitstream = new TComBitstream; |
---|
71 | |
---|
72 | m_apcBitstream->create( BITS_BUF_SIZE ); |
---|
73 | } |
---|
74 | |
---|
75 | Void TAppDecTop::destroy() |
---|
76 | { |
---|
77 | if ( m_apcBitstream ) |
---|
78 | { |
---|
79 | m_apcBitstream->destroy(); |
---|
80 | delete m_apcBitstream; |
---|
81 | m_apcBitstream = NULL; |
---|
82 | } |
---|
83 | if( m_pchBitstreamFile ) |
---|
84 | { |
---|
85 | free(m_pchBitstreamFile); |
---|
86 | } |
---|
87 | if( m_pchReconFile ) |
---|
88 | { |
---|
89 | free(m_pchReconFile); |
---|
90 | } |
---|
91 | } |
---|
92 | |
---|
93 | // ==================================================================================================================== |
---|
94 | // Public member functions |
---|
95 | // ==================================================================================================================== |
---|
96 | |
---|
97 | /** |
---|
98 | - create internal class |
---|
99 | - initialize internal class |
---|
100 | - until the end of the bitstream, call decoding function in TDecTop class |
---|
101 | - delete allocated buffers |
---|
102 | - destroy internal class |
---|
103 | . |
---|
104 | */ |
---|
105 | Void TAppDecTop::decode() |
---|
106 | { |
---|
107 | TComBitstream* pcBitstream = m_apcBitstream; |
---|
108 | UInt uiPOC; |
---|
109 | TComList<TComPic*>* pcListPic; |
---|
110 | Bool bFirstSliceDecoded = true; |
---|
111 | |
---|
112 | // create & initialize internal classes |
---|
113 | xCreateDecLib(); |
---|
114 | xInitDecLib (); |
---|
115 | #if DCM_SKIP_DECODING_FRAMES |
---|
116 | // m_iPOCLastDisplay += m_iSkipFrame; // set the last displayed POC correctly for skip forward. |
---|
117 | #endif |
---|
118 | |
---|
119 | // main decoder loop |
---|
120 | Bool bEos = false; |
---|
121 | Bool resizedBitstreamBuffer = false; |
---|
122 | |
---|
123 | Bool bIsDepth = false; |
---|
124 | Int iViewIdx = 0; |
---|
125 | TComSPS cComSPS ; |
---|
126 | NalUnitType eNalUnitType; |
---|
127 | |
---|
128 | |
---|
129 | while ( !bEos ) |
---|
130 | { |
---|
131 | streampos lLocation = m_cTVideoIOBitstreamFile.getFileLocation(); |
---|
132 | bEos = m_cTVideoIOBitstreamFile.readBits( pcBitstream ); |
---|
133 | if (bEos) |
---|
134 | { |
---|
135 | //if (!bFirstSliceDecoded) m_cTDecTop.decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_iPOCLastDisplay); |
---|
136 | if( bIsDepth ) |
---|
137 | { |
---|
138 | if (!bFirstSliceDecoded) m_acTDecDepthTopList[iViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iViewIdx] ); |
---|
139 | m_acTDecDepthTopList[iViewIdx]->executeDeblockAndAlf( bEos, pcBitstream, uiPOC, pcListPic, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iViewIdx]); |
---|
140 | } |
---|
141 | else |
---|
142 | { |
---|
143 | if (!bFirstSliceDecoded) m_acTDecTopList[iViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiPOCLastDisplayList[iViewIdx] ); |
---|
144 | m_acTDecTopList[iViewIdx]->executeDeblockAndAlf( bEos, pcBitstream, uiPOC, pcListPic, m_iSkipFrame, m_aiPOCLastDisplayList[iViewIdx]); |
---|
145 | } |
---|
146 | if( pcListPic ) |
---|
147 | { |
---|
148 | // write reconstuction to file |
---|
149 | xWriteOutput( pcListPic ); |
---|
150 | } |
---|
151 | break; |
---|
152 | } |
---|
153 | |
---|
154 | // call actual decoding function |
---|
155 | #if DCM_SKIP_DECODING_FRAMES |
---|
156 | Bool bNewPicture; |
---|
157 | if( bIsDepth ) |
---|
158 | bNewPicture = m_acTDecDepthTopList[iViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iViewIdx] ); |
---|
159 | else |
---|
160 | bNewPicture = m_acTDecTopList[iViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiPOCLastDisplayList[iViewIdx] ); |
---|
161 | bFirstSliceDecoded = true; |
---|
162 | |
---|
163 | if( eNalUnitType == NAL_UNIT_SPS ) |
---|
164 | { |
---|
165 | #if POZNAN_SYNTH |
---|
166 | if(cComSPS.getViewId()==0 && !cComSPS.isDepth()) // it should be called at first view at the begining of the stream |
---|
167 | initRenderer(cComSPS); |
---|
168 | #endif |
---|
169 | if( cComSPS.isDepth() && (m_bUsingDepth==false) ) // expected not using depth, but bitstream are using depth |
---|
170 | { // know from sps |
---|
171 | assert( cComSPS.getViewId() == 0 && iViewIdx == 0 && !bIsDepth ); |
---|
172 | startUsingDepth() ; |
---|
173 | } |
---|
174 | if( cComSPS.isDepth() && !bIsDepth ) |
---|
175 | { |
---|
176 | assert( cComSPS.getViewId() == iViewIdx ); |
---|
177 | m_acTDecDepthTopList[iViewIdx]->setSPS(cComSPS); |
---|
178 | } |
---|
179 | else if( cComSPS.getViewId() >= m_acTVideoIOYuvReconFileList.size() ) // expecting iViewIdx, but got cComSPS.getViewIdx() |
---|
180 | { |
---|
181 | assert( cComSPS.getViewId() == m_acTVideoIOYuvReconFileList.size() ); |
---|
182 | assert( !cComSPS.isDepth() ); |
---|
183 | increaseNumberOfViews(cComSPS.getViewId()+1); |
---|
184 | m_acTDecTopList[cComSPS.getViewId()]->setSPS(cComSPS); |
---|
185 | } |
---|
186 | bEos = m_cTVideoIOBitstreamFile.readBits( pcBitstream ); |
---|
187 | assert( !bEos); |
---|
188 | if( cComSPS.isDepth() ) |
---|
189 | m_acTDecDepthTopList[cComSPS.getViewId()]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiDepthPOCLastDisplayList[cComSPS.getViewId()]); // decode PPS |
---|
190 | else |
---|
191 | m_acTDecTopList[cComSPS.getViewId()]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiPOCLastDisplayList[cComSPS.getViewId()]); // decode PPS |
---|
192 | assert( eNalUnitType == NAL_UNIT_PPS ); |
---|
193 | } |
---|
194 | assert( eNalUnitType != NAL_UNIT_SEI ); // not yet supported for MVC |
---|
195 | if (bNewPicture) |
---|
196 | { |
---|
197 | if( bIsDepth ) |
---|
198 | m_acTDecDepthTopList[iViewIdx]->executeDeblockAndAlf( bEos, pcBitstream, uiPOC, pcListPic, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iViewIdx]); |
---|
199 | else |
---|
200 | m_acTDecTopList[iViewIdx]->executeDeblockAndAlf( bEos, pcBitstream, uiPOC, pcListPic, m_iSkipFrame, m_aiPOCLastDisplayList[iViewIdx]); |
---|
201 | if (!m_cTVideoIOBitstreamFile.good()) m_cTVideoIOBitstreamFile.clear(); |
---|
202 | m_cTVideoIOBitstreamFile.setFileLocation( lLocation ); |
---|
203 | bFirstSliceDecoded = false; |
---|
204 | |
---|
205 | if( m_bUsingDepth && !bIsDepth ) |
---|
206 | { |
---|
207 | bIsDepth = true; |
---|
208 | } |
---|
209 | else |
---|
210 | { |
---|
211 | bIsDepth = false; |
---|
212 | if( iViewIdx<m_acTDecTopList.size()-1) |
---|
213 | { |
---|
214 | iViewIdx++ ; |
---|
215 | } |
---|
216 | else |
---|
217 | { |
---|
218 | iViewIdx = 0; |
---|
219 | |
---|
220 | // end of access unit: delete extra pic buffers |
---|
221 | Int iNumViews = (Int)m_acTVideoIOYuvReconFileList.size(); |
---|
222 | for( Int iVId = 0; iVId < iNumViews; iVId++ ) |
---|
223 | { |
---|
224 | if( iVId < (Int)m_acTDecTopList.size() && m_acTDecTopList[iVId] ) |
---|
225 | { |
---|
226 | m_acTDecTopList[iVId]->deleteExtraPicBuffers( (Int)uiPOC ); |
---|
227 | } |
---|
228 | if( iVId < (Int)m_acTDecDepthTopList.size() && m_acTDecDepthTopList[iVId] ) |
---|
229 | { |
---|
230 | m_acTDecDepthTopList[iVId]->deleteExtraPicBuffers( (Int)uiPOC ); |
---|
231 | } |
---|
232 | } |
---|
233 | |
---|
234 | #if AMVP_BUFFERCOMPRESS |
---|
235 | // compress motion for entire access unit |
---|
236 | for( Int iVId = 0; iVId < iNumViews; iVId++ ) |
---|
237 | { |
---|
238 | if( iVId < (Int)m_acTDecTopList.size() && m_acTDecTopList[iVId] ) |
---|
239 | { |
---|
240 | m_acTDecTopList[iVId]->compressMotion( (Int)uiPOC ); |
---|
241 | } |
---|
242 | if( iVId < (Int)m_acTDecDepthTopList.size() && m_acTDecDepthTopList[iVId] ) |
---|
243 | { |
---|
244 | m_acTDecDepthTopList[iVId]->compressMotion( (Int)uiPOC ); |
---|
245 | } |
---|
246 | } |
---|
247 | #endif |
---|
248 | } |
---|
249 | } |
---|
250 | } |
---|
251 | #else |
---|
252 | #error |
---|
253 | m_cTDecTop.decode( bEos, pcBitstream, uiPOC, pcListPic ); |
---|
254 | #endif |
---|
255 | |
---|
256 | |
---|
257 | if (!resizedBitstreamBuffer) |
---|
258 | { |
---|
259 | TComSPS *sps = m_acTDecTopList[0]->getSPS(); |
---|
260 | if (sps) |
---|
261 | { |
---|
262 | pcBitstream->destroy(); |
---|
263 | pcBitstream->create(sps->getWidth() * sps->getHeight() * 2); |
---|
264 | resizedBitstreamBuffer = true; |
---|
265 | } |
---|
266 | } |
---|
267 | |
---|
268 | if( pcListPic ) |
---|
269 | { |
---|
270 | // write reconstuction to file |
---|
271 | xWriteOutput( pcListPic ); |
---|
272 | } |
---|
273 | } |
---|
274 | |
---|
275 | // delete buffers |
---|
276 | for(Int i=0; i<m_acTDecTopList.size(); i++) |
---|
277 | m_acTDecTopList[i]->deletePicBuffer(); |
---|
278 | |
---|
279 | if (m_bUsingDepth) |
---|
280 | { |
---|
281 | for(Int i=0; i<m_acTDecDepthTopList.size(); i++) |
---|
282 | m_acTDecDepthTopList[i]->deletePicBuffer(); |
---|
283 | } |
---|
284 | |
---|
285 | // destroy internal classes |
---|
286 | xDestroyDecLib(); |
---|
287 | } |
---|
288 | |
---|
289 | // ==================================================================================================================== |
---|
290 | // Protected member functions |
---|
291 | // ==================================================================================================================== |
---|
292 | |
---|
293 | Void TAppDecTop::xCreateDecLib() |
---|
294 | { |
---|
295 | // open bitstream file |
---|
296 | m_cTVideoIOBitstreamFile.openBits( m_pchBitstreamFile, false); // read mode |
---|
297 | |
---|
298 | // create decoder class |
---|
299 | // m_cTDecTop.create(); |
---|
300 | m_acTDecTopList.push_back(new TDecTop) ;// at least one decoder |
---|
301 | m_acTDecTopList[0]->create() ; |
---|
302 | |
---|
303 | m_aiPOCLastDisplayList.push_back(-1+m_iSkipFrame) ; |
---|
304 | |
---|
305 | if( m_pchScaleOffsetFile ) |
---|
306 | { |
---|
307 | m_pScaleOffsetFile = ::fopen( m_pchScaleOffsetFile, "wt" ); |
---|
308 | AOF( m_pScaleOffsetFile ); |
---|
309 | } |
---|
310 | m_cCamParsCollector.init( m_pScaleOffsetFile ); |
---|
311 | } |
---|
312 | |
---|
313 | Void TAppDecTop::xDestroyDecLib() |
---|
314 | { |
---|
315 | // close bitstream file |
---|
316 | m_cTVideoIOBitstreamFile.closeBits(); |
---|
317 | |
---|
318 | for(Int iViewIdx=0; iViewIdx<m_acTVideoIOYuvReconFileList.size() ; iViewIdx++) |
---|
319 | { |
---|
320 | m_acTVideoIOYuvReconFileList[iViewIdx]->close(); |
---|
321 | delete m_acTVideoIOYuvReconFileList[iViewIdx]; m_acTVideoIOYuvReconFileList[iViewIdx] = NULL ; |
---|
322 | } |
---|
323 | |
---|
324 | // destroy decoder class |
---|
325 | // m_cTDecTop.destroy(); |
---|
326 | for(Int iViewIdx=0; iViewIdx<m_acTDecTopList.size() ; iViewIdx++) |
---|
327 | { |
---|
328 | m_acTDecTopList[iViewIdx]->destroy() ; |
---|
329 | delete m_acTDecTopList[iViewIdx] ; m_acTDecTopList[iViewIdx] = NULL ; |
---|
330 | } |
---|
331 | |
---|
332 | for(Int iViewIdx=0; iViewIdx<m_acTVideoIOYuvDepthReconFileList.size() ; iViewIdx++) |
---|
333 | { |
---|
334 | m_acTVideoIOYuvDepthReconFileList[iViewIdx]->close(); |
---|
335 | delete m_acTVideoIOYuvDepthReconFileList[iViewIdx]; m_acTVideoIOYuvDepthReconFileList[iViewIdx] = NULL ; |
---|
336 | } |
---|
337 | |
---|
338 | for(Int iViewIdx=0; iViewIdx<m_acTDecDepthTopList.size() ; iViewIdx++) |
---|
339 | { |
---|
340 | m_acTDecDepthTopList[iViewIdx]->destroy() ; |
---|
341 | delete m_acTDecDepthTopList[iViewIdx] ; m_acTDecDepthTopList[iViewIdx] = NULL ; |
---|
342 | } |
---|
343 | |
---|
344 | m_cCamParsCollector.uninit(); |
---|
345 | if( m_pScaleOffsetFile ) |
---|
346 | { |
---|
347 | ::fclose( m_pScaleOffsetFile ); |
---|
348 | } |
---|
349 | } |
---|
350 | |
---|
351 | Void TAppDecTop::xInitDecLib() |
---|
352 | { |
---|
353 | // initialize decoder class |
---|
354 | m_acTDecTopList[0]->init( this ); |
---|
355 | m_acTDecTopList[0]->setViewIdx(0); |
---|
356 | m_acTDecTopList[0]->setPictureDigestEnabled(m_pictureDigestEnabled); |
---|
357 | m_acTDecTopList[0]->setCamParsCollector( &m_cCamParsCollector ); |
---|
358 | } |
---|
359 | |
---|
360 | /** \param pcListPic list of pictures to be written to file |
---|
361 | \param bFirst first picture? |
---|
362 | \todo DYN_REF_FREE should be revised |
---|
363 | */ |
---|
364 | Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic ) |
---|
365 | { |
---|
366 | TComList<TComPic*>::iterator iterPic = pcListPic->begin(); |
---|
367 | |
---|
368 | while (iterPic != pcListPic->end()) |
---|
369 | { |
---|
370 | TComPic* pcPic = *(iterPic); |
---|
371 | Int iViewIdx = pcPic->getViewIdx(); |
---|
372 | Int bIsDepth = pcPic->getSlice(0)->getSPS()->isDepth() ; |
---|
373 | |
---|
374 | if (!bIsDepth) |
---|
375 | { |
---|
376 | if( m_acTVideoIOYuvReconFileList.size() < iViewIdx+1 ) |
---|
377 | increaseNumberOfViews( iViewIdx+1 ) ; |
---|
378 | |
---|
379 | if ( pcPic->getReconMark() && pcPic->getPOC() == (m_aiPOCLastDisplayList[iViewIdx] + 1) ) |
---|
380 | { |
---|
381 | // write to file |
---|
382 | if ( m_pchReconFile ) |
---|
383 | { |
---|
384 | m_acTVideoIOYuvReconFileList[iViewIdx]->write( pcPic->getPicYuvRec(), pcPic->getSlice(0)->getSPS()->getPad() ); |
---|
385 | } |
---|
386 | |
---|
387 | // update POC of display order |
---|
388 | m_aiPOCLastDisplayList[iViewIdx] = pcPic->getPOC(); |
---|
389 | |
---|
390 | // erase non-referenced picture in the reference picture list after display |
---|
391 | if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true ) |
---|
392 | { |
---|
393 | #if !DYN_REF_FREE |
---|
394 | pcPic->setReconMark(false); |
---|
395 | |
---|
396 | // mark it should be extended later |
---|
397 | pcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
398 | |
---|
399 | #else |
---|
400 | pcPic->destroy(); |
---|
401 | pcListPic->erase( iterPic ); |
---|
402 | iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! |
---|
403 | continue; |
---|
404 | #endif |
---|
405 | } |
---|
406 | } |
---|
407 | } /// end !bIsDepth |
---|
408 | else |
---|
409 | { |
---|
410 | if( m_acTVideoIOYuvDepthReconFileList.size() < iViewIdx+1 ) |
---|
411 | increaseNumberOfViews( iViewIdx+1 ) ; |
---|
412 | |
---|
413 | if ( pcPic->getReconMark() && pcPic->getPOC() == (m_aiDepthPOCLastDisplayList[iViewIdx] + 1) ) |
---|
414 | { |
---|
415 | // write to file |
---|
416 | if ( m_pchReconFile ) |
---|
417 | { |
---|
418 | m_acTVideoIOYuvDepthReconFileList[iViewIdx]->write( pcPic->getPicYuvRec(), pcPic->getSlice(0)->getSPS()->getPad() ); |
---|
419 | } |
---|
420 | |
---|
421 | // update POC of display order |
---|
422 | m_aiDepthPOCLastDisplayList[iViewIdx] = pcPic->getPOC(); |
---|
423 | |
---|
424 | // erase non-referenced picture in the reference picture list after display |
---|
425 | if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true ) |
---|
426 | { |
---|
427 | #if !DYN_REF_FREE |
---|
428 | pcPic->setReconMark(false); |
---|
429 | |
---|
430 | // mark it should be extended later |
---|
431 | pcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
432 | |
---|
433 | #else |
---|
434 | pcPic->destroy(); |
---|
435 | pcListPic->erase( iterPic ); |
---|
436 | iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! |
---|
437 | continue; |
---|
438 | #endif |
---|
439 | } |
---|
440 | } |
---|
441 | } // end bIsDepth |
---|
442 | |
---|
443 | iterPic++; |
---|
444 | } |
---|
445 | } |
---|
446 | |
---|
447 | Void TAppDecTop::startUsingDepth() |
---|
448 | { |
---|
449 | m_bUsingDepth = true ; |
---|
450 | increaseNumberOfViews( (Int)m_acTVideoIOYuvReconFileList.size() ); |
---|
451 | } |
---|
452 | |
---|
453 | Void TAppDecTop::increaseNumberOfViews (Int iNewNumberOfViews) |
---|
454 | { |
---|
455 | while( m_acTVideoIOYuvReconFileList.size() < iNewNumberOfViews) |
---|
456 | { |
---|
457 | m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv); |
---|
458 | |
---|
459 | // GT FIX |
---|
460 | Char cBuffer[4] ; |
---|
461 | sprintf(cBuffer,"_%i",(Int)m_acTVideoIOYuvReconFileList.size()-1 ); |
---|
462 | Char* pchNextFilename; |
---|
463 | xAppendToFileNameEnd( m_pchReconFile, cBuffer, pchNextFilename); |
---|
464 | // GT FIX END |
---|
465 | if ( m_outputBitDepth == 0 ) |
---|
466 | m_outputBitDepth = g_uiBitDepth + g_uiBitIncrement; |
---|
467 | m_acTVideoIOYuvReconFileList.back()->open( pchNextFilename, true, m_outputBitDepth, g_uiBitDepth + g_uiBitIncrement ); |
---|
468 | free (pchNextFilename); |
---|
469 | } |
---|
470 | |
---|
471 | while( m_aiPOCLastDisplayList.size() < iNewNumberOfViews ) |
---|
472 | m_aiPOCLastDisplayList.push_back(-1+m_iSkipFrame) ; |
---|
473 | |
---|
474 | while( m_acTDecTopList.size() < iNewNumberOfViews) |
---|
475 | { |
---|
476 | m_acTDecTopList.push_back(new TDecTop) ;// at least one decoder |
---|
477 | m_acTDecTopList.back()->create() ; |
---|
478 | m_acTDecTopList.back()->init( this, false ); |
---|
479 | m_acTDecTopList.back()->setViewIdx((Int)m_acTDecTopList.size()-1); |
---|
480 | m_acTDecTopList.back()->setPictureDigestEnabled(m_pictureDigestEnabled); |
---|
481 | m_acTDecTopList.back()->setCamParsCollector( &m_cCamParsCollector ); |
---|
482 | } |
---|
483 | if( m_bUsingDepth ) |
---|
484 | { |
---|
485 | while( m_acTVideoIOYuvDepthReconFileList.size() < iNewNumberOfViews ) |
---|
486 | { |
---|
487 | m_acTVideoIOYuvDepthReconFileList.push_back(new TVideoIOYuv); |
---|
488 | // GT FIX |
---|
489 | Char* pchTempFilename = NULL; |
---|
490 | xAppendToFileNameEnd( m_pchReconFile, "_depth", pchTempFilename); |
---|
491 | Char cBuffer[4] ; |
---|
492 | sprintf(cBuffer,"_%i",(Int)m_acTVideoIOYuvDepthReconFileList.size()-1 ); |
---|
493 | Char* pchDepthFilename = NULL; |
---|
494 | xAppendToFileNameEnd( pchTempFilename, cBuffer, pchDepthFilename); |
---|
495 | // GT FIX END |
---|
496 | if ( m_outputBitDepth == 0 ) |
---|
497 | m_outputBitDepth = g_uiBitDepth + g_uiBitIncrement; |
---|
498 | m_acTVideoIOYuvDepthReconFileList.back()->open( pchDepthFilename, true, m_outputBitDepth, g_uiBitDepth + g_uiBitIncrement ); |
---|
499 | free (pchTempFilename); |
---|
500 | free( pchDepthFilename ); |
---|
501 | } |
---|
502 | while( m_aiDepthPOCLastDisplayList.size() < iNewNumberOfViews ) |
---|
503 | m_aiDepthPOCLastDisplayList.push_back(-1+m_iSkipFrame) ; |
---|
504 | while( m_acTDecDepthTopList.size() < iNewNumberOfViews) |
---|
505 | { |
---|
506 | m_acTDecDepthTopList.push_back(new TDecTop) ;// at least one decoder |
---|
507 | m_acTDecDepthTopList.back()->create() ; |
---|
508 | m_acTDecDepthTopList.back()->init( this, false ); |
---|
509 | m_acTDecDepthTopList.back()->setViewIdx((Int)m_acTDecTopList.size()-1); |
---|
510 | m_acTDecDepthTopList.back()->setPictureDigestEnabled(m_pictureDigestEnabled); |
---|
511 | m_acTDecDepthTopList.back()->setToDepth( true ); |
---|
512 | m_acTDecDepthTopList.back()->setCamParsCollector( &m_cCamParsCollector ); |
---|
513 | } |
---|
514 | } |
---|
515 | } |
---|
516 | |
---|
517 | |
---|
518 | // GT FIX |
---|
519 | std::vector<TComPic*> TAppDecTop::getSpatialRefPics( Int iViewIdx, Int iPoc, Bool bIsDepth ) // only for mvc functionality yet |
---|
520 | { |
---|
521 | std::vector<TComPic*> apcRefPics( iViewIdx, (TComPic*)NULL ); |
---|
522 | for( int iRefViewIdx = 0; iRefViewIdx < iViewIdx; iRefViewIdx++ ) |
---|
523 | { |
---|
524 | TComPic* pcRefPic = getPicFromView( iRefViewIdx, iPoc, bIsDepth ); |
---|
525 | assert( pcRefPic != NULL ); |
---|
526 | apcRefPics[iRefViewIdx] = pcRefPic; |
---|
527 | } |
---|
528 | return apcRefPics; |
---|
529 | } |
---|
530 | |
---|
531 | TComPic* TAppDecTop::getPicFromView( Int iViewIdx, Int iPoc, bool bIsDepth ) |
---|
532 | { |
---|
533 | TComList<TComPic*>* apcListPic = (bIsDepth ? m_acTDecDepthTopList[iViewIdx] : m_acTDecTopList[iViewIdx])->getListPic(); |
---|
534 | TComPic* pcRefPic = NULL; |
---|
535 | for( TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++ ) |
---|
536 | { |
---|
537 | if( (*it)->getPOC() == iPoc ) |
---|
538 | { |
---|
539 | pcRefPic = *it; |
---|
540 | break; |
---|
541 | } |
---|
542 | } |
---|
543 | return pcRefPic; |
---|
544 | } |
---|
545 | |
---|
546 | #if POZNAN_SYNTH |
---|
547 | Void TAppDecTop::initRenderer(TComSPS &cComSPS) |
---|
548 | { |
---|
549 | m_cAvailabilityRenderer.init(cComSPS.getWidth(), cComSPS.getHeight(),true,0,LOG2_DISP_PREC_LUT,true, 0,0,0,0,0,6,4,1,0,6 ); //GT: simplest configuration |
---|
550 | } |
---|
551 | //* |
---|
552 | Void TAppDecTop::storeSynthPicsInBuffer(Int iCoddedViewIdx,Int iCoddedViewOrderIdx, Int iCurPoc, Bool bDepth) |
---|
553 | { |
---|
554 | Int iLeftViewIdx = -1; |
---|
555 | Int iRightViewIdx = -1; |
---|
556 | Int iNearestViewIdx = -1; |
---|
557 | Bool bIsBaseView; |
---|
558 | Bool bRenderFromLeft; |
---|
559 | |
---|
560 | Int iRelDistToLeft = 128; |
---|
561 | if(iCoddedViewIdx==0) //First on View Coded List |
---|
562 | { |
---|
563 | TComPic* pcPic = getPicFromView( iCoddedViewIdx, iCurPoc, false ); |
---|
564 | return; |
---|
565 | } |
---|
566 | iNearestViewIdx = 0; |
---|
567 | bRenderFromLeft = iCoddedViewOrderIdx>0?true:false; |
---|
568 | //m_cCamParsCollector.getNearestBaseView(iCoddedViewIdx, iNearestViewIdx, iRelDistToLeft, bRenderFromLeft); |
---|
569 | |
---|
570 | m_cAvailabilityRenderer.setShiftLUTs( |
---|
571 | m_cCamParsCollector.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx], |
---|
572 | m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx], |
---|
573 | m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx], |
---|
574 | m_cCamParsCollector.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],//right |
---|
575 | m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx], |
---|
576 | m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx], |
---|
577 | iRelDistToLeft |
---|
578 | ); |
---|
579 | |
---|
580 | TComPic* pcPic = getPicFromView( iCoddedViewIdx, iCurPoc, bDepth ); |
---|
581 | |
---|
582 | TComPicYuv* pcPicYuvSynthView = pcPic->getPicYuvSynth(); |
---|
583 | TComPicYuv* pcPicYuvAvailView = pcPic->getPicYuvAvail(); |
---|
584 | if(!pcPicYuvSynthView) |
---|
585 | { |
---|
586 | pcPic->addSynthesisBuffer(); |
---|
587 | pcPicYuvSynthView = pcPic->getPicYuvSynth(); |
---|
588 | } |
---|
589 | if(!pcPicYuvAvailView) |
---|
590 | { |
---|
591 | pcPic->addAvailabilityBuffer(); |
---|
592 | pcPicYuvAvailView = pcPic->getPicYuvAvail(); |
---|
593 | } |
---|
594 | |
---|
595 | //m_cAvailabilityRenderer.extrapolateAvailabilityView( xGetPicFromView( iNearestViewIdx, iCurPoc, false )->getPicYuvRec(), xGetPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvERView, pcPicYuvAvailView, bRenderFromLeft ); |
---|
596 | m_cAvailabilityRenderer.extrapolateAvailabilityView( getPicFromView( iNearestViewIdx, iCurPoc, false )->getPicYuvRec(), getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvSynthView, pcPicYuvAvailView, bRenderFromLeft ); |
---|
597 | |
---|
598 | pcPicYuvAvailView->setBorderExtension( false );//Needed?? |
---|
599 | pcPicYuvAvailView->extendPicBorder();//Needed?? |
---|
600 | |
---|
601 | #if POZNAN_OUTPUT_AVAILABLE_MAP |
---|
602 | { |
---|
603 | Char acFilenameBase[1024]; |
---|
604 | ::sprintf( acFilenameBase, "Available_%s_%s_V%d.yuv", (bDepth ? "Depth":"Tex"),( true ? "Dec" : "Enc" ), iCoddedViewIdx); |
---|
605 | pcPicYuvAvailView->dump(acFilenameBase, iCurPoc!=0); |
---|
606 | } |
---|
607 | #endif |
---|
608 | #if POZNAN_OUTPUT_SYNTH |
---|
609 | { |
---|
610 | Char acFilenameBase[1024]; |
---|
611 | ::sprintf( acFilenameBase, "Synth_%s_%s_V%d.yuv", (bDepth ? "Depth":"Tex"),( true ? "Dec" : "Enc" ), iCoddedViewIdx ); |
---|
612 | pcPicYuvSynthView->dump(acFilenameBase, iCurPoc!=0); |
---|
613 | } |
---|
614 | #endif |
---|
615 | |
---|
616 | } |
---|
617 | #endif |
---|