📄 vopmbdec.c
字号:
pmbmd->m_bSkip = TRUE; pmbmd->m_mbType = FORWARD; // can be set to FORWARD mode since the result is the same g_NumMVs = TOTAL_16x16_FWD_BWD_MVS; // Initialize the UV MotionVector index g_UVMVId = g_UVMVId2 = 4; // Setup some pointers within the context & initialize some // default values (that remain the same for all MBs) MP4V_INITMBDATA(); if (MP4V_EOF()) {#ifdef ENABLE_PRINTS printf("decodeBVOP : dummy submit-1\n");#endif pMAEContext->dummysubmit = 1; // drop this frame goto SUBMIT_B_CONTEXT; } } else { MP4V_CHECKRESYNCMARKER(&bResyncMark); if (bResyncMark) { decodeVideoPacketHeader(&iCurrentQP); iVideoPacketNumber++; FwdPred0->x = FwdPred0->y = BwdPred0->x = BwdPred0->y = 0;#ifdef ENABLE_INTERLACING FwdPred1->x = FwdPred1->y = BwdPred1->x = BwdPred1->y = 0;#endif } if (MP4V_EOF()) {#ifdef ENABLE_PRINTS printf("decodeBVOP : dummy submit-2\n");#endif pMAEContext->dummysubmit = 1; // drop this frame goto SUBMIT_B_CONTEXT; } pmbmd->m_iVideoPacketNumber = iVideoPacketNumber; //mv out of if by wchen to set even when errR is off; always used in mbdec // End Toshiba(1998-1-16:B-VOP+Error) decodeMBTextureHeadOfBVOP (pmbmd, &iCurrentQP); decodeMVofBVOP (pmv, pmvBackward, pmbmd, pmvRef, pmbmdRef); // Add yet another check for running out of data. Once the MAI buffering scheme is corrected, we need to get rid of these unwanted // EOF checks which aren't needed as per the decoder design & also will give us a big boost in performance if (MP4V_EOF()) {#ifdef ENABLE_PRINTS printf("decodeBVOP : dummy submit-3\n");#endif pMAEContext->dummysubmit = 1; // drop this frame goto SUBMIT_B_CONTEXT; } nMBMode = 0, nMBType = 0;#ifdef ENABLE_INTERLACING if(m_vopmd.bInterlace) { switch (pmbmd->m_mbType) { case FORWARD: nMBMode = MBMODE_FWD_ALL_420; n4MV = pmbmd->m_bhas4MVForward; break; case BACKWARD: nMBMode = MBMODE_BWD_ALL_420; n4MV = pmbmd->m_bhas4MVBackward; break; case DIRECT: case INTERPOLATE: nMBMode = MBMODE_BID_ALL_420; n4MV = pmbmd->m_bhas4MVForward; break; } if (pmbmd->m_bFieldMV) nMBType = MBT_16x8; else { if (n4MV) nMBType = MBT_8x8; else nMBType = MBT_16x16; } } else#endif // Initialize the UV MotionVector index g_UVMVId = g_UVMVId2 = 4; if (pmbmd->m_mbType == DIRECT || pmbmd->m_mbType == INTERPOLATE) {#ifdef DUAL_MODE nMBMode = MBMODE_FWD_ALL_420; if (pmbmd->m_bhas4MVForward != TRUE && pmbmd->m_mbType != DIRECT) { nMBType = MBT_16x16; } else { nMBType = MBT_8x8; } nMBMode |= MBMODE_BWD_ALL_420;#endif nMBMode = MBMODE_BID_ALL_420; if (pmbmd->m_bhas4MVBackward != TRUE && pmbmd->m_mbType != DIRECT) { nMBType = MBT_16x16; g_NumMVs = TOTAL_16x16_BID_MVS; } else { nMBType = MBT_8x8; g_NumMVs = TOTAL_8x8_BID_MVS; g_UVMVId = g_UVMVId2 = 8; } } else { (pmbmd->m_mbType == FORWARD) ? (nMBMode = MBMODE_FWD_ALL_420) : (nMBMode = MBMODE_BWD_ALL_420); if (pmbmd->m_bhas4MVForward == TRUE || pmbmd->m_bhas4MVBackward == TRUE) { nMBType = MBT_8x8; g_NumMVs = TOTAL_8x8_FWD_BWD_MVS; } else { nMBType = MBT_16x16; g_NumMVs = TOTAL_16x16_FWD_BWD_MVS; } }#ifdef ENABLE_INTERLACING printf("Update MBType & MBMode correctly\n");#endif g_pHeader2->mbmode = nMBMode; g_pHeader3->mbtype = nMBType; // Setup some pointers within the context & initialize some default values (that remain the same for all MBs) MP4V_INITMBDATA();#ifdef ENABLE_INTERLACING if (m_vopmd.bInterlace == TRUE && nBldOpt == USE_MAE && pmbmd->m_bFieldMV) { // Do all of the OOF range check only if we are in Interlaced mode Get_BVOP_YUVILMVs (pmv, pmvBackward, pmbmd, iMBX, iMBY, x, y, ppxlcCurrQMBY, ppxlcCurrQMBU, ppxlcCurrQMBV, &m_rctRefVOPY0,&m_rctRefVOPY1); if (nFlipToRef == FLIP_TO_REF && !nDoPadding) { // Copy the reference frame into the m_IFFlipQ0_Y/U/V buffers CopyRefFrameWhenFlipping (m_IFFlipQ0_Y, m_pvopcRefQ0->pixelsY (), iPicWidth, iPicHeight, iPicWidth, iPicWidth + EXPANDY_REF_FRAMEx2); CopyRefFrameWhenFlipping (m_IFFlipQ0_U, m_pvopcRefQ0->pixelsU (), iPicWidth/2, iPicHeight/2, iPicWidth/2, iPicWidth/2 + EXPANDUV_REF_FRAMEx2); CopyRefFrameWhenFlipping (m_IFFlipQ0_V, m_pvopcRefQ0->pixelsV (), iPicWidth/2, iPicHeight/2, iPicWidth/2, iPicWidth/2 + EXPANDUV_REF_FRAMEx2); // Generate the OOF bytes in the m_IFFlipQ0_Y/U/V buffers m_ActiveRef = FORWARD_REFERENCES; repeatPadYOrA (m_IFFlipQ0_Y, (CVOPU8YUVBA *)m_OOFFlipQ0_Y); repeatPadUV ((CVOPU8YUVBA *)m_OOFFlipQ0_Y); // Copy the reference frame into the m_IFFlipQ1_Y/U/V buffers CopyRefFrameWhenFlipping (m_IFFlipQ1_Y, m_pvopcRefQ1->pixelsY (), iPicWidth, iPicHeight, iPicWidth, iPicWidth + EXPANDY_REF_FRAMEx2); CopyRefFrameWhenFlipping (m_IFFlipQ1_U, m_pvopcRefQ1->pixelsU (), iPicWidth/2, iPicHeight/2, iPicWidth/2, iPicWidth/2 + EXPANDUV_REF_FRAMEx2); CopyRefFrameWhenFlipping (m_IFFlipQ1_V, m_pvopcRefQ1->pixelsV (), iPicWidth/2, iPicHeight/2, iPicWidth/2, iPicWidth/2 + EXPANDUV_REF_FRAMEx2); // Generate the OOF bytes in the m_IFFlipQ1_Y/U/V buffers m_ActiveRef = BACKWARD_REFERENCES; repeatPadYOrA (m_IFFlipQ1_Y, (CVOPU8YUVBA *)m_OOFFlipQ1_Y); repeatPadUV ((CVOPU8YUVBA *)m_OOFFlipQ1_Y); // Restore back to the original value m_ActiveRef = FORWARD_REFERENCES; nDoPadding = 1; } }#endif if (!pmbmd->m_bSkip) { DECODETEXTUREINTERMB (pmbmd);#ifdef ENABLE_INTERLACING if (nFlipToRef == FLIP_TO_REF) { m_iFrameWidthY += EXPANDY_REF_FRAMEx2; m_iFrameWidthUV += EXPANDUV_REF_FRAMEx2; motionCompAndAddErrorMB_BVOP (pmv, pmvBackward, pmbmd, iMBX, iMBY, x, y, &m_FlipRctVOPY0, &m_FlipRctVOPY1); } else#endif motionCompAndAddErrorMB_BVOP (pmv, pmvBackward,pmbmd); } else {#ifdef ENABLE_INTERLACING if (m_vopmd.bInterlace) // Need to remove this 'if' (Bob Eifrig) {#ifndef NO_ASSERTS assert(pmbmd->m_mbType == DIRECT);#endif pmbmd->m_vctDirectDeltaMV.x = 0; pmbmd->m_vctDirectDeltaMV.y = 0; memset (m_ppxliErrorMBY, 0, MB_SQUARE_SIZE * sizeof(Int)); memset (m_ppxliErrorMBU, 0, BLOCK_SQUARE_SIZE * sizeof(Int)); memset (m_ppxliErrorMBV, 0, BLOCK_SQUARE_SIZE * sizeof(Int));// HV For Travis if (nFlipToRef == FLIP_TO_REF) { m_iFrameWidthY += EXPANDY_REF_FRAMEx2; m_iFrameWidthUV += EXPANDUV_REF_FRAMEx2; motionCompAndAddErrorMB_BVOP (pmv, pmvBackward, pmbmd, iMBX, iMBY, x, y, &m_FlipRctVOPY0, &m_FlipRctVOPY1); // Since the Final data is written within the above // function, we need to do the decrement there itself// m_iFrameWidthY -= EXPANDY_REF_FRAMEx2;// m_iFrameWidthUV -= EXPANDUV_REF_FRAMEx2; } else { motionCompAndAddErrorMB_BVOP (pmv, pmvBackward, pmbmd, iMBX, iMBY, x, y, &m_rctRefVOPY0, &m_rctRefVOPY1); }// ~HV For Travis } else #endif { // The reference code is processing "SKIPPED" MBs here as well!! motionCompSkipMB_BVOP (pmv, pmvBackward, pmbmd); } } }#ifndef NEW_MAE_DRIVER if (!MP4V_nBytesUsed) { // Fill in all the frame related registers // Assign the FWD TOP pointers pMAERegs->fwd_y_top_ptr = (uint32)m_pMAERef0Y; pMAERegs->fwd_cb_top_ptr = (uint32)m_pMAERef0Y + m_iSizeYPlane; pMAERegs->fwd_cr_top_ptr = (uint32)m_pMAERef0Y + m_iSizeYPlane + m_iSizeUVPlane; // Assign the BWD TOP pointers pMAERegs->bwd_y_top_ptr = (uint32)m_pMAERef1Y; pMAERegs->bwd_cb_top_ptr = (uint32)m_pMAERef1Y + m_iSizeYPlane; pMAERegs->bwd_cr_top_ptr = (uint32)m_pMAERef1Y + m_iSizeYPlane + m_iSizeUVPlane; // FWD BOT pointers are 1 row below the FWD TOP pointers pMAERegs->fwd_y_bot_ptr = (uint32)m_pMAERef0Y + g_pVO->m_iFrameWidthY; pMAERegs->fwd_cb_bot_ptr = (uint32)m_pMAERef0Y + m_iSizeYPlane + g_pVO->m_iFrameWidthUV; pMAERegs->fwd_cr_bot_ptr = (uint32)m_pMAERef0Y + m_iSizeYPlane + m_iSizeUVPlane + g_pVO->m_iFrameWidthUV; // BWD BOT pointers are 1 row below the FWD BOT pointers pMAERegs->bwd_y_bot_ptr = (uint32)m_pMAERef1Y + g_pVO->m_iFrameWidthY; pMAERegs->bwd_cb_bot_ptr = (uint32)m_pMAERef1Y + m_iSizeYPlane + g_pVO->m_iFrameWidthUV; pMAERegs->bwd_cr_bot_ptr = (uint32)m_pMAERef1Y + m_iSizeYPlane + m_iSizeUVPlane + g_pVO->m_iFrameWidthUV; MP4V_FILLMAEREGISTERS(BFRAME, g_pVOP->bInterlace); }#endif#ifdef ENABLE_INTERLACING // When bRefBlksAssigned is FALSE, all the params in pmbmd are not valid since all the fields in this // struct are from the previous MB!! So, lets just reset some values to zero before calling the CModel(MAE) // ******************************************************************************************************* if (!bRefBlksAssigned) { pmbmd->m_bFieldMV = 0; pmbmd->m_bFieldDCT = 0; pmbmd->m_bForwardTop = 0; pmbmd->m_bForwardBottom = 0; pmbmd->m_bBackwardTop = 0; pmbmd->m_bBackwardBottom = 0; } // Interlacing if (pmbmd->m_bFieldMV) { g_pHeader3->fp = MAE_FIELD_PREDICTION; if (!pmbmd->m_bForwardTop) g_pHeader3->ft = 1; if (!pmbmd->m_bForwardBottom) g_pHeader3->fb = 1; if (!pmbmd->m_bBackwardTop) g_pHeader3->bt = 1; if (!pmbmd->m_bBackwardBottom) g_pHeader3->bb = 1; } // Field DCT if (pmbmd->m_bFieldDCT) g_pHeader3->dctt = 1;#endif // Rounding control g_pHeader3->rnd = g_pVOP->iRoundingControl; // Y Precision if (g_pVOL->bQuarterSample) g_pHeader3->mcprecy = MAE_QUARTER_PEL; QueueMB (); if(g_pVO->m_bCodedFutureRef!=FALSE) { pmbmdRef++; pmvRef += PVOP_MV_PER_REF_PER_MB; }#ifdef ENABLE_INTERLACING // Put back to MAE mode if we had flipped if (nFlipToRef == FLIP_TO_REF) { // Update the FlipArray nFlipArray[g_MAEWrapper->Get_MAEConfig_nMB ("CVideoObjectDecoder::decodeBVOP", __LINE__, __FILE__)] = FLIP_TO_REF; nBldOpt = USE_MAE; nFlipToRef = NO_FLIP; }#endif pmbmd++; pmv += BVOP_MV_PER_REF_PER_MB; pmvBackward += BVOP_MV_PER_REF_PER_MB;#ifdef MP4V_DEBUG g_nGlobMB++;#endif#ifdef ENABLE_INTERLACING // Check if the previous MB got flipped, If so, don't call WrapGetNextContext if( nFlipArray[g_MAEWrapper->Get_MAEConfig_nMB ("CVideoObjectDecoder::decodeBVOP", __LINE__, __FILE__)-1] == NO_FLIP)#endif MP4V_WRAPGETNEXTCONTEXT (); } }#ifdef ENABLE_INTERLACING // Due to CModel bug wherein it cannot retain already filled in MB data (due to // the flipping logic), we need to do the copy before calling the CModel if (nDoPadding) CopyCurFrmsForCModel ((PixelC *)m_pvopcCurrQ->pixelsY () + m_iStartInRefToCurrRctY, (PixelC *)m_pvopcCurrQ->pixelsU () + m_iStartInRefToCurrRctUV, (PixelC *)m_pvopcCurrQ->pixelsV () + m_iStartInRefToCurrRctUV, iPicWidth, iPicHeight);#endifSUBMIT_B_CONTEXT:#ifdef ENABLE_PRINTS printf("TNUM = %d PTS = %d\n", pMAEContext->tnum, pMAEContext->pts);#endif // Now that we have queued all the MBs for this frame, let us ask MAE to process the same WrapSubmitMBs();}// Moved from errdec.cppINLINE Int checkStartCode(){ Int nBitsPeeked; Int iStuffedBits = peekBitsTillByteAlign (&nBitsPeeked); #ifndef NO_ASSERTS assert (nBitsPeeked > 0 && nBitsPeeked <= 8);#endif if (iStuffedBits == ((1 << (nBitsPeeked - 1)) - 1)) return (peekBitsFromByteAlign (NUMBITS_START_CODE_PREFIX) == START_CODE_PREFIX); return FALSE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -