[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 |
---|
[837] | 167 | Bool loopFiltered = false; |
---|
| 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 | { |
---|
| 290 | g_disableHLSTrace = true; // Trancing 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 | { |
---|
[608] | 299 | #if H_MV |
---|
| 300 | assert( decIdxLastPic != -1 ); |
---|
[837] | 301 | // TODO add loop filtered variable here |
---|
[608] | 302 | m_tDecTop[decIdxLastPic]->endPicDecoding(poc, pcListPic, m_targetDecLayerIdSet ); |
---|
| 303 | #else |
---|
[837] | 304 | if (!loopFiltered || bitstreamFile) |
---|
| 305 | { |
---|
| 306 | m_cTDecTop.executeLoopFilters(poc, pcListPic); |
---|
| 307 | } |
---|
| 308 | loopFiltered = (nalu.m_nalUnitType == NAL_UNIT_EOS); |
---|
[608] | 309 | #endif |
---|
[56] | 310 | } |
---|
[608] | 311 | #if H_3D |
---|
| 312 | if ( allLayersDecoded || !bitstreamFile ) |
---|
[56] | 313 | { |
---|
[608] | 314 | for( Int dI = 0; dI < m_numDecoders; dI++ ) |
---|
| 315 | { |
---|
| 316 | TComPic* picLastCoded = m_ivPicLists.getPic( m_tDecTop[dI]->getLayerId(), pocLastPic ); |
---|
| 317 | assert( picLastCoded != NULL ); |
---|
| 318 | picLastCoded->compressMotion(1); |
---|
| 319 | } |
---|
| 320 | } |
---|
| 321 | #endif |
---|
| 322 | |
---|
| 323 | if( pcListPic ) |
---|
| 324 | { |
---|
| 325 | #if H_MV |
---|
| 326 | if ( m_pchReconFiles[decIdxLastPic] && !m_reconOpen[decIdxLastPic] ) |
---|
| 327 | #else |
---|
[655] | 328 | if ( m_pchReconFile && !openedReconFile ) |
---|
[608] | 329 | #endif |
---|
[2] | 330 | { |
---|
[608] | 331 | if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; } |
---|
| 332 | if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; } |
---|
| 333 | |
---|
| 334 | #if H_MV |
---|
| 335 | m_tVideoIOYuvReconFile[decIdxLastPic]->open( m_pchReconFiles[decIdxLastPic], true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode |
---|
| 336 | m_reconOpen[decIdxLastPic] = true; |
---|
[2] | 337 | } |
---|
[608] | 338 | if ( bNewPicture && newSliceDiffPoc && |
---|
| 339 | #else |
---|
| 340 | m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode |
---|
[655] | 341 | openedReconFile = true; |
---|
[608] | 342 | } |
---|
| 343 | if ( bNewPicture && |
---|
| 344 | #endif |
---|
| 345 | ( nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
| 346 | || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP |
---|
| 347 | || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
| 348 | || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 349 | || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP ) ) |
---|
| 350 | { |
---|
| 351 | #if H_MV |
---|
| 352 | xFlushOutput( pcListPic, decIdxLastPic ); |
---|
| 353 | #else |
---|
| 354 | xFlushOutput( pcListPic ); |
---|
| 355 | #endif |
---|
| 356 | } |
---|
[837] | 357 | if (nalu.m_nalUnitType == NAL_UNIT_EOS) |
---|
| 358 | { |
---|
| 359 | #if H_MV |
---|
| 360 | xFlushOutput( pcListPic, decIdxLastPic ); |
---|
| 361 | #else |
---|
| 362 | xFlushOutput( pcListPic ); |
---|
| 363 | #endif |
---|
| 364 | } |
---|
[56] | 365 | // write reconstruction to file |
---|
[608] | 366 | if(bNewPicture) |
---|
[2] | 367 | { |
---|
[608] | 368 | #if H_MV |
---|
| 369 | xWriteOutput( pcListPic, decIdxLastPic, nalu.m_temporalId ); |
---|
[2] | 370 | } |
---|
| 371 | } |
---|
[608] | 372 | } |
---|
| 373 | |
---|
| 374 | #if H_3D |
---|
[57] | 375 | if( m_cCamParsCollector.isInitialized() ) |
---|
| 376 | { |
---|
| 377 | m_cCamParsCollector.setSlice( 0 ); |
---|
| 378 | } |
---|
[608] | 379 | #endif |
---|
| 380 | for(UInt decIdx = 0; decIdx < m_numDecoders; decIdx++) |
---|
[2] | 381 | { |
---|
[608] | 382 | xFlushOutput( m_tDecTop[decIdx]->getListPic(), decIdx ); |
---|
| 383 | } |
---|
| 384 | #else |
---|
| 385 | xWriteOutput( pcListPic, nalu.m_temporalId ); |
---|
| 386 | } |
---|
| 387 | } |
---|
| 388 | } |
---|
| 389 | |
---|
| 390 | xFlushOutput( pcListPic ); |
---|
| 391 | // delete buffers |
---|
| 392 | m_cTDecTop.deletePicBuffer(); |
---|
| 393 | #endif |
---|
| 394 | |
---|
| 395 | // destroy internal classes |
---|
[2] | 396 | xDestroyDecLib(); |
---|
| 397 | } |
---|
| 398 | |
---|
| 399 | // ==================================================================================================================== |
---|
| 400 | // Protected member functions |
---|
| 401 | // ==================================================================================================================== |
---|
| 402 | |
---|
[608] | 403 | Void TAppDecTop::xCreateDecLib() |
---|
| 404 | { |
---|
| 405 | #if H_MV |
---|
| 406 | // initialize global variables |
---|
| 407 | initROM(); |
---|
| 408 | #if H_3D_DIM_DMM |
---|
| 409 | initWedgeLists(); |
---|
| 410 | #endif |
---|
| 411 | #else |
---|
| 412 | // create decoder class |
---|
| 413 | m_cTDecTop.create(); |
---|
| 414 | #endif |
---|
| 415 | } |
---|
| 416 | |
---|
[2] | 417 | Void TAppDecTop::xDestroyDecLib() |
---|
| 418 | { |
---|
[608] | 419 | #if H_MV |
---|
| 420 | // destroy ROM |
---|
| 421 | destroyROM(); |
---|
[2] | 422 | |
---|
[608] | 423 | for(Int decIdx = 0; decIdx < m_numDecoders ; decIdx++) |
---|
[2] | 424 | { |
---|
[608] | 425 | if( m_tVideoIOYuvReconFile[decIdx] ) |
---|
[56] | 426 | { |
---|
[608] | 427 | m_tVideoIOYuvReconFile[decIdx]->close(); |
---|
| 428 | delete m_tVideoIOYuvReconFile[decIdx]; |
---|
| 429 | m_tVideoIOYuvReconFile[decIdx] = NULL ; |
---|
[56] | 430 | } |
---|
[2] | 431 | |
---|
[608] | 432 | if( m_tDecTop[decIdx] ) |
---|
[56] | 433 | { |
---|
[608] | 434 | m_tDecTop[decIdx]->deletePicBuffer(); |
---|
| 435 | m_tDecTop[decIdx]->destroy() ; |
---|
[56] | 436 | } |
---|
[608] | 437 | delete m_tDecTop[decIdx] ; |
---|
| 438 | m_tDecTop[decIdx] = NULL ; |
---|
[2] | 439 | } |
---|
[608] | 440 | #else |
---|
| 441 | if ( m_pchReconFile ) |
---|
| 442 | { |
---|
| 443 | m_cTVideoIOYuvReconFile. close(); |
---|
| 444 | } |
---|
| 445 | |
---|
| 446 | // destroy decoder class |
---|
| 447 | m_cTDecTop.destroy(); |
---|
| 448 | #endif |
---|
| 449 | #if H_3D |
---|
[57] | 450 | m_cCamParsCollector.uninit(); |
---|
| 451 | if( m_pScaleOffsetFile ) |
---|
| 452 | { |
---|
| 453 | ::fclose( m_pScaleOffsetFile ); |
---|
| 454 | } |
---|
[608] | 455 | #endif |
---|
[56] | 456 | } |
---|
[2] | 457 | |
---|
[608] | 458 | Void TAppDecTop::xInitDecLib() |
---|
[56] | 459 | { |
---|
[608] | 460 | #if !H_MV |
---|
| 461 | // initialize decoder class |
---|
| 462 | m_cTDecTop.init(); |
---|
| 463 | m_cTDecTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); |
---|
| 464 | #endif |
---|
| 465 | } |
---|
| 466 | |
---|
| 467 | /** \param pcListPic list of pictures to be written to file |
---|
| 468 | \todo DYN_REF_FREE should be revised |
---|
| 469 | */ |
---|
| 470 | #if H_MV |
---|
| 471 | Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, Int decIdx, Int tId ) |
---|
| 472 | #else |
---|
| 473 | Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, UInt tId ) |
---|
| 474 | #endif |
---|
| 475 | { |
---|
[837] | 476 | |
---|
| 477 | if (pcListPic->empty()) |
---|
| 478 | { |
---|
| 479 | return; |
---|
| 480 | } |
---|
| 481 | |
---|
[56] | 482 | TComList<TComPic*>::iterator iterPic = pcListPic->begin(); |
---|
[655] | 483 | Int numPicsNotYetDisplayed = 0; |
---|
| 484 | |
---|
[56] | 485 | while (iterPic != pcListPic->end()) |
---|
[2] | 486 | { |
---|
[56] | 487 | TComPic* pcPic = *(iterPic); |
---|
[608] | 488 | #if H_MV |
---|
| 489 | if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[decIdx]) |
---|
| 490 | #else |
---|
| 491 | if(pcPic->getOutputMark() && pcPic->getPOC() > m_iPOCLastDisplay) |
---|
| 492 | #endif |
---|
[56] | 493 | { |
---|
[655] | 494 | numPicsNotYetDisplayed++; |
---|
[56] | 495 | } |
---|
| 496 | iterPic++; |
---|
[2] | 497 | } |
---|
[56] | 498 | iterPic = pcListPic->begin(); |
---|
[655] | 499 | if (numPicsNotYetDisplayed>2) |
---|
| 500 | { |
---|
| 501 | iterPic++; |
---|
| 502 | } |
---|
[56] | 503 | |
---|
[655] | 504 | TComPic* pcPic = *(iterPic); |
---|
| 505 | if (numPicsNotYetDisplayed>2 && pcPic->isField()) //Field Decoding |
---|
[2] | 506 | { |
---|
[655] | 507 | TComList<TComPic*>::iterator endPic = pcListPic->end(); |
---|
| 508 | endPic--; |
---|
| 509 | iterPic = pcListPic->begin(); |
---|
| 510 | while (iterPic != endPic) |
---|
| 511 | { |
---|
| 512 | TComPic* pcPicTop = *(iterPic); |
---|
| 513 | iterPic++; |
---|
| 514 | TComPic* pcPicBottom = *(iterPic); |
---|
| 515 | |
---|
[608] | 516 | #if H_MV |
---|
[655] | 517 | if ( pcPicTop->getOutputMark() && (numPicsNotYetDisplayed > pcPicTop->getNumReorderPics(tId) && !(pcPicTop->getPOC()%2) && pcPicBottom->getPOC() == pcPicTop->getPOC()+1) |
---|
| 518 | && pcPicBottom->getOutputMark() && (numPicsNotYetDisplayed > pcPicBottom->getNumReorderPics(tId) && (pcPicTop->getPOC() == m_pocLastDisplay[decIdx]+1 || m_pocLastDisplay[decIdx]<0))) |
---|
[608] | 519 | #else |
---|
[655] | 520 | if ( pcPicTop->getOutputMark() && (numPicsNotYetDisplayed > pcPicTop->getNumReorderPics(tId) && !(pcPicTop->getPOC()%2) && pcPicBottom->getPOC() == pcPicTop->getPOC()+1) |
---|
| 521 | && pcPicBottom->getOutputMark() && (numPicsNotYetDisplayed > pcPicBottom->getNumReorderPics(tId) && (pcPicTop->getPOC() == m_iPOCLastDisplay+1 || m_iPOCLastDisplay<0))) |
---|
[608] | 522 | #endif |
---|
[655] | 523 | { |
---|
| 524 | // write to file |
---|
| 525 | numPicsNotYetDisplayed = numPicsNotYetDisplayed-2; |
---|
[608] | 526 | #if H_MV |
---|
| 527 | if ( m_pchReconFiles[decIdx] ) |
---|
| 528 | #else |
---|
[655] | 529 | if ( m_pchReconFile ) |
---|
[608] | 530 | #endif |
---|
[655] | 531 | { |
---|
| 532 | const Window &conf = pcPicTop->getConformanceWindow(); |
---|
| 533 | const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window(); |
---|
| 534 | |
---|
| 535 | const Bool isTff = pcPicTop->isTopField(); |
---|
[608] | 536 | #if H_MV |
---|
[622] | 537 | assert( conf .getScaledFlag() ); |
---|
| 538 | assert( defDisp.getScaledFlag() ); |
---|
[655] | 539 | m_tVideoIOYuvReconFile[decIdx]->write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(), |
---|
| 540 | #else |
---|
| 541 | m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(), |
---|
[622] | 542 | #endif |
---|
[655] | 543 | conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), |
---|
| 544 | conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), |
---|
| 545 | conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), |
---|
| 546 | conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff ); |
---|
| 547 | } |
---|
| 548 | |
---|
| 549 | // update POC of display order |
---|
| 550 | #if H_MV |
---|
| 551 | m_pocLastDisplay[decIdx] = pcPic->getPOC(); |
---|
[608] | 552 | #else |
---|
[655] | 553 | m_iPOCLastDisplay = pcPicBottom->getPOC(); |
---|
[608] | 554 | #endif |
---|
[655] | 555 | |
---|
| 556 | // erase non-referenced picture in the reference picture list after display |
---|
| 557 | if ( !pcPicTop->getSlice(0)->isReferenced() && pcPicTop->getReconMark() == true ) |
---|
| 558 | { |
---|
| 559 | #if !DYN_REF_FREE |
---|
| 560 | pcPicTop->setReconMark(false); |
---|
| 561 | |
---|
| 562 | // mark it should be extended later |
---|
| 563 | pcPicTop->getPicYuvRec()->setBorderExtension( false ); |
---|
| 564 | |
---|
| 565 | #else |
---|
| 566 | pcPicTop->destroy(); |
---|
| 567 | pcListPic->erase( iterPic ); |
---|
| 568 | iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! |
---|
| 569 | continue; |
---|
| 570 | #endif |
---|
| 571 | } |
---|
| 572 | if ( !pcPicBottom->getSlice(0)->isReferenced() && pcPicBottom->getReconMark() == true ) |
---|
| 573 | { |
---|
| 574 | #if !DYN_REF_FREE |
---|
| 575 | pcPicBottom->setReconMark(false); |
---|
| 576 | |
---|
| 577 | // mark it should be extended later |
---|
| 578 | pcPicBottom->getPicYuvRec()->setBorderExtension( false ); |
---|
| 579 | |
---|
| 580 | #else |
---|
| 581 | pcPicBottom->destroy(); |
---|
| 582 | pcListPic->erase( iterPic ); |
---|
| 583 | iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! |
---|
| 584 | continue; |
---|
| 585 | #endif |
---|
| 586 | } |
---|
| 587 | pcPicTop->setOutputMark(false); |
---|
| 588 | pcPicBottom->setOutputMark(false); |
---|
[56] | 589 | } |
---|
[655] | 590 | } |
---|
| 591 | } |
---|
| 592 | else if (!pcPic->isField()) //Frame Decoding |
---|
| 593 | { |
---|
| 594 | iterPic = pcListPic->begin(); |
---|
| 595 | while (iterPic != pcListPic->end()) |
---|
| 596 | { |
---|
| 597 | pcPic = *(iterPic); |
---|
| 598 | |
---|
[608] | 599 | #if H_MV |
---|
[655] | 600 | if ( pcPic->getOutputMark() && (numPicsNotYetDisplayed > pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_pocLastDisplay[decIdx])) |
---|
| 601 | #else |
---|
| 602 | if ( pcPic->getOutputMark() && (numPicsNotYetDisplayed > pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay)) |
---|
| 603 | #endif |
---|
| 604 | { |
---|
| 605 | // write to file |
---|
| 606 | numPicsNotYetDisplayed--; |
---|
| 607 | #if H_MV |
---|
| 608 | if ( m_pchReconFiles[decIdx] ) |
---|
[608] | 609 | #else |
---|
[655] | 610 | if ( m_pchReconFile ) |
---|
[608] | 611 | #endif |
---|
[655] | 612 | { |
---|
| 613 | const Window &conf = pcPic->getConformanceWindow(); |
---|
| 614 | const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window(); |
---|
| 615 | #if H_MV |
---|
| 616 | assert( conf .getScaledFlag() ); |
---|
| 617 | assert( defDisp.getScaledFlag() ); |
---|
| 618 | m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(), |
---|
| 619 | #else |
---|
| 620 | m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(), |
---|
| 621 | #endif |
---|
| 622 | conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), |
---|
| 623 | conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), |
---|
| 624 | conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), |
---|
| 625 | conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() ); |
---|
| 626 | } |
---|
[56] | 627 | |
---|
[655] | 628 | // update POC of display order |
---|
| 629 | #if H_MV |
---|
| 630 | m_pocLastDisplay[decIdx] = pcPic->getPOC(); |
---|
| 631 | #else |
---|
| 632 | m_iPOCLastDisplay = pcPic->getPOC(); |
---|
| 633 | #endif |
---|
[56] | 634 | |
---|
[655] | 635 | // erase non-referenced picture in the reference picture list after display |
---|
| 636 | if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true ) |
---|
| 637 | { |
---|
| 638 | #if !DYN_REF_FREE |
---|
| 639 | pcPic->setReconMark(false); |
---|
| 640 | |
---|
| 641 | // mark it should be extended later |
---|
| 642 | pcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
| 643 | |
---|
[56] | 644 | #else |
---|
[655] | 645 | pcPic->destroy(); |
---|
| 646 | pcListPic->erase( iterPic ); |
---|
| 647 | iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! |
---|
| 648 | continue; |
---|
[56] | 649 | #endif |
---|
[655] | 650 | } |
---|
| 651 | pcPic->setOutputMark(false); |
---|
[56] | 652 | } |
---|
[655] | 653 | |
---|
| 654 | iterPic++; |
---|
[56] | 655 | } |
---|
[2] | 656 | } |
---|
| 657 | } |
---|
| 658 | /** \param pcListPic list of pictures to be written to file |
---|
| 659 | \todo DYN_REF_FREE should be revised |
---|
| 660 | */ |
---|
[608] | 661 | #if H_MV |
---|
| 662 | Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic, Int decIdx ) |
---|
| 663 | #else |
---|
| 664 | Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic ) |
---|
| 665 | #endif |
---|
[2] | 666 | { |
---|
[837] | 667 | if(!pcListPic || pcListPic->empty()) |
---|
[56] | 668 | { |
---|
| 669 | return; |
---|
[655] | 670 | } |
---|
[2] | 671 | TComList<TComPic*>::iterator iterPic = pcListPic->begin(); |
---|
[655] | 672 | |
---|
[56] | 673 | iterPic = pcListPic->begin(); |
---|
[655] | 674 | TComPic* pcPic = *(iterPic); |
---|
[56] | 675 | |
---|
[655] | 676 | if (pcPic->isField()) //Field Decoding |
---|
[2] | 677 | { |
---|
[655] | 678 | TComList<TComPic*>::iterator endPic = pcListPic->end(); |
---|
| 679 | endPic--; |
---|
| 680 | TComPic *pcPicTop, *pcPicBottom = NULL; |
---|
| 681 | while (iterPic != endPic) |
---|
[2] | 682 | { |
---|
[655] | 683 | pcPicTop = *(iterPic); |
---|
| 684 | iterPic++; |
---|
| 685 | pcPicBottom = *(iterPic); |
---|
| 686 | |
---|
| 687 | if ( pcPicTop->getOutputMark() && pcPicBottom->getOutputMark() && !(pcPicTop->getPOC()%2) && (pcPicBottom->getPOC() == pcPicTop->getPOC()+1) ) |
---|
| 688 | { |
---|
| 689 | // write to file |
---|
[608] | 690 | #if H_MV |
---|
| 691 | if ( m_pchReconFiles[decIdx] ) |
---|
| 692 | #else |
---|
[655] | 693 | if ( m_pchReconFile ) |
---|
[608] | 694 | #endif |
---|
[655] | 695 | { |
---|
| 696 | const Window &conf = pcPicTop->getConformanceWindow(); |
---|
| 697 | const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window(); |
---|
| 698 | const Bool isTff = pcPicTop->isTopField(); |
---|
[608] | 699 | #if H_MV |
---|
[622] | 700 | assert( conf .getScaledFlag() ); |
---|
| 701 | assert( defDisp.getScaledFlag() ); |
---|
[655] | 702 | m_tVideoIOYuvReconFile[decIdx]->write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(), |
---|
| 703 | #else |
---|
| 704 | m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(), |
---|
[622] | 705 | #endif |
---|
[655] | 706 | conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), |
---|
| 707 | conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), |
---|
| 708 | conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), |
---|
| 709 | conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff ); |
---|
| 710 | } |
---|
| 711 | |
---|
| 712 | // update POC of display order |
---|
| 713 | #if H_MV |
---|
| 714 | m_pocLastDisplay[decIdx] = pcPic->getPOC(); |
---|
[608] | 715 | #else |
---|
[655] | 716 | m_iPOCLastDisplay = pcPicBottom->getPOC(); |
---|
| 717 | #endif |
---|
| 718 | // erase non-referenced picture in the reference picture list after display |
---|
| 719 | if ( !pcPicTop->getSlice(0)->isReferenced() && pcPicTop->getReconMark() == true ) |
---|
| 720 | { |
---|
| 721 | #if !DYN_REF_FREE |
---|
| 722 | pcPicTop->setReconMark(false); |
---|
| 723 | |
---|
| 724 | // mark it should be extended later |
---|
| 725 | pcPicTop->getPicYuvRec()->setBorderExtension( false ); |
---|
| 726 | |
---|
| 727 | #else |
---|
| 728 | pcPicTop->destroy(); |
---|
| 729 | pcListPic->erase( iterPic ); |
---|
| 730 | iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! |
---|
| 731 | continue; |
---|
[608] | 732 | #endif |
---|
[655] | 733 | } |
---|
| 734 | if ( !pcPicBottom->getSlice(0)->isReferenced() && pcPicBottom->getReconMark() == true ) |
---|
| 735 | { |
---|
| 736 | #if !DYN_REF_FREE |
---|
| 737 | pcPicBottom->setReconMark(false); |
---|
| 738 | |
---|
| 739 | // mark it should be extended later |
---|
| 740 | pcPicBottom->getPicYuvRec()->setBorderExtension( false ); |
---|
| 741 | |
---|
| 742 | #else |
---|
| 743 | pcPicBottom->destroy(); |
---|
| 744 | pcListPic->erase( iterPic ); |
---|
| 745 | iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! |
---|
| 746 | continue; |
---|
| 747 | #endif |
---|
| 748 | } |
---|
| 749 | pcPicTop->setOutputMark(false); |
---|
| 750 | pcPicBottom->setOutputMark(false); |
---|
| 751 | |
---|
| 752 | #if !DYN_REF_FREE |
---|
| 753 | if(pcPicTop) |
---|
| 754 | { |
---|
| 755 | pcPicTop->destroy(); |
---|
| 756 | delete pcPicTop; |
---|
| 757 | pcPicTop = NULL; |
---|
| 758 | } |
---|
| 759 | #endif |
---|
[2] | 760 | } |
---|
[655] | 761 | } |
---|
| 762 | if(pcPicBottom) |
---|
| 763 | { |
---|
| 764 | pcPicBottom->destroy(); |
---|
| 765 | delete pcPicBottom; |
---|
| 766 | pcPicBottom = NULL; |
---|
| 767 | } |
---|
| 768 | } |
---|
| 769 | else //Frame decoding |
---|
| 770 | { |
---|
| 771 | while (iterPic != pcListPic->end()) |
---|
| 772 | { |
---|
| 773 | pcPic = *(iterPic); |
---|
[56] | 774 | |
---|
[655] | 775 | if ( pcPic->getOutputMark() ) |
---|
| 776 | { |
---|
| 777 | // write to file |
---|
[608] | 778 | #if H_MV |
---|
[655] | 779 | if ( m_pchReconFiles[decIdx] ) |
---|
| 780 | #else |
---|
| 781 | if ( m_pchReconFile ) |
---|
| 782 | #endif |
---|
| 783 | { |
---|
| 784 | const Window &conf = pcPic->getConformanceWindow(); |
---|
| 785 | const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window(); |
---|
| 786 | #if H_MV |
---|
| 787 | assert( conf .getScaledFlag() ); |
---|
| 788 | assert( defDisp.getScaledFlag() ); |
---|
| 789 | m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(), |
---|
| 790 | #else |
---|
| 791 | m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(), |
---|
| 792 | #endif |
---|
| 793 | conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(), |
---|
| 794 | conf.getWindowRightOffset() + defDisp.getWindowRightOffset(), |
---|
| 795 | conf.getWindowTopOffset() + defDisp.getWindowTopOffset(), |
---|
| 796 | conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() ); |
---|
| 797 | } |
---|
| 798 | |
---|
| 799 | // update POC of display order |
---|
| 800 | #if H_MV |
---|
[608] | 801 | m_pocLastDisplay[decIdx] = pcPic->getPOC(); |
---|
| 802 | #else |
---|
[655] | 803 | m_iPOCLastDisplay = pcPic->getPOC(); |
---|
[608] | 804 | #endif |
---|
[655] | 805 | |
---|
| 806 | // erase non-referenced picture in the reference picture list after display |
---|
| 807 | if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true ) |
---|
| 808 | { |
---|
[56] | 809 | #if !DYN_REF_FREE |
---|
[655] | 810 | pcPic->setReconMark(false); |
---|
| 811 | |
---|
| 812 | // mark it should be extended later |
---|
| 813 | pcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
| 814 | |
---|
[56] | 815 | #else |
---|
[655] | 816 | pcPic->destroy(); |
---|
| 817 | pcListPic->erase( iterPic ); |
---|
| 818 | iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! |
---|
| 819 | continue; |
---|
[56] | 820 | #endif |
---|
[655] | 821 | } |
---|
| 822 | pcPic->setOutputMark(false); |
---|
[2] | 823 | } |
---|
[608] | 824 | #if !H_MV |
---|
| 825 | #if !DYN_REF_FREE |
---|
[655] | 826 | if(pcPic) |
---|
| 827 | { |
---|
| 828 | pcPic->destroy(); |
---|
| 829 | delete pcPic; |
---|
| 830 | pcPic = NULL; |
---|
| 831 | } |
---|
| 832 | #endif |
---|
| 833 | #endif |
---|
| 834 | iterPic++; |
---|
[608] | 835 | } |
---|
[2] | 836 | } |
---|
[608] | 837 | #if H_MV |
---|
| 838 | m_pocLastDisplay[decIdx] = -MAX_INT; |
---|
| 839 | #else |
---|
[56] | 840 | pcListPic->clear(); |
---|
[608] | 841 | m_iPOCLastDisplay = -MAX_INT; |
---|
| 842 | #endif |
---|
[2] | 843 | } |
---|
[608] | 844 | |
---|
| 845 | /** \param nalu Input nalu to check whether its LayerId is within targetDecLayerIdSet |
---|
| 846 | */ |
---|
| 847 | Bool TAppDecTop::isNaluWithinTargetDecLayerIdSet( InputNALUnit* nalu ) |
---|
[2] | 848 | { |
---|
[608] | 849 | if ( m_targetDecLayerIdSet.size() == 0 ) // By default, the set is empty, meaning all LayerIds are allowed |
---|
[2] | 850 | { |
---|
[608] | 851 | return true; |
---|
[2] | 852 | } |
---|
[608] | 853 | for (std::vector<Int>::iterator it = m_targetDecLayerIdSet.begin(); it != m_targetDecLayerIdSet.end(); it++) |
---|
| 854 | { |
---|
| 855 | #if H_MV |
---|
| 856 | if ( nalu->m_layerId == (*it) ) |
---|
[81] | 857 | #else |
---|
[608] | 858 | if ( nalu->m_reservedZero6Bits == (*it) ) |
---|
[81] | 859 | #endif |
---|
[56] | 860 | { |
---|
[608] | 861 | return true; |
---|
[56] | 862 | } |
---|
| 863 | } |
---|
[608] | 864 | return false; |
---|
[2] | 865 | } |
---|
| 866 | |
---|
[608] | 867 | #if H_MV |
---|
| 868 | Int TAppDecTop::xGetDecoderIdx( Int layerId, Bool createFlag /*= false */ ) |
---|
| 869 | { |
---|
| 870 | Int decIdx = -1; |
---|
[738] | 871 | |
---|
| 872 | if ( layerId > MAX_NUM_LAYER_IDS-1 ) |
---|
| 873 | { |
---|
| 874 | return decIdx; |
---|
| 875 | } |
---|
| 876 | |
---|
[608] | 877 | if ( m_layerIdToDecIdx[ layerId ] != -1 ) |
---|
| 878 | { |
---|
| 879 | decIdx = m_layerIdToDecIdx[ layerId ]; |
---|
[210] | 880 | } |
---|
| 881 | else |
---|
[608] | 882 | { |
---|
| 883 | assert ( createFlag ); |
---|
| 884 | assert( m_numDecoders < MAX_NUM_LAYERS ); |
---|
[210] | 885 | |
---|
[608] | 886 | decIdx = m_numDecoders; |
---|
| 887 | |
---|
| 888 | // Init decoder |
---|
| 889 | m_tDecTop[ decIdx ] = new TDecTop; |
---|
| 890 | m_tDecTop[ decIdx ]->create(); |
---|
| 891 | m_tDecTop[ decIdx ]->init( ); |
---|
| 892 | m_tDecTop[ decIdx ]->setLayerId( layerId ); |
---|
| 893 | m_tDecTop[ decIdx ]->setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); |
---|
| 894 | m_tDecTop[ decIdx ]->setIvPicLists( &m_ivPicLists ); |
---|
[738] | 895 | m_tDecTop[ decIdx ]->setLayerInitilizedFlags( m_layerInitilizedFlags ); |
---|
| 896 | |
---|
[608] | 897 | #if H_3D |
---|
| 898 | m_tDecTop[ decIdx ]->setCamParsCollector( &m_cCamParsCollector ); |
---|
[210] | 899 | #endif |
---|
[2] | 900 | |
---|
[608] | 901 | // append pic list of new decoder to PicLists |
---|
| 902 | assert( m_ivPicLists.size() == m_numDecoders ); |
---|
| 903 | m_ivPicLists.push_back( m_tDecTop[ decIdx ]->getListPic() ); |
---|
[2] | 904 | |
---|
[608] | 905 | // create recon file related stuff |
---|
| 906 | Char* pchTempFilename = NULL; |
---|
| 907 | if ( m_pchReconFile ) |
---|
| 908 | { |
---|
| 909 | Char buffer[4]; |
---|
| 910 | sprintf(buffer,"_%i", layerId ); |
---|
| 911 | assert ( m_pchReconFile ); |
---|
| 912 | xAppendToFileNameEnd( m_pchReconFile , buffer, pchTempFilename ); |
---|
| 913 | assert( m_pchReconFiles.size() == m_numDecoders ); |
---|
[2] | 914 | } |
---|
[210] | 915 | |
---|
[608] | 916 | m_pchReconFiles.push_back( pchTempFilename ); |
---|
[296] | 917 | |
---|
[608] | 918 | m_tVideoIOYuvReconFile[ decIdx ] = new TVideoIOYuv; |
---|
| 919 | m_reconOpen [ decIdx ] = false; |
---|
[443] | 920 | |
---|
[608] | 921 | // set others |
---|
| 922 | m_pocLastDisplay [ decIdx ] = -MAX_INT; |
---|
| 923 | m_layerIdToDecIdx [ layerId ] = decIdx; |
---|
[296] | 924 | |
---|
[608] | 925 | m_numDecoders++; |
---|
| 926 | }; |
---|
| 927 | return decIdx; |
---|
[296] | 928 | } |
---|
| 929 | #endif |
---|
[56] | 930 | //! \} |
---|