Changeset 1313 in 3DVCSoftware for trunk/source/Lib/TLibDecoder/TDecGop.cpp


Ignore:
Timestamp:
13 Aug 2015, 17:38:13 (9 years ago)
Author:
tech
Message:

Merged 14.1-update-dev1@1312.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibDecoder/TDecGop.cpp

    r1179 r1313  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
     4 * granted under this license.
    55 *
    6 * Copyright (c) 2010-2015, ITU/ISO/IEC
     6 * Copyright (c) 2010-2015, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4646#include <time.h>
    4747
    48 extern Bool g_md5_mismatch; ///< top level flag to signal when there is a decode problem
    49 
    5048//! \ingroup TLibDecoder
    5149//! \{
    52 static void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI);
     50static Void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI, const BitDepths &bitDepths, UInt &numChecksumErrors);
    5351// ====================================================================================================================
    5452// Constructor / destructor / initialization / destroy
     
    5654
    5755TDecGop::TDecGop()
     56 : m_numberOfChecksumErrorsDetected(0)
    5857{
    5958  m_dDecTime = 0;
    60   m_pcSbacDecoders = NULL;
    61   m_pcBinCABACs = NULL;
    6259}
    6360
    6461TDecGop::~TDecGop()
    6562{
    66  
     63
    6764}
    6865
    6966Void TDecGop::create()
    7067{
    71  
     68
    7269}
    7370
     
    7774}
    7875
    79 Void TDecGop::init( TDecEntropy*            pcEntropyDecoder, 
    80                    TDecSbac*               pcSbacDecoder, 
     76Void TDecGop::init( TDecEntropy*            pcEntropyDecoder,
     77                   TDecSbac*               pcSbacDecoder,
    8178                   TDecBinCABAC*           pcBinCABAC,
    82                    TDecCavlc*              pcCavlcDecoder, 
    83                    TDecSlice*              pcSliceDecoder, 
     79                   TDecCavlc*              pcCavlcDecoder,
     80                   TDecSlice*              pcSliceDecoder,
    8481                   TComLoopFilter*         pcLoopFilter,
    8582                   TComSampleAdaptiveOffset* pcSAO
     
    9289  m_pcSliceDecoder        = pcSliceDecoder;
    9390  m_pcLoopFilter          = pcLoopFilter;
    94   m_pcSAO  = pcSAO; 
     91  m_pcSAO                 = pcSAO;
     92  m_numberOfChecksumErrorsDetected = 0;
    9593}
    9694
     
    103101// ====================================================================================================================
    104102
    105 Void TDecGop::decompressSlice(TComInputBitstream* pcBitstream, TComPic*& rpcPic)
    106 {
    107   TComSlice*  pcSlice = rpcPic->getSlice(rpcPic->getCurrSliceIdx());
     103Void TDecGop::decompressSlice(TComInputBitstream* pcBitstream, TComPic* pcPic)
     104{
     105  TComSlice*  pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx());
    108106  // Table of extracted substreams.
    109107  // These must be deallocated AND their internal fifos, too.
     
    111109
    112110  //-- For time output for each slice
    113   long iBeforeTime = clock();
     111  clock_t iBeforeTime = clock();
    114112  m_pcSbacDecoder->init( (TDecBinIf*)m_pcBinCABAC );
    115113  m_pcEntropyDecoder->setEntropyDecoder (m_pcSbacDecoder);
    116114
    117   UInt uiNumSubstreams = pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag() ? pcSlice->getNumEntryPointOffsets()+1 : pcSlice->getPPS()->getNumSubstreams();
     115  const UInt uiNumSubstreams = pcSlice->getNumberOfSubstreamSizes()+1;
    118116
    119117  // init each couple {EntropyDecoder, Substream}
    120   UInt *puiSubstreamSizes = pcSlice->getSubstreamSizes();
    121118  ppcSubstreams    = new TComInputBitstream*[uiNumSubstreams];
    122   m_pcSbacDecoders = new TDecSbac[uiNumSubstreams];
    123   m_pcBinCABACs    = new TDecBinCABAC[uiNumSubstreams];
    124119  for ( UInt ui = 0 ; ui < uiNumSubstreams ; ui++ )
    125120  {
    126     m_pcSbacDecoders[ui].init(&m_pcBinCABACs[ui]);
    127     ppcSubstreams[ui] = pcBitstream->extractSubstream(ui+1 < uiNumSubstreams ? puiSubstreamSizes[ui] : pcBitstream->getNumBitsLeft());
    128   }
    129 
    130   for ( UInt ui = 0 ; ui+1 < uiNumSubstreams; ui++ )
    131   {
    132     m_pcEntropyDecoder->setEntropyDecoder ( &m_pcSbacDecoders[uiNumSubstreams - 1 - ui] );
    133     m_pcEntropyDecoder->setBitstream      (  ppcSubstreams   [uiNumSubstreams - 1 - ui] );
    134     m_pcEntropyDecoder->resetEntropy      (pcSlice);
    135   }
    136 
    137   m_pcEntropyDecoder->setEntropyDecoder ( m_pcSbacDecoder  );
    138   m_pcEntropyDecoder->setBitstream      ( ppcSubstreams[0] );
    139   m_pcEntropyDecoder->resetEntropy      (pcSlice);
    140 #if H_3D_NBDV
     121    ppcSubstreams[ui] = pcBitstream->extractSubstream(ui+1 < uiNumSubstreams ? (pcSlice->getSubstreamSize(ui)<<3) : pcBitstream->getNumBitsLeft());
     122  }
     123
     124#if NH_3D_NBDV
    141125  if(pcSlice->getViewIndex() && !pcSlice->getIsDepth()) //Notes from QC: this condition shall be changed once the configuration is completed, e.g. in pcSlice->getSPS()->getMultiviewMvPredMode() || ARP in prev. HTM. Remove this comment once it is done.
    142126  {
    143     Int iColPoc = pcSlice->getRefPOC(RefPicList(1-pcSlice->getColFromL0Flag()), pcSlice->getColRefIdx());
    144     rpcPic->setNumDdvCandPics(rpcPic->getDisCandRefPictures(iColPoc));
     127    Int iColPoc = pcSlice->getRefPOC(RefPicList(1 - pcSlice->getColFromL0Flag()), pcSlice->getColRefIdx());
     128    pcPic->setNumDdvCandPics(pcPic->getDisCandRefPictures(iColPoc));
    145129  }
    146130
    147131  if(pcSlice->getViewIndex() && !pcSlice->getIsDepth() && !pcSlice->isIntra()) //Notes from QC: this condition shall be changed once the configuration is completed, e.g. in pcSlice->getSPS()->getMultiviewMvPredMode() || ARP in prev. HTM. Remove this comment once it is done.
    148132  {
    149     rpcPic->checkTemporalIVRef();
     133    pcPic->checkTemporalIVRef();
    150134  }
    151135
    152136  if(pcSlice->getIsDepth())
    153137  {
    154     rpcPic->checkTextureRef();
    155   }
    156 #endif
    157 #if H_3D
     138    pcPic->checkTextureRef();
     139  }
     140#endif
     141#if NH_3D
    158142  pcSlice->setDepthToDisparityLUTs();
    159143#endif
    160   m_pcSbacDecoders[0].load(m_pcSbacDecoder);
    161   m_pcSliceDecoder->decompressSlice( ppcSubstreams, rpcPic, m_pcSbacDecoder, m_pcSbacDecoders);
    162   m_pcEntropyDecoder->setBitstream(  ppcSubstreams[uiNumSubstreams-1] );
     144
     145  m_pcSliceDecoder->decompressSlice( ppcSubstreams, pcPic, m_pcSbacDecoder);
    163146  // deallocate all created substreams, including internal buffers.
    164147  for (UInt ui = 0; ui < uiNumSubstreams; ui++)
    165148  {
    166     ppcSubstreams[ui]->deleteFifo();
    167149    delete ppcSubstreams[ui];
    168150  }
    169151  delete[] ppcSubstreams;
    170   delete[] m_pcSbacDecoders; m_pcSbacDecoders = NULL;
    171   delete[] m_pcBinCABACs; m_pcBinCABACs = NULL;
    172152
    173153  m_dDecTime += (Double)(clock()-iBeforeTime) / CLOCKS_PER_SEC;
    174154}
    175155
    176 Void TDecGop::filterPicture(TComPic*& rpcPic)
    177 {
    178   TComSlice*  pcSlice = rpcPic->getSlice(rpcPic->getCurrSliceIdx());
     156Void TDecGop::filterPicture(TComPic* pcPic)
     157{
     158  TComSlice*  pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx());
    179159
    180160  //-- For time output for each slice
    181   long iBeforeTime = clock();
     161  clock_t iBeforeTime = clock();
    182162
    183163  // deblocking filter
    184164  Bool bLFCrossTileBoundary = pcSlice->getPPS()->getLoopFilterAcrossTilesEnabledFlag();
    185165  m_pcLoopFilter->setCfg(bLFCrossTileBoundary);
    186   m_pcLoopFilter->loopFilterPic( rpcPic );
     166  m_pcLoopFilter->loopFilterPic( pcPic );
     167
    187168  if( pcSlice->getSPS()->getUseSAO() )
    188169  {
    189     m_pcSAO->reconstructBlkSAOParams(rpcPic, rpcPic->getPicSym()->getSAOBlkParam());
    190     m_pcSAO->SAOProcess(rpcPic);
    191     m_pcSAO->PCMLFDisableProcess(rpcPic);
    192   }
    193 #if H_3D
    194   rpcPic->compressMotion(2);
    195 #endif
    196 #if !H_3D
    197   rpcPic->compressMotion();
     170    m_pcSAO->reconstructBlkSAOParams(pcPic, pcPic->getPicSym()->getSAOBlkParam());
     171    m_pcSAO->SAOProcess(pcPic);
     172    m_pcSAO->PCMLFDisableProcess(pcPic);
     173  }
     174#if NH_3D
     175  pcPic->compressMotion(2);
     176#else
     177  pcPic->compressMotion();
    198178#endif
    199179  Char c = (pcSlice->isIntra() ? 'I' : pcSlice->isInterP() ? 'P' : 'B');
    200   if (!pcSlice->isReferenced()) c += 32;
     180  if (!pcSlice->isReferenced())
     181  {
     182    c += 32;
     183  }
    201184
    202185  //-- For time output for each slice
    203 #if H_MV
    204   printf("\nLayer %2d   POC %4d TId: %1d ( %c-SLICE, QP%3d ) ", pcSlice->getLayerId(),
     186#if NH_MV
     187  printf("Layer %2d   POC %4d TId: %1d ( %c-SLICE, QP%3d ) ", pcSlice->getLayerId(),
    205188                                                              pcSlice->getPOC(),
    206189                                                              pcSlice->getTLayer(),
     
    208191                                                              pcSlice->getSliceQp() );
    209192#else
    210   printf("\nPOC %4d TId: %1d ( %c-SLICE, QP%3d ) ", pcSlice->getPOC(),
    211                                                     pcSlice->getTLayer(),
    212                                                     c,
    213                                                     pcSlice->getSliceQp() );
     193  printf("POC %4d TId: %1d ( %c-SLICE, QP%3d ) ", pcSlice->getPOC(),
     194                                                  pcSlice->getTLayer(),
     195                                                  c,
     196                                                  pcSlice->getSliceQp() );
    214197#endif
    215198
     
    223206    for (Int iRefIndex = 0; iRefIndex < pcSlice->getNumRefIdx(RefPicList(iRefList)); iRefIndex++)
    224207    {
    225 #if H_MV
     208#if NH_MV
    226209      if( pcSlice->getLayerId() != pcSlice->getRefLayerId( RefPicList(iRefList), iRefIndex ) )
    227210      {
     
    232215#endif
    233216      printf ("%d ", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex));
    234 #if H_MV
     217#if NH_MV
    235218      }
    236219#endif
     
    240223  if (m_decodedPictureHashSEIEnabled)
    241224  {
    242     SEIMessages pictureHashes = getSeisByType(rpcPic->getSEIs(), SEI::DECODED_PICTURE_HASH );
     225    SEIMessages pictureHashes = getSeisByType(pcPic->getSEIs(), SEI::DECODED_PICTURE_HASH );
    243226    const SEIDecodedPictureHash *hash = ( pictureHashes.size() > 0 ) ? (SEIDecodedPictureHash*) *(pictureHashes.begin()) : NULL;
    244227    if (pictureHashes.size() > 1)
     
    246229      printf ("Warning: Got multiple decoded picture hash SEI messages. Using first.");
    247230    }
    248     calcAndPrintHashStatus(*rpcPic->getPicYuvRec(), hash);
    249   }
    250 #if !H_MV
    251 #if SETTING_PIC_OUTPUT_MARK
    252   rpcPic->setOutputMark(rpcPic->getSlice(0)->getPicOutputFlag() ? true : false);
    253 #else
    254   rpcPic->setOutputMark(true);
    255 #endif
    256   rpcPic->setReconMark(true);
     231    calcAndPrintHashStatus(*(pcPic->getPicYuvRec()), hash, pcSlice->getSPS()->getBitDepths(), m_numberOfChecksumErrorsDetected);
     232  }
     233
     234  printf("\n");
     235#if !NH_MV
     236  pcPic->setOutputMark(pcPic->getSlice(0)->getPicOutputFlag() ? true : false);
     237  pcPic->setReconMark(true);
    257238#endif
    258239}
     
    269250 *            unk         - no SEI message was available for comparison
    270251 */
    271 static void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI)
     252static Void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI, const BitDepths &bitDepths, UInt &numChecksumErrors)
    272253{
    273254  /* calculate MD5sum for entire reconstructed picture */
    274   UChar recon_digest[3][16];
     255  TComPictureHash recon_digest;
    275256  Int numChar=0;
    276257  const Char* hashType = "\0";
     
    280261    switch (pictureHashSEI->method)
    281262    {
    282     case SEIDecodedPictureHash::MD5:
    283       {
    284         hashType = "MD5";
    285         calcMD5(pic, recon_digest);
    286         numChar = 16;
    287         break;
    288       }
    289     case SEIDecodedPictureHash::CRC:
    290       {
    291         hashType = "CRC";
    292         calcCRC(pic, recon_digest);
    293         numChar = 2;
    294         break;
    295       }
    296     case SEIDecodedPictureHash::CHECKSUM:
    297       {
    298         hashType = "Checksum";
    299         calcChecksum(pic, recon_digest);
    300         numChar = 4;
    301         break;
    302       }
    303     default:
    304       {
    305         assert (!"unknown hash type");
    306       }
     263      case SEIDecodedPictureHash::MD5:
     264        {
     265          hashType = "MD5";
     266          numChar = calcMD5(pic, recon_digest, bitDepths);
     267          break;
     268        }
     269      case SEIDecodedPictureHash::CRC:
     270        {
     271          hashType = "CRC";
     272          numChar = calcCRC(pic, recon_digest, bitDepths);
     273          break;
     274        }
     275      case SEIDecodedPictureHash::CHECKSUM:
     276        {
     277          hashType = "Checksum";
     278          numChar = calcChecksum(pic, recon_digest, bitDepths);
     279          break;
     280        }
     281      default:
     282        {
     283          assert (!"unknown hash type");
     284          break;
     285        }
    307286    }
    308287  }
     
    315294  {
    316295    ok = "(OK)";
    317     for(Int yuvIdx = 0; yuvIdx < 3; yuvIdx++)
     296    if (recon_digest != pictureHashSEI->m_pictureHash)
    318297    {
    319       for (UInt i = 0; i < numChar; i++)
    320       {
    321         if (recon_digest[yuvIdx][i] != pictureHashSEI->digest[yuvIdx][i])
    322         {
    323           ok = "(***ERROR***)";
    324           mismatch = true;
    325         }
    326       }
     298      ok = "(***ERROR***)";
     299      mismatch = true;
    327300    }
    328301  }
    329302
    330   printf("[%s:%s,%s] ", hashType, digestToString(recon_digest, numChar), ok);
     303  printf("[%s:%s,%s] ", hashType, hashToString(recon_digest, numChar).c_str(), ok);
    331304
    332305  if (mismatch)
    333306  {
    334     g_md5_mismatch = true;
    335     printf("[rx%s:%s] ", hashType, digestToString(pictureHashSEI->digest, numChar));
     307    numChecksumErrors++;
     308    printf("[rx%s:%s] ", hashType, hashToString(pictureHashSEI->m_pictureHash, numChar).c_str());
    336309  }
    337310}
Note: See TracChangeset for help on using the changeset viewer.