Changeset 1470 in SHVCSoftware for branches/SHM-dev/source/App/TAppDecoder


Ignore:
Timestamp:
9 Sep 2015, 18:31:04 (9 years ago)
Author:
seregin
Message:

port rev 4599

Location:
branches/SHM-dev/source/App/TAppDecoder
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp

    r1467 r1470  
    6464#if Q0074_COLOUR_REMAPPING_SEI
    6565: m_pcSeiColourRemappingInfoPrevious(NULL)
    66 , m_pcPicYuvColourRemapped(NULL)
    6766#endif
    6867{
     
    8079#if Q0074_COLOUR_REMAPPING_SEI
    8180 ,m_pcSeiColourRemappingInfoPrevious(NULL)
    82  ,m_pcPicYuvColourRemapped(NULL)
    8381#endif
    8482{
     
    137135Void TAppDecTop::decode()
    138136{
    139   Int                poc;
     137  Int                 poc;
    140138  TComList<TComPic*>* pcListPic = NULL;
    141139
     
    161159  // create & initialize internal classes
    162160  xCreateDecLib();
    163   xInitDecLib  (); 
     161  xInitDecLib  ();
     162
     163#if Q0074_COLOUR_REMAPPING_SEI
     164  // clear contents of colour-remap-information-SEI output file
     165  if (!m_colourRemapSEIFileName.empty())
     166  {
     167    std::ofstream ofile(m_colourRemapSEIFileName.c_str());
     168    if (!ofile.good() || !ofile.is_open())
     169    {
     170      fprintf(stderr, "\nUnable to open file '%s' for writing colour-remap-information-SEI video\n", m_colourRemapSEIFileName.c_str());
     171      exit(EXIT_FAILURE);
     172    }
     173  }
     174#endif
    164175
    165176  // main decoder loop
     
    446457  m_iPOCLastDisplay += m_iSkipFrame;      // set the last displayed POC correctly for skip forward.
    447458
     459#if Q0074_COLOUR_REMAPPING_SEI
     460  // clear contents of colour-remap-information-SEI output file
     461  if (!m_colourRemapSEIFileName.empty())
     462  {
     463    std::ofstream ofile(m_colourRemapSEIFileName.c_str());
     464    if (!ofile.good() || !ofile.is_open())
     465    {
     466      fprintf(stderr, "\nUnable to open file '%s' for writing colour-remap-information-SEI video\n", m_colourRemapSEIFileName.c_str());
     467      exit(EXIT_FAILURE);
     468    }
     469  }
     470#endif
     471
    448472  // main decoder loop
    449473  Bool openedReconFile = false; // reconstruction file not yet opened. (must be performed after SPS is seen)
     
    645669  m_cTDecTop.destroy();
    646670#endif
     671#if Q0074_COLOUR_REMAPPING_SEI
     672  if (m_pcSeiColourRemappingInfoPrevious != NULL)
     673  {
     674    delete m_pcSeiColourRemappingInfoPrevious;
     675    m_pcSeiColourRemappingInfoPrevious = NULL;
     676  }
     677#endif
    647678}
    648679
     
    688719    delete m_pcSeiColourRemappingInfoPrevious;
    689720    m_pcSeiColourRemappingInfoPrevious = NULL;
    690   }
    691   if (m_pcPicYuvColourRemapped != NULL)
    692   {
    693     m_pcPicYuvColourRemapped->destroy();
    694     delete m_pcPicYuvColourRemapped;
    695     m_pcPicYuvColourRemapped  = NULL;
    696721  }
    697722#endif
     
    929954        if (!m_colourRemapSEIFileName.empty())
    930955        {
    931           xOutputColourRemapPic(pcPic, activeSPS);
     956          xOutputColourRemapPic(pcPic);
    932957        }
    933958#endif
     
    11011126        if (!m_colourRemapSEIFileName.empty())
    11021127        {
    1103           xOutputColourRemapPic(pcPic, &(pcPic->getPicSym()->getSPS()));
     1128          xOutputColourRemapPic(pcPic);
    11041129        }
    11051130#endif
     
    11641189#if Q0074_COLOUR_REMAPPING_SEI
    11651190
    1166 Void TAppDecTop::xOutputColourRemapPic(TComPic* pcPic, const TComSPS* activeSPS)
    1167 {
     1191Void TAppDecTop::xOutputColourRemapPic(TComPic* pcPic)
     1192{
     1193  const TComSPS &sps=pcPic->getPicSym()->getSPS();
    11681194  SEIMessages colourRemappingInfo = getSeisByType(pcPic->getSEIs(), SEI::COLOUR_REMAPPING_INFO );
    11691195  SEIColourRemappingInfo *seiColourRemappingInfo = ( colourRemappingInfo.size() > 0 ) ? (SEIColourRemappingInfo*) *(colourRemappingInfo.begin()) : NULL;
     
    11751201  if (seiColourRemappingInfo)
    11761202  {
    1177     applyColourRemapping(*pcPic->getPicYuvRec(), *seiColourRemappingInfo, *activeSPS);
     1203    applyColourRemapping(*pcPic->getPicYuvRec(), *seiColourRemappingInfo, sps);
     1204
     1205    // save the last CRI SEI received
     1206    if (m_pcSeiColourRemappingInfoPrevious == NULL)
     1207    {
     1208      m_pcSeiColourRemappingInfoPrevious = new SEIColourRemappingInfo();
     1209    }
     1210    m_pcSeiColourRemappingInfoPrevious->copyFrom(*seiColourRemappingInfo);
    11781211  }
    11791212  else  // using the last CRI SEI received
    11801213  {
     1214    // TODO: prevent persistence of CRI SEI across C(L)VS.
    11811215    if (m_pcSeiColourRemappingInfoPrevious != NULL)
    11821216    {
     
    11851219        printf("Warning No SEI-CRI message is present for the current picture, persistence of the CRI is not managed\n");
    11861220      }
    1187       SEIColourRemappingInfo *seiColourRemappingInfoCopy;
    1188       seiColourRemappingInfoCopy = m_pcSeiColourRemappingInfoPrevious;
    1189       applyColourRemapping(*pcPic->getPicYuvRec(), *seiColourRemappingInfoCopy, *activeSPS);
    1190     }
    1191   }
    1192 
    1193   // save the last CRI SEI received
    1194   if( seiColourRemappingInfo != NULL)
    1195   {
    1196     if (m_pcSeiColourRemappingInfoPrevious != NULL)
    1197     {
    1198       delete m_pcSeiColourRemappingInfoPrevious;
    1199       m_pcSeiColourRemappingInfoPrevious = NULL;
    1200     }
    1201     m_pcSeiColourRemappingInfoPrevious = new SEIColourRemappingInfo();
    1202     m_pcSeiColourRemappingInfoPrevious->copyFrom(*seiColourRemappingInfo);
     1221      applyColourRemapping(*pcPic->getPicYuvRec(), *m_pcSeiColourRemappingInfoPrevious, sps);
     1222    }
    12031223  }
    12041224}
     
    13731393
    13741394  const Int maxBitDepth = 16;
    1375   Bool firstPicture = true;
    13761395
    13771396  // create colour remapped picture
    1378   if ( m_pcPicYuvColourRemapped == NULL )
    1379   {
    1380     const ChromaFormat chromaFormatIDC = pic.getChromaFormat();
     1397  if( !criSEI.m_colourRemapCancelFlag && pic.getChromaFormat()!=CHROMA_400) // 4:0:0 not supported.
     1398  {
     1399    const Int          iHeight         = pic.getHeight(COMPONENT_Y);
    13811400    const Int          iWidth          = pic.getWidth(COMPONENT_Y);
    1382     const Int          iHeight         = pic.getHeight(COMPONENT_Y);
    1383     const UInt         uiMaxCuWidth    = activeSPS.getMaxCUWidth();
    1384     const UInt         uiMaxCuHeight   = activeSPS.getMaxCUHeight();
    1385     const UInt         uiMaxDepth      = activeSPS.getMaxTotalCUDepth();
    1386     m_pcPicYuvColourRemapped  = new TComPicYuv;
    1387     m_pcPicYuvColourRemapped->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true );
    1388   }
    1389   else
    1390   {
    1391     firstPicture = false;
    1392   }
    1393 
    1394   if( !criSEI.m_colourRemapCancelFlag )
    1395   {
    1396     const Int  iHeight  = pic.getHeight(COMPONENT_Y);
    1397     const Int  iWidth   = pic.getWidth(COMPONENT_Y);
    1398     const Int  iStride  = pic.getStride(COMPONENT_Y);
    1399     const Int  iCStride = pic.getStride(COMPONENT_Cb);
    1400     const Bool b444     = ( pic.getChromaFormat() == CHROMA_444 );
    1401     const Bool b422     = ( pic.getChromaFormat() == CHROMA_422 );
    1402     const Bool b420     = ( pic.getChromaFormat() == CHROMA_420 );
     1401    const ChromaFormat chromaFormatIDC = pic.getChromaFormat();
     1402
     1403    TComPicYuv picYuvColourRemapped;
     1404    picYuvColourRemapped.createWithoutCUInfo( iWidth, iHeight, chromaFormatIDC );
     1405
     1406    const Int  iStrideIn   = pic.getStride(COMPONENT_Y);
     1407    const Int  iCStrideIn  = pic.getStride(COMPONENT_Cb);
     1408    const Int  iStrideOut  = picYuvColourRemapped.getStride(COMPONENT_Y);
     1409    const Int  iCStrideOut = picYuvColourRemapped.getStride(COMPONENT_Cb);
     1410    const Bool b444        = ( pic.getChromaFormat() == CHROMA_444 );
     1411    const Bool b422        = ( pic.getChromaFormat() == CHROMA_422 );
     1412    const Bool b420        = ( pic.getChromaFormat() == CHROMA_420 );
    14031413
    14041414    std::vector<Int> preLut[3];
     
    14111421    YUVIn[COMPONENT_Cb] = pic.getAddr(COMPONENT_Cb);
    14121422    YUVIn[COMPONENT_Cr] = pic.getAddr(COMPONENT_Cr);
    1413     YUVOut[COMPONENT_Y]  = m_pcPicYuvColourRemapped->getAddr(COMPONENT_Y);
    1414     YUVOut[COMPONENT_Cb] = m_pcPicYuvColourRemapped->getAddr(COMPONENT_Cb);
    1415     YUVOut[COMPONENT_Cr] = m_pcPicYuvColourRemapped->getAddr(COMPONENT_Cr);
    1416 
    1417     Int bitDepth = criSEI.m_colourRemapBitDepth;
    1418     BitDepths bitDepthsCriFile;
    1419     bitDepthsCriFile.recon[CHANNEL_TYPE_LUMA] = bitDepth;
     1423    YUVOut[COMPONENT_Y]  = picYuvColourRemapped.getAddr(COMPONENT_Y);
     1424    YUVOut[COMPONENT_Cb] = picYuvColourRemapped.getAddr(COMPONENT_Cb);
     1425    YUVOut[COMPONENT_Cr] = picYuvColourRemapped.getAddr(COMPONENT_Cr);
     1426
     1427    const Int bitDepth = criSEI.m_colourRemapBitDepth;
     1428    BitDepths        bitDepthsCriFile;
     1429    bitDepthsCriFile.recon[CHANNEL_TYPE_LUMA]   = bitDepth;
    14201430    bitDepthsCriFile.recon[CHANNEL_TYPE_CHROMA] = bitDepth; // Different bitdepth is not implemented
    14211431
     
    14831493      }
    14841494
    1485       YUVIn[COMPONENT_Y]  += iStride;
    1486       YUVOut[COMPONENT_Y] += iStride;
     1495      YUVIn[COMPONENT_Y]  += iStrideIn;
     1496      YUVOut[COMPONENT_Y] += iStrideOut;
    14871497      if( !(b420 && !(y&1)) )
    14881498      {
    1489          YUVIn[COMPONENT_Cb]  += iCStride;
    1490          YUVIn[COMPONENT_Cr]  += iCStride;
    1491          YUVOut[COMPONENT_Cb] += iCStride;
    1492          YUVOut[COMPONENT_Cr] += iCStride;
     1499         YUVIn[COMPONENT_Cb]  += iCStrideIn;
     1500         YUVIn[COMPONENT_Cr]  += iCStrideIn;
     1501         YUVOut[COMPONENT_Cb] += iCStrideOut;
     1502         YUVOut[COMPONENT_Cr] += iCStrideOut;
    14931503      }
    14941504    }
    14951505    //Write remapped picture in display order
    1496     m_pcPicYuvColourRemapped->dump( m_colourRemapSEIFileName, bitDepthsCriFile, !firstPicture );
     1506    picYuvColourRemapped.dump( m_colourRemapSEIFileName, bitDepthsCriFile, true );
     1507    picYuvColourRemapped.destroy();
    14971508  }
    14981509}
     
    15211532
    15221533#if Q0074_COLOUR_REMAPPING_SEI
    1523     if (!m_colourRemapSEIFileName.empty())
    1524     {
    1525       xOutputColourRemapPic(pic, pic->getSlice(0)->getSPS());
     1534    if( !m_colourRemapSEIFileName.empty() )
     1535    {
     1536      xOutputColourRemapPic(pic);
    15261537    }
    15271538#endif
  • branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.h

    r1460 r1470  
    8383#if Q0074_COLOUR_REMAPPING_SEI
    8484  SEIColourRemappingInfo*         m_pcSeiColourRemappingInfoPrevious;
    85   TComPicYuv*                     m_pcPicYuvColourRemapped;       ///< Colour Remapped picture
    8685#endif
    8786
     
    129128private:
    130129  Void applyColourRemapping(const TComPicYuv& pic, SEIColourRemappingInfo& pCriSEI, const TComSPS &activeSPS);
    131   Void xOutputColourRemapPic(TComPic* pcPic, const TComSPS* activeSPS);
     130  Void xOutputColourRemapPic(TComPic* pcPic);
    132131#endif
    133132#if ALIGNED_BUMPING
Note: See TracChangeset for help on using the changeset viewer.