mbdataaccess.cpp
来自「JMVM MPEG MVC/3DAV 测试平台 国际通用标准」· C++ 代码 · 共 2,199 行 · 第 1/5 页
CPP
2,199 行
Bool bColZeroFlagBlk2 = false;
Bool bColZeroFlagBlk3 = false;
//===== get reference indices and spatially predicted motion vectors =====
Mv acMvPred[2];
SChar ascRefIdx[2];
xSetNeighboursMvPredictor(LIST_0, B4x4Idx(0), B4x4Idx(3) );
if( ( ascRefIdx[LIST_0] = m_cMv3D_A.minRefIdx( m_cMv3D_B ).minRefIdx( m_cMv3D_C ).getRef() ) > 0 )
{
xGetMvPredictorUseNeighbours( acMvPred[LIST_0], ascRefIdx[LIST_0], MEDIAN );
}
xSetNeighboursMvPredictor(LIST_1, B4x4Idx(0), B4x4Idx(3) );
if( ( ascRefIdx[LIST_1] = m_cMv3D_A.minRefIdx( m_cMv3D_B ).minRefIdx( m_cMv3D_C ).getRef() ) > 0 )
{
xGetMvPredictorUseNeighbours( acMvPred[LIST_1], ascRefIdx[LIST_1], MEDIAN );
}
//===== check reference indices =====
if( ascRefIdx[LIST_0] < 1 && ascRefIdx[LIST_1] < 1 )
{
ascRefIdx[LIST_0] = 1;
ascRefIdx[LIST_1] = 1;
bDirectZeroPred = true;
bAllColNonZero = true;
}
//===== check co-located =====
if( ! bAllColNonZero )
{
Bool b = false;
if (m_rcSliceHeader.getIsEncodingFlag())
{
if (m_rcSliceHeader.getRefFrameList(LIST_0)->getEntry(0)->getViewId() == m_rcSliceHeader.getViewId()
&& m_rcSliceHeader.getRefFrameList(LIST_1)->getEntry(0)->getViewId() == m_rcSliceHeader.getViewId() )
b = true;
}
else
{
if( (m_rcSliceHeader.getRefPicList(LIST_0).get(0).getFrame()->getViewId() == m_rcSliceHeader.getViewId())
&& m_rcSliceHeader.getRefPicList(LIST_1).get(0).getFrame()->getViewId()== m_rcSliceHeader.getViewId())
b =true;
}
if (b)
{
SChar scRefIdxCol;
Mv acMvCol[4];
if( ! bAllColNonZero )
{
if( b8x8 )
{
SParIdx4x4 eSubMbPartIdx = ( eParIdx <= PART_8x8_1 ? ( eParIdx == PART_8x8_0 ? SPART_4x4_0 : SPART_4x4_1 )
: ( eParIdx == PART_8x8_2 ? SPART_4x4_2 : SPART_4x4_3 ) );
xGetColocatedMvRefIdx( acMvCol[0], scRefIdxCol, B4x4Idx( eParIdx + eSubMbPartIdx ) );
}
else
{
//===== THIS SHALL NEVER BE CALLED FOR INTERLACED SEQUENCES =====
xGetColocatedMvsRefIdxNonInterlaced( acMvCol, scRefIdxCol, eParIdx );
}
bAllColNonZero = ( scRefIdxCol != 1 );
}
if( ! bAllColNonZero )
{
bColZeroFlagBlk0 = ( acMvCol[0].getAbsHor() <= 1 && acMvCol[0].getAbsVer() <= 1 );
if( ! b8x8 )
{
bColZeroFlagBlk1 = ( acMvCol[1].getAbsHor() <= 1 && acMvCol[1].getAbsVer() <= 1 );
bColZeroFlagBlk2 = ( acMvCol[2].getAbsHor() <= 1 && acMvCol[2].getAbsVer() <= 1 );
bColZeroFlagBlk3 = ( acMvCol[3].getAbsHor() <= 1 && acMvCol[3].getAbsVer() <= 1 );
}
}
}
}
//===== set motion vectors and reference frames =====
for( uiLstIdx = 0; uiLstIdx < 2; uiLstIdx++ )
{
ListIdx eListIdx = ListIdx( uiLstIdx );
MbMotionData& rcMbMotionDataLX = getMbMotionData( eListIdx );
SChar scRefIdx = ascRefIdx[ eListIdx ];
Bool bZeroMv;
//----- set motion vectors -----
if( b8x8 || bAllColNonZero || scRefIdx < 1 )
{
bZeroMv = ( bDirectZeroPred || scRefIdx < 1 || ( scRefIdx == 1 && bColZeroFlagBlk0 ) );
const Mv& rcMv = ( bZeroMv ? Mv::ZeroMv() : acMvPred [ eListIdx ] );
rcMbMotionDataLX.setAllMv( rcMv, eParIdx );
}
else
{
bZeroMv = ( scRefIdx == 1 && bColZeroFlagBlk0 );
const Mv& rcMv0 = ( bZeroMv ? Mv::ZeroMv() : acMvPred [ eListIdx ] );
rcMbMotionDataLX.setAllMv( rcMv0, eParIdx, SPART_4x4_0 );
bZeroMv = ( scRefIdx == 1 && bColZeroFlagBlk1 );
const Mv& rcMv1 = ( bZeroMv ? Mv::ZeroMv() : acMvPred [ eListIdx ] );
rcMbMotionDataLX.setAllMv( rcMv1, eParIdx, SPART_4x4_1 );
bZeroMv = ( scRefIdx == 1 && bColZeroFlagBlk2 );
const Mv& rcMv2 = ( bZeroMv ? Mv::ZeroMv() : acMvPred [ eListIdx ] );
rcMbMotionDataLX.setAllMv( rcMv2, eParIdx, SPART_4x4_2 );
bZeroMv = ( scRefIdx == 1 && bColZeroFlagBlk3 );
const Mv& rcMv3 = ( bZeroMv ? Mv::ZeroMv() : acMvPred [ eListIdx ] );
rcMbMotionDataLX.setAllMv( rcMv3, eParIdx, SPART_4x4_3 );
}
//----- set reference indices and reference pictures -----
rcMbMotionDataLX.setRefIdx ( scRefIdx, eParIdx );
if( m_rcSliceHeader.getRefPicList( eListIdx).size() )
{
const Frame* pcFrame = ( scRefIdx < 1 ? 0 : m_rcSliceHeader.getRefPic ( scRefIdx, eListIdx ).getFrame() );
rcMbMotionDataLX.setRefPic ( pcFrame, eParIdx );
}
}
#if JMVM_ONLY // JVT-U052
if(!getSH().getAVCFlag()) //JVT-W035
{
if( getMbData().getBlkMode( Par8x8( eParIdx < PART_8x8_2 ? (eParIdx>>1) : ((eParIdx - 4)>>1)) ) != BLK_SKIP )
{
if( eParIdx == PART_8x8_0 )
{
Icp& cIcp = getMbData().getMbIcp().getIcp();
getIcpPredictor(cIcp, ascRefIdx[LIST_0], ascRefIdx[LIST_1]);
//{{KHU (JVT-Y033)
if( cIcp.getPredOffset() == 0 )
cIcp.setPredIcAct(0);
else
cIcp.setPredIcAct(1);
//}}
}
else
if( eParIdx == PART_8x8_3 )
{
Icp cIcp, &cPrevIcp = getMbData().getMbIcp().getIcp();
getIcpPredictor(cIcp, ascRefIdx[LIST_0], ascRefIdx[LIST_1]);
cPrevIcp.setPredOffset( (cPrevIcp.getPredOffset() + cIcp.getPredOffset())/4 );
//{{KHU (JVT-Y033)
if( cIcp.getPredOffset() == 0 )
{
cIcp.setPredIcAct(0);
cPrevIcp.setPredIcAct(0);
}
else
{
cIcp.setPredIcAct(1);
cPrevIcp.setPredIcAct(1);
}
//}}
}
else
{
Icp cIcp, &cPrevIcp = getMbData().getMbIcp().getIcp();
getIcpPredictor(cIcp, ascRefIdx[LIST_0], ascRefIdx[LIST_1]);
cPrevIcp.setPredOffset( cPrevIcp.getPredOffset() + cIcp.getPredOffset() );
//{{KHU (JVT-Y033)
if( cIcp.getPredOffset() == 0 )
{
cIcp.setPredIcAct(0);
cPrevIcp.setPredIcAct(0);
}
else
{
cIcp.setPredIcAct(1);
cPrevIcp.setPredIcAct(1);
}
//}}
}
}
}
#endif
}
Bool MbDataAccess::xTemporalDirectModeMvRef( Mv acMv[], SChar ascRefIdx[], LumaIdx cIdx, Bool bFaultTolerant )
{
SChar scRefIdxCol;
Mv cMvCol;
const RefPic& rcRefPicCol = xGetColocatedMvRefPic( cMvCol, scRefIdxCol, cIdx );
//----- get reference index for list 0 -----
if( scRefIdxCol > 0 )
{
if( rcRefPicCol.isAvailable() )
{
const RefPic cRefPic = rcRefPicCol;
ascRefIdx[LIST_0] = getSH().getRefPicList( LIST_0 ).find( cRefPic );
SChar sMaxRefIdx = getSH().getNumRefIdxActive(LIST_0);
if(ascRefIdx[LIST_0] < 1 || ascRefIdx[LIST_0] > sMaxRefIdx)
{
ROFRS( bFaultTolerant, false ); // not allowed
ascRefIdx[LIST_0] = 1;
}
}
else
{
ROFRS( bFaultTolerant, false ); // not allowed
}
}
Int iScale = getSH().getDistScaleFactor( ascRefIdx[LIST_0], ascRefIdx[LIST_1] );
if( iScale == 1024 )
{
acMv[LIST_0] = cMvCol;
acMv[LIST_1] = Mv::ZeroMv();
}
else
{
acMv[LIST_0] = cMvCol.scaleMv( iScale );
acMv[LIST_1] = acMv[LIST_0] - cMvCol;
}
return true; // OK
}
// TMM_EC {{
Bool MbDataAccess::xTemporalDirectModeMvRefVirtual( Mv acMv[], SChar ascRefIdx[], LumaIdx cIdx, Bool bFaultTolerant, RefFrameList& rcRefFrameListL0, RefFrameList& rcRefFrameListL1 )
{
SChar scRefIdxCol;
Mv cMvCol;
const RefPic& rcRefPicCol = xGetColocatedMvRefPic( cMvCol, scRefIdxCol, cIdx );
//----- get reference index for list 0 -----
if( scRefIdxCol > 0 )
{
if( rcRefPicCol.isAvailable() )
{
const RefPic cRefPic = rcRefPicCol;
ascRefIdx[LIST_0] = getSH().getRefPicList( LIST_0 ).find( cRefPic );
SChar sMaxRefIdx = getSH().getNumRefIdxActive(LIST_0);
if(ascRefIdx[LIST_0] < 1 || ascRefIdx[LIST_0] > sMaxRefIdx)
{
ROFRS( bFaultTolerant, false ); // not allowed
ascRefIdx[LIST_0] = 1;
}
}
else
{
ROFRS( bFaultTolerant, false ); // not allowed
}
}
Int iScale = getSH().getDistScaleFactorVirtual( ascRefIdx[LIST_0], ascRefIdx[LIST_1], rcRefFrameListL0, rcRefFrameListL1 );
if( iScale == 1024 )
{
acMv[LIST_0] = cMvCol;
acMv[LIST_1] = Mv::ZeroMv();
}
else
{
acMv[LIST_0] = cMvCol.scaleMv( iScale );
acMv[LIST_1] = acMv[LIST_0] - cMvCol;
}
return true; // OK
}
// TMM_EC }}
Bool MbDataAccess::xTemporalDirectModeMvsRefNonInterlaced( Mv aacMv[][4], SChar ascRefIdx[], ParIdx8x8 eParIdx, Bool bFaultTolerant )
{
SChar scRefIdxCol;
Mv acMvCol[4];
const RefPic& rcRefPicCol = xGetColocatedMvsRefPicNonInterlaced( acMvCol, scRefIdxCol, eParIdx );
//----- get reference index for list 0 -----
if( scRefIdxCol > 0 )
{
if( rcRefPicCol.isAvailable() )
{
const RefPic cRefPic = rcRefPicCol;
ascRefIdx[LIST_0] = getSH().getRefPicList( LIST_0 ).find( cRefPic );
if(ascRefIdx[LIST_0] < 1 || ascRefIdx[LIST_0] > (SChar)getSH().getNumRefIdxActive(LIST_0))
{
ROFRS( bFaultTolerant, false ); // not allowed
ascRefIdx[LIST_0] = 1;
}
}
else
{
ROFRS( bFaultTolerant, false ); // not allowed
}
}
Int iScale = 1024;
if( m_rcSliceHeader.getRefPicList(LIST_1).size() )
{
iScale = m_rcSliceHeader.getDistScaleFactor ( ascRefIdx[LIST_0], ascRefIdx[LIST_1] );
}
else
{
iScale = m_rcSliceHeader.getDistScaleFactorScal ( ascRefIdx[LIST_0], ascRefIdx[LIST_1] );
}
if( iScale == 1024 )
{
for( UInt uiIndex = 0; uiIndex < 4; uiIndex++ )
{
aacMv[LIST_0][uiIndex] = acMvCol[uiIndex];
aacMv[LIST_1][uiIndex] = Mv::ZeroMv();
}
}
else
{
for( UInt uiIndex = 0; uiIndex < 4; uiIndex++ )
{
aacMv[LIST_0][uiIndex] = acMvCol[uiIndex].scaleMv( iScale );
aacMv[LIST_1][uiIndex] = aacMv[LIST_0][uiIndex] - acMvCol[uiIndex];
}
}
return true; // OK
}
Bool MbDataAccess::xTemporalDirectMode( ParIdx8x8 eParIdx, Bool b8x8, Bool bFaultTolerant )
{
Bool bModeAllowed;
SChar ascRefIdx[2] = { 1, 1 };
if( b8x8 )
{
Mv acMv[2];
SParIdx4x4 eSubMbPartIdx = ( eParIdx <= PART_8x8_1 ? ( eParIdx == PART_8x8_0 ? SPART_4x4_0 : SPART_4x4_1 )
: ( eParIdx == PART_8x8_2 ? SPART_4x4_2 : SPART_4x4_3 ) );
B4x4Idx cIdx = B4x4Idx( eParIdx + eSubMbPartIdx );
bModeAllowed = xTemporalDirectModeMvRef( acMv, ascRefIdx, cIdx, bFaultTolerant );
ROFRS( bModeAllowed, bModeAllowed );
for( UInt uiLstIdx = 0; uiLstIdx < 2; uiLstIdx++ )
{
ListIdx eListIdx = ListIdx( uiLstIdx );
MbMotionData& rcMbMotionDataLX = getMbMotionData( eListIdx );
if( m_rcSliceHeader.getRefPicList( LIST_1).size() )
{
const Frame* pcFrame = ( ascRefIdx[eListIdx] < 1 ? 0 : m_rcSliceHeader.getRefPic ( ascRefIdx[eListIdx], eListIdx ).getFrame() );
rcMbMotionDataLX.setRefPic( pcFrame, eParIdx );
}
rcMbMotionDataLX.setAllMv ( acMv [eListIdx], eParIdx );
rcMbMotionDataLX.setRefIdx( ascRefIdx[eListIdx], eParIdx );
}
}
else // do not do this for interlaced stuff
{
Mv aacMv[2][4];
bModeAllowed = xTemporalDirectModeMvsRefNonInterlaced( aacMv, ascRefIdx, eParIdx, bFaultTolerant );
ROFRS( bModeAllowed, bModeAllowed );
for( UInt uiLstIdx = 0; uiLstIdx < 2; uiLstIdx++ )
{
ListIdx eListIdx = ListIdx( uiLstIdx );
MbMotionData& rcMbMotionDataLX = getMbMotionData( eListIdx );
if( m_rcSliceHeader.getRefPicList( LIST_1).size() )
{
const Frame* pcFrame = ( ascRefIdx[eListIdx] < 1 ? 0 : m_rcSliceHeader.getRefPic ( ascRefIdx[eListIdx], eListIdx ).getFrame() );
rcMbMotionDataLX.setRefPic( pcFrame, eParIdx );
}
rcMbMotionDataLX.setRefIdx( ascRefIdx[eListIdx], eParIdx );
rcMbMotionDataLX.setAllMv ( aacMv[eListIdx][0], eParIdx, SPART_4x4_0 );
rcMbMotionDataLX.setAllMv ( aacMv[eListIdx][1], eParIdx, SPART_4x4_1 );
rcMbMotionDataLX.setAllMv ( aacMv[eListIdx][2], eParIdx, SPART_4x4_2 );
rcMbMotionDataLX.setAllMv ( aacMv[eListIdx][3], eParIdx, SPART_4x4_3 );
}
}
return bModeAllowed; // OK
}
//TMM_EC {{
Bool MbDataAccess::xTemporalDirectModeVirtual( ParIdx8x8 eParIdx, Bool b8x8, Bool bFaultTolerant, RefFrameList& rcRefFrameListL0, RefFrameList& rcRefFrameListL1 )
{
Bool bModeAllowed;
SChar ascRefIdx[2] = { 1, 1 };
if( b8x8 )
{
Mv acMv[2];
SParIdx4x4 eSubMbPartIdx = ( eParIdx <= PART_8x8_1 ? ( eParIdx == PART_8x8_0 ? SPART_4x4_0 : SPART_4x4_1 )
: ( eParIdx == PART_8x8_2 ? SPART_4x4_2 : SPART_4x4_3 ) );
B4x4Idx cIdx = B4x4Idx( eParIdx + eSubMbPartIdx );
bModeAllowed = xTemporalDirectModeMvRefVirtual( acMv, ascRefIdx, cIdx, bFaultTolerant, rcRefFrameListL0, rcRefFrameListL1 );
ROFRS( bModeAllowed, bModeAllowed );
for( UInt uiLstIdx = 0; uiLstIdx < 2; uiLstIdx++ )
{
ListIdx eListIdx = ListIdx( uiLstIdx );
MbMotionData& rcMbMotionDataLX = getMbMotionData( eListIdx );
if( m_rcSliceHeader.getNumRefIdxActive( LIST_1) != 0)
{
RefFrameList *pcRefFrameList;
if ( eListIdx == LIST_0)
pcRefFrameList = &rcRefFrameListL0;
else
pcRefFrameList = &rcRefFrameListL1;
}
rcMbMotionDataLX.setAllMv ( acMv [eListIdx], eParIdx );
rcMbMotionDataLX.setRefIdx( ascRefIdx[eListIdx], eParIdx );
}
}
else // do not do this for interlaced stuff
{
Mv aacMv[2][4];
bModeAllowed = xTemporalDirectModeMvsRefNonInterlaced( aacMv, ascRefIdx, eParIdx, bFaultTolerant );
ROFRS( bModeAllowed, bModeAllowed );
for( UInt uiLstIdx = 0; uiLstIdx < 2; uiLstIdx++ )
{
ListIdx eListIdx = ListIdx( uiLstIdx );
MbMotionData& rcMbMotionDataLX = getMbMotionData( eListIdx );
if( m_rcSliceHeader.getRefPicList( LIST_1).size() )
{
const Frame* pcFrame = ( ascRefIdx[eListIdx] < 1 ? 0 : m_rcSliceHeader.getRefPic ( ascRefIdx[eListIdx], eListIdx ).getFrame() );
rcMbMotionDataLX.setRefPic( pcFrame, eParIdx );
}
rcMbMotionDataLX.setRefIdx( ascRefIdx[eListIdx], eParIdx );
rcMbMotionDataLX.setAllMv ( aacMv[eListIdx][0], eParIdx, SPART_4x4_0 );
rcMbMotionDataLX.setAllMv ( aacMv[eListIdx][1], eParIdx, SPART_4x4_1 );
rcMbMotionDataLX.setAllMv ( aacMv[eListIdx][2], eParIdx, SPART_4x4_2 );
rcMbMotionDataLX.setAllMv ( aacMv[eListIdx][3], eParIdx, SPART_4x4_3 );
}
}
return bModeAllowed; // OK
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?