Ignore:
Timestamp:
28 Oct 2015, 17:46:00 (9 years ago)
Author:
tech
Message:

Update to HM-16.7.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-15.2-dev/source/Lib/TLibVideoIO/TVideoIOYuv.cpp

    r1313 r1360  
    9595}
    9696
     97static Void
     98copyPlane(const TComPicYuv &src, const ComponentID srcPlane, TComPicYuv &dest, const ComponentID destPlane);
    9799
    98100// ====================================================================================================================
     
    116118 * \param internalBitDepth bit-depth array to scale image data to/from when reading/writing.
    117119 */
    118 Void TVideoIOYuv::open( Char* pchFile, Bool bWriteMode, const Int fileBitDepth[MAX_NUM_CHANNEL_TYPE], const Int MSBExtendedBitDepth[MAX_NUM_CHANNEL_TYPE], const Int internalBitDepth[MAX_NUM_CHANNEL_TYPE] )
     120Void TVideoIOYuv::open( const std::string &fileName, Bool bWriteMode, const Int fileBitDepth[MAX_NUM_CHANNEL_TYPE], const Int MSBExtendedBitDepth[MAX_NUM_CHANNEL_TYPE], const Int internalBitDepth[MAX_NUM_CHANNEL_TYPE] )
    119121{
    120122  //NOTE: files cannot have bit depth greater than 16
     
    141143  if ( bWriteMode )
    142144  {
    143     m_cHandle.open( pchFile, ios::binary | ios::out );
     145    m_cHandle.open( fileName.c_str(), ios::binary | ios::out );
    144146
    145147    if( m_cHandle.fail() )
     
    151153  else
    152154  {
    153     m_cHandle.open( pchFile, ios::binary | ios::in );
     155    m_cHandle.open( fileName.c_str(), ios::binary | ios::in );
    154156
    155157    if( m_cHandle.fail() )
     
    217219
    218220  /* fall back to consuming the input */
    219   Char buf[512];
     221  TChar buf[512];
    220222  const streamoff offset_mod_bufsize = offset % sizeof(buf);
    221223  for (streamoff i = 0; i < offset - offset_mod_bufsize; i += sizeof(buf))
     
    274276  const UInt stride_file      = (width444 * (is16bit ? 2 : 1)) >> csx_file;
    275277
    276   UChar  *buf   = new UChar[stride_file];
     278  std::vector<UChar> bufVec(stride_file);
     279  UChar *buf=&(bufVec[0]);
    277280
    278281  if (compID!=COMPONENT_Y && (fileFormat==CHROMA_400 || destFormat==CHROMA_400))
     
    297300      if (fd.eof() || fd.fail() )
    298301      {
    299         delete[] buf;
    300302        return false;
    301303      }
     
    311313      {
    312314        // read a new line
    313         fd.read(reinterpret_cast<Char*>(buf), stride_file);
     315        fd.read(reinterpret_cast<TChar*>(buf), stride_file);
    314316        if (fd.eof() || fd.fail() )
    315317        {
    316           delete[] buf;
    317318          return false;
    318319        }
     
    381382    }
    382383  }
    383   delete[] buf;
    384384  return true;
    385385}
     
    419419  const UInt height_file      = height444>>csy_file;
    420420
    421   UChar  *buf   = new UChar[stride_file];
     421  std::vector<UChar> bufVec(stride_file);
     422  UChar *buf=&(bufVec[0]);
    422423
    423424  if (compID!=COMPONENT_Y && (fileFormat==CHROMA_400 || srcFormat==CHROMA_400))
     
    447448        }
    448449
    449         fd.write(reinterpret_cast<Char*>(buf), stride_file);
     450        fd.write(reinterpret_cast<const TChar*>(buf), stride_file);
    450451        if (fd.eof() || fd.fail() )
    451452        {
    452           delete[] buf;
    453453          return false;
    454454        }
     
    506506        }
    507507
    508         fd.write(reinterpret_cast<Char*>(buf), stride_file);
     508        fd.write(reinterpret_cast<const TChar*>(buf), stride_file);
    509509        if (fd.eof() || fd.fail() )
    510510        {
    511           delete[] buf;
    512511          return false;
    513512        }
     
    521520    }
    522521  }
    523   delete[] buf;
    524522  return true;
    525523}
     
    544542  const UInt height_file      = height444>>csy_file;
    545543
    546   UChar  *buf   = new UChar[stride_file * 2];
     544  std::vector<UChar> bufVec(stride_file * 2);
     545  UChar *buf=&(bufVec[0]);
    547546
    548547  if (compID!=COMPONENT_Y && (fileFormat==CHROMA_400 || srcFormat==CHROMA_400))
     
    577576        }
    578577
    579         fd.write(reinterpret_cast<Char*>(buf), (stride_file * 2));
     578        fd.write(reinterpret_cast<const TChar*>(buf), (stride_file * 2));
    580579        if (fd.eof() || fd.fail() )
    581580        {
    582           delete[] buf;
    583581          return false;
    584582        }
     
    642640        }
    643641
    644         fd.write(reinterpret_cast<Char*>(buf), (stride_file * 2));
     642        fd.write(reinterpret_cast<const TChar*>(buf), (stride_file * 2));
    645643        if (fd.eof() || fd.fail() )
    646644        {
    647           delete[] buf;
    648645          return false;
    649646        }
     
    658655    }
    659656  }
    660   delete[] buf;
    661657  return true;
    662658}
     
    760756  if (ipCSC!=IPCOLOURSPACE_UNCHANGED)
    761757  {
    762     cPicYuvCSCd.create(pPicYuvUser->getWidth(COMPONENT_Y), pPicYuvUser->getHeight(COMPONENT_Y), pPicYuvUser->getChromaFormat(), pPicYuvUser->getWidth(COMPONENT_Y), pPicYuvUser->getHeight(COMPONENT_Y), 0, false);
     758    cPicYuvCSCd.createWithoutCUInfo(pPicYuvUser->getWidth(COMPONENT_Y), pPicYuvUser->getHeight(COMPONENT_Y), pPicYuvUser->getChromaFormat() );
    763759    ColourSpaceConvert(*pPicYuvUser, cPicYuvCSCd, ipCSC, false);
    764760  }
     
    766762
    767763  // compute actual YUV frame size excluding padding size
    768   const Int   iStride444 = pPicYuv->getStride(COMPONENT_Y);
    769   const UInt width444  = pPicYuv->getWidth(COMPONENT_Y) - confLeft - confRight;
    770   const UInt height444 = pPicYuv->getHeight(COMPONENT_Y) -  confTop  - confBottom;
    771764  Bool is16bit = false;
    772765  Bool nonZeroBitDepthShift=false;
    773 
    774   if ((width444 == 0) || (height444 == 0))
    775   {
    776     printf ("\nWarning: writing %d x %d luma sample output picture!", width444, height444);
    777   }
    778766
    779767  for(UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++)
     
    799787  {
    800788    dstPicYuv = new TComPicYuv;
    801     dstPicYuv->create( pPicYuv->getWidth(COMPONENT_Y), pPicYuv->getHeight(COMPONENT_Y), pPicYuv->getChromaFormat(), pPicYuv->getWidth(COMPONENT_Y), pPicYuv->getHeight(COMPONENT_Y), 0, false );
    802     pPicYuv->copyToPic(dstPicYuv);
     789    dstPicYuv->createWithoutCUInfo( pPicYuv->getWidth(COMPONENT_Y), pPicYuv->getHeight(COMPONENT_Y), pPicYuv->getChromaFormat() );
    803790
    804791    for(UInt comp=0; comp<dstPicYuv->getNumberValidComponents(); comp++)
     
    810797      const Pel maxval = b709Compliance? ((0xff << (m_MSBExtendedBitDepth[ch] - 8)) -1) : (1 << m_MSBExtendedBitDepth[ch]) - 1;
    811798
     799      copyPlane(*pPicYuv, compID, *dstPicYuv, compID);
    812800      scalePlane(dstPicYuv->getAddr(compID), dstPicYuv->getStride(compID), dstPicYuv->getWidth(compID), dstPicYuv->getHeight(compID), -m_bitdepthShift[ch], minval, maxval);
    813801    }
     
    817805    dstPicYuv = pPicYuv;
    818806  }
    819 #if NH_3D
    820   for(UInt comp=0; retval && comp< ::getNumberValidComponents(format); comp++)
    821 #else
     807
     808  const Int  stride444 = dstPicYuv->getStride(COMPONENT_Y);
     809  const UInt width444  = dstPicYuv->getWidth(COMPONENT_Y) - confLeft - confRight;
     810  const UInt height444 = dstPicYuv->getHeight(COMPONENT_Y) -  confTop  - confBottom;
     811
     812  if ((width444 == 0) || (height444 == 0))
     813  {
     814    printf ("\nWarning: writing %d x %d luma sample output picture!", width444, height444);
     815  }
     816
    822817  for(UInt comp=0; retval && comp<dstPicYuv->getNumberValidComponents(); comp++)
    823 #endif
    824818  {
    825819    const ComponentID compID = ComponentID(comp);
    826820    const ChannelType ch=toChannelType(compID);
    827     const UInt csx = pPicYuv->getComponentScaleX(compID);
    828     const UInt csy = pPicYuv->getComponentScaleY(compID);
    829     const Int planeOffset =  (confLeft>>csx) + (confTop>>csy) * pPicYuv->getStride(compID);
    830     if (! writePlane(m_cHandle, dstPicYuv->getAddr(compID) + planeOffset, is16bit, iStride444, width444, height444, compID, dstPicYuv->getChromaFormat(), format, m_fileBitdepth[ch]))
     821    const UInt csx = dstPicYuv->getComponentScaleX(compID);
     822    const UInt csy = dstPicYuv->getComponentScaleY(compID);
     823    const Int planeOffset =  (confLeft>>csx) + (confTop>>csy) * dstPicYuv->getStride(compID);
     824    if (! writePlane(m_cHandle, dstPicYuv->getAddr(compID) + planeOffset, is16bit, stride444, width444, height444, compID, dstPicYuv->getChromaFormat(), format, m_fileBitdepth[ch]))
    831825    {
    832826      retval=false;
     
    852846  if (ipCSC!=IPCOLOURSPACE_UNCHANGED)
    853847  {
    854     cPicYuvTopCSCd   .create(pPicYuvUserTop   ->getWidth(COMPONENT_Y), pPicYuvUserTop   ->getHeight(COMPONENT_Y), pPicYuvUserTop   ->getChromaFormat(), pPicYuvUserTop   ->getWidth(COMPONENT_Y), pPicYuvUserTop   ->getHeight(COMPONENT_Y), 0, false);
    855     cPicYuvBottomCSCd.create(pPicYuvUserBottom->getWidth(COMPONENT_Y), pPicYuvUserBottom->getHeight(COMPONENT_Y), pPicYuvUserBottom->getChromaFormat(), pPicYuvUserBottom->getWidth(COMPONENT_Y), pPicYuvUserBottom->getHeight(COMPONENT_Y), 0, false);
     848    cPicYuvTopCSCd   .createWithoutCUInfo(pPicYuvUserTop   ->getWidth(COMPONENT_Y), pPicYuvUserTop   ->getHeight(COMPONENT_Y), pPicYuvUserTop   ->getChromaFormat() );
     849    cPicYuvBottomCSCd.createWithoutCUInfo(pPicYuvUserBottom->getWidth(COMPONENT_Y), pPicYuvUserBottom->getHeight(COMPONENT_Y), pPicYuvUserBottom->getChromaFormat() );
    856850    ColourSpaceConvert(*pPicYuvUserTop,    cPicYuvTopCSCd,    ipCSC, false);
    857851    ColourSpaceConvert(*pPicYuvUserBottom, cPicYuvBottomCSCd, ipCSC, false);
     
    892886    {
    893887      dstPicYuv = new TComPicYuv;
    894       dstPicYuv->create( pPicYuv->getWidth(COMPONENT_Y), pPicYuv->getHeight(COMPONENT_Y), pPicYuv->getChromaFormat(), pPicYuv->getWidth(COMPONENT_Y), pPicYuv->getHeight(COMPONENT_Y), 0, false );
    895       pPicYuv->copyToPic(dstPicYuv);
     888      dstPicYuv->createWithoutCUInfo( pPicYuv->getWidth(COMPONENT_Y), pPicYuv->getHeight(COMPONENT_Y), pPicYuv->getChromaFormat() );
    896889
    897890      for(UInt comp=0; comp<dstPicYuv->getNumberValidComponents(); comp++)
     
    903896        const Pel maxval = b709Compliance? ((0xff << (m_MSBExtendedBitDepth[ch] - 8)) -1) : (1 << m_MSBExtendedBitDepth[ch]) - 1;
    904897
     898        copyPlane(*pPicYuv, compID, *dstPicYuv, compID);
    905899        scalePlane(dstPicYuv->getAddr(compID), dstPicYuv->getStride(compID), dstPicYuv->getWidth(compID), dstPicYuv->getHeight(compID), -m_bitdepthShift[ch], minval, maxval);
    906900      }
     
    916910  assert(dstPicYuvTop->getNumberValidComponents() == dstPicYuvBottom->getNumberValidComponents());
    917911  assert(dstPicYuvTop->getChromaFormat()          == dstPicYuvBottom->getChromaFormat()         );
    918   assert(dstPicYuvTop->getWidth(COMPONENT_Y)      == dstPicYuvBottom->getWidth(COMPONENT_Y)    );
    919   assert(dstPicYuvTop->getHeight(COMPONENT_Y)     == dstPicYuvBottom->getHeight(COMPONENT_Y)    );
    920   assert(dstPicYuvTop->getStride(COMPONENT_Y)     == dstPicYuvBottom->getStride(COMPONENT_Y)    );
    921912
    922913  for(UInt comp=0; retval && comp<dstPicYuvTop->getNumberValidComponents(); comp++)
     
    925916    const ChannelType ch=toChannelType(compID);
    926917
     918    assert(dstPicYuvTop->getWidth          (compID) == dstPicYuvBottom->getWidth          (compID));
     919    assert(dstPicYuvTop->getHeight         (compID) == dstPicYuvBottom->getHeight         (compID));
    927920    assert(dstPicYuvTop->getComponentScaleX(compID) == dstPicYuvBottom->getComponentScaleX(compID));
    928921    assert(dstPicYuvTop->getComponentScaleY(compID) == dstPicYuvBottom->getComponentScaleY(compID));
Note: See TracChangeset for help on using the changeset viewer.