📄 vopsedec.c
字号:
setRefStartingPointers (); computeVOPMembers (); }#endif#ifdef MP4V_DEBUG g_nGlobMB = 0;#endif // Call the appropriate frame decode function if (g_pVOP->vopPredType == IVOP) decodeIVOP ();#ifdef ENABLE_SPRITE else if (g_pVOP->vopPredType == PVOP || g_pVOP->vopPredType == SPRITE)#else else if (g_pVOP->vopPredType == PVOP)#endif decodePVOP (); else decodeBVOP (); // Increment the frame count nFrames++; // store the direct mode data if (g_pVOP->vopPredType != BVOP) { CMBMode* pmbmdTmp; CMotionVector* pmvTmp;#ifdef ENABLE_NON_RECTANGLE_USAGE if(g_pVOL->fAUsage != RECTANGLE && bPrevRefVopWasCoded) saveShapeMode(); if(g_pVOL->fAUsage != RECTANGLE) saveBaseShapeMode(); #endif pmbmdTmp = g_pVO->m_rgmbmd; g_pVO->m_rgmbmd = g_pVO->m_rgmbmdRef; g_pVO->m_rgmbmdRef = pmbmdTmp; pmvTmp = g_pVO->m_rgmv; g_pVO->m_rgmv = g_pVO->m_rgmvRef; g_pVO->m_rgmvRef = pmvTmp; g_pVO->m_rgmvBackward = g_pVO->m_rgmv + BVOP_MV_PER_REF_PER_MB * g_pVO->m_iSessNumMB; }#ifdef ENABLE_NON_RECTANGLE_USAGE else if (TmpVOLType == BASE_LAYER && g_pVOP->vopPredType == BVOP ) { if( g_pVOL->fAUsage != RECTANGLE) saveBaseShapeMode(); } if (g_pVOL->fAUsage != RECTANGLE) { if (g_pVOP->vopPredType != BVOP || (TmpVOLType == ENHN_LAYER && g_pVOP->vopPredType == BVOP && g_pVOP->iRefSelectCode == 0)) { m_iNumMBRef = m_iNumMB; m_iNumMBXRef = m_iNumMBX; m_iNumMBYRef = m_iNumMBY; m_iOffsetForPadY = RCT_OFFSET((&m_rctRefFrameY), m_rctCurrVOPY.left, m_rctCurrVOPY.top); m_iOffsetForPadUV = RCT_OFFSET((&m_rctRefFrameUV), m_rctCurrVOPUV.left, m_rctCurrVOPUV.top); m_rctPrevNoExpandY = m_rctCurrVOPY; m_rctPrevNoExpandUV = m_rctCurrVOPUV; m_rctRefVOPY1 = m_rctCurrVOPY; RCT_EXPAND((&m_rctRefVOPY1), EXPANDY_REFVOP); m_rctRefVOPUV1 = m_rctCurrVOPUV; RCT_EXPAND((&m_rctRefVOPUV1), EXPANDUV_REFVOP); } else { // For Temporal Scalability Added by Sharp(1998-02-10)//OBSS_SAIT_991015 //for Base layer BVOP padding if (TmpVOLType == BASE_LAYER && g_pVOP->vopPredType == BVOP) { if(!g_pVOL->bShapeOnly) { m_iOffsetForPadY = RCT_OFFSET((&m_rctRefFrameY), m_rctCurrVOPY.left, m_rctCurrVOPY.top); m_iOffsetForPadUV = RCT_OFFSET((&m_rctRefFrameUV), m_rctCurrVOPUV.left, m_rctCurrVOPUV.top); m_rctPrevNoExpandY = m_rctCurrVOPY; m_rctPrevNoExpandUV = m_rctCurrVOPUV; } }//~OBSS_SAIT_991015 m_iBVOPOffsetForPadY = RCT_OFFSET((&m_rctRefFrameY), m_rctCurrVOPY.left, m_rctCurrVOPY.top); m_iBVOPOffsetForPadUV = RCT_OFFSET((&m_rctRefFrameUV), m_rctCurrVOPUV.left, m_rctCurrVOPUV.top); m_rctBVOPPrevNoExpandY = m_rctCurrVOPY; m_rctBVOPPrevNoExpandUV = m_rctCurrVOPUV; m_rctBVOPRefVOPY1 = m_rctCurrVOPY; RCT_EXPAND((&m_rctBVOPRefVOPY1), EXPANDY_REFVOP); m_rctBVOPRefVOPUV1 = m_rctCurrVOPUV; RCT_EXPAND((&m_rctBVOPRefVOPUV1), EXPANDUV_REFVOP); } // For Temporal Scalability End Sharp(1998-02-10) //give a comment that this is ac/dc pred stuff Int nBlk = (g_pVOL->fAUsage == EIGHT_BIT) ? 6+g_pVOL->iAuxCompCount*4 : 6; for (Int iMB = 0; iMB < m_iNumMBX; iMB++) { for (Int iBlk = 0; iBlk < nBlk; iBlk++) { delete [] (m_rgpmbmAbove [iMB]->rgblkm) [iBlk]; delete [] (m_rgpmbmCurr [iMB]->rgblkm) [iBlk]; } delete [] m_rgpmbmAbove [iMB]->rgblkm; delete m_rgpmbmAbove [iMB]; delete [] m_rgpmbmCurr [iMB]->rgblkm; delete m_rgpmbmCurr [iMB]; } delete [] m_rgpmbmAbove; delete [] m_rgpmbmCurr; }#endif return TRUE;}INLINE Int h263_decode (){ static Bool first_time = TRUE; CMBMode* pmbmdTmp; CMotionVector* pmvTmp; if (!first_time) { Int nLocalBit; while (peekBits(NUMBITS_SHORT_HEADER_START_CODE) != SHORT_VIDEO_START_MARKER) { if(MP4V_EOF()) // [FDS] return EOF; MP4V_RETSINGLEBIT(&nLocalBit); } getBits(22); g_pVO->m_t = video_plane_with_short_header(); } else { first_time = FALSE; g_pVO->m_tPastRef = g_pVO->m_tFutureRef = g_pVO->m_t; } g_pVO->m_bUseGOV=FALSE; g_pVO->m_bLinkisBroken=FALSE; g_pVOP->iRoundingControl=0; g_pVOP->iIntraDcSwitchThr=0; g_pVOP->bInterlace=FALSE; g_pVOP->bAlternateScan=FALSE; g_pVOP->mvInfoForward.uiFCode=1; g_pVOP->mvInfoForward.uiScaleFactor = 1 << (g_pVOP->mvInfoForward.uiFCode - 1); g_pVOP->mvInfoForward.uiRange = 16 << g_pVOP->mvInfoForward.uiFCode; g_pVOP->mvInfoBackward.uiFCode = 1; g_pVOP->bShapeCodingType=1; g_pVO->m_tPastRef = g_pVO->m_tFutureRef; g_pVO->m_tFutureRef = g_pVO->m_t; g_pVO->m_iBCount = 0;#ifndef NEW_MAE_DRIVER updateAllRefVOPs ();#endif#ifdef ENABLE_PRINTS switch(g_pVOP->vopPredType) { case IVOP: printf("IVOP : "); break; case PVOP: printf("PVOP : "); break; case BVOP: printf("BVOP : "); break; default: break; }#endif // Call the appropriate frame decode function if (g_pVOP->vopPredType == IVOP) decodeIVOP (); else if (g_pVOP->vopPredType == PVOP) decodePVOP (); else decodeBVOP (); // Increment the frame count nFrames++; pmbmdTmp = g_pVO->m_rgmbmd; g_pVO->m_rgmbmd = g_pVO->m_rgmbmdRef; g_pVO->m_rgmbmdRef = pmbmdTmp; pmvTmp = g_pVO->m_rgmv; g_pVO->m_rgmv = g_pVO->m_rgmvRef; g_pVO->m_rgmvRef = pmvTmp; g_pVO->m_rgmvBackward = g_pVO->m_rgmv + BVOP_MV_PER_REF_PER_MB * g_pVO->m_iSessNumMB; g_pVO->m_iBVOPOffsetForPadY = g_pVO->m_iOffsetForPadY; g_pVO->m_iBVOPOffsetForPadUV = g_pVO->m_iOffsetForPadUV; g_pVO->m_rctBVOPPrevNoExpandY = g_pVO->m_rctPrevNoExpandY; g_pVO->m_rctBVOPPrevNoExpandUV = g_pVO->m_rctPrevNoExpandUV; return TRUE; }UInt video_plane_with_short_header(){ UInt uiTemporalReference, uiSourceFormat, uiPictureCodingType, uiVopQuant; UInt TmpNumGobs, TmpNumMBGob; Int TmpW, TmpH, nLocalBit; uiTemporalReference = getBits (8); getBits(5); uiSourceFormat = getBits (3); if (uiSourceFormat==1) { TmpNumGobs=6; TmpNumMBGob=8; TmpW=128; TmpH=96; } else if (uiSourceFormat==2) { TmpNumGobs=9; TmpNumMBGob=11; TmpW=176; TmpH=144; } else if (uiSourceFormat==3) { TmpNumGobs=18; TmpNumMBGob=22; TmpW=352; TmpH=288; } else if (uiSourceFormat==4) { TmpNumGobs=18; TmpNumMBGob=88; TmpW=704; TmpH=576; } else if (uiSourceFormat==5) { TmpNumGobs=18; TmpNumMBGob=352; TmpW=1408; TmpH=1152; } else { fprintf(stderr,"Wrong Source Format in video_plane_with_short_header()\n"); exit (0); } g_pDecoder->uiNumGobsInVop=TmpNumGobs; g_pDecoder->uiNumMacroblocksInGob=TmpNumMBGob; g_pVO->m_ivolWidth=TmpW; g_pVO->m_ivolHeight=TmpH; MP4V_RETSINGLEBIT(&uiPictureCodingType); if (uiPictureCodingType==0) g_pVOP->vopPredType=IVOP; else g_pVOP->vopPredType=PVOP; getBits(4); uiVopQuant = getBits(5); g_pVOP->intStepI=uiVopQuant; g_pVOP->intStep=uiVopQuant; // idem MP4V_RETSINGLEBIT(&nLocalBit); do { MP4V_RETSINGLEBIT(&g_pDecoder->uiPei); if (g_pDecoder->uiPei==1) getBits(8); } while (g_pDecoder->uiPei==1 && !MP4V_EOF()); g_pVO->m_uiVOId = 1; g_pVOL->iClockRate = 30; g_pVO->m_iNumBitsTimeIncr = 4; g_pVOL->bShapeOnly=FALSE; g_pVOL->fAUsage = RECTANGLE; g_pVOL->bAdvPredDisable = TRUE; g_pVO->m_uiSprite = FALSE; g_pVOL->bNot8Bit=FALSE; g_pVOL->uiQuantPrecision=5; g_pVOL->nBits=8; g_pVOL->fQuantizer=Q_H263; g_pVOL->bDataPartitioning=FALSE; g_pVOL->bReversibleVlc=FALSE; g_pVOL->volType=BASE_LAYER; g_pVOL->ihor_sampling_factor_n=1; g_pVOL->ihor_sampling_factor_m=1; g_pVOL->iver_sampling_factor_n=1; g_pVOL->iver_sampling_factor_m=1; g_pVOL->bDeblockFilterDisable=TRUE; g_pVOL->bQuarterSample = 0; g_pVOL->bRoundingControlDisable = 0; g_pVOL->iInitialRoundingType = 0; g_pVOL->bResyncMarkerDisable = 1; g_pVOL->bVPBitTh = 0; g_pVOL->bSadctDisable = 1; g_pVOL->bComplexityEstimationDisable = 1; g_pVOL->breduced_resolution_vop_enable = 0; g_pVOL->bNewpredEnable=FALSE; return uiTemporalReference;}#ifndef NEW_MAE_DRIVER// perform this after VOP prediction type decided and before encodingVoid updateAllRefVOPs (){ if (g_pVOP->vopPredType != BVOP) { unsigned char *m_pMAETmpY = m_pMAERef0Y; m_pMAERef0Y = m_pMAERef1Y; m_pMAERef1Y = m_pMAETmpY; }}#endifInt findStartCode(){ Int bUserData; // ensure byte alignment MP4V_FLUSH (0); do { bUserData = 0; if(MP4V_EOF()) return EOF; while(peekBits(NUMBITS_START_CODE_PREFIX)!=START_CODE_PREFIX) { getBits(8); if(MP4V_EOF()) return EOF; } getBits(NUMBITS_START_CODE_PREFIX); if(peekBits(NUMBITS_START_CODE_SUFFIX)==USER_DATA_START_CODE) bUserData = 1; } while(bUserData); return 0;}Int decodeVSHead (){ UInt uiIsVisualObjectIdent, uiVideoSignalType; UInt uiProfile, uiVSOType; UInt uiSC = getBits (NUMBITS_START_CODE_SUFFIX); if (uiSC != VSS_START_CODE) return 1; // visual session header uiProfile = getBits (NUMBITS_VSS_PROFILE); if (findStartCode()) return 1; uiSC = getBits (NUMBITS_START_CODE_SUFFIX); if (uiSC != VSO_START_CODE) return 1; // visual object header MP4V_RETSINGLEBIT(&uiIsVisualObjectIdent); if (uiIsVisualObjectIdent) { UInt uiVSOPriority; UInt uiVSOVerID = getBits (NUMBITS_VSO_VERID); if (uiVSOVerID != VSO_VERID) return 1; uiVSOPriority = getBits (NUMBITS_VSO_PRIORITY); } uiVSOType = getBits (NUMBITS_VSO_TYPE); if (uiVSOType != VSO_TYPE) return 1; MP4V_RETSINGLEBIT(&uiVideoSignalType); if (uiVideoSignalType) { UInt uiRange, uiColor; UInt uiFormat = getBits (3); MP4V_RETSINGLEBIT(&uiRange); MP4V_RETSINGLEBIT(&uiColor); if (uiColor) { getBits (24); } } if (findStartCode()) return 1; return 0;}Void decodeVOHead (CVideoObjectDecoder *pVOD){ UInt uiVoStartCode; findStartCode(); if(peekBits(NUMBITS_START_CODE_SUFFIX)==VSS_START_CODE) { if(decodeVSHead()) exit(fprintf(stderr,"decodeVOHead : Failed to decode visual sequence headers\n")); } uiVoStartCode = getBits (NUMBITS_VO_START_CODE); while (uiVoStartCode != VO_START_CODE) {#ifdef ENABLE_PRINTS printf("NULL VO detected - will try to find the next VO_START_CODE, uiVoStartCode=0x%x\n", uiVoStartCode);#endif if (findStartCode()) break; /* EOF */ uiVoStartCode = getBits (NUMBITS_VO_START_CODE); } #ifndef NO_ASSERTS assert(uiVoStartCode == VO_START_CODE);#endif g_pVO->m_uiVOId = getBits (NUMBITS_VO_ID);}int decodeVOLHead (CVideoObjectDecoder *pVOD, VOLMode *pVOL, VOPMode *pVOP){ UInt i,j, uiOLI, uiResyncMarkerDisable, uiVolStartCode; UInt uiVOLId, uiOLType, uiAspect;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -