📄 umc_vc1_dec_mb_bpic_adv.cpp
字号:
VC1SingletonMB* sMB = pContext->m_pSingleMB;
VC1MB* pCurrMB = pContext->m_pCurrMB;
VC1PictureLayerHeader* picLayerHeader = pContext->m_picLayerHeader;
Ipp16s* savedMV = pContext->savedMV_Curr + (sMB->widthMB * sMB->m_currMBYpos
+ sMB->m_currMBXpos)*4*2*2;
Ipp16s Xt,Yt, Xb, Yb;
Ipp16s Xtopf,Ytopf,Xbottomf,Ybottomf;
Ipp16s Xtopb,Ytopb,Xbottomb,Ybottomb;
CalculateMV_Interlace(savedMV,savedMV+4, savedMV+8,savedMV+12,&Xt,&Yt,&Xb,&Yb);
Scale_Direct_MV_Interlace(picLayerHeader,Xt,Yt,&Xtopf,&Ytopf,&Xtopb,&Ytopb);
Scale_Direct_MV_Interlace(picLayerHeader,Xb,Yb,&Xbottomf,&Ybottomf,&Xbottomb,&Ybottomb);
writeMV(pCurrMB,Xtopf,Ytopf,Xbottomf,Ybottomf,0);
writeMV(pCurrMB,Xtopb,Ytopb,Xbottomb,Ybottomb,1);
return VC1_OK;
}
static const B_MB_DECODE B_InterlaceFrame_MB_Dispatch_table[] =
{
(B_MB_DECODE)(MBLayer_InterlaceFrameBpicture_NONDIRECT_Decode),
(B_MB_DECODE)(MBLayer_InterlaceFrameBpicture_SKIP_NONDIRECT_Decode),
};
//Figure 20: Syntax diagram for frame MB layer in interlace-coded B picture
VC1Status MBLayer_Frame_InterlacedBpicture(VC1Context* pContext)
{
VC1MB* pCurrMB = pContext->m_pCurrMB;
VC1SingletonMB* sMB = pContext->m_pSingleMB;
VC1PictureLayerHeader* picLayerHeader = pContext->m_picLayerHeader;
Ipp32s DIRECTBBIT=0;
Ipp32s SKIPMBBIT=0;
Ipp32s blk_num;
Ipp32u ACPRED = 0;
Ipp32u tempValue;
VC1Status vc1Res = VC1_OK;
pCurrMB->m_cbpBits = 0;
sMB->m_ubNumFirstCodedBlk = 0;
#ifdef VC1_DEBUG_ON
VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_POSITION,VM_STRING("\t\t\tX: %d, Y: %d\n"),
sMB->m_currMBXpos, sMB->m_currMBYpos);
#endif
memset(pContext->m_pBlock, 0, sizeof(Ipp16s)*8*8*VC1_NUM_OF_BLOCKS);
pCurrMB->LeftTopRightPositionFlag = CalculateLeftTopRightPositionFlag(sMB);
Set_MQuant(pContext);
//Y
pCurrMB->currYPitch = sMB->currYPitch;
pCurrMB->currYPlane = sMB->currYPlane + pCurrMB->currYPitch*sMB->m_currMBYpos*VC1_PIXEL_IN_LUMA
+ sMB->m_currMBXpos*VC1_PIXEL_IN_LUMA;
//U
pCurrMB->currUPitch = sMB->currUPitch;
pCurrMB->currUPlane = sMB->currUPlane + pCurrMB->currUPitch*sMB->m_currMBYpos*VC1_PIXEL_IN_CHROMA
+ sMB->m_currMBXpos*VC1_PIXEL_IN_CHROMA;
//V
pCurrMB->currVPitch = sMB->currVPitch;
pCurrMB->currVPlane = sMB->currVPlane + pCurrMB->currVPitch*sMB->m_currMBYpos*VC1_PIXEL_IN_CHROMA
+ sMB->m_currMBXpos*VC1_PIXEL_IN_CHROMA;
//check SKIPMB mode
{
if(VC1_IS_BITPLANE_RAW_MODE(&picLayerHeader->SKIPMB))
{
VC1_GET_BITS(1, SKIPMBBIT);
}
else
{
SKIPMBBIT = picLayerHeader->SKIPMB.m_databits[sMB->widthMB * sMB->m_currMBYpos + sMB->m_currMBXpos];
}
}
if(SKIPMBBIT == 1)
{
pCurrMB->mbType = VC1_MB_1MV_INTER;
}
else
{
Ipp32s ret;
ret = ippiDecodeHuffmanOne_1u32s (
&pContext->m_bitstream.pBitstream,
&pContext->m_bitstream.bitOffset,
&sMB->MBMODEIndex,
picLayerHeader->m_pMBMode
);
VM_ASSERT(ret == ippStsNoErr);
pCurrMB->mbType = VC1_MB_Mode_PBPic_MBtype_Table[sMB->MBMODEIndex];
}
//INTRA
if(pCurrMB->mbType == VC1_MB_INTRA)
{
for (blk_num = 0; blk_num < VC1_NUM_OF_BLOCKS; blk_num++)
pCurrMB->m_pBlocks[blk_num].blkType = VC1_BLK_INTRA;
//check fieldtx coding mode
{
Ipp32s FIELDTX;
if(VC1_IS_BITPLANE_RAW_MODE(&picLayerHeader->FIELDTX))
{
VC1_GET_BITS(1, FIELDTX);
} else {
FIELDTX = picLayerHeader->FIELDTX.m_databits
[sMB->widthMB * sMB->m_currMBYpos + sMB->m_currMBXpos];
}
pCurrMB->FIELDTX = FIELDTX;
}
VC1_GET_BITS(1, tempValue); //CBPRESENT
if(tempValue == 1) //CBPRESENT
{
//CBPCY decoding
Ipp32s ret;
ret = ippiDecodeHuffmanOne_1u32s(&pContext->m_bitstream.pBitstream,
&pContext->m_bitstream.bitOffset,
&pCurrMB->m_cbpBits,
picLayerHeader->m_pCurrCBPCYtbl);
VM_ASSERT(ret == ippStsNoErr);
}
VC1_GET_BITS(1, ACPRED);
if (picLayerHeader->m_DQuantFRM)
Set_Alt_MQUANT(pContext);
memset(pContext->m_pBlock, 0, sizeof(Ipp16s)*8*8*VC1_NUM_OF_BLOCKS);
CalculateIntraFlag(pContext);
PDCPredictionTable[pContext->m_seqLayerHeader->DQUANT](pContext);
sMB->ZigzagTable = AdvZigZagTables_PBInterlace_luma[ACPRED];
for(blk_num = 0; blk_num < VC1_NUM_OF_LUMA; blk_num++)
{
vc1Res = BLKLayer_Intra_Luma_Adv(pContext, blk_num,ACPRED);
if(vc1Res != VC1_OK)
{
VM_ASSERT(0);
break;
}
}
sMB->ZigzagTable = AdvZigZagTables_PBInterlace_chroma[ACPRED];
for(blk_num; blk_num < VC1_NUM_OF_BLOCKS; blk_num++)
{
vc1Res = BLKLayer_Intra_Chroma_Adv(pContext, blk_num,ACPRED);
if(vc1Res != VC1_OK)
{
VM_ASSERT(0);
break;
}
}
}
else
{
//inter
if(SKIPMBBIT == 0)
pCurrMB->FIELDTX = VC1_MB_Mode_PBPic_FIELDTX_Table[sMB->MBMODEIndex];
// DIRECTBBIT
if(VC1_IS_BITPLANE_RAW_MODE(&picLayerHeader->m_DirectMB))
{
VC1_GET_BITS(1, DIRECTBBIT);
}
else
{
DIRECTBBIT = picLayerHeader->m_DirectMB.m_databits[sMB->widthMB * sMB->m_currMBYpos + sMB->m_currMBXpos];
}
pContext->m_pCurrMB->SkipAndDirectFlag = (Ipp8u)(DIRECTBBIT+(SKIPMBBIT<<1));
STATISTICS_START_TIME(m_timeStatistics->motion_vector_decoding_StartTime);
if (!DIRECTBBIT)
B_InterlaceFrame_MB_Dispatch_table[SKIPMBBIT](pContext);
else if (!SKIPMBBIT)
MBLayer_InterlaceFrameBpicture_DIRECT_Decode(pContext);
else
MBLayer_InterlaceFrameBpicture_SKIP_DIRECT_Decode(pContext);
STATISTICS_END_TIME(m_timeStatistics->motion_vector_decoding_StartTime,
m_timeStatistics->motion_vector_decoding_EndTime,
m_timeStatistics->motion_vector_decoding_TotalTime);
if((picLayerHeader->m_DQuantFRM == 1) && (pCurrMB->m_cbpBits!=0))
Set_Alt_MQUANT(pContext);
if(picLayerHeader->TTMBF==0 && pCurrMB->m_cbpBits &&
pContext->m_seqLayerHeader->VSTRANSFORM)
{
//TTMB
GetTTMB(pContext);
}
CalculateIntraFlag(pContext);
if(SKIPMBBIT == 0)
{
sMB->ZigzagTable = AdvZigZagTables_PBInterlace_luma[ACPRED];
for(blk_num = 0; blk_num < VC1_NUM_OF_LUMA; blk_num++)
{
vc1Res = BLKLayer_Inter_Luma_Adv(pContext, blk_num);
if(vc1Res != VC1_OK)
{
VM_ASSERT(0);
break;
}
}
sMB->ZigzagTable = AdvZigZagTables_PBInterlace_chroma[ACPRED];
for(blk_num; blk_num < VC1_NUM_OF_BLOCKS; blk_num++)
{
vc1Res = BLKLayer_Inter_Chroma_Adv(pContext, blk_num);
if(vc1Res != VC1_OK)
{
VM_ASSERT(0);
break;
}
}
}
}
AssignCodedBlockPattern(pCurrMB,sMB);
return vc1Res;
}
VC1Status MBLayer_InterlaceFieldBpicture_NONDIRECT_Decode(VC1Context* pContext)
{
VC1Status vc1Res = VC1_OK;
Ipp32s i=0;
Ipp32s ret = ippStsNoErr;
VC1MB* pCurrMB = pContext->m_pCurrMB;
VC1SingletonMB* sMB = pContext->m_pSingleMB;
VC1PictureLayerHeader* picLayerHeader = pContext->m_picLayerHeader;
pCurrMB->dmv_x[1][0] = 0;
pCurrMB->dmv_x[0][0] = 0;
pCurrMB->dmv_y[1][0] = 0;
pCurrMB->dmv_y[0][0] = 0;
pCurrMB->predictor_flag[0] = 0;
pCurrMB->predictor_flag[1] = 0;
for (i=0;i<VC1_NUM_OF_BLOCKS;i++)
{
pCurrMB->m_pBlocks[i].blkType= VC1_BLK_INTER8X8;;
}
CalculateIntraFlag(pContext);
if(VC1_GET_MBTYPE(pCurrMB->mbType) == VC1_MB_1MV_INTER)
{
if(VC1_MB_Mode_PBFieldPic_MVData_Table[sMB->MBMODEIndex])
{
pCurrMB->predictor_flag[0] = DecodeMVDiff_TwoReferenceField_Adv(pContext,&pCurrMB->dmv_x[0][0],&pCurrMB->dmv_y[0][0]);//BMV1
}
if((VC1_GET_PREDICT(pCurrMB->mbType)==VC1_MB_INTERP)
&& sMB->INTERPMVP)
{
pCurrMB->predictor_flag[1] = DecodeMVDiff_TwoReferenceField_Adv(pContext,&pCurrMB->dmv_x[1][0],&pCurrMB->dmv_y[1][0]);
//BMV2
} else if ( VC1_GET_PREDICT(pCurrMB->mbType)!=VC1_MB_INTERP)
{
pCurrMB->dmv_x[1][0] = pCurrMB->dmv_x[0][0];
pCurrMB->dmv_y[1][0] = pCurrMB->dmv_y[0][0];
}
}
else
{
//4 MV type
{
//4MVBP
ret = ippiDecodeHuffmanOne_1u32s(&pContext->m_bitstream.pBitstream,
&pContext->m_bitstream.bitOffset,
&pCurrMB->MVBP,
picLayerHeader->m_pMV4BP);
VM_ASSERT(ret == ippStsNoErr);
MBLayer_InterlaceFieldBpicture4MV_Decode(pContext);
}
}
if(VC1_MB_Mode_PBFieldPic_CBPPresent_Table[sMB->MBMODEIndex])
{
//CBPCY
ret = ippiDecodeHuffmanOne_1u32s(&pContext->m_bitstream.pBitstream,
&pContext->m_bitstream.bitOffset,
&pCurrMB->m_cbpBits,
picLayerHeader->m_pCurrCBPCYtbl);
VM_ASSERT(ret == ippStsNoErr);
}
else
{
pCurrMB->m_cbpBits = 0;
}
return vc1Res;
}
VC1Status MBLayer_InterlaceFieldBpicture_NONDIRECT_Predicition(VC1Context* pContext)
{
VC1Status vc1Res = VC1_OK;
Ipp16s X=0,Y=0;
VC1MB* pCurrMB = pContext->m_pCurrMB;
if(VC1_GET_MBTYPE(pCurrMB->mbType) != VC1_MB_1MV_INTER)
{
MBLayer_InterlaceFieldBpicture4MV_Prediction(pContext);
pCurrMB->predictor_flag[0] = 0;
}
Field1MVPrediction(pContext);
switch (pCurrMB->mbType)
{
case (VC1_MB_1MV_INTER|VC1_MB_FORWARD):
{
#ifdef VC1_DEBUG_ON
VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_MV_FIELD,VM_STRING("predictor_flag = %d\n"), pCurrMB->predictor_flag[0]);
#endif
CalculateField1MVTwoReferenceBPic(pContext,&X,&Y,0,&pCurrMB->predictor_flag[0]);
ApplyMVPredictionCalculateTwoReference(pContext->m_picLayerHeader,&X,&Y,pCurrMB->dmv_x[0][0],pCurrMB->dmv_y[0][0],pCurrMB->predictor_flag[0]);
writeMV_w_predict(pContext,X,Y,X,Y,0,pCurrMB->predictor_flag[0]);
#ifdef VC1_DEBUG_ON
VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_MV_FIELD,VM_STRING("\n\n"));
#endif
{
Ipp16s Xbtop = 0;
Ipp16s Ybtop = 0;
#ifdef VC1_DEBUG_ON
VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_MV_FIELD,VM_STRING("predictor_flag = %d\n"), pCurrMB->predictor_flag[1]);
#endif
CalculateField1MVTwoReferenceBPic(pContext, &Xbtop, &Ybtop,1,&pCurrMB->predictor_flag[1]);
writeMV_w_predict(pContext,Xbtop,Ybtop,Xbtop,Ybtop,1,pCurrMB->predictor_flag[1]);
}
}
break;
case (VC1_MB_4MV_INTER|VC1_MB_FORWARD):
{
// need to fill backward population
Ipp32s blk_num;
#ifdef VC1_DEBUG_ON
VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_MV_FIELD,VM_STRING("predictor_flag = %d\n"), pCurrMB->predictor_flag[0]);
#endif
CalculateField1MVTwoReferenceBPic(pContext, &X,&Y,1,&pCurrMB->predictor_flag[0]);
pCurrMB->m_pBlocks[0].mv[1][0] = X;
pCurrMB->m_pBlocks[0].mv[1][1] = Y;
pCurrMB->m_pBlocks[0].mv_s_polarity[1] = 1 - pCurrMB->predictor_flag[0];
#ifdef VC1_DEBUG_ON
VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_MV_FIELD,VM_STRING("\n\n"));
#endif
for( blk_num = 1; blk_num < 4; blk_num++)
{
pCurrMB->m_pBlocks[blk_num].fieldFlag[1] = pCurrMB->fieldFlag[1];
pCurrMB->m_pBlocks[blk_num].mv[1][0] = X;
pCurrMB->m_pBlocks[blk_num].mv[1][1] = Y;
pCurrMB->m_pBlocks[blk_num].mv_s_polarity[1] = 1 - pCurrMB->predictor_flag[0];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -