Skip to content
Snippets Groups Projects
DecApp.cpp 39.8 KiB
Newer Older
  • Learn to ignore specific revisions
  •     endPic--;
        Picture *pcPicTop, *pcPicBottom = NULL;
        while (iterPic != endPic)
        {
          pcPicTop = *(iterPic);
          iterPic++;
          pcPicBottom = *(iterPic);
    
    
    Vadim Seregin's avatar
    Vadim Seregin committed
          if( pcPicTop->layerId != layerId && layerId != NOT_VALID )
          {
            continue;
          }
    
    
          if ( pcPicTop->neededForOutput && pcPicBottom->neededForOutput && !(pcPicTop->getPOC()%2) && (pcPicBottom->getPOC() == pcPicTop->getPOC()+1) )
          {
            // write to file
            if ( !m_reconFileName.empty() )
            {
    
              const Window &conf = pcPicTop->cs->pps->getConformanceWindow();
    
              const bool    isTff   = pcPicTop->topField;
    
    
              m_cVideoIOYuvReconFile[pcPicTop->layerId].write( pcPicTop->getRecoBuf(), pcPicBottom->getRecoBuf(),
    
                                            m_outputColourSpaceConvert,
                                            false, // TODO: m_packedYUVMode,
    
                                            conf.getWindowLeftOffset() * SPS::getWinUnitX( pcPicTop->cs->sps->getChromaFormatIdc() ),
                                            conf.getWindowRightOffset() * SPS::getWinUnitX( pcPicTop->cs->sps->getChromaFormatIdc() ),
                                            conf.getWindowTopOffset() * SPS::getWinUnitY( pcPicTop->cs->sps->getChromaFormatIdc() ),
                                            conf.getWindowBottomOffset() * SPS::getWinUnitY( pcPicTop->cs->sps->getChromaFormatIdc() ),
    
    #if JVET_P2008_OUTPUT_LOG
            writeLineToOutputLog(pcPicTop);
            writeLineToOutputLog(pcPicBottom);
    #endif
    
            // update POC of display order
            m_iPOCLastDisplay = pcPicBottom->getPOC();
    
            // erase non-referenced picture in the reference picture list after display
            if( ! pcPicTop->referenced && pcPicTop->reconstructed )
            {
              pcPicTop->reconstructed = false;
            }
            if( ! pcPicBottom->referenced && pcPicBottom->reconstructed )
            {
              pcPicBottom->reconstructed = false;
            }
            pcPicTop->neededForOutput = false;
            pcPicBottom->neededForOutput = false;
    
            if(pcPicTop)
            {
              pcPicTop->destroy();
              delete pcPicTop;
              pcPicTop = NULL;
            }
          }
        }
        if(pcPicBottom)
        {
          pcPicBottom->destroy();
          delete pcPicBottom;
          pcPicBottom = NULL;
        }
      }
      else //Frame decoding
      {
        while (iterPic != pcListPic->end())
        {
          pcPic = *(iterPic);
    
    
    Vadim Seregin's avatar
    Vadim Seregin committed
          if( pcPic->layerId != layerId && layerId != NOT_VALID )
          {
            iterPic++;
            continue;
          }
    
    
          if (pcPic->neededForOutput)
          {
            // write to file
    
            if (!m_reconFileName.empty())
            {
    
    Brian Heng's avatar
    Brian Heng committed
              const Window &conf = pcPic->getConformanceWindow();
    
              const SPS* sps = pcPic->cs->sps;
              ChromaFormat chromaFormatIDC = sps->getChromaFormatIdc();
    
    Vadim Seregin's avatar
    Vadim Seregin committed
              if( m_upscaledOutput )
              {
    
                m_cVideoIOYuvReconFile[pcPic->layerId].writeUpscaledPicture( *sps, *pcPic->cs->pps, pcPic->getRecoBuf(), m_outputColourSpaceConvert, m_packedYUVMode, m_upscaledOutput, NUM_CHROMA_FORMAT, m_bClipOutputVideoToRec709Range );
    
              {
                m_cVideoIOYuvReconFile[pcPic->layerId].write( pcPic->getRecoBuf().get( COMPONENT_Y ).width, pcPic->getRecoBuf().get( COMPONENT_Y ).height, pcPic->getRecoBuf(),
    
                                            conf.getWindowLeftOffset() * SPS::getWinUnitX( chromaFormatIDC ),
                                            conf.getWindowRightOffset() * SPS::getWinUnitX( chromaFormatIDC ),
                                            conf.getWindowTopOffset() * SPS::getWinUnitY( chromaFormatIDC ),
                                            conf.getWindowBottomOffset() * SPS::getWinUnitY( chromaFormatIDC ),
    
                                            NUM_CHROMA_FORMAT, m_bClipOutputVideoToRec709Range );
    
    #if JVET_P2008_OUTPUT_LOG
            writeLineToOutputLog(pcPic);
    #endif
    
            // update POC of display order
            m_iPOCLastDisplay = pcPic->getPOC();
    
            // erase non-referenced picture in the reference picture list after display
            if (!pcPic->referenced && pcPic->reconstructed)
            {
              pcPic->reconstructed = false;
            }
            pcPic->neededForOutput = false;
          }
          if(pcPic != NULL)
          {
            pcPic->destroy();
            delete pcPic;
            pcPic = NULL;
    
    Vadim Seregin's avatar
    Vadim Seregin committed
    
      if( layerId != NOT_VALID )
      {
    
        pcListPic->remove_if([](Picture* p) { return p == nullptr; });
    
      pcListPic->clear();
      m_iPOCLastDisplay = -MAX_INT;
    }
    
    /** \param nalu Input nalu to check whether its LayerId is within targetDecLayerIdSet
     */
    
    #if JVET_Q0814_DPB
    bool DecApp::xIsNaluWithinTargetDecLayerIdSet( const InputNALUnit* nalu ) const
    {
      if( !m_targetDecLayerIdSet.size() ) // By default, the set is empty, meaning all LayerIds are allowed
      {
        return true;
      }
    
      return std::find( m_targetDecLayerIdSet.begin(), m_targetDecLayerIdSet.end(), nalu->m_nuhLayerId ) != m_targetDecLayerIdSet.end();
    }
    
    /** \param nalu Input nalu to check whether its LayerId is within targetOutputLayerIdSet
     */
    bool DecApp::xIsNaluWithinTargetOutputLayerIdSet( const InputNALUnit* nalu ) const
    {
      if( !m_targetOutputLayerIdSet.size() ) // By default, the set is empty, meaning all LayerIds are allowed
      {
        return true;
      }
    
      return std::find( m_targetOutputLayerIdSet.begin(), m_targetOutputLayerIdSet.end(), nalu->m_nuhLayerId ) != m_targetOutputLayerIdSet.end();
    }
    #else
    
    bool DecApp::isNaluWithinTargetDecLayerIdSet( InputNALUnit* nalu )
    {
      if ( m_targetDecLayerIdSet.size() == 0 ) // By default, the set is empty, meaning all LayerIds are allowed
      {
        return true;
      }
      for (std::vector<int>::iterator it = m_targetDecLayerIdSet.begin(); it != m_targetDecLayerIdSet.end(); it++)
      {
        if ( nalu->m_nuhLayerId == (*it) )
        {
          return true;
        }
      }
      return false;
    }
    
    
    /** \param nalu Input nalu to check whether its LayerId is within targetOutputLayerIdSet
     */
    bool DecApp::isNaluWithinTargetOutputLayerIdSet(InputNALUnit* nalu)
    {
      if (m_targetOutputLayerIdSet.size() == 0) // By default, the set is empty, meaning all LayerIds are allowed
      {
        return true;
      }
      for (std::vector<int>::iterator it = m_targetOutputLayerIdSet.begin(); it != m_targetOutputLayerIdSet.end(); it++)
      {
        if (nalu->m_nuhLayerId == (*it))
        {
          return true;
        }
      }
      return false;
    }