📄 vopmbdec.c
字号:
{ uiGobNumber++; } } else { uiGobNumber++; } iMBXstart=0; iMBXstop= g_pVO->m_ivolWidth/16; iMBYstart=(uiGobNumber*(g_pVO->m_ivolHeight/16)/uiNumberOfGobs)-1; iMBYstop= iMBYstart+(g_pVO->m_ivolHeight/16)/uiNumberOfGobs; } MP4V_nBytesUsed = 0; if (MP4V_EOF()) return; // Call MAE-Wrapper to get a pointer to 1 Frame worth of memory pMAEContext = WrapGetContext (MP4V_nBytesUsed); // Fill in all the frame related registers#ifdef NEW_MAE_DRIVER MP4V_FILLFRAMEPARAMETERS(IFRAME);#else MP4V_FILLMAEREGISTERS(IFRAME, g_pVOP->bInterlace);#endif // Now, get the temporal number MP4V_COMPUTETEMPORALNUMBER(&pMAEContext->tnum, IFRAME); // Set the anchor flag & frametype pMAEContext->anchor_flag = 1;#ifndef NEW_MAE_DRIVER pMAEContext->frametype = IFRAME;#endif for (iMBY = iMBYstart; iMBY < iMBYstop; iMBY++) // [FDS] { for (iMBX = iMBXstart; iMBX < iMBXstop; iMBX++) { SKIPANYSTUFFING(); MP4V_CHECKRESYNCMARKER(&bResyncMark); if (bResyncMark) { decodeVideoPacketHeader(&iCurrentQP); iVideoPacketNumber++; bRestartDelayedQP = TRUE; } pmbmd->m_iVideoPacketNumber = iVideoPacketNumber; //mv out of if by wchen to set even when errR is off; always used in mbdec decodeMBTextureHeadOfIVOP (pmbmd, &iCurrentQP, &bRestartDelayedQP); if (MP4V_EOF()) {#ifdef ENABLE_PRINTS printf("decodeIVOP : dummy submit-1\n");#endif pMAEContext->dummysubmit = 1; // drop this frame goto SUBMIT_I_CONTEXT; } // Setup some pointers within the context & initialize some // default values (that remain the same for all MBs) MP4V_CLEARHEADERWORDS (); if (g_NumWMs) { int8 *pWMatrix = (int8 *)pMAEContext->pWM; Int i, *piQuantizerMatrix; g_pHeader0->wtchgmsk = WM_INTRA_Y | WM_INTRA_C | WM_INTER_Y | WM_INTER_C; // Weighting Matrices data if (g_pVOL->fQuantizer == Q_H263) memset (pWMatrix, 1, (g_NumWMs * WM_DATA_SIZE)); // All 1s in this case else { // Setup Intra WMs piQuantizerMatrix = g_pVOL->rgiIntraQuantizerMatrix; for (i = 0; i < BLOCK_SQUARE_SIZE; i+=4) { pWMatrix[i+3] = pWMatrix[i+3+BLOCK_SQUARE_SIZE] = piQuantizerMatrix [i+0]; pWMatrix[i+2] = pWMatrix[i+2+BLOCK_SQUARE_SIZE] = piQuantizerMatrix [i+1]; pWMatrix[i+1] = pWMatrix[i+1+BLOCK_SQUARE_SIZE] = piQuantizerMatrix [i+2]; pWMatrix[i+0] = pWMatrix[i+0+BLOCK_SQUARE_SIZE] = piQuantizerMatrix [i+3]; } // Setup Inter WMs pWMatrix += (2 * WM_DATA_SIZE); // Move the pointer to the Inter WMs piQuantizerMatrix = g_pVOL->rgiInterQuantizerMatrix; for (i = 0; i < BLOCK_SQUARE_SIZE; i+=4) { pWMatrix[i+3] = pWMatrix[i+3+BLOCK_SQUARE_SIZE] = piQuantizerMatrix [i+0]; pWMatrix[i+2] = pWMatrix[i+2+BLOCK_SQUARE_SIZE] = piQuantizerMatrix [i+1]; pWMatrix[i+1] = pWMatrix[i+1+BLOCK_SQUARE_SIZE] = piQuantizerMatrix [i+2]; pWMatrix[i+0] = pWMatrix[i+0+BLOCK_SQUARE_SIZE] = piQuantizerMatrix [i+3]; } }#ifdef INLINE_MV_CLIPPING if (g_pVOL->bQuarterSample) { // Re-initialize these now for QPEL precision MULTIPLY_BY = 32; LIMIT_FOR_16x16 = -64; LIMIT_FOR_8x8 = -32; SHIFT_BY = 2; }#endif } MP4V_INITMBDATA(); DECODETEXTUREINTRAMB (pmbmd, iMBX, iMBY); // Reset the number of Weighing Matrices g_NumWMs = 0;#ifdef MP4V_DEBUG g_nGlobMB++;#endifEND_OF_DECODING2: pmbmd++; // Get the next context MP4V_WRAPGETNEXTCONTEXT (); } if (MP4V_EOF()) {#ifdef ENABLE_PRINTS printf("decodeIVOP : dummy submit-2\n");#endif pMAEContext->dummysubmit = 1; // drop this frame goto SUBMIT_I_CONTEXT; } // May.25 2000 for MB stuffing decoding on the last MB if (checkStartCode()) // this MB contains only MCBPC stuffing { break; } // ~May.25 2000 for MB stuffing decoding on the last MB ppmbmTemp = g_pVO->m_rgpmbmAbove; g_pVO->m_rgpmbmAbove = g_pVO->m_rgpmbmCurr; g_pVO->m_rgpmbmCurr = ppmbmTemp; } } // KPN Terminate while loop Gob layer [FDS]SUBMIT_I_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(); SKIPANYSTUFFING();}#ifdef UNDER_CE Void decodePVOP () #elseINLINE Void decodePVOP () #endif{ Int iMBX, iMBY, iMBTop; CoordI y = 0; CoordI x = 0; Int iMBXstart, iMBXstop, iMBYstart, iMBYstop; // added by KPN [FDS] UInt uiNumberOfGobs; Bool bFirstGobRow; CMBMode *pmbmd = g_pVO->m_rgmbmd; CMotionVector *pmv = g_pVO->m_rgmv; Int iNumMBX = g_pVO->m_iNumMBX;#ifdef DUAL_MODE SptXmitMode TmpSMode = g_pVOP->SpriteXmitMode; UInt m_uiSprite;#endif Bool TmpQPel = g_pVOL->bQuarterSample; MacroBlockMemory** ppmbmTemp; Int iCurrentQP = g_pVOP->intStep, iQP, iQpPred; Int iDcScaler, iDcScalerY, iDcScalerC; Int iVideoPacketNumber = 0; Bool bLeftBndry; Bool bRightBndry; Bool bTopBndry; Bool bRestartDelayedQP = TRUE; unsigned char nTrueInterP; MacroBlockMemory* pmbmLeft = NULL; MacroBlockMemory* pmbmTop = NULL; MacroBlockMemory* pmbmLeftTop = NULL; CMBMode* pmbmdLeft = NULL; CMBMode* pmbmdTop = NULL; CMBMode* pmbmdLeftTop = NULL; BlockMemory blkmPred;#ifndef NEW_MAE_DRIVER pMAERegs->cur_y_frame_ptr = get_cur_buffer(); pMAERegs->cur_cb_frame_ptr = pMAERegs->cur_y_frame_ptr + m_iSizeYPlane; pMAERegs->cur_cr_frame_ptr = pMAERegs->cur_cb_frame_ptr + m_iSizeUVPlane; m_pMAERef1Y = (PixelC*) pMAERegs->cur_y_frame_ptr; #endif // Added for error resilient mode by Toshiba(1997-11-14) g_pVO->m_iVPMBnum = 0; // End Toshiba(1997-11-14) g_NumMVs = 0; MP4V_nBytesUsed = 0; bFirstGobRow=FALSE; if (!main_short_video_header) { uiNumberOfGobs = 1; iMBXstart=0; iMBXstop= iNumMBX; iMBYstart=0; iMBYstop= g_pVO->m_iNumMBY; } else // short_header { uiNumberOfGobs = g_pDecoder->uiNumGobsInVop; iMBXstart=0; iMBXstop= 0; iMBYstart=0; iMBYstop= 0; } g_pDecoder->uiGobNumber=0; #ifdef DUAL_MODE m_uiSprite = g_pVO->m_uiSprite;#endif while (g_pDecoder->uiGobNumber < uiNumberOfGobs) { if (!main_short_video_header) g_pDecoder->uiGobNumber++; else { g_pDecoder->uiGobHeaderEmpty=1; if (g_pDecoder->uiGobNumber != 0) { if (checkGOBMarker()) { UInt uiGobResyncMarker; g_pDecoder->uiGobHeaderEmpty=0; MP4V_FLUSH(0); uiGobResyncMarker= getBits(29); //getBits (17 ); //g_pDecoder->uiGobNumber= //getBits(5); //UInt uiGobFrameId = //getBits(2); //UInt uiVopQuant= //getBits(5); //UInt uiVopQuant= uiGobResyncMarker & 0x1f; // Read 5 bits uiGobResyncMarker>>=7; //UInt uiGobFrameId = uiGobResyncMarker & 0x03; // Read 2 bits g_pDecoder->uiGobNumber= uiGobResyncMarker & 0x1f; // Read 5 bits bFirstGobRow=TRUE; g_pDecoder->uiGobNumber++; } else g_pDecoder->uiGobNumber++; } else g_pDecoder->uiGobNumber++; iMBXstart=0; iMBXstop= g_pVO->m_ivolWidth/16; iMBYstart=(g_pDecoder->uiGobNumber*(g_pVO->m_ivolHeight/16)/uiNumberOfGobs)-1; iMBYstop= iMBYstart+(g_pVO->m_ivolHeight/16)/uiNumberOfGobs; } if (MP4V_EOF()) return; // Call MAE-Wrapper to get a pointer to 1 Frame worth of memory pMAEContext = WrapGetContext (MP4V_nBytesUsed); // Now, get the temporal number MP4V_COMPUTETEMPORALNUMBER(&pMAEContext->tnum, PFRAME); // Set the anchor flag & frametype pMAEContext->anchor_flag = 1; #ifdef NEW_MAE_DRIVER MP4V_FILLFRAMEPARAMETERS(PFRAME);#else pMAEContext->frametype = PFRAME;#endif for (iMBY = iMBYstart; iMBY < iMBYstop; iMBY++, y += MB_SIZE) { // Added for error resilience mode By Toshiba SKIPANYSTUFFING(); MP4V_CHECKRESYNCMARKER(&bResyncMark); if (bResyncMark) { decodeVideoPacketHeader(&iCurrentQP); iVideoPacketNumber++; bRestartDelayedQP = TRUE; } pmbmd->m_iVideoPacketNumber = iVideoPacketNumber; if (iMBY==0) { bRightBndry = TRUE; bTopBndry = TRUE; } else { bRightBndry = !((pmbmd - iNumMBX + 1) -> m_iVideoPacketNumber == pmbmd->m_iVideoPacketNumber); bTopBndry = !((pmbmd - iNumMBX) -> m_iVideoPacketNumber == pmbmd->m_iVideoPacketNumber); } if (bFirstGobRow) // Added by KPN { bTopBndry=TRUE; bRightBndry=TRUE; } #ifdef DUAL_MODE // only RECTANGLE or non-transparent MB will be decoded for the update piece if (m_uiSprite == 0 || m_uiSprite == 2) #endif { // GMC decodeMBTextureHeadOfPVOP (pmbmd, &iCurrentQP, &bRestartDelayedQP); // GMC if(!pmbmd -> m_bMCSEL) // ~GMC decodeMV (pmbmd, pmv, TRUE, bRightBndry, bTopBndry, FALSE, 0, iMBY); // GMC else { Int iPmvx, iPmvy, iHalfx, iHalfy, i; CVector vctOrg; globalmv (&iPmvx, &iPmvy, &iHalfx, &iHalfy, 0, y, g_pVOP->mvInfoForward.uiRange, TmpQPel); vctOrg.x = iPmvx*2 + iHalfx; vctOrg.y = iPmvy*2 + iHalfy; CMOTIONVECTOR_INIT3(pmv, iPmvx, iPmvy); pmv -> iHalfX = iHalfx; pmv -> iHalfY = iHalfy; COMPUTETRUEMV(pmv); COMPUTEMV(pmv); for (i = 1; i < PVOP_MV_PER_REF_PER_MB; i++) pmv[i] = *pmv; } // ~GMC } #ifdef DUAL_MODE else if (m_uiSprite == 1 && TmpSMode != STOP) {#ifdef ENABLE_NON_RECTANGLE_USAGE if (g_pVOL->fAUsage != RECTANGLE) { if (pmbmd -> m_rgTranspStatus [0] != ALL) decodeMBTextureHeadOfPVOP (pmbmd, &iCurrentQP, &bRestartDelayedQP); } else#endif decodeMBTextureHeadOfPVOP (pmbmd, &iCurrentQP, &bRestartDelayedQP); }#endif x = 0; // RRV modification for (iMBX = iMBXstart; iMBX < iMBXstop; iMBX++, x += MB_SIZE) // [FDS] { nTrueInterP = INTER_CODED_AS_INTER; if (MP4V_EOF()) {#ifdef ENABLE_PRINTS printf("decodePVOP : dummy submit-1\n");#endif pMAEContext->dummysubmit = 1; // drop this frame goto SUBMIT_P_CONTEXT; } // Set default to Intra MB g_NumMVs = TOTAL_INTRA_MVS; // Reset the number of coded blocks nCodedBlocks = 0; // Initialize the UV MotionVector index g_UVMVId = g_UVMVId2 = 4; if (pmbmd->m_dctMd == INTER || pmbmd->m_dctMd == INTERQ) {#ifdef ENABLE_INTERLACING // This is an Inter MB. Lets decide how many MVs we need (P frame, only FWD MVs) if (!pmbmd->m_bhas4MVForward && !pmbmd->m_bFieldMV) g_NumMVs = TOTAL_16x16_FWD_BWD_MVS; else if (pmbmd->m_bFieldMV) g_NumMVs = TOTAL_16x8_FWD_BWD_MVS; else g_NumMVs = TOTAL_8x8_FWD_BWD_MVS;#else // This is an Inter MB. Lets decide how many MVs we need (P frame, only FWD MVs) if (!pmbmd->m_bhas4MVForward) g_NumMVs = TOTAL_16x16_FWD_BWD_MVS; else g_NumMVs = TOTAL_8x8_FWD_BWD_MVS;#endif } // Setup some pointers within the context & initialize some // default values (that remain the same for all MBs) MP4V_CLEARHEADERWORDS (); MP4V_INITMBDATA(); // MB position g_pHeader3->xpos = iMBX * 2; g_pHeader3->ypos = iMBY * 2; // HV#ifdef ENABLE_INTERLACING if (pmbmd->m_dctMd == INTER || pmbmd->m_dctMd == INTERQ) { if (m_uiSprite == 0 || m_uiSprite == 2) // GMC { // Do all of the OOF range check only if we are in Interlaced mode
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -