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