Changeset 1386 in 3DVCSoftware for trunk/source/Lib/TLibVideoIO
- Timestamp:
- 13 Nov 2015, 16:29:39 (9 years ago)
- Location:
- trunk/source/Lib/TLibVideoIO
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibVideoIO/TVideoIOYuv.cpp
r1313 r1386 95 95 } 96 96 97 static Void 98 copyPlane(const TComPicYuv &src, const ComponentID srcPlane, TComPicYuv &dest, const ComponentID destPlane); 97 99 98 100 // ==================================================================================================================== … … 116 118 * \param internalBitDepth bit-depth array to scale image data to/from when reading/writing. 117 119 */ 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] )120 Void 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] ) 119 121 { 120 122 //NOTE: files cannot have bit depth greater than 16 … … 141 143 if ( bWriteMode ) 142 144 { 143 m_cHandle.open( pchFile, ios::binary | ios::out );145 m_cHandle.open( fileName.c_str(), ios::binary | ios::out ); 144 146 145 147 if( m_cHandle.fail() ) … … 151 153 else 152 154 { 153 m_cHandle.open( pchFile, ios::binary | ios::in );155 m_cHandle.open( fileName.c_str(), ios::binary | ios::in ); 154 156 155 157 if( m_cHandle.fail() ) … … 217 219 218 220 /* fall back to consuming the input */ 219 Char buf[512];221 TChar buf[512]; 220 222 const streamoff offset_mod_bufsize = offset % sizeof(buf); 221 223 for (streamoff i = 0; i < offset - offset_mod_bufsize; i += sizeof(buf)) … … 274 276 const UInt stride_file = (width444 * (is16bit ? 2 : 1)) >> csx_file; 275 277 276 UChar *buf = new UChar[stride_file]; 278 std::vector<UChar> bufVec(stride_file); 279 UChar *buf=&(bufVec[0]); 277 280 278 281 if (compID!=COMPONENT_Y && (fileFormat==CHROMA_400 || destFormat==CHROMA_400)) … … 297 300 if (fd.eof() || fd.fail() ) 298 301 { 299 delete[] buf;300 302 return false; 301 303 } … … 311 313 { 312 314 // read a new line 313 fd.read(reinterpret_cast< Char*>(buf), stride_file);315 fd.read(reinterpret_cast<TChar*>(buf), stride_file); 314 316 if (fd.eof() || fd.fail() ) 315 317 { 316 delete[] buf;317 318 return false; 318 319 } … … 381 382 } 382 383 } 383 delete[] buf;384 384 return true; 385 385 } … … 419 419 const UInt height_file = height444>>csy_file; 420 420 421 UChar *buf = new UChar[stride_file]; 421 std::vector<UChar> bufVec(stride_file); 422 UChar *buf=&(bufVec[0]); 422 423 423 424 if (compID!=COMPONENT_Y && (fileFormat==CHROMA_400 || srcFormat==CHROMA_400)) … … 447 448 } 448 449 449 fd.write(reinterpret_cast< Char*>(buf), stride_file);450 fd.write(reinterpret_cast<const TChar*>(buf), stride_file); 450 451 if (fd.eof() || fd.fail() ) 451 452 { 452 delete[] buf;453 453 return false; 454 454 } … … 506 506 } 507 507 508 fd.write(reinterpret_cast< Char*>(buf), stride_file);508 fd.write(reinterpret_cast<const TChar*>(buf), stride_file); 509 509 if (fd.eof() || fd.fail() ) 510 510 { 511 delete[] buf;512 511 return false; 513 512 } … … 521 520 } 522 521 } 523 delete[] buf;524 522 return true; 525 523 } … … 544 542 const UInt height_file = height444>>csy_file; 545 543 546 UChar *buf = new UChar[stride_file * 2]; 544 std::vector<UChar> bufVec(stride_file * 2); 545 UChar *buf=&(bufVec[0]); 547 546 548 547 if (compID!=COMPONENT_Y && (fileFormat==CHROMA_400 || srcFormat==CHROMA_400)) … … 577 576 } 578 577 579 fd.write(reinterpret_cast< Char*>(buf), (stride_file * 2));578 fd.write(reinterpret_cast<const TChar*>(buf), (stride_file * 2)); 580 579 if (fd.eof() || fd.fail() ) 581 580 { 582 delete[] buf;583 581 return false; 584 582 } … … 642 640 } 643 641 644 fd.write(reinterpret_cast< Char*>(buf), (stride_file * 2));642 fd.write(reinterpret_cast<const TChar*>(buf), (stride_file * 2)); 645 643 if (fd.eof() || fd.fail() ) 646 644 { 647 delete[] buf;648 645 return false; 649 646 } … … 658 655 } 659 656 } 660 delete[] buf;661 657 return true; 662 658 } … … 760 756 if (ipCSC!=IPCOLOURSPACE_UNCHANGED) 761 757 { 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() ); 763 759 ColourSpaceConvert(*pPicYuvUser, cPicYuvCSCd, ipCSC, false); 764 760 } … … 766 762 767 763 // 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;771 764 Bool is16bit = false; 772 765 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 }778 766 779 767 for(UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) … … 799 787 { 800 788 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() ); 803 790 804 791 for(UInt comp=0; comp<dstPicYuv->getNumberValidComponents(); comp++) … … 810 797 const Pel maxval = b709Compliance? ((0xff << (m_MSBExtendedBitDepth[ch] - 8)) -1) : (1 << m_MSBExtendedBitDepth[ch]) - 1; 811 798 799 copyPlane(*pPicYuv, compID, *dstPicYuv, compID); 812 800 scalePlane(dstPicYuv->getAddr(compID), dstPicYuv->getStride(compID), dstPicYuv->getWidth(compID), dstPicYuv->getHeight(compID), -m_bitdepthShift[ch], minval, maxval); 813 801 } … … 817 805 dstPicYuv = pPicYuv; 818 806 } 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 819 817 #if NH_3D 820 818 for(UInt comp=0; retval && comp< ::getNumberValidComponents(format); comp++) … … 825 823 const ComponentID compID = ComponentID(comp); 826 824 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]))825 const UInt csx = dstPicYuv->getComponentScaleX(compID); 826 const UInt csy = dstPicYuv->getComponentScaleY(compID); 827 const Int planeOffset = (confLeft>>csx) + (confTop>>csy) * dstPicYuv->getStride(compID); 828 if (! writePlane(m_cHandle, dstPicYuv->getAddr(compID) + planeOffset, is16bit, stride444, width444, height444, compID, dstPicYuv->getChromaFormat(), format, m_fileBitdepth[ch])) 831 829 { 832 830 retval=false; … … 852 850 if (ipCSC!=IPCOLOURSPACE_UNCHANGED) 853 851 { 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);852 cPicYuvTopCSCd .createWithoutCUInfo(pPicYuvUserTop ->getWidth(COMPONENT_Y), pPicYuvUserTop ->getHeight(COMPONENT_Y), pPicYuvUserTop ->getChromaFormat() ); 853 cPicYuvBottomCSCd.createWithoutCUInfo(pPicYuvUserBottom->getWidth(COMPONENT_Y), pPicYuvUserBottom->getHeight(COMPONENT_Y), pPicYuvUserBottom->getChromaFormat() ); 856 854 ColourSpaceConvert(*pPicYuvUserTop, cPicYuvTopCSCd, ipCSC, false); 857 855 ColourSpaceConvert(*pPicYuvUserBottom, cPicYuvBottomCSCd, ipCSC, false); … … 892 890 { 893 891 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); 892 dstPicYuv->createWithoutCUInfo( pPicYuv->getWidth(COMPONENT_Y), pPicYuv->getHeight(COMPONENT_Y), pPicYuv->getChromaFormat() ); 896 893 897 894 for(UInt comp=0; comp<dstPicYuv->getNumberValidComponents(); comp++) … … 903 900 const Pel maxval = b709Compliance? ((0xff << (m_MSBExtendedBitDepth[ch] - 8)) -1) : (1 << m_MSBExtendedBitDepth[ch]) - 1; 904 901 902 copyPlane(*pPicYuv, compID, *dstPicYuv, compID); 905 903 scalePlane(dstPicYuv->getAddr(compID), dstPicYuv->getStride(compID), dstPicYuv->getWidth(compID), dstPicYuv->getHeight(compID), -m_bitdepthShift[ch], minval, maxval); 906 904 } … … 916 914 assert(dstPicYuvTop->getNumberValidComponents() == dstPicYuvBottom->getNumberValidComponents()); 917 915 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) );921 916 922 917 for(UInt comp=0; retval && comp<dstPicYuvTop->getNumberValidComponents(); comp++) … … 925 920 const ChannelType ch=toChannelType(compID); 926 921 922 assert(dstPicYuvTop->getWidth (compID) == dstPicYuvBottom->getWidth (compID)); 923 assert(dstPicYuvTop->getHeight (compID) == dstPicYuvBottom->getHeight (compID)); 927 924 assert(dstPicYuvTop->getComponentScaleX(compID) == dstPicYuvBottom->getComponentScaleX(compID)); 928 925 assert(dstPicYuvTop->getComponentScaleY(compID) == dstPicYuvBottom->getComponentScaleY(compID)); -
trunk/source/Lib/TLibVideoIO/TVideoIOYuv.h
r1313 r1386 64 64 virtual ~TVideoIOYuv() {} 65 65 66 Void 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] ); ///< open or create file66 Void 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] ); ///< open or create file 67 67 Void close (); ///< close file 68 68
Note: See TracChangeset for help on using the changeset viewer.