[5] | 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 |
---|
[56] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[56] | 6 | * Copyright (c) 2010-2012, ITU/ISO/IEC |
---|
[5] | 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. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 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 | */ |
---|
[2] | 33 | |
---|
| 34 | /** \file TAppDecTop.cpp |
---|
| 35 | \brief Decoder application class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include <list> |
---|
[56] | 39 | #include <vector> |
---|
[2] | 40 | #include <stdio.h> |
---|
| 41 | #include <fcntl.h> |
---|
| 42 | #include <assert.h> |
---|
| 43 | |
---|
| 44 | #include "TAppDecTop.h" |
---|
[56] | 45 | #include "TLibDecoder/AnnexBread.h" |
---|
| 46 | #include "TLibDecoder/NALread.h" |
---|
[2] | 47 | |
---|
[56] | 48 | //! \ingroup TAppDecoder |
---|
| 49 | //! \{ |
---|
[2] | 50 | |
---|
| 51 | // ==================================================================================================================== |
---|
| 52 | // Constructor / destructor / initialization / destroy |
---|
| 53 | // ==================================================================================================================== |
---|
| 54 | |
---|
| 55 | TAppDecTop::TAppDecTop() |
---|
| 56 | { |
---|
| 57 | ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag)); |
---|
[56] | 58 | m_useDepth = false; |
---|
[57] | 59 | m_pScaleOffsetFile = 0; |
---|
[2] | 60 | } |
---|
| 61 | |
---|
| 62 | Void TAppDecTop::create() |
---|
| 63 | { |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | Void TAppDecTop::destroy() |
---|
| 67 | { |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | // ==================================================================================================================== |
---|
| 71 | // Public member functions |
---|
| 72 | // ==================================================================================================================== |
---|
| 73 | |
---|
| 74 | /** |
---|
| 75 | - create internal class |
---|
| 76 | - initialize internal class |
---|
| 77 | - until the end of the bitstream, call decoding function in TDecTop class |
---|
| 78 | - delete allocated buffers |
---|
| 79 | - destroy internal class |
---|
| 80 | . |
---|
| 81 | */ |
---|
| 82 | Void TAppDecTop::decode() |
---|
| 83 | { |
---|
[56] | 84 | increaseNumberOfViews( 1 ); |
---|
| 85 | #if SONY_COLPIC_AVAILABILITY |
---|
| 86 | m_tDecTop[0]->setViewOrderIdx(0); |
---|
[2] | 87 | #endif |
---|
[56] | 88 | Int viewDepthId = 0; |
---|
| 89 | Int previousViewDepthId = 0; |
---|
| 90 | UInt uiPOC[MAX_VIEW_NUM*2]; |
---|
| 91 | TComList<TComPic*>* pcListPic[MAX_VIEW_NUM*2]; |
---|
| 92 | Bool newPicture[MAX_VIEW_NUM*2]; |
---|
| 93 | Bool previousPictureDecoded = false; |
---|
| 94 | for( Int i = 0; i < MAX_VIEW_NUM*2; i++ ) |
---|
| 95 | { |
---|
| 96 | uiPOC[i] = 0; |
---|
| 97 | pcListPic[i] = NULL; |
---|
| 98 | newPicture[i] = false; |
---|
| 99 | } |
---|
[2] | 100 | |
---|
[56] | 101 | ifstream bitstreamFile(m_pchBitstreamFile, ifstream::in | ifstream::binary); |
---|
| 102 | if (!bitstreamFile) |
---|
| 103 | { |
---|
| 104 | fprintf(stderr, "\nfailed to open bitstream file `%s' for reading\n", m_pchBitstreamFile); |
---|
| 105 | exit(EXIT_FAILURE); |
---|
| 106 | } |
---|
[2] | 107 | |
---|
[56] | 108 | if( m_pchScaleOffsetFile ) |
---|
| 109 | { |
---|
| 110 | m_pScaleOffsetFile = ::fopen( m_pchScaleOffsetFile, "wt" ); |
---|
| 111 | AOF( m_pScaleOffsetFile ); |
---|
| 112 | } |
---|
| 113 | m_cCamParsCollector.init( m_pScaleOffsetFile ); |
---|
| 114 | |
---|
| 115 | InputByteStream bytestream(bitstreamFile); |
---|
| 116 | |
---|
| 117 | while (!!bitstreamFile) |
---|
[2] | 118 | { |
---|
[56] | 119 | /* location serves to work around a design fault in the decoder, whereby |
---|
| 120 | * the process of reading a new slice that is the first slice of a new frame |
---|
| 121 | * requires the TDecTop::decode() method to be called again with the same |
---|
| 122 | * nal unit. */ |
---|
| 123 | streampos location = bitstreamFile.tellg(); |
---|
| 124 | AnnexBStats stats = AnnexBStats(); |
---|
| 125 | vector<uint8_t> nalUnit; |
---|
| 126 | InputNALUnit nalu; |
---|
| 127 | byteStreamNALUnit(bytestream, nalUnit, stats); |
---|
| 128 | |
---|
| 129 | // call actual decoding function |
---|
| 130 | if (nalUnit.empty()) |
---|
[2] | 131 | { |
---|
[56] | 132 | /* this can happen if the following occur: |
---|
| 133 | * - empty input file |
---|
| 134 | * - two back-to-back start_code_prefixes |
---|
| 135 | * - start_code_prefix immediately followed by EOF |
---|
| 136 | */ |
---|
| 137 | fprintf(stderr, "Warning: Attempt to decode an empty NAL unit\n"); |
---|
[2] | 138 | } |
---|
| 139 | else |
---|
| 140 | { |
---|
[56] | 141 | read(nalu, nalUnit); |
---|
| 142 | Int viewId = nalu.m_viewId; |
---|
| 143 | Int depth = nalu.m_isDepth ? 1 : 0; |
---|
| 144 | viewDepthId = viewId * 2 + depth; // coding order T0D0T1D1T2D2 |
---|
| 145 | newPicture[viewDepthId] = false; |
---|
| 146 | if( viewDepthId >= m_tDecTop.size() ) |
---|
[2] | 147 | { |
---|
[56] | 148 | increaseNumberOfViews( viewDepthId +1 ); |
---|
[2] | 149 | } |
---|
[56] | 150 | if(m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) |
---|
[2] | 151 | { |
---|
[56] | 152 | previousPictureDecoded = false; |
---|
[2] | 153 | } |
---|
[56] | 154 | if(m_tDecTop.size() > 1 && (viewDepthId != previousViewDepthId) && previousPictureDecoded ) |
---|
[42] | 155 | { |
---|
[56] | 156 | m_tDecTop[previousViewDepthId]->executeDeblockAndAlf(uiPOC[previousViewDepthId], pcListPic[previousViewDepthId], m_iSkipFrame, m_pocLastDisplay[previousViewDepthId]); |
---|
| 157 | } |
---|
| 158 | if( ( viewDepthId == 0 && (viewDepthId != previousViewDepthId) ) || m_tDecTop.size() == 1 ) |
---|
[42] | 159 | { |
---|
[56] | 160 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 161 | for( Int i = 0; i < m_tDecTop.size(); i++ ) |
---|
[42] | 162 | { |
---|
[56] | 163 | m_tDecTop[i]->deleteExtraPicBuffers( uiPOC[i] ); |
---|
[42] | 164 | } |
---|
[56] | 165 | #endif |
---|
| 166 | for( Int i = 0; i < m_tDecTop.size(); i++ ) |
---|
[42] | 167 | { |
---|
[56] | 168 | m_tDecTop[i]->compressMotion( uiPOC[i] ); |
---|
[42] | 169 | } |
---|
[56] | 170 | } |
---|
| 171 | if( !(m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) ) |
---|
[42] | 172 | { |
---|
[56] | 173 | newPicture[viewDepthId] = m_tDecTop[viewDepthId]->decode(nalu, m_iSkipFrame, m_pocLastDisplay[viewDepthId]); |
---|
| 174 | if (newPicture[viewDepthId]) |
---|
[42] | 175 | { |
---|
[56] | 176 | bitstreamFile.clear(); |
---|
| 177 | /* location points to the current nalunit payload[1] due to the |
---|
| 178 | * need for the annexB parser to read three extra bytes. |
---|
| 179 | * [1] except for the first NAL unit in the file |
---|
| 180 | * (but bNewPicture doesn't happen then) */ |
---|
| 181 | bitstreamFile.seekg(location-streamoff(3)); |
---|
| 182 | bytestream.reset(); |
---|
[42] | 183 | } |
---|
[56] | 184 | if( nalu.isSlice() ) |
---|
[42] | 185 | { |
---|
[56] | 186 | previousPictureDecoded = true; |
---|
[42] | 187 | } |
---|
| 188 | } |
---|
[56] | 189 | } |
---|
| 190 | if( ( (newPicture[viewDepthId] || !bitstreamFile) && m_tDecTop.size() == 1) || (!bitstreamFile && previousPictureDecoded == true) ) |
---|
| 191 | { |
---|
| 192 | m_tDecTop[viewDepthId]->executeDeblockAndAlf(uiPOC[viewDepthId], pcListPic[viewDepthId], m_iSkipFrame, m_pocLastDisplay[viewDepthId]); |
---|
| 193 | } |
---|
| 194 | if( pcListPic[viewDepthId] ) |
---|
| 195 | { |
---|
| 196 | if( newPicture[viewDepthId] && (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR || (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDV && m_tDecTop[viewDepthId]->getNalUnitTypeBaseView() == NAL_UNIT_CODED_SLICE_IDR)) ) |
---|
[2] | 197 | { |
---|
[56] | 198 | xFlushOutput( pcListPic[viewDepthId], viewDepthId ); |
---|
[2] | 199 | } |
---|
[56] | 200 | // write reconstruction to file |
---|
| 201 | if(newPicture[viewDepthId]) |
---|
[2] | 202 | { |
---|
[56] | 203 | #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
| 204 | xWriteOutput( pcListPic[viewDepthId], viewDepthId, nalu.m_temporalId ); |
---|
[2] | 205 | #else |
---|
[56] | 206 | xWriteOutput( pcListPic[viewDepthId], viewDepthId ); |
---|
[2] | 207 | #endif |
---|
| 208 | } |
---|
| 209 | } |
---|
[56] | 210 | previousViewDepthId = viewDepthId; |
---|
| 211 | } |
---|
[57] | 212 | if( m_cCamParsCollector.isInitialized() ) |
---|
| 213 | { |
---|
| 214 | m_cCamParsCollector.setSlice( 0 ); |
---|
| 215 | } |
---|
[56] | 216 | // last frame |
---|
| 217 | for( Int viewDepthIdx = 0; viewDepthIdx < m_tDecTop.size(); viewDepthIdx++ ) |
---|
[2] | 218 | { |
---|
[56] | 219 | xFlushOutput( pcListPic[viewDepthIdx], viewDepthIdx ); |
---|
| 220 | } |
---|
[2] | 221 | xDestroyDecLib(); |
---|
| 222 | } |
---|
| 223 | |
---|
| 224 | // ==================================================================================================================== |
---|
| 225 | // Protected member functions |
---|
| 226 | // ==================================================================================================================== |
---|
| 227 | |
---|
| 228 | Void TAppDecTop::xDestroyDecLib() |
---|
| 229 | { |
---|
| 230 | |
---|
[56] | 231 | for(Int viewDepthIdx=0; viewDepthIdx<m_tVideoIOYuvReconFile.size() ; viewDepthIdx++) |
---|
[2] | 232 | { |
---|
[56] | 233 | if( m_tVideoIOYuvReconFile[viewDepthIdx] ) |
---|
| 234 | { |
---|
| 235 | m_tVideoIOYuvReconFile[viewDepthIdx]->close(); |
---|
| 236 | delete m_tVideoIOYuvReconFile[viewDepthIdx]; |
---|
| 237 | m_tVideoIOYuvReconFile[viewDepthIdx] = NULL ; |
---|
| 238 | } |
---|
[2] | 239 | } |
---|
| 240 | |
---|
[56] | 241 | for(Int viewDepthIdx=0; viewDepthIdx<m_tDecTop.size() ; viewDepthIdx++) |
---|
[2] | 242 | { |
---|
[56] | 243 | if( m_tDecTop[viewDepthIdx] ) |
---|
| 244 | { |
---|
| 245 | if( !m_useDepth && (viewDepthIdx % 2 == 1) ) |
---|
| 246 | { |
---|
| 247 | } |
---|
| 248 | else |
---|
| 249 | { |
---|
| 250 | m_tDecTop[viewDepthIdx]->deletePicBuffer(); |
---|
| 251 | m_tDecTop[viewDepthIdx]->destroy() ; |
---|
| 252 | } |
---|
| 253 | delete m_tDecTop[viewDepthIdx] ; |
---|
| 254 | m_tDecTop[viewDepthIdx] = NULL ; |
---|
| 255 | } |
---|
[2] | 256 | } |
---|
[57] | 257 | |
---|
| 258 | m_cCamParsCollector.uninit(); |
---|
| 259 | if( m_pScaleOffsetFile ) |
---|
| 260 | { |
---|
| 261 | ::fclose( m_pScaleOffsetFile ); |
---|
| 262 | } |
---|
[56] | 263 | } |
---|
[2] | 264 | |
---|
[56] | 265 | #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
| 266 | Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, Int viewDepthId, UInt tId ) |
---|
| 267 | #else |
---|
| 268 | Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, Int viewDepthId ) |
---|
| 269 | #endif |
---|
| 270 | { |
---|
| 271 | TComList<TComPic*>::iterator iterPic = pcListPic->begin(); |
---|
| 272 | Int not_displayed = 0; |
---|
| 273 | |
---|
| 274 | while (iterPic != pcListPic->end()) |
---|
[2] | 275 | { |
---|
[56] | 276 | TComPic* pcPic = *(iterPic); |
---|
| 277 | if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[viewDepthId]) |
---|
| 278 | { |
---|
| 279 | not_displayed++; |
---|
| 280 | } |
---|
| 281 | iterPic++; |
---|
[2] | 282 | } |
---|
[56] | 283 | iterPic = pcListPic->begin(); |
---|
| 284 | |
---|
| 285 | while (iterPic != pcListPic->end()) |
---|
[2] | 286 | { |
---|
[56] | 287 | TComPic* pcPic = *(iterPic); |
---|
| 288 | #if PIC_CROPPING |
---|
| 289 | TComSPS *sps = pcPic->getSlice(0)->getSPS(); |
---|
| 290 | #endif |
---|
| 291 | |
---|
| 292 | #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
| 293 | if ( pcPic->getOutputMark() && (not_displayed > pcPic->getSlice(0)->getSPS()->getNumReorderPics(tId) && pcPic->getPOC() > m_pocLastDisplay[viewDepthId])) |
---|
| 294 | #else |
---|
| 295 | if ( pcPic->getOutputMark() && (not_displayed > pcPic->getSlice(0)->getSPS()->getNumReorderFrames() && pcPic->getPOC() > m_pocLastDisplay[viewDepthId])) |
---|
| 296 | #endif |
---|
| 297 | { |
---|
| 298 | // write to file |
---|
| 299 | not_displayed--; |
---|
| 300 | if ( m_pchReconFile ) |
---|
| 301 | { |
---|
| 302 | #if PIC_CROPPING |
---|
| 303 | m_tVideoIOYuvReconFile[viewDepthId]->write( pcPic->getPicYuvRec(), sps->getPicCropLeftOffset(), sps->getPicCropRightOffset(), sps->getPicCropTopOffset(), sps->getPicCropBottomOffset() ); |
---|
| 304 | #else |
---|
| 305 | m_tVideoIOYuvReconFile[viewDepthId]->write( pcPic->getPicYuvRec(), pcPic->getSlice(0)->getSPS()->getPad() ); |
---|
| 306 | #endif |
---|
| 307 | } |
---|
| 308 | |
---|
| 309 | // update POC of display order |
---|
| 310 | m_pocLastDisplay[viewDepthId] = pcPic->getPOC(); |
---|
| 311 | |
---|
| 312 | // erase non-referenced picture in the reference picture list after display |
---|
| 313 | if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true ) |
---|
| 314 | { |
---|
| 315 | #if !DYN_REF_FREE |
---|
| 316 | pcPic->setReconMark(false); |
---|
| 317 | |
---|
| 318 | // mark it should be extended later |
---|
| 319 | pcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
| 320 | |
---|
| 321 | #else |
---|
| 322 | pcPic->destroy(); |
---|
| 323 | pcListPic->erase( iterPic ); |
---|
| 324 | iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! |
---|
| 325 | continue; |
---|
| 326 | #endif |
---|
| 327 | } |
---|
| 328 | pcPic->setOutputMark(false); |
---|
| 329 | } |
---|
| 330 | |
---|
| 331 | iterPic++; |
---|
[2] | 332 | } |
---|
| 333 | } |
---|
| 334 | |
---|
| 335 | /** \param pcListPic list of pictures to be written to file |
---|
| 336 | \todo DYN_REF_FREE should be revised |
---|
| 337 | */ |
---|
[56] | 338 | Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic, Int viewDepthId ) |
---|
[2] | 339 | { |
---|
[56] | 340 | if(!pcListPic) |
---|
| 341 | { |
---|
| 342 | return; |
---|
| 343 | } |
---|
[2] | 344 | TComList<TComPic*>::iterator iterPic = pcListPic->begin(); |
---|
| 345 | |
---|
[56] | 346 | iterPic = pcListPic->begin(); |
---|
| 347 | |
---|
[2] | 348 | while (iterPic != pcListPic->end()) |
---|
| 349 | { |
---|
| 350 | TComPic* pcPic = *(iterPic); |
---|
[56] | 351 | #if PIC_CROPPING |
---|
| 352 | TComSPS *sps = pcPic->getSlice(0)->getSPS(); |
---|
| 353 | #endif |
---|
[2] | 354 | |
---|
[56] | 355 | if ( pcPic->getOutputMark() ) |
---|
[2] | 356 | { |
---|
[56] | 357 | // write to file |
---|
| 358 | if ( m_pchReconFile ) |
---|
[2] | 359 | { |
---|
[56] | 360 | #if PIC_CROPPING |
---|
| 361 | m_tVideoIOYuvReconFile[viewDepthId]->write( pcPic->getPicYuvRec(), sps->getPicCropLeftOffset(), sps->getPicCropRightOffset(), sps->getPicCropTopOffset(), sps->getPicCropBottomOffset() ); |
---|
| 362 | #else |
---|
| 363 | m_tVideoIOYuvReconFile[viewDepthId]->write( pcPic->getPicYuvRec(), pcPic->getSlice(0)->getSPS()->getPad() ); |
---|
| 364 | #endif |
---|
[2] | 365 | } |
---|
[56] | 366 | |
---|
| 367 | // update POC of display order |
---|
| 368 | m_pocLastDisplay[viewDepthId] = pcPic->getPOC(); |
---|
| 369 | |
---|
| 370 | // erase non-referenced picture in the reference picture list after display |
---|
| 371 | if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true ) |
---|
[2] | 372 | { |
---|
[56] | 373 | #if !DYN_REF_FREE |
---|
| 374 | pcPic->setReconMark(false); |
---|
| 375 | |
---|
| 376 | // mark it should be extended later |
---|
| 377 | pcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
| 378 | |
---|
| 379 | #else |
---|
| 380 | pcPic->destroy(); |
---|
| 381 | pcListPic->erase( iterPic ); |
---|
| 382 | iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! |
---|
| 383 | continue; |
---|
| 384 | #endif |
---|
[2] | 385 | } |
---|
[56] | 386 | pcPic->setOutputMark(false); |
---|
| 387 | } |
---|
| 388 | |
---|
[2] | 389 | iterPic++; |
---|
| 390 | } |
---|
[56] | 391 | pcListPic->clear(); |
---|
| 392 | m_pocLastDisplay[viewDepthId] = -MAX_INT; |
---|
[2] | 393 | } |
---|
| 394 | |
---|
[56] | 395 | Void TAppDecTop::increaseNumberOfViews ( Int newNumberOfViewDepth ) |
---|
[2] | 396 | { |
---|
[56] | 397 | if ( m_outputBitDepth == 0 ) |
---|
[2] | 398 | { |
---|
[56] | 399 | m_outputBitDepth = g_uiBitDepth + g_uiBitIncrement; |
---|
[2] | 400 | } |
---|
[56] | 401 | Int viewId = (newNumberOfViewDepth-1)>>1; // coding order T0D0T1D1T2D2 |
---|
| 402 | Bool isDepth = ((newNumberOfViewDepth % 2) == 0); // coding order T0D0T1D1T2D2 |
---|
| 403 | if( isDepth ) |
---|
| 404 | m_useDepth = true; |
---|
| 405 | while( m_tVideoIOYuvReconFile.size() < newNumberOfViewDepth) |
---|
[2] | 406 | { |
---|
[56] | 407 | m_tVideoIOYuvReconFile.push_back(new TVideoIOYuv); |
---|
| 408 | Char buffer[4]; |
---|
| 409 | sprintf(buffer,"_%i", (Int)(m_tVideoIOYuvReconFile.size()-1) / 2 ); |
---|
| 410 | Char* nextFilename = NULL; |
---|
| 411 | if( (m_tVideoIOYuvReconFile.size() % 2) == 0 ) |
---|
[2] | 412 | { |
---|
| 413 | Char* pchTempFilename = NULL; |
---|
| 414 | xAppendToFileNameEnd( m_pchReconFile, "_depth", pchTempFilename); |
---|
[56] | 415 | xAppendToFileNameEnd( pchTempFilename, buffer, nextFilename); |
---|
| 416 | free ( pchTempFilename ); |
---|
[2] | 417 | } |
---|
[56] | 418 | else |
---|
[2] | 419 | { |
---|
[56] | 420 | xAppendToFileNameEnd( m_pchReconFile, buffer, nextFilename); |
---|
[2] | 421 | } |
---|
[56] | 422 | if( isDepth || ( !isDepth && (m_tVideoIOYuvReconFile.size() % 2) == 1 ) ) |
---|
| 423 | { |
---|
| 424 | m_tVideoIOYuvReconFile.back()->open( nextFilename, true, m_outputBitDepth, g_uiBitDepth + g_uiBitIncrement ); |
---|
| 425 | } |
---|
| 426 | free ( nextFilename ); |
---|
[2] | 427 | } |
---|
[56] | 428 | while( m_pocLastDisplay.size() < newNumberOfViewDepth ) |
---|
| 429 | { |
---|
| 430 | m_pocLastDisplay.push_back(-MAX_INT+m_iSkipFrame); |
---|
| 431 | } |
---|
| 432 | while( m_tDecTop.size() < newNumberOfViewDepth) |
---|
| 433 | { |
---|
| 434 | m_tDecTop.push_back(new TDecTop); |
---|
| 435 | if( isDepth || ( !isDepth && (m_tVideoIOYuvReconFile.size() % 2) == 1 ) ) |
---|
| 436 | { |
---|
| 437 | m_tDecTop.back()->create(); |
---|
| 438 | m_tDecTop.back()->init( this, newNumberOfViewDepth == 1); |
---|
| 439 | m_tDecTop.back()->setViewId( viewId ); |
---|
| 440 | m_tDecTop.back()->setIsDepth( isDepth ); |
---|
| 441 | m_tDecTop.back()->setPictureDigestEnabled(m_pictureDigestEnabled); |
---|
[57] | 442 | m_tDecTop.back()->setCamParsCollector( &m_cCamParsCollector ); |
---|
[56] | 443 | } |
---|
| 444 | } |
---|
[2] | 445 | } |
---|
| 446 | |
---|
[56] | 447 | TDecTop* TAppDecTop::getTDecTop( Int viewId, Bool isDepth ) |
---|
| 448 | { |
---|
| 449 | return m_tDecTop[(isDepth ? 1 : 0) + viewId * 2]; // coding order T0D0T1D1T2D2 |
---|
| 450 | } |
---|
[2] | 451 | |
---|
[56] | 452 | std::vector<TComPic*> TAppDecTop::getInterViewRefPics( Int viewId, Int poc, Bool isDepth, TComSPS* sps ) |
---|
[2] | 453 | { |
---|
[56] | 454 | std::vector<TComPic*> apcRefPics( sps->getNumberOfUsableInterViewRefs(), (TComPic*)NULL ); |
---|
| 455 | for( Int k = 0; k < sps->getNumberOfUsableInterViewRefs(); k++ ) |
---|
[2] | 456 | { |
---|
[56] | 457 | TComPic* pcRefPic = xGetPicFromView( sps->getUsableInterViewRef( k ) + viewId, poc, isDepth ); |
---|
[2] | 458 | assert( pcRefPic != NULL ); |
---|
[56] | 459 | apcRefPics[k] = pcRefPic; |
---|
[2] | 460 | } |
---|
| 461 | return apcRefPics; |
---|
| 462 | } |
---|
| 463 | |
---|
[56] | 464 | TComPic* TAppDecTop::xGetPicFromView( Int viewId, Int poc, Bool isDepth ) |
---|
[2] | 465 | { |
---|
[56] | 466 | assert( ( viewId >= 0 ) ); |
---|
| 467 | |
---|
| 468 | TComList<TComPic*>* apcListPic = getTDecTop( viewId, isDepth )->getListPic(); |
---|
| 469 | TComPic* pcPic = NULL; |
---|
[2] | 470 | for( TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++ ) |
---|
| 471 | { |
---|
[56] | 472 | if( (*it)->getPOC() == poc ) |
---|
[2] | 473 | { |
---|
[56] | 474 | pcPic = *it; |
---|
[2] | 475 | break; |
---|
| 476 | } |
---|
| 477 | } |
---|
[56] | 478 | return pcPic; |
---|
[2] | 479 | } |
---|
[56] | 480 | //! \} |
---|