[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 | * |
---|
[608] | 6 | * Copyright (c) 2010-2013, 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() |
---|
[608] | 56 | #if !H_MV |
---|
| 57 | : m_iPOCLastDisplay(-MAX_INT) |
---|
| 58 | #else |
---|
| 59 | : m_numDecoders( 0 ) |
---|
| 60 | #endif |
---|
[2] | 61 | { |
---|
[608] | 62 | #if H_MV |
---|
[738] | 63 | for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++) |
---|
| 64 | { |
---|
| 65 | m_layerIdToDecIdx[i] = -1; |
---|
| 66 | m_layerInitilizedFlags[i] = false; |
---|
| 67 | } |
---|
[608] | 68 | #endif |
---|
| 69 | #if H_3D |
---|
| 70 | m_pScaleOffsetFile = 0; |
---|
| 71 | #endif |
---|
[2] | 72 | } |
---|
| 73 | |
---|
| 74 | Void TAppDecTop::create() |
---|
| 75 | { |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | Void TAppDecTop::destroy() |
---|
| 79 | { |
---|
[608] | 80 | if (m_pchBitstreamFile) |
---|
| 81 | { |
---|
| 82 | free (m_pchBitstreamFile); |
---|
| 83 | m_pchBitstreamFile = NULL; |
---|
| 84 | } |
---|
| 85 | #if H_MV |
---|
| 86 | for (Int decIdx = 0; decIdx < m_numDecoders; decIdx++) |
---|
| 87 | { |
---|
| 88 | if (m_pchReconFiles[decIdx]) |
---|
| 89 | { |
---|
| 90 | free (m_pchReconFiles[decIdx]); |
---|
| 91 | m_pchReconFiles[decIdx] = NULL; |
---|
| 92 | } |
---|
| 93 | } |
---|
| 94 | #endif |
---|
| 95 | if (m_pchReconFile) |
---|
| 96 | { |
---|
| 97 | free (m_pchReconFile); |
---|
| 98 | m_pchReconFile = NULL; |
---|
| 99 | } |
---|
| 100 | #if H_3D |
---|
| 101 | if (m_pchScaleOffsetFile) |
---|
| 102 | { |
---|
| 103 | free (m_pchScaleOffsetFile); |
---|
| 104 | m_pchScaleOffsetFile = NULL; |
---|
| 105 | } |
---|
| 106 | #endif |
---|
[2] | 107 | } |
---|
| 108 | |
---|
| 109 | // ==================================================================================================================== |
---|
| 110 | // Public member functions |
---|
| 111 | // ==================================================================================================================== |
---|
| 112 | |
---|
| 113 | /** |
---|
| 114 | - create internal class |
---|
| 115 | - initialize internal class |
---|
| 116 | - until the end of the bitstream, call decoding function in TDecTop class |
---|
| 117 | - delete allocated buffers |
---|
| 118 | - destroy internal class |
---|
| 119 | . |
---|
| 120 | */ |
---|
| 121 | Void TAppDecTop::decode() |
---|
| 122 | { |
---|
[608] | 123 | Int poc; |
---|
| 124 | #if H_MV |
---|
| 125 | poc = -1; |
---|
[77] | 126 | #endif |
---|
[608] | 127 | TComList<TComPic*>* pcListPic = NULL; |
---|
[210] | 128 | |
---|
[56] | 129 | ifstream bitstreamFile(m_pchBitstreamFile, ifstream::in | ifstream::binary); |
---|
| 130 | if (!bitstreamFile) |
---|
| 131 | { |
---|
| 132 | fprintf(stderr, "\nfailed to open bitstream file `%s' for reading\n", m_pchBitstreamFile); |
---|
| 133 | exit(EXIT_FAILURE); |
---|
| 134 | } |
---|
[2] | 135 | |
---|
[608] | 136 | #if H_3D |
---|
[56] | 137 | if( m_pchScaleOffsetFile ) |
---|
| 138 | { |
---|
| 139 | m_pScaleOffsetFile = ::fopen( m_pchScaleOffsetFile, "wt" ); |
---|
| 140 | AOF( m_pScaleOffsetFile ); |
---|
| 141 | } |
---|
| 142 | m_cCamParsCollector.init( m_pScaleOffsetFile ); |
---|
[608] | 143 | #endif |
---|
[56] | 144 | InputByteStream bytestream(bitstreamFile); |
---|
| 145 | |
---|
[608] | 146 | // create & initialize internal classes |
---|
| 147 | xCreateDecLib(); |
---|
| 148 | xInitDecLib (); |
---|
| 149 | #if !H_MV |
---|
| 150 | m_iPOCLastDisplay += m_iSkipFrame; // set the last displayed POC correctly for skip forward. |
---|
| 151 | |
---|
| 152 | // main decoder loop |
---|
[655] | 153 | Bool openedReconFile = false; // reconstruction file not yet opened. (must be performed after SPS is seen) |
---|
[608] | 154 | #else |
---|
| 155 | #if H_3D |
---|
| 156 | Int pocCurrPic = -MAX_INT; |
---|
| 157 | Int pocLastPic = -MAX_INT; |
---|
| 158 | #endif |
---|
| 159 | |
---|
| 160 | Int layerIdCurrPic = 0; |
---|
| 161 | |
---|
| 162 | Int decIdxLastPic = 0; |
---|
| 163 | Int decIdxCurrPic = 0; |
---|
| 164 | |
---|
| 165 | Bool firstSlice = true; |
---|
| 166 | #endif |
---|
| 167 | |
---|
[56] | 168 | while (!!bitstreamFile) |
---|
[2] | 169 | { |
---|
[56] | 170 | /* location serves to work around a design fault in the decoder, whereby |
---|
| 171 | * the process of reading a new slice that is the first slice of a new frame |
---|
| 172 | * requires the TDecTop::decode() method to be called again with the same |
---|
| 173 | * nal unit. */ |
---|
| 174 | streampos location = bitstreamFile.tellg(); |
---|
[608] | 175 | #if H_MV |
---|
| 176 | #if ENC_DEC_TRACE |
---|
| 177 | Int64 symCount = g_nSymbolCounter; |
---|
| 178 | #endif |
---|
| 179 | #endif |
---|
[56] | 180 | AnnexBStats stats = AnnexBStats(); |
---|
| 181 | vector<uint8_t> nalUnit; |
---|
| 182 | InputNALUnit nalu; |
---|
| 183 | byteStreamNALUnit(bytestream, nalUnit, stats); |
---|
| 184 | |
---|
| 185 | // call actual decoding function |
---|
[608] | 186 | Bool bNewPicture = false; |
---|
| 187 | #if H_MV |
---|
| 188 | Bool newSliceDiffPoc = false; |
---|
| 189 | Bool newSliceDiffLayer = false; |
---|
[738] | 190 | Bool sliceSkippedFlag = false; |
---|
[608] | 191 | #if H_3D |
---|
| 192 | Bool allLayersDecoded = false; |
---|
| 193 | #endif |
---|
| 194 | #endif |
---|
[56] | 195 | if (nalUnit.empty()) |
---|
[2] | 196 | { |
---|
[56] | 197 | /* this can happen if the following occur: |
---|
| 198 | * - empty input file |
---|
| 199 | * - two back-to-back start_code_prefixes |
---|
| 200 | * - start_code_prefix immediately followed by EOF |
---|
| 201 | */ |
---|
| 202 | fprintf(stderr, "Warning: Attempt to decode an empty NAL unit\n"); |
---|
[2] | 203 | } |
---|
| 204 | else |
---|
| 205 | { |
---|
[56] | 206 | read(nalu, nalUnit); |
---|
[608] | 207 | #if H_MV |
---|
[738] | 208 | if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu) || nalu.m_layerId > MAX_NUM_LAYER_IDS-1 ) |
---|
[77] | 209 | { |
---|
[608] | 210 | bNewPicture = false; |
---|
[738] | 211 | if ( !bitstreamFile ) |
---|
| 212 | { |
---|
| 213 | decIdxLastPic = decIdxCurrPic; |
---|
| 214 | } |
---|
[77] | 215 | } |
---|
[210] | 216 | else |
---|
[608] | 217 | { |
---|
[738] | 218 | Int decIdx = xGetDecoderIdx( nalu.m_layerId , true ); |
---|
[608] | 219 | newSliceDiffLayer = nalu.isSlice() && ( nalu.m_layerId != layerIdCurrPic ) && !firstSlice; |
---|
[738] | 220 | newSliceDiffPoc = m_tDecTop[decIdx]->decode(nalu, m_iSkipFrame, m_pocLastDisplay[decIdx], newSliceDiffLayer, sliceSkippedFlag ); |
---|
[608] | 221 | // decode function only returns true when all of the following conditions are true |
---|
| 222 | // - poc in particular layer changes |
---|
| 223 | // - nalu does not belong to first slice in layer |
---|
| 224 | // - nalu.isSlice() == true |
---|
| 225 | |
---|
[738] | 226 | // Update TargetDecLayerIdList only when not specified by layer id file, specification by file might actually out of conformance. |
---|
| 227 | if (nalu.m_nalUnitType == NAL_UNIT_VPS && m_targetDecLayerIdSetFileEmpty ) |
---|
| 228 | { |
---|
| 229 | TComVPS* vps = m_tDecTop[decIdx]->getPrefetchedVPS(); |
---|
| 230 | if ( m_targetOptLayerSetIdx == -1 ) |
---|
| 231 | { |
---|
| 232 | // Not normative! Corresponds to specification by "External Means". (Should be set equal to 0, when no external means available. ) |
---|
| 233 | m_targetOptLayerSetIdx = vps->getVpsNumLayerSetsMinus1(); |
---|
| 234 | } |
---|
| 235 | |
---|
| 236 | m_targetDecLayerIdSet = vps->getTargetDecLayerIdList( m_targetOptLayerSetIdx ); |
---|
| 237 | } |
---|
| 238 | bNewPicture = ( newSliceDiffLayer || newSliceDiffPoc ) && !sliceSkippedFlag; |
---|
| 239 | if ( nalu.isSlice() && firstSlice && !sliceSkippedFlag ) |
---|
[210] | 240 | { |
---|
[608] | 241 | layerIdCurrPic = nalu.m_layerId; |
---|
| 242 | #if H_3D |
---|
| 243 | pocCurrPic = m_tDecTop[decIdx]->getCurrPoc(); |
---|
| 244 | #endif |
---|
| 245 | decIdxCurrPic = decIdx; |
---|
| 246 | firstSlice = false; |
---|
[210] | 247 | } |
---|
[608] | 248 | |
---|
| 249 | if ( bNewPicture || !bitstreamFile ) |
---|
| 250 | { |
---|
| 251 | layerIdCurrPic = nalu.m_layerId; |
---|
| 252 | #if H_3D |
---|
| 253 | pocLastPic = pocCurrPic; |
---|
| 254 | pocCurrPic = m_tDecTop[decIdx]->getCurrPoc(); |
---|
| 255 | #endif |
---|
| 256 | decIdxLastPic = decIdxCurrPic; |
---|
| 257 | decIdxCurrPic = decIdx; |
---|
| 258 | #if H_3D |
---|
| 259 | allLayersDecoded = ( pocCurrPic != pocLastPic ); |
---|
| 260 | #endif |
---|
[210] | 261 | } |
---|
| 262 | #else |
---|
[608] | 263 | if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu) ) |
---|
[210] | 264 | { |
---|
[655] | 265 | bNewPicture = false; |
---|
[210] | 266 | } |
---|
[608] | 267 | else |
---|
[2] | 268 | { |
---|
[608] | 269 | bNewPicture = m_cTDecTop.decode(nalu, m_iSkipFrame, m_iPOCLastDisplay); |
---|
[56] | 270 | #endif |
---|
[608] | 271 | if (bNewPicture) |
---|
[42] | 272 | { |
---|
[56] | 273 | bitstreamFile.clear(); |
---|
| 274 | /* location points to the current nalunit payload[1] due to the |
---|
| 275 | * need for the annexB parser to read three extra bytes. |
---|
| 276 | * [1] except for the first NAL unit in the file |
---|
| 277 | * (but bNewPicture doesn't happen then) */ |
---|
| 278 | bitstreamFile.seekg(location-streamoff(3)); |
---|
| 279 | bytestream.reset(); |
---|
[608] | 280 | #if ENC_DEC_TRACE |
---|
| 281 | #if H_MV_ENC_DEC_TRAC |
---|
| 282 | const Bool resetCounter = false; |
---|
| 283 | if ( resetCounter ) |
---|
| 284 | { |
---|
| 285 | g_nSymbolCounter = symCount; // Only reset counter SH becomes traced twice |
---|
[210] | 286 | } |
---|
[608] | 287 | else |
---|
| 288 | { |
---|
| 289 | g_disableHLSTrace = true; // Trancing of second parsing of SH is not carried out |
---|
| 290 | } |
---|
| 291 | #else |
---|
| 292 | g_nSymbolCounter = symCount; |
---|
[210] | 293 | #endif |
---|
[608] | 294 | #endif |
---|
[42] | 295 | } |
---|
| 296 | } |
---|
[56] | 297 | } |
---|
[608] | 298 | if (bNewPicture || !bitstreamFile) |
---|
[56] | 299 | { |
---|
[608] | 300 | #if H_MV |
---|
| 301 | assert( decIdxLastPic != -1 ); |
---|
| 302 | m_tDecTop[decIdxLastPic]->endPicDecoding(poc, pcListPic, m_targetDecLayerIdSet ); |
---|
| 303 | #else |
---|
| 304 | m_cTDecTop.executeLoopFilters(poc, pcListPic); |
---|
| 305 | #endif |
---|
[56] | 306 | } |
---|
[608] | 307 | #if H_3D |
---|
| 308 | if ( allLayersDecoded || !bitstreamFile ) |
---|
[56] | 309 | { |
---|
[608] | 310 | for( Int dI = 0; dI < m_numDecoders; dI++ ) |
---|
| 311 | { |
---|
| 312 | TComPic* picLastCoded = m_ivPicLists.getPic( m_tDecTop[dI]->getLayerId(), pocLastPic ); |
---|
| 313 | assert( picLastCoded != NULL ); |
---|
| 314 | picLastCoded->compressMotion(1); |
---|
| 315 | } |
---|
| 316 | } |
---|
| 317 | #endif |
---|
| 318 | |
---|
| 319 | if( pcListPic ) |
---|
| 320 | { |
---|
| 321 | #if H_MV |
---|
| 322 | if ( m_pchReconFiles[decIdxLastPic] && !m_reconOpen[decIdxLastPic] ) |
---|
| 323 | #else |
---|
[655] | 324 | if ( m_pchReconFile && !openedReconFile ) |
---|
[608] | 325 | #endif |
---|
[2] | 326 | { |
---|
[608] | 327 | if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; } |
---|
| 328 | if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; } |
---|
| 329 | |
---|
| 330 | #if H_MV |
---|
| 331 | m_tVideoIOYuvReconFile[decIdxLastPic]->open( m_pchReconFiles[decIdxLastPic], true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode |
---|
| 332 | m_reconOpen[decIdxLastPic] = true; |
---|
[2] | 333 | } |
---|
[608] | 334 | if ( bNewPicture && newSliceDiffPoc && |
---|
| 335 | #else |
---|
| 336 | m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode |
---|
[655] | 337 | openedReconFile = true; |
---|
[608] | 338 | } |
---|
| 339 | if ( bNewPicture && |
---|
| 340 | #endif |
---|
| 341 | ( nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
| 342 | || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP |
---|
| 343 | || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
| 344 | || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 345 | || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP ) ) |
---|
| 346 | { |
---|
| 347 | #if H_MV |
---|
| 348 | xFlushOutput( pcListPic, decIdxLastPic ); |
---|
| 349 | #else |
---|
| 350 | xFlushOutput( pcListPic ); |
---|
| 351 | #endif |
---|
| 352 | } |
---|
[56] | 353 | // write reconstruction to file |
---|
[608] | 354 | if(bNewPicture) |
---|
[2] | 355 | { |
---|
[608] | 356 | #if H_MV |
---|
| 357 | xWriteOutput( pcListPic, decIdxLastPic, nalu.m_temporalId ); |
---|
[2] | 358 | } |
---|
| 359 | } |
---|
[608] | 360 | } |
---|
| 361 | |
---|
| 362 | #if H_3D |
---|
[57] | 363 | if( m_cCamParsCollector.isInitialized() ) |
---|
| 364 | { |
---|
| 365 | m_cCamParsCollector.setSlice( 0 ); |
---|
| 366 | } |
---|
[608] | 367 | #endif |
---|
| 368 | for(UInt decIdx = 0; decIdx < m_numDecoders; decIdx++) |
---|
[2] | 369 | { |
---|
[608] | 370 | xFlushOutput( m_tDecTop[decIdx]->getListPic(), decIdx ); |
---|
| 371 | } |
---|
| 372 | #else |
---|
| 373 | xWriteOutput( pcListPic, nalu.m_temporalId ); |
---|
| 374 | } |
---|
| 375 | } |
---|
| 376 | } |
---|
| 377 | |
---|
| 378 | xFlushOutput( pcListPic ); |
---|
| 379 | // delete buffers |
---|
| 380 | m_cTDecTop.deletePicBuffer(); |
---|
| 381 | #endif |
---|
| 382 | |
---|
| 383 | // destroy internal classes |
---|
[2] | 384 | xDestroyDecLib(); |
---|
| 385 | } |
---|
| 386 | |
---|
| 387 | // ==================================================================================================================== |
---|
| 388 | // Protected member functions |
---|
| 389 | // ==================================================================================================================== |
---|
| 390 | |
---|
[608] | 391 | Void TAppDecTop::xCreateDecLib() |
---|
| 392 | { |
---|
| 393 | #if H_MV |
---|
| 394 | // initialize global variables |
---|
| 395 | initROM(); |
---|
| 396 | #if H_3D_DIM_DMM |
---|
| 397 | initWedgeLists(); |
---|
| 398 | #endif |
---|
| 399 | #else |
---|
| 400 | // create decoder class |
---|
| 401 | m_cTDecTop.create(); |
---|
| 402 | #endif |
---|
| 403 | } |
---|
| 404 | |
---|
[2] | 405 | Void TAppDecTop::xDestroyDecLib() |
---|
| 406 | { |
---|
[608] | 407 | #if H_MV |
---|
| 408 | // destroy ROM |
---|
| 409 | destroyROM(); |
---|
[2] | 410 | |
---|
[608] | 411 | for(Int decIdx = 0; decIdx < m_numDecoders ; decIdx++) |
---|
[2] | 412 | { |
---|
[608] | 413 | if( m_tVideoIOYuvReconFile[decIdx] ) |
---|
[56] | 414 | { |
---|
[608] | 415 | m_tVideoIOYuvReconFile[decIdx]->close(); |
---|
| 416 | delete m_tVideoIOYuvReconFile[decIdx]; |
---|
| 417 | m_tVideoIOYuvReconFile[decIdx] = NULL ; |
---|
[56] | 418 | } |
---|
[2] | 419 | |
---|
[608] | 420 | if( m_tDecTop[decIdx] ) |
---|
[56] | 421 | { |
---|
[608] | 422 | m_tDecTop[decIdx]->deletePicBuffer(); |
---|
| 423 | m_tDecTop[decIdx]->destroy() ; |
---|
[56] | 424 | } |
---|
[608] | 425 | delete m_tDecTop[decIdx] ; |
---|
| 426 | m_tDecTop[decIdx] = NULL ; |
---|
[2] | 427 | } |
---|
[608] | 428 | #else |
---|
| 429 | if ( m_pchReconFile ) |
---|
| 430 | { |
---|
| 431 | m_cTVideoIOYuvReconFile. close(); |
---|
| 432 | } |
---|
| 433 | |
---|
| 434 | // destroy decoder class |
---|
| 435 | m_cTDecTop.destroy(); |
---|
| 436 | #endif |
---|
| 437 | #if H_3D |
---|
[57] | 438 | m_cCamParsCollector.uninit(); |
---|
| 439 | if( m_pScaleOffsetFile ) |
---|
| 440 | { |
---|
| 441 | ::fclose( m_pScaleOffsetFile ); |
---|
| 442 | } |
---|
[608] | 443 | #endif |
---|
[56] | 444 | } |
---|
[2] | 445 | |
---|
[608] | 446 | Void TAppDecTop::xInitDecLib() |
---|
[56] | 447 | { |
---|
[608] | 448 | #if !H_MV |
---|
| 449 | // initialize decoder class |
---|
| 450 | m_cTDecTop.init(); |
---|
| 451 | m_cTDecTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); |
---|
| 452 | #endif |
---|
| 453 | } |
---|
| 454 | |
---|
| 455 | /** \param pcListPic list of pictures to be written to file |
---|
| 456 | \todo DYN_REF_FREE should be revised |
---|
| 457 | */ |
---|
| 458 | #if H_MV |
---|
| 459 | Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, Int decIdx, Int tId ) |
---|
| 460 | #else |
---|
| 461 | Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, UInt tId ) |
---|
| 462 | #endif |
---|
| 463 | { |
---|
[56] | 464 | TComList<TComPic*>::iterator iterPic = pcListPic->begin(); |
---|
[655] | 465 | Int numPicsNotYetDisplayed = 0; |
---|
| 466 | |
---|
[56] | 467 | while (iterPic != pcListPic->end()) |
---|
[2] | 468 | { |
---|
[56] | 469 | TComPic* pcPic = *(iterPic); |
---|
[608] | 470 | #if H_MV |
---|
| 471 | if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[decIdx]) |
---|
| 472 | #else |
---|
| 473 | if(pcPic->getOutputMark() && pcPic->getPOC() > m_iPOCLastDisplay) |
---|
| 474 | #endif |
---|
[56] | 475 | { |
---|
[655] | 476 | numPicsNotYetDisplayed++; |
---|
[56] | 477 | } |
---|
| 478 | iterPic++; |
---|
[2] | 479 | } |
---|
[56] | 480 | iterPic = pcListPic->begin(); |
---|
[655] | 481 | if (numPicsNotYetDisplayed>2) |
---|
| 482 | { |
---|
| 483 | iterPic++; |
---|
| 484 | } |
---|
[56] | 485 | |
---|
[655] | 486 | TComPic* pcPic = *(iterPic); |
---|
| 487 | if (numPicsNotYetDisplayed>2 && pcPic->isField()) //Field Decoding |
---|
[2] | 488 | { |
---|
[655] | 489 | TComList<TComPic*>::iterator endPic = pcListPic->end(); |
---|
| 490 | endPic--; |
---|
| 491 | iterPic = pcListPic->begin(); |
---|
| 492 | while (iterPic != endPic) |
---|
| 493 | { |
---|
| 494 | TComPic* pcPicTop = *(iterPic); |
---|
| 495 | iterPic++; |
---|
| 496 | TComPic* pcPicBottom = *(iterPic); |
---|
| 497 | |
---|
[608] | 498 | #if H_MV |
---|
[655] | 499 | if ( pcPicTop->getOutputMark() && (numPicsNotYetDisplayed > pcPicTop->getNumReorderPics(tId) && !(pcPicTop->getPOC()%2) && pcPicBottom->getPOC() == pcPicTop->getPOC()+1) |
---|
| 500 | && pcPicBottom->getOutputMark() && (numPicsNotYetDisplayed > pcPicBottom->getNumReorderPics(tId) && (pcPicTop->getPOC() == m_pocLastDisplay[decIdx]+1 || m_pocLastDisplay[decIdx]<0))) |
---|
[608] | 501 | #else |
---|
[655] | 502 | if ( pcPicTop->getOutputMark() && (numPicsNotYetDisplayed > pcPicTop->getNumReorderPics(tId) && !(pcPicTop->getPOC()%2) && pcPicBottom->getPOC() == pcPicTop->getPOC()+1) |
---|
| 503 | && pcPicBottom->getOutputMark() && (numPicsNotYetDisplayed > pcPicBottom->getNumReorderPics(tId) && (pcPicTop->getPOC() == m_iPOCLastDisplay+1 || m_iPOCLastDisplay<0))) |
---|
[608] | 504 | #endif |
---|
[655] | 505 | { |
---|
| 506 | // write to file |
---|
| 507 | numPicsNotYetDisplayed = numPicsNotYetDisplayed-2; |
---|
[608] | 508 | #if H_MV |
---|
| 509 | if ( m_pchReconFiles[decIdx] ) |
---|
| 510 | #else |
---|
[655] | 511 | if ( m_pchReconFile ) |
---|
[608] | 512 | #endif |
---|
[655] | 513 | { |
---|
| 514 | const Window &conf = pcPicTop->getConformanceWindow(); |
---|
| 515 | const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window(); |
---|
| 516 | |
---|
| 517 | const Bool isTff = pcPicTop->isTopField(); |
---|
[608] | 518 | #if H_MV |
---|
[622] | 519 | assert( conf .getScaledFlag() ); |
---|
| 520 | assert( defDisp.getScaledFlag() ); |
---|
[655] | 521 | m_tVideoIOYuvReconFile[decIdx]->write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(), |
---|
| 522 | #else |
---|
| 523 | m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(), |
---|
[622] | 524 | #endif |
---|
[655] | 525 | conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), |
---|
| 526 | conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), |
---|
| 527 | conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), |
---|
| 528 | conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff ); |
---|
| 529 | } |
---|
| 530 | |
---|
| 531 | // update POC of display order |
---|
| 532 | #if H_MV |
---|
| 533 | m_pocLastDisplay[decIdx] = pcPic->getPOC(); |
---|
[608] | 534 | #else |
---|
[655] | 535 | m_iPOCLastDisplay = pcPicBottom->getPOC(); |
---|
[608] | 536 | #endif |
---|
[655] | 537 | |
---|
| 538 | // erase non-referenced picture in the reference picture list after display |
---|
| 539 | if ( !pcPicTop->getSlice(0)->isReferenced() && pcPicTop->getReconMark() == true ) |
---|
| 540 | { |
---|
| 541 | #if !DYN_REF_FREE |
---|
| 542 | pcPicTop->setReconMark(false); |
---|
| 543 | |
---|
| 544 | // mark it should be extended later |
---|
| 545 | pcPicTop->getPicYuvRec()->setBorderExtension( false ); |
---|
| 546 | |
---|
| 547 | #else |
---|
| 548 | pcPicTop->destroy(); |
---|
| 549 | pcListPic->erase( iterPic ); |
---|
| 550 | iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! |
---|
| 551 | continue; |
---|
| 552 | #endif |
---|
| 553 | } |
---|
| 554 | if ( !pcPicBottom->getSlice(0)->isReferenced() && pcPicBottom->getReconMark() == true ) |
---|
| 555 | { |
---|
| 556 | #if !DYN_REF_FREE |
---|
| 557 | pcPicBottom->setReconMark(false); |
---|
| 558 | |
---|
| 559 | // mark it should be extended later |
---|
| 560 | pcPicBottom->getPicYuvRec()->setBorderExtension( false ); |
---|
| 561 | |
---|
| 562 | #else |
---|
| 563 | pcPicBottom->destroy(); |
---|
| 564 | pcListPic->erase( iterPic ); |
---|
| 565 | iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! |
---|
| 566 | continue; |
---|
| 567 | #endif |
---|
| 568 | } |
---|
| 569 | pcPicTop->setOutputMark(false); |
---|
| 570 | pcPicBottom->setOutputMark(false); |
---|
[56] | 571 | } |
---|
[655] | 572 | } |
---|
| 573 | } |
---|
| 574 | else if (!pcPic->isField()) //Frame Decoding |
---|
| 575 | { |
---|
| 576 | iterPic = pcListPic->begin(); |
---|
| 577 | while (iterPic != pcListPic->end()) |
---|
| 578 | { |
---|
| 579 | pcPic = *(iterPic); |
---|
| 580 | |
---|
[608] | 581 | #if H_MV |
---|
[655] | 582 | if ( pcPic->getOutputMark() && (numPicsNotYetDisplayed > pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_pocLastDisplay[decIdx])) |
---|
| 583 | #else |
---|
| 584 | if ( pcPic->getOutputMark() && (numPicsNotYetDisplayed > pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay)) |
---|
| 585 | #endif |
---|
| 586 | { |
---|
| 587 | // write to file |
---|
| 588 | numPicsNotYetDisplayed--; |
---|
| 589 | #if H_MV |
---|
| 590 | if ( m_pchReconFiles[decIdx] ) |
---|
[608] | 591 | #else |
---|
[655] | 592 | if ( m_pchReconFile ) |
---|
[608] | 593 | #endif |
---|
[655] | 594 | { |
---|
| 595 | const Window &conf = pcPic->getConformanceWindow(); |
---|
| 596 | const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window(); |
---|
| 597 | #if H_MV |
---|
| 598 | assert( conf .getScaledFlag() ); |
---|
| 599 | assert( defDisp.getScaledFlag() ); |
---|
| 600 | m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(), |
---|
| 601 | #else |
---|
| 602 | m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(), |
---|
| 603 | #endif |
---|
| 604 | conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), |
---|
| 605 | conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), |
---|
| 606 | conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), |
---|
| 607 | conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() ); |
---|
| 608 | } |
---|
[56] | 609 | |
---|
[655] | 610 | // update POC of display order |
---|
| 611 | #if H_MV |
---|
| 612 | m_pocLastDisplay[decIdx] = pcPic->getPOC(); |
---|
| 613 | #else |
---|
| 614 | m_iPOCLastDisplay = pcPic->getPOC(); |
---|
| 615 | #endif |
---|
[56] | 616 | |
---|
[655] | 617 | // erase non-referenced picture in the reference picture list after display |
---|
| 618 | if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true ) |
---|
| 619 | { |
---|
| 620 | #if !DYN_REF_FREE |
---|
| 621 | pcPic->setReconMark(false); |
---|
| 622 | |
---|
| 623 | // mark it should be extended later |
---|
| 624 | pcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
| 625 | |
---|
[56] | 626 | #else |
---|
[655] | 627 | pcPic->destroy(); |
---|
| 628 | pcListPic->erase( iterPic ); |
---|
| 629 | iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! |
---|
| 630 | continue; |
---|
[56] | 631 | #endif |
---|
[655] | 632 | } |
---|
| 633 | pcPic->setOutputMark(false); |
---|
[56] | 634 | } |
---|
[655] | 635 | |
---|
| 636 | iterPic++; |
---|
[56] | 637 | } |
---|
[2] | 638 | } |
---|
| 639 | } |
---|
| 640 | /** \param pcListPic list of pictures to be written to file |
---|
| 641 | \todo DYN_REF_FREE should be revised |
---|
| 642 | */ |
---|
[608] | 643 | #if H_MV |
---|
| 644 | Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic, Int decIdx ) |
---|
| 645 | #else |
---|
| 646 | Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic ) |
---|
| 647 | #endif |
---|
[2] | 648 | { |
---|
[56] | 649 | if(!pcListPic) |
---|
| 650 | { |
---|
| 651 | return; |
---|
[655] | 652 | } |
---|
[2] | 653 | TComList<TComPic*>::iterator iterPic = pcListPic->begin(); |
---|
[655] | 654 | |
---|
[56] | 655 | iterPic = pcListPic->begin(); |
---|
[655] | 656 | TComPic* pcPic = *(iterPic); |
---|
[56] | 657 | |
---|
[655] | 658 | if (pcPic->isField()) //Field Decoding |
---|
[2] | 659 | { |
---|
[655] | 660 | TComList<TComPic*>::iterator endPic = pcListPic->end(); |
---|
| 661 | endPic--; |
---|
| 662 | TComPic *pcPicTop, *pcPicBottom = NULL; |
---|
| 663 | while (iterPic != endPic) |
---|
[2] | 664 | { |
---|
[655] | 665 | pcPicTop = *(iterPic); |
---|
| 666 | iterPic++; |
---|
| 667 | pcPicBottom = *(iterPic); |
---|
| 668 | |
---|
| 669 | if ( pcPicTop->getOutputMark() && pcPicBottom->getOutputMark() && !(pcPicTop->getPOC()%2) && (pcPicBottom->getPOC() == pcPicTop->getPOC()+1) ) |
---|
| 670 | { |
---|
| 671 | // write to file |
---|
[608] | 672 | #if H_MV |
---|
| 673 | if ( m_pchReconFiles[decIdx] ) |
---|
| 674 | #else |
---|
[655] | 675 | if ( m_pchReconFile ) |
---|
[608] | 676 | #endif |
---|
[655] | 677 | { |
---|
| 678 | const Window &conf = pcPicTop->getConformanceWindow(); |
---|
| 679 | const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window(); |
---|
| 680 | const Bool isTff = pcPicTop->isTopField(); |
---|
[608] | 681 | #if H_MV |
---|
[622] | 682 | assert( conf .getScaledFlag() ); |
---|
| 683 | assert( defDisp.getScaledFlag() ); |
---|
[655] | 684 | m_tVideoIOYuvReconFile[decIdx]->write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(), |
---|
| 685 | #else |
---|
| 686 | m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(), |
---|
[622] | 687 | #endif |
---|
[655] | 688 | conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), |
---|
| 689 | conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), |
---|
| 690 | conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), |
---|
| 691 | conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff ); |
---|
| 692 | } |
---|
| 693 | |
---|
| 694 | // update POC of display order |
---|
| 695 | #if H_MV |
---|
| 696 | m_pocLastDisplay[decIdx] = pcPic->getPOC(); |
---|
[608] | 697 | #else |
---|
[655] | 698 | m_iPOCLastDisplay = pcPicBottom->getPOC(); |
---|
| 699 | #endif |
---|
| 700 | // erase non-referenced picture in the reference picture list after display |
---|
| 701 | if ( !pcPicTop->getSlice(0)->isReferenced() && pcPicTop->getReconMark() == true ) |
---|
| 702 | { |
---|
| 703 | #if !DYN_REF_FREE |
---|
| 704 | pcPicTop->setReconMark(false); |
---|
| 705 | |
---|
| 706 | // mark it should be extended later |
---|
| 707 | pcPicTop->getPicYuvRec()->setBorderExtension( false ); |
---|
| 708 | |
---|
| 709 | #else |
---|
| 710 | pcPicTop->destroy(); |
---|
| 711 | pcListPic->erase( iterPic ); |
---|
| 712 | iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! |
---|
| 713 | continue; |
---|
[608] | 714 | #endif |
---|
[655] | 715 | } |
---|
| 716 | if ( !pcPicBottom->getSlice(0)->isReferenced() && pcPicBottom->getReconMark() == true ) |
---|
| 717 | { |
---|
| 718 | #if !DYN_REF_FREE |
---|
| 719 | pcPicBottom->setReconMark(false); |
---|
| 720 | |
---|
| 721 | // mark it should be extended later |
---|
| 722 | pcPicBottom->getPicYuvRec()->setBorderExtension( false ); |
---|
| 723 | |
---|
| 724 | #else |
---|
| 725 | pcPicBottom->destroy(); |
---|
| 726 | pcListPic->erase( iterPic ); |
---|
| 727 | iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! |
---|
| 728 | continue; |
---|
| 729 | #endif |
---|
| 730 | } |
---|
| 731 | pcPicTop->setOutputMark(false); |
---|
| 732 | pcPicBottom->setOutputMark(false); |
---|
| 733 | |
---|
| 734 | #if !DYN_REF_FREE |
---|
| 735 | if(pcPicTop) |
---|
| 736 | { |
---|
| 737 | pcPicTop->destroy(); |
---|
| 738 | delete pcPicTop; |
---|
| 739 | pcPicTop = NULL; |
---|
| 740 | } |
---|
| 741 | #endif |
---|
[2] | 742 | } |
---|
[655] | 743 | } |
---|
| 744 | if(pcPicBottom) |
---|
| 745 | { |
---|
| 746 | pcPicBottom->destroy(); |
---|
| 747 | delete pcPicBottom; |
---|
| 748 | pcPicBottom = NULL; |
---|
| 749 | } |
---|
| 750 | } |
---|
| 751 | else //Frame decoding |
---|
| 752 | { |
---|
| 753 | while (iterPic != pcListPic->end()) |
---|
| 754 | { |
---|
| 755 | pcPic = *(iterPic); |
---|
[56] | 756 | |
---|
[655] | 757 | if ( pcPic->getOutputMark() ) |
---|
| 758 | { |
---|
| 759 | // write to file |
---|
[608] | 760 | #if H_MV |
---|
[655] | 761 | if ( m_pchReconFiles[decIdx] ) |
---|
| 762 | #else |
---|
| 763 | if ( m_pchReconFile ) |
---|
| 764 | #endif |
---|
| 765 | { |
---|
| 766 | const Window &conf = pcPic->getConformanceWindow(); |
---|
| 767 | const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window(); |
---|
| 768 | #if H_MV |
---|
| 769 | assert( conf .getScaledFlag() ); |
---|
| 770 | assert( defDisp.getScaledFlag() ); |
---|
| 771 | m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(), |
---|
| 772 | #else |
---|
| 773 | m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(), |
---|
| 774 | #endif |
---|
| 775 | conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), |
---|
| 776 | conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), |
---|
| 777 | conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), |
---|
| 778 | conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() ); |
---|
| 779 | } |
---|
| 780 | |
---|
| 781 | // update POC of display order |
---|
| 782 | #if H_MV |
---|
[608] | 783 | m_pocLastDisplay[decIdx] = pcPic->getPOC(); |
---|
| 784 | #else |
---|
[655] | 785 | m_iPOCLastDisplay = pcPic->getPOC(); |
---|
[608] | 786 | #endif |
---|
[655] | 787 | |
---|
| 788 | // erase non-referenced picture in the reference picture list after display |
---|
| 789 | if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true ) |
---|
| 790 | { |
---|
[56] | 791 | #if !DYN_REF_FREE |
---|
[655] | 792 | pcPic->setReconMark(false); |
---|
| 793 | |
---|
| 794 | // mark it should be extended later |
---|
| 795 | pcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
| 796 | |
---|
[56] | 797 | #else |
---|
[655] | 798 | pcPic->destroy(); |
---|
| 799 | pcListPic->erase( iterPic ); |
---|
| 800 | iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! |
---|
| 801 | continue; |
---|
[56] | 802 | #endif |
---|
[655] | 803 | } |
---|
| 804 | pcPic->setOutputMark(false); |
---|
[2] | 805 | } |
---|
[608] | 806 | #if !H_MV |
---|
| 807 | #if !DYN_REF_FREE |
---|
[655] | 808 | if(pcPic) |
---|
| 809 | { |
---|
| 810 | pcPic->destroy(); |
---|
| 811 | delete pcPic; |
---|
| 812 | pcPic = NULL; |
---|
| 813 | } |
---|
| 814 | #endif |
---|
| 815 | #endif |
---|
| 816 | iterPic++; |
---|
[608] | 817 | } |
---|
[2] | 818 | } |
---|
[608] | 819 | #if H_MV |
---|
| 820 | m_pocLastDisplay[decIdx] = -MAX_INT; |
---|
| 821 | #else |
---|
[56] | 822 | pcListPic->clear(); |
---|
[608] | 823 | m_iPOCLastDisplay = -MAX_INT; |
---|
| 824 | #endif |
---|
[2] | 825 | } |
---|
[608] | 826 | |
---|
| 827 | /** \param nalu Input nalu to check whether its LayerId is within targetDecLayerIdSet |
---|
| 828 | */ |
---|
| 829 | Bool TAppDecTop::isNaluWithinTargetDecLayerIdSet( InputNALUnit* nalu ) |
---|
[2] | 830 | { |
---|
[608] | 831 | if ( m_targetDecLayerIdSet.size() == 0 ) // By default, the set is empty, meaning all LayerIds are allowed |
---|
[2] | 832 | { |
---|
[608] | 833 | return true; |
---|
[2] | 834 | } |
---|
[608] | 835 | for (std::vector<Int>::iterator it = m_targetDecLayerIdSet.begin(); it != m_targetDecLayerIdSet.end(); it++) |
---|
| 836 | { |
---|
| 837 | #if H_MV |
---|
| 838 | if ( nalu->m_layerId == (*it) ) |
---|
[81] | 839 | #else |
---|
[608] | 840 | if ( nalu->m_reservedZero6Bits == (*it) ) |
---|
[81] | 841 | #endif |
---|
[56] | 842 | { |
---|
[608] | 843 | return true; |
---|
[56] | 844 | } |
---|
| 845 | } |
---|
[608] | 846 | return false; |
---|
[2] | 847 | } |
---|
| 848 | |
---|
[608] | 849 | #if H_MV |
---|
| 850 | Int TAppDecTop::xGetDecoderIdx( Int layerId, Bool createFlag /*= false */ ) |
---|
| 851 | { |
---|
| 852 | Int decIdx = -1; |
---|
[738] | 853 | |
---|
| 854 | if ( layerId > MAX_NUM_LAYER_IDS-1 ) |
---|
| 855 | { |
---|
| 856 | return decIdx; |
---|
| 857 | } |
---|
| 858 | |
---|
[608] | 859 | if ( m_layerIdToDecIdx[ layerId ] != -1 ) |
---|
| 860 | { |
---|
| 861 | decIdx = m_layerIdToDecIdx[ layerId ]; |
---|
[210] | 862 | } |
---|
| 863 | else |
---|
[608] | 864 | { |
---|
| 865 | assert ( createFlag ); |
---|
| 866 | assert( m_numDecoders < MAX_NUM_LAYERS ); |
---|
[210] | 867 | |
---|
[608] | 868 | decIdx = m_numDecoders; |
---|
| 869 | |
---|
| 870 | // Init decoder |
---|
| 871 | m_tDecTop[ decIdx ] = new TDecTop; |
---|
| 872 | m_tDecTop[ decIdx ]->create(); |
---|
| 873 | m_tDecTop[ decIdx ]->init( ); |
---|
| 874 | m_tDecTop[ decIdx ]->setLayerId( layerId ); |
---|
| 875 | m_tDecTop[ decIdx ]->setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); |
---|
| 876 | m_tDecTop[ decIdx ]->setIvPicLists( &m_ivPicLists ); |
---|
[738] | 877 | m_tDecTop[ decIdx ]->setLayerInitilizedFlags( m_layerInitilizedFlags ); |
---|
| 878 | |
---|
[608] | 879 | #if H_3D |
---|
| 880 | m_tDecTop[ decIdx ]->setCamParsCollector( &m_cCamParsCollector ); |
---|
[210] | 881 | #endif |
---|
[2] | 882 | |
---|
[608] | 883 | // append pic list of new decoder to PicLists |
---|
| 884 | assert( m_ivPicLists.size() == m_numDecoders ); |
---|
| 885 | m_ivPicLists.push_back( m_tDecTop[ decIdx ]->getListPic() ); |
---|
[2] | 886 | |
---|
[608] | 887 | // create recon file related stuff |
---|
| 888 | Char* pchTempFilename = NULL; |
---|
| 889 | if ( m_pchReconFile ) |
---|
| 890 | { |
---|
| 891 | Char buffer[4]; |
---|
| 892 | sprintf(buffer,"_%i", layerId ); |
---|
| 893 | assert ( m_pchReconFile ); |
---|
| 894 | xAppendToFileNameEnd( m_pchReconFile , buffer, pchTempFilename ); |
---|
| 895 | assert( m_pchReconFiles.size() == m_numDecoders ); |
---|
[2] | 896 | } |
---|
[210] | 897 | |
---|
[608] | 898 | m_pchReconFiles.push_back( pchTempFilename ); |
---|
[296] | 899 | |
---|
[608] | 900 | m_tVideoIOYuvReconFile[ decIdx ] = new TVideoIOYuv; |
---|
| 901 | m_reconOpen [ decIdx ] = false; |
---|
[443] | 902 | |
---|
[608] | 903 | // set others |
---|
| 904 | m_pocLastDisplay [ decIdx ] = -MAX_INT; |
---|
| 905 | m_layerIdToDecIdx [ layerId ] = decIdx; |
---|
[296] | 906 | |
---|
[608] | 907 | m_numDecoders++; |
---|
| 908 | }; |
---|
| 909 | return decIdx; |
---|
[296] | 910 | } |
---|
| 911 | #endif |
---|
[56] | 912 | //! \} |
---|