📄 errenc.cpp
字号:
iRowLength_DP[iVPlastMBnum][iBlk] = 0;
if(pmbmd -> m_rgTranspStatus [0] != ALL) {
for (iBlk = Y_BLOCK1; iBlk <= A_BLOCK4; iBlk++) {
iRowLength_DP [iVPlastMBnum][iBlk] = new Int [BLOCK_SIZE];
for ( Int t = 0; t < BLOCK_SIZE; t++)
iRowLength_DP [iVPlastMBnum][iBlk][t] = m_rgiCurrMBCoeffWidth[iBlk][t];
}
}
}
// end HHI
ppxlcOrigMBBY += MB_SIZE;
pmbmd++;
#ifdef __TRACE_AND_STATS_
m_statsVOP += m_statsMB;
#endif // __TRACE_AND_STATS_
ppxlcRefMBY += MB_SIZE;
ppxlcRefMBU += BLOCK_SIZE;
ppxlcRefMBV += BLOCK_SIZE;
ppxlcRefMBBY += MB_SIZE;
ppxlcRefMBBUV += BLOCK_SIZE;
ppxlcOrigMBY += MB_SIZE;
ppxlcOrigMBU += BLOCK_SIZE;
ppxlcOrigMBV += BLOCK_SIZE;
iVPtotal = (int) m_statsVOP.total() - iVPCounter;
if( iVPtotal > m_volmd.bVPBitTh || iVPlastMBnum == m_iNumMB-1 /* last MB in a VOP */) {
// Set to output bitstream
m_pbitstrmOut->SetDontSendBits(FALSE);
// encode video packet
iVPCounter = m_statsVOP.total();
m_statsVP.reset();
if( m_iVPMBnum > 0 )
{
m_statsVP.nBitsHead = codeVideoPacketHeader (m_rgmbmd[m_iVPMBnum].m_stepSize);
bRestartDelayedQP = TRUE;
}
DataPartitioningMotionCoding(m_iVPMBnum, iVPlastMBnum, &m_statsVP, iCoefQ_DP);
m_pbitstrmOut -> putBits (DC_MARKER, NUMBITS_DP_DC_MARKER, "DC_marker");
m_statsVP.nBitsHead += NUMBITS_DP_DC_MARKER;
// 09/19/99 HHI Schueuer: added for sadct
if (!m_volmd.bSadctDisable)
DataPartitioningTextureCoding(m_iVPMBnum, iVPlastMBnum, &m_statsVP, iCoefQ_DP, iRowLength_DP);
else
DataPartitioningTextureCoding(m_iVPMBnum, iVPlastMBnum, &m_statsVP, iCoefQ_DP);
assert( iVPtotal + m_statsVP.nBitsHead == (int) m_statsVP.total() );
m_iVPMBnum = iVPlastMBnum + 1;
}
}
MacroBlockMemory** ppmbmTemp = m_rgpmbmAbove;
m_rgpmbmAbove = m_rgpmbmCurr;
m_rgpmbmCurr = ppmbmTemp;
ppxlcRefY += m_iFrameWidthYxMBSize;
ppxlcRefU += m_iFrameWidthUVxBlkSize;
ppxlcRefV += m_iFrameWidthUVxBlkSize;
ppxlcRefBY += m_iFrameWidthYxMBSize;
ppxlcRefBUV += m_iFrameWidthUVxBlkSize;
ppxlcOrigY += m_iFrameWidthYxMBSize;
ppxlcOrigBY += m_iFrameWidthYxMBSize;
ppxlcOrigU += m_iFrameWidthUVxBlkSize;
ppxlcOrigV += m_iFrameWidthUVxBlkSize;
}
// delete CoefQ_DP
for( Int iMB = 0; iMB < m_iNumMB; iMB++ ) {
for (Int iBlk = 0; iBlk < 6; iBlk++) {
delete [] iCoefQ_DP [iMB] [iBlk];
}
delete [] iCoefQ_DP[iMB];
}
delete [] iCoefQ_DP;
// 09/17/99 HHI Schueuer: delete iRowLength _DP sadct
if (!m_volmd.bSadctDisable) {
for (Int iMB = 0; iMB < m_iNumMB; iMB++) {
for (Int iBlk = 0; iBlk < 11; iBlk++)
delete [] iRowLength_DP[iMB][iBlk];
delete [] iRowLength_DP[iMB];
}
delete [] iRowLength_DP;
}
else {
delete []iRowLength_DP;
}
// end HHI;
// restore normal output stream
m_pbitstrmShapeMBOut = m_pbitstrmOut;
// Set to output bitstream
m_pbitstrmOut->SetDontSendBits(FALSE);
}
Void CVideoObjectEncoder::encodeNSForPVOP_WithShape_DP ()
{
assert( m_volmd.bDataPartitioning );
assert( m_vopmd.vopPredType==PVOP || (m_uiSprite == 2 && m_vopmd.vopPredType==SPRITE) ); // GMC
assert( m_volmd.fAUsage == ONE_BIT && m_volmd.bShapeOnly == FALSE );
assert(m_volmd.nBits==8);
Int iMBX, iMBY;
motionEstPVOP_WithShape ();
// Rate Control
if (m_uiRateControl == RC_MPEG4) {
Double Ec = m_iMAD / (Double) (m_iNumMBY * m_iNumMBX * 16 * 16);
m_statRC.setMad (Ec);
if (m_statRC.noCodedFrame () >= RC_START_RATE_CONTROL) {
UInt newQStep = m_statRC.updateQuanStepsize ();
m_vopmd.intStepDiff = newQStep - m_vopmd.intStep; // DQUANT
m_vopmd.intStep = newQStep;
}
cout << "\t" << "Q:" << "\t\t\t" << m_vopmd.intStep << "\n";
m_statRC.setQc (m_vopmd.intStep);
}
CoordI y = m_rctCurrVOPY.top;
CMBMode* pmbmd = m_rgmbmd;
Int iQPPrev = m_vopmd.intStep;
Int iQPAlphaPrev; // dummy - not used
CMotionVector* pmv = m_rgmv;
CMotionVector* pmvBY = m_rgmvBY;
Int iVPCounter = m_statsVOP.total();
Int iVPtotal;
m_iVPMBnum = 0;
CStatistics m_statsVP(0);
// DCT coefficient buffer for Data Partitioning mode
Int*** iCoefQ_DP = new Int** [m_iNumMB];
// 09/19/99 HHI Schueuer: buffer for rowlength needed by sadct
Int*** iRowLength_DP;
if (!m_volmd.bSadctDisable)
iRowLength_DP = new Int** [m_iNumMB];
else
iRowLength_DP = NULL;
// end HHI
PixelC* ppxlcRefY = (PixelC*) m_pvopcRefQ1->pixelsY () + m_iStartInRefToCurrRctY;
PixelC* ppxlcRefU = (PixelC*) m_pvopcRefQ1->pixelsU () + m_iStartInRefToCurrRctUV;
PixelC* ppxlcRefV = (PixelC*) m_pvopcRefQ1->pixelsV () + m_iStartInRefToCurrRctUV;
PixelC* ppxlcRefBY = (PixelC*) m_pvopcRefQ1->pixelsBY () + m_iStartInRefToCurrRctY;
PixelC* ppxlcRefBUV = (PixelC*) m_pvopcRefQ1->pixelsBUV () + m_iStartInRefToCurrRctUV;
PixelC* ppxlcOrigY = (PixelC*) m_pvopcOrig->pixelsBoundY ();
PixelC* ppxlcOrigU = (PixelC*) m_pvopcOrig->pixelsBoundU ();
PixelC* ppxlcOrigV = (PixelC*) m_pvopcOrig->pixelsBoundV ();
PixelC* ppxlcOrigBY = (PixelC*) m_pvopcOrig->pixelsBoundBY ();
// Added for error resilient mode by Toshiba(1997-11-14)
Bool bCodeVPHeaderNext = FALSE; // needed only for OBMC
Int iTempVPMBnum = 0;
Int iCounter;
// End Toshiba(1997-11-14)
Bool bRestartDelayedQP = TRUE;
for (iMBY = 0; iMBY < m_iNumMBY; iMBY++, y += MB_SIZE) {
PixelC* ppxlcRefMBY = ppxlcRefY;
PixelC* ppxlcRefMBU = ppxlcRefU;
PixelC* ppxlcRefMBV = ppxlcRefV;
PixelC* ppxlcRefMBBY = ppxlcRefBY;
PixelC* ppxlcRefMBBUV = ppxlcRefBUV;
PixelC* ppxlcOrigMBY = ppxlcOrigY;
PixelC* ppxlcOrigMBU = ppxlcOrigU;
PixelC* ppxlcOrigMBV = ppxlcOrigV;
PixelC* ppxlcOrigMBBY = ppxlcOrigBY;
CoordI x = m_rctCurrVOPY.left;
#ifdef __TRACE_AND_STATS_
m_statsMB.reset ();
#endif // __TRACE_AND_STATS_
// initiate advance shape coding
// shape bitstream is set to shape cache
m_pbitstrmShapeMBOut = m_pbitstrmShape_DP[iMBY * m_iNumMBX];
// pmbmd->m_bPadded=FALSE;
// Added for error resilient mode by Toshiba(1997-11-14)
// The following operation is needed only for OBMC
// if( bCodeVPHeaderNext ) {
// iTempVPMBnum = m_iVPMBnum;
// m_iVPMBnum = VPMBnum(0, iMBY);
// }
// End Toshiba(1997-11-14)
copyToCurrBuffJustShape (ppxlcOrigMBBY, m_iFrameWidthY);
// Modified for error resilient mode by Toshiba(1997-11-14)
ShapeMode shpmdColocatedMB;
if(m_vopmd.bShapeCodingType) {
shpmdColocatedMB = m_rgmbmdRef [
min (max (0, iMBY), m_iNumMBYRef - 1) * m_iNumMBXRef].m_shpmd;
encodePVOPMBJustShape(ppxlcRefMBBY, pmbmd, shpmdColocatedMB, pmv, pmvBY, x, y, 0, iMBY);
}
else {
m_statsMB.nBitsShape += codeIntraShape (ppxlcRefMBBY, pmbmd, 0, iMBY);
decideTransparencyStatus (pmbmd, m_ppxlcCurrMBBY);
}
// if( bCodeVPHeaderNext )
// m_iVPMBnum = iTempVPMBnum;
// End Toshiba(1997-11-14)
if(pmbmd->m_bhas4MVForward)
padMotionVectors(pmbmd,pmv);
for (iMBX = 0; iMBX < m_iNumMBX; iMBX++, x += MB_SIZE) {
pmbmd->m_stepSize = iQPPrev + pmbmd->m_intStepDelta;
#ifdef __TRACE_AND_STATS_
m_pbitstrmOut->trace (CSite (iMBX, iMBY), "MB_X_Y (Texture)");
// shape quantization part
m_statsMB.reset ();
#endif // __TRACE_AND_STATS_
Int iVPlastMBnum = iMBY * m_iNumMBX + iMBX;
pmbmd->m_bPadded=FALSE;
if(iMBX<m_iNumMBX-1)
{
// shape bitstream is set to shape cache
m_pbitstrmShapeMBOut = m_pbitstrmShape_DP[iMBY * m_iNumMBX + iMBX + 1];
// Added for error resilient mode by Toshiba(1997-11-14)
// The following operation is needed only for OBMC
if( bCodeVPHeaderNext ) {
iTempVPMBnum = m_iVPMBnum;
m_iVPMBnum = VPMBnum(iMBX+1, iMBY);
}
// End Toshiba(1997-11-14)
// code shape 1mb in advance
copyToCurrBuffJustShape (ppxlcOrigMBBY+MB_SIZE,m_iFrameWidthY);
// Modified for error resilient mode by Toshiba(1997-11-14)
if(m_vopmd.bShapeCodingType) {
shpmdColocatedMB = m_rgmbmdRef [
min (max (0, iMBX+1), m_iNumMBXRef-1) +
min (max (0, iMBY), m_iNumMBYRef-1) * m_iNumMBXRef
].m_shpmd;
encodePVOPMBJustShape(
ppxlcRefMBBY+MB_SIZE, pmbmd+1,
shpmdColocatedMB,
pmv+PVOP_MV_PER_REF_PER_MB,
pmvBY+1, x+MB_SIZE, y,
iMBX+1, iMBY
);
}
else {
m_statsMB.nBitsShape
+= codeIntraShape (
ppxlcRefMBBY+MB_SIZE,
pmbmd+1, iMBX+1, iMBY
);
decideTransparencyStatus (pmbmd+1,
m_ppxlcCurrMBBY);
}
// End Toshiba(1997-11-14)
// Added for error resilient mode by Toshiba(1997-11-14)
// The following operation is needed only for OBMC
if( bCodeVPHeaderNext )
m_iVPMBnum = iTempVPMBnum;
// End Toshiba(1997-11-14)
if((pmbmd+1)->m_bhas4MVForward)
padMotionVectors(pmbmd+1, pmv+PVOP_MV_PER_REF_PER_MB);
}
// Set not to output but count bitstream
m_pbitstrmOut->SetDontSendBits(TRUE);
// copy DCT coefficient to buffer
iCoefQ_DP[iVPlastMBnum] = new Int* [6];
Int iBlk;
for (iBlk = 0; iBlk < 6; iBlk++) {
iCoefQ_DP [iVPlastMBnum] [iBlk] = new Int [BLOCK_SQUARE_SIZE];
}
// 09/19/99 HHI Schueuer: copy rowlength for sadct
if (!m_volmd.bSadctDisable) {
iRowLength_DP[iVPlastMBnum] = new Int* [11];
Int iBlk;
for (iBlk = ALL_Y_BLOCKS; iBlk < ALL_A_BLOCKS; iBlk++)
iRowLength_DP[iVPlastMBnum][iBlk] = 0;
}
// end HHI
if(m_volmd.bShapeOnly==FALSE)
{
if (pmbmd -> m_rgTranspStatus [0] != ALL) {
// need to copy binary shape too since curr buff is future shape
copyToCurrBuffWithShape(ppxlcOrigMBY, ppxlcOrigMBU, ppxlcOrigMBV,
ppxlcRefMBBY, NULL, m_iFrameWidthY, m_iFrameWidthUV);
downSampleBY (m_ppxlcCurrMBBY, m_ppxlcCurrMBBUV);
// 09/19/99 HHI Schueuer: sadct
if (!m_volmd.bSadctDisable){
deriveSADCTRowLengths (m_rgiCurrMBCoeffWidth, m_ppxlcCurrMBBY, m_ppxlcCurrMBBUV, pmbmd->m_rgTranspStatus);
encodePVOPMBTextureWithShape(ppxlcRefMBY, ppxlcRefMBU, ppxlcRefMBV, NULL, pmbmd, pmv, iMBX, iMBY, x, y,
iQPPrev, iQPAlphaPrev, bRestartDelayedQP, m_ppxlcCurrMBBY, m_ppxlcCurrMBBUV);
}
else
encodePVOPMBTextureWithShape(ppxlcRefMBY, ppxlcRefMBU, ppxlcRefMBV, NULL, pmbmd, pmv, iMBX, iMBY, x, y,
iQPPrev, iQPAlphaPrev, bRestartDelayedQP);
// copy DCT coefficient to buffer
for (iBlk = 0; iBlk < 6; iBlk++) {
for( Int t = 0; t < BLOCK_SQUARE_SIZE; t++ )
iCoefQ_DP[iVPlastMBnum][iBlk][t] = m_rgpiCoefQ[iBlk][t];
}
// 09/19/99 HHI Schueuer: copy rowlength for sadct
if (!m_volmd.bSadctDisable) {
for (iBlk = Y_BLOCK1; iBlk <= A_BLOCK4; iBlk++) {
iRowLength_DP [iVPlastMBnum][iBlk] = new Int [BLOCK_SIZE];
for ( Int t = 0; t < BLOCK_SIZE; t++)
iRowLength_DP [iVPlastMBnum][iBlk][t] = m_rgiCurrMBCoeffWidth[iBlk][t];
}
}
// end HHI
if (pmbmd -> m_rgTranspStatus [0] == PARTIAL)
mcPadCurrMB (ppxlcRefMBY, ppxlcRefMBU, ppxlcRefMBV, NULL);
padNeighborTranspMBs (
iMBX, iMBY,
pmbmd,
ppxlcRefMBY, ppxlcRefMBU, ppxlcRefMBV, NULL
);
}
else {
padCurrAndTopTranspMBFromNeighbor (
iMBX, iMBY,
pmbmd,
ppxlcRefMBY, ppxlcRefMBU, ppxlcRefMBV, NULL
);
}
}
// Set to output bitstream
m_pbitstrmOut->SetDontSendBits(FALSE);
pmbmd++;
pmv += PVOP_MV_PER_REF_PER_MB;
pmvBY++;
ppxlcRefMBBY += MB_SIZE;
ppxlcRefMBBUV += BLOCK_SIZE;
ppxlcOrigMBBY += MB_SIZE;
#ifdef __TRACE_AND_STATS_
m_statsVOP += m_statsMB;
#endif // __TRACE_AND_STATS_
ppxlcRefMBY += MB_SIZE;
ppxlcRefMBU += BLOCK_SIZE;
ppxlcRefMBV += BLOCK_SIZE;
ppxlcOrigMBY += MB_SIZE;
ppxlcOrigMBU += BLOCK_SIZE;
ppxlcOrigMBV += BLOCK_SIZE;
iVPtotal = (int) m_statsVOP.total() - iVPCounter;
if( bCodeVPHeaderNext || iVPlastMBnum == m_iNumMB-1 /* last MB in a VOP */) {
// Set to output bitstream
m_pbitstrmOut->SetDontSendBits(FALSE);
// encode video packet
iVPCounter = m_statsVOP.total();
m_statsVP.reset();
if( m_iVPMBnum > 0 )
{
m_statsVP.nBitsHead = codeVideoPacketHeader (m_rgmbmd[m_iVPMBnum].m_stepSize);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -