📄 huffman.cpp
字号:
UInt CHuffmanEncoder::encodeSymbol (Int lSymbol, Char* rgchSymbolName, Bool bDontSendBits){ Int lSize=m_pSizeTable[lSymbol]; if (bDontSendBits == TRUE) //for counting bits return (lSize);// Added for Data Partitioning by Toshiba (98-1-16) if(m_pBitStream -> GetDontSendBits()) return (lSize);// End Toshiba(1998-1-16) Int iCode=m_pCodeTable[lSymbol]; Int lPrevCounter = m_pBitStream -> getCounter (); m_pBitStream -> putBits (iCode,lSize, rgchSymbolName); return (m_pBitStream -> getCounter () - lPrevCounter);}CEntropyEncoderSet::CEntropyEncoderSet (COutBitStream &bitStream){ m_pentrencDCT = new CHuffmanEncoder (bitStream, g_rgVlcDCT); m_pentrencDCTIntra = new CHuffmanEncoder (bitStream, g_rgVlcDCTIntra); // Added for data partitioning mode By Toshiba(1998-1-16:DP+RVLC) m_pentrencDCTRVLC = new CHuffmanEncoder (bitStream, g_rgVlcDCTRVLC); m_pentrencDCTIntraRVLC = new CHuffmanEncoder (bitStream, g_rgVlcDCTIntraRVLC); // End Toshiba(1998-1-16:DP+RVLC) m_pentrencMV = new CHuffmanEncoder (bitStream, g_rgVlcMV); m_pentrencMCBPCintra = new CHuffmanEncoder (bitStream, g_rgVlcMCBPCintra); m_pentrencMCBPCinter = new CHuffmanEncoder (bitStream, g_rgVlcMCBPCinter); m_pentrencCBPY = new CHuffmanEncoder (bitStream, g_rgVlcCBPY); m_pentrencCBPY1 = new CHuffmanEncoder (bitStream, g_rgVlcCBPY1); m_pentrencCBPY2 = new CHuffmanEncoder (bitStream, g_rgVlcCBPY2); m_pentrencCBPY3 = new CHuffmanEncoder (bitStream, g_rgVlcCBPY3); m_pentrencIntraDCy = new CHuffmanEncoder (bitStream, g_rgVlcIntraDCy); m_pentrencIntraDCc = new CHuffmanEncoder (bitStream, g_rgVlcIntraDCc); m_pentrencMbTypeBVOP = new CHuffmanEncoder (bitStream, g_rgVlcMbTypeBVOP); m_pentrencWrpPnt = new CHuffmanEncoder (bitStream, g_rgVlcWrpPnt); m_ppentrencShapeMode [0] = new CHuffmanEncoder (bitStream, g_rgVlcShapeMode0); m_ppentrencShapeMode [1] = new CHuffmanEncoder (bitStream, g_rgVlcShapeMode1); m_ppentrencShapeMode [2] = new CHuffmanEncoder (bitStream, g_rgVlcShapeMode2); m_ppentrencShapeMode [3] = new CHuffmanEncoder (bitStream, g_rgVlcShapeMode3); m_ppentrencShapeMode [4] = new CHuffmanEncoder (bitStream, g_rgVlcShapeMode4); m_ppentrencShapeMode [5] = new CHuffmanEncoder (bitStream, g_rgVlcShapeMode5); m_ppentrencShapeMode [6] = new CHuffmanEncoder (bitStream, g_rgVlcShapeMode6); m_pentrencShapeMV1 = new CHuffmanEncoder (bitStream, g_rgVlcShapeMV1); m_pentrencShapeMV2 = new CHuffmanEncoder (bitStream, g_rgVlcShapeMV2); /*ifstream istrmTableDCT; ifstream istrmTableDCTintra; ifstream istrmTableMV; ifstream istrmTableMCBPCintra; ifstream istrmTableMCBPCinter; ifstream istrmTableCBPY; ifstream istrmTableCBPY2; ifstream istrmTableCBPY3;// Added for data partitioning mode By Toshiba(1998-1-16:DP+RVLC) ifstream istrmTableCBPY1DP; ifstream istrmTableCBPY2DP; ifstream istrmTableCBPY3DP;// End Toshiba(1998-1-16:DP+RVLC) ifstream istrmTableIntraDCy; ifstream istrmTableIntraDCc; ifstream istrmMbTypeBVOP; ifstream istrmWrpPnt; ifstream istrmShapeMode [7]; ifstream istrmShapeMv1; ifstream istrmShapeMv2; // Added for data partitioning mode By Toshiba(1998-1-16:DP+RVLC) ifstream istrmTableDCTRVLC; ifstream istrmTableDCTIntraRVLC; // End Toshiba(1998-1-16:DP+RVLC) // get the vm_home value Char *rgchVmHome = getenv ( "VM_HOME" ); assert (rgchVmHome != NULL ); Char rgchFile [100]; strcpy (rgchFile, rgchVmHome); Int iLength = strlen (rgchFile); Char* pch = rgchFile + iLength; FULLNAME (sys, vlcdct.txt); istrmTableDCT.open (rgchFile); FULLNAME (sys, dctin.txt); istrmTableDCTintra.open (rgchFile); FULLNAME (sys, vlcmvd.txt); istrmTableMV.open (rgchFile); FULLNAME (sys, mcbpc1.txt); istrmTableMCBPCintra.open (rgchFile); FULLNAME (sys, mcbpc2.txt); istrmTableMCBPCinter.open (rgchFile); FULLNAME (sys, cbpy.txt); istrmTableCBPY.open (rgchFile); FULLNAME (sys, cbpy2.txt); istrmTableCBPY2.open (rgchFile); FULLNAME (sys, cbpy3.txt); istrmTableCBPY3.open (rgchFile);// Added for data partitioning mode By Toshiba(1998-1-16:DP+RVLC) FULLNAME (sys, cbpy1dp.txt); istrmTableCBPY1DP.open (rgchFile); FULLNAME (sys, cbpy2dp.txt); istrmTableCBPY2DP.open (rgchFile); FULLNAME (sys, cbpy3dp.txt); istrmTableCBPY3DP.open (rgchFile);// End Toshiba(1998-1-16:DP+RVLC) FULLNAME (sys, dcszy.txt); istrmTableIntraDCy.open (rgchFile); FULLNAME (sys, dcszc.txt); istrmTableIntraDCc.open (rgchFile); FULLNAME (sys, mbtyp.txt); istrmMbTypeBVOP.open (rgchFile); FULLNAME (sys, wrppnt.txt); istrmWrpPnt.open (rgchFile); FULLNAME (sys, shpmd0.txt); istrmShapeMode[0].open (rgchFile); FULLNAME (sys, shpmd1.txt); istrmShapeMode[1].open (rgchFile); FULLNAME (sys, shpmd2.txt); istrmShapeMode[2].open (rgchFile); FULLNAME (sys, shpmd3.txt); istrmShapeMode[3].open (rgchFile); FULLNAME (sys, shpmd4.txt); istrmShapeMode[4].open (rgchFile); FULLNAME (sys, shpmd5.txt); istrmShapeMode[5].open (rgchFile); FULLNAME (sys, shpmd6.txt); istrmShapeMode[6].open (rgchFile); FULLNAME (sys, shpmv1.txt); istrmShapeMv1.open (rgchFile); FULLNAME (sys, shpmv2.txt); istrmShapeMv2.open (rgchFile); // Added for data partitioning mode By Toshiba(1998-1-16:DP+RVLC) FULLNAME (sys, rvlcdct.txt); istrmTableDCTRVLC.open (rgchFile); FULLNAME (sys, rvlcin.txt); istrmTableDCTIntraRVLC.open (rgchFile); // End Toshiba(1998-1-16:DP+RVLC) m_pentrencDCT -> loadTable (istrmTableDCT); m_pentrencDCTIntra -> loadTable (istrmTableDCTintra); m_pentrencMV -> loadTable (istrmTableMV); m_pentrencMCBPCintra -> loadTable (istrmTableMCBPCintra); m_pentrencMCBPCinter -> loadTable (istrmTableMCBPCinter); m_pentrencCBPY -> loadTable (istrmTableCBPY); m_pentrencCBPY2 -> loadTable (istrmTableCBPY2); m_pentrencCBPY3 -> loadTable (istrmTableCBPY3); // Added for data partitioning mode By Toshiba(1998-1-16:DP+RVLC) m_pentrencCBPY1DP -> loadTable (istrmTableCBPY1DP); m_pentrencCBPY2DP -> loadTable (istrmTableCBPY2DP); m_pentrencCBPY3DP -> loadTable (istrmTableCBPY3DP); // End Toshiba(1998-1-16:DP+RVLC) m_pentrencIntraDCy -> loadTable (istrmTableIntraDCy); m_pentrencIntraDCc -> loadTable (istrmTableIntraDCc); m_pentrencMbTypeBVOP->loadTable (istrmMbTypeBVOP); m_pentrencWrpPnt->loadTable (istrmWrpPnt); for (iShapeMd = 0; iShapeMd < 7; iShapeMd++) m_ppentrencShapeMode [iShapeMd]->loadTable (istrmShapeMode [iShapeMd]); m_pentrencShapeMV1->loadTable (istrmShapeMv1); m_pentrencShapeMV2->loadTable (istrmShapeMv2); // Added for data partitioning mode By Toshiba(1998-1-16:DP+RVLC) m_pentrencDCTRVLC -> loadTable (istrmTableDCTRVLC); m_pentrencDCTIntraRVLC -> loadTable (istrmTableDCTIntraRVLC); // End Toshiba(1998-1-16:DP+RVLC) */}CEntropyEncoderSet::~CEntropyEncoderSet(){ delete m_pentrencDCT; delete m_pentrencDCTIntra; delete m_pentrencMV; delete m_pentrencMCBPCintra; delete m_pentrencMCBPCinter; delete m_pentrencCBPY; delete m_pentrencCBPY2; delete m_pentrencCBPY3; delete m_pentrencIntraDCy; delete m_pentrencIntraDCc; delete m_pentrencMbTypeBVOP; delete m_pentrencWrpPnt; for (UInt iShapeMd = 0; iShapeMd < 7; iShapeMd++) delete m_ppentrencShapeMode [iShapeMd]; delete m_pentrencShapeMV1; delete m_pentrencShapeMV2; // Added for data partitioning mode By Toshiba(1998-1-16:DP+RVLC) delete m_pentrencDCTRVLC; delete m_pentrencDCTIntraRVLC; // End Toshiba(1998-1-16:DP+RVLC)}CEntropyDecoderSet::CEntropyDecoderSet (CInBitStream &bitStream){ m_pentrdecDCT = new CHuffmanDecoder (bitStream, g_rgVlcDCT); m_pentrdecDCTIntra = new CHuffmanDecoder (bitStream, g_rgVlcDCTIntra); // Added for data partitioning mode By Toshiba(1998-1-16:DP+RVLC) m_pentrdecDCTRVLC = new CHuffmanDecoder (bitStream, g_rgVlcDCTRVLC); m_pentrdecDCTIntraRVLC = new CHuffmanDecoder (bitStream, g_rgVlcDCTIntraRVLC); // End Toshiba(1998-1-16:DP+RVLC) m_pentrdecMV = new CHuffmanDecoder (bitStream, g_rgVlcMV); m_pentrdecMCBPCintra = new CHuffmanDecoder (bitStream, g_rgVlcMCBPCintra); m_pentrdecMCBPCinter = new CHuffmanDecoder (bitStream, g_rgVlcMCBPCinter); m_pentrdecCBPY = new CHuffmanDecoder (bitStream, g_rgVlcCBPY); m_pentrdecCBPY1 = new CHuffmanDecoder (bitStream, g_rgVlcCBPY1); m_pentrdecCBPY2 = new CHuffmanDecoder (bitStream, g_rgVlcCBPY2); m_pentrdecCBPY3 = new CHuffmanDecoder (bitStream, g_rgVlcCBPY3); m_pentrdecIntraDCy = new CHuffmanDecoder (bitStream, g_rgVlcIntraDCy); m_pentrdecIntraDCc = new CHuffmanDecoder (bitStream, g_rgVlcIntraDCc); m_pentrdecMbTypeBVOP = new CHuffmanDecoder (bitStream, g_rgVlcMbTypeBVOP); m_pentrdecWrpPnt = new CHuffmanDecoder (bitStream, g_rgVlcWrpPnt); m_ppentrdecShapeMode [0] = new CHuffmanDecoder (bitStream, g_rgVlcShapeMode0); m_ppentrdecShapeMode [1] = new CHuffmanDecoder (bitStream, g_rgVlcShapeMode1); m_ppentrdecShapeMode [2] = new CHuffmanDecoder (bitStream, g_rgVlcShapeMode2); m_ppentrdecShapeMode [3] = new CHuffmanDecoder (bitStream, g_rgVlcShapeMode3); m_ppentrdecShapeMode [4] = new CHuffmanDecoder (bitStream, g_rgVlcShapeMode4); m_ppentrdecShapeMode [5] = new CHuffmanDecoder (bitStream, g_rgVlcShapeMode5); m_ppentrdecShapeMode [6] = new CHuffmanDecoder (bitStream, g_rgVlcShapeMode6); m_pentrdecShapeMV1 = new CHuffmanDecoder (bitStream, g_rgVlcShapeMV1); m_pentrdecShapeMV2 = new CHuffmanDecoder (bitStream, g_rgVlcShapeMV2);/* ifstream istrmTableDCT; ifstream istrmTableDCTIntra; ifstream istrmTableMV; ifstream istrmTableMCBPCintra; ifstream istrmTableMCBPCinter; ifstream istrmTableCBPY; ifstream istrmTableCBPY2; ifstream istrmTableCBPY3;// Added for data partitioning mode By Toshiba(1998-1-16:DP+RVLC) ifstream istrmTableCBPY1DP; ifstream istrmTableCBPY2DP; ifstream istrmTableCBPY3DP;// End Toshiba(1998-1-16:DP+RVLC) ifstream istrmTableIntraDCy; ifstream istrmTableIntraDCc; ifstream istrmMbTypeBVOP; ifstream istrmWrpPnt; ifstream istrmShapeMode [7]; ifstream istrmShapeMv1; ifstream istrmShapeMv2; // Added for data partitioning mode By Toshiba(1998-1-16:DP+RVLC) ifstream istrmTableDCTRVLC; ifstream istrmTableDCTIntraRVLC; // End Toshiba(1998-1-16:DP+RVLC) // get the vm_home value Char *rgchVmHome = getenv ( "VM_HOME" ); assert (rgchVmHome != NULL ); Char rgchFile [100]; strcpy (rgchFile, rgchVmHome); Int iLength = strlen (rgchFile); Char* pch = rgchFile + iLength; FULLNAME (sys, vlcdct.txt); istrmTableDCT.open (rgchFile); FULLNAME (sys, dctin.txt); istrmTableDCTIntra.open (rgchFile); FULLNAME (sys, vlcmvd.txt); istrmTableMV.open (rgchFile); FULLNAME (sys, mcbpc1.txt); istrmTableMCBPCintra.open (rgchFile); FULLNAME (sys, mcbpc2.txt); istrmTableMCBPCinter.open (rgchFile); FULLNAME (sys, cbpy.txt); istrmTableCBPY.open (rgchFile); FULLNAME (sys, cbpy2.txt); istrmTableCBPY2.open (rgchFile); FULLNAME (sys, cbpy3.txt); istrmTableCBPY3.open (rgchFile); // Added for data partitioning mode By Toshiba(1998-1-16:DP+RVLC) FULLNAME (sys, cbpy1dp.txt); istrmTableCBPY1DP.open (rgchFile); FULLNAME (sys, cbpy2dp.txt); istrmTableCBPY2DP.open (rgchFile); FULLNAME (sys, cbpy3dp.txt); istrmTableCBPY3DP.open (rgchFile);// End Toshiba(1998-1-16:DP+RVLC) FULLNAME (sys, dcszy.txt); istrmTableIntraDCy.open (rgchFile); FULLNAME (sys, dcszc.txt); istrmTableIntraDCc.open (rgchFile); FULLNAME (sys, mbtyp.txt); istrmMbTypeBVOP.open (rgchFile); FULLNAME (sys, wrppnt.txt); istrmWrpPnt.open (rgchFile); FULLNAME (sys, shpmd0.txt); istrmShapeMode[0].open (rgchFile); FULLNAME (sys, shpmd1.txt); istrmShapeMode[1].open (rgchFile); FULLNAME (sys, shpmd2.txt); istrmShapeMode[2].open (rgchFile); FULLNAME (sys, shpmd3.txt); istrmShapeMode[3].open (rgchFile); FULLNAME (sys, shpmd4.txt); istrmShapeMode[4].open (rgchFile); FULLNAME (sys, shpmd5.txt); istrmShapeMode[5].open (rgchFile); FULLNAME (sys, shpmd6.txt); istrmShapeMode[6].open (rgchFile); FULLNAME (sys, shpmv1.txt); istrmShapeMv1.open (rgchFile); FULLNAME (sys, shpmv2.txt); istrmShapeMv2.open (rgchFile); // Added for data partitioning mode By Toshiba(1998-1-16:DP+RVLC) FULLNAME (sys, rvlcdct.txt); istrmTableDCTRVLC.open (rgchFile); FULLNAME (sys, rvlcin.txt); istrmTableDCTIntraRVLC.open (rgchFile); // End Toshiba(1998-1-16:DP+RVLC) m_pentrdecDCT -> loadTable (istrmTableDCT); m_pentrdecDCTIntra -> loadTable (istrmTableDCTIntra); m_pentrdecMV -> loadTable (istrmTableMV); m_pentrdecMCBPCintra -> loadTable (istrmTableMCBPCintra); m_pentrdecMCBPCinter -> loadTable (istrmTableMCBPCinter); m_pentrdecCBPY -> loadTable (istrmTableCBPY); m_pentrdecCBPY2 -> loadTable (istrmTableCBPY2); m_pentrdecCBPY3 -> loadTable (istrmTableCBPY3); // Added for data partitioning mode By Toshiba(1998-1-16:DP+RVLC) m_pentrdecCBPY1DP -> loadTable (istrmTableCBPY1DP); m_pentrdecCBPY2DP -> loadTable (istrmTableCBPY2DP); m_pentrdecCBPY3DP -> loadTable (istrmTableCBPY3DP); // End Toshiba(1998-1-16:DP+RVLC) m_pentrdecIntraDCy -> loadTable (istrmTableIntraDCy); m_pentrdecIntraDCc -> loadTable (istrmTableIntraDCc); m_pentrdecMbTypeBVOP -> loadTable (istrmMbTypeBVOP); m_pentrdecWrpPnt -> loadTable (istrmWrpPnt); for (iShapeMd = 0; iShapeMd < 7; iShapeMd++) m_ppentrdecShapeMode [iShapeMd]->loadTable (istrmShapeMode[iShapeMd]); m_pentrdecShapeMV1->loadTable (istrmShapeMv1); m_pentrdecShapeMV2->loadTable (istrmShapeMv2); // Added for data partitioning mode By Toshiba(1998-1-16:DP+RVLC) m_pentrdecDCTRVLC -> loadTable (istrmTableDCTRVLC); m_pentrdecDCTIntraRVLC -> loadTable (istrmTableDCTIntraRVLC); // End Toshiba(1998-1-16:DP+RVLC) */}CEntropyDecoderSet::~CEntropyDecoderSet(){ delete m_pentrdecDCT; delete m_pentrdecDCTIntra; delete m_pentrdecMV; delete m_pentrdecMCBPCintra; delete m_pentrdecMCBPCinter; delete m_pentrdecCBPY; delete m_pentrdecCBPY1; delete m_pentrdecCBPY2; delete m_pentrdecCBPY3; delete m_pentrdecIntraDCy; delete m_pentrdecIntraDCc; delete m_pentrdecMbTypeBVOP; delete m_pentrdecWrpPnt ; for (UInt iShapeMd = 0; iShapeMd < 7; iShapeMd++) delete m_ppentrdecShapeMode [iShapeMd]; delete m_pentrdecShapeMV1; delete m_pentrdecShapeMV2; // Added for data partitioning mode By Toshiba(1998-1-16:DP+RVLC) delete m_pentrdecDCTRVLC; delete m_pentrdecDCTIntraRVLC; // End Toshiba(1998-1-16:DP+RVLC)}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -