📄 vopsedec.c
字号:
Int iElem, iAuxComp, iClockRate, nLocalBit; Bool bRandom, bFixFrameRate;#ifdef DUAL_MODE Bool bLightChange, *bTmp;#endif UInt uiMark, uiCTP, uiAUsage; // hack to get init'ed pVOL->bSadctDisable = 0; findStartCode(); uiVolStartCode = getBits (NUMBITS_VOL_START_CODE); while (uiVolStartCode != VOL_START_CODE) {#ifdef ENABLE_PRINTS printf("NULL VOL detected - will try to find the next VOL_START_CODE, uiVolStartCode=0x%x\n", uiVolStartCode);#endif if (findStartCode()) break; /* EOF */ uiVolStartCode = getBits (NUMBITS_VOL_START_CODE); } #ifndef NO_ASSERTS assert(uiVolStartCode == VOL_START_CODE); #endif uiVOLId = getBits (NUMBITS_VOL_ID); MP4V_RETSINGLEBIT(&bRandom); uiOLType = getBits(8); // VOL_type_indication MP4V_RETSINGLEBIT(&uiOLI); if(uiOLI) { // GMC pVOL->uiVerID = getBits (4); // video_oject_layer_verid // Here, is_object_layer_identifier is used for Version1/Version2 // identification at this moment (tentative solution). // vol_type_indicator is not useless for version 2 at present. // need discussion at Video Group about this issue. getBits (3); // video_oject_layer_priority } else { pVOL->uiVerID = 1; // ~GMC } uiAspect = getBits (4); if(uiAspect==15) // extended PAR { UInt iParWidth = getBits (8); UInt iParHeight = getBits (8); } MP4V_RETSINGLEBIT(&uiCTP); m_iNumBFrames = 0; // Just reset to 0 #ifdef PRINT_BIT_RATE printf("PeakBitRate\t: ");#endif if(uiCTP) { UInt uiChromaFormat, uiLowDelay, uiVBVParams; uiChromaFormat = getBits (2); MP4V_RETSINGLEBIT(&uiLowDelay); MP4V_RETSINGLEBIT(&uiVBVParams); // HV // Since uiLowDelay dictates the presence of // B-frames check & set m_iNumBFrames accordingly if (uiLowDelay) m_iNumBFrames = 0; // No B-Frames else m_iNumBFrames = 1; // Just 1 B-Frame in every sequence // ~HV if(uiVBVParams) { UInt uiFirstHalfBitRate, uiLatterHalfBitRate; UInt uiFirstHalfVbvBufferSize, uiLatterHalfVbvBufferSize; UInt uiFirstHalfVbvBufferOccupany, uiLatterHalfVbvBufferOccupany; uiFirstHalfBitRate = getBits (15); MP4V_RETSINGLEBIT(&uiMark);#ifndef NO_ASSERTS assert(uiMark==1);#endif uiLatterHalfBitRate = getBits (15); MP4V_RETSINGLEBIT(&uiMark);#ifndef NO_ASSERTS assert(uiMark==1);#endif #ifdef PRINT_BIT_RATE { int iHi, iLo, iFinal; printf(" FirstHalf = %d LatterHalf = %d (in 400 bits/s units)\n", uiFirstHalfBitRate, uiLatterHalfBitRate); iHi = (uiFirstHalfBitRate << 15) * 400; iLo = uiLatterHalfBitRate * 400; iFinal = iHi | iLo; printf("Final PeakBitRate : %d bps %d Kbps\n", iFinal, (iFinal/1000)); }#endif uiFirstHalfVbvBufferSize = getBits (15); MP4V_RETSINGLEBIT(&uiMark);#ifndef NO_ASSERTS assert(uiMark==1);#endif uiLatterHalfVbvBufferSize = getBits (3); uiFirstHalfVbvBufferOccupany = getBits (11); MP4V_RETSINGLEBIT(&uiMark);#ifndef NO_ASSERTS assert(uiMark==1);#endif uiLatterHalfVbvBufferOccupany = getBits (15); MP4V_RETSINGLEBIT(&uiMark);#ifndef NO_ASSERTS assert(uiMark==1);#endif }#ifdef PRINT_BIT_RATE else printf(" Not Available!!\n");#endif } #ifdef PRINT_BIT_RATE else printf(" Not Available!!\n");#endif uiAUsage = getBits (NUMBITS_VOL_SHAPE); // MAC (SB) 1-Dec-99#ifdef DUAL_MODE if (uiAUsage==3) // gray scale { if (pVOL->uiVerID!=1) { pVOL->iAlphaShapeExtension = getBits (4); pVOL->iAuxCompCount = CVideoObject::getAuxCompCount(pVOL->iAlphaShapeExtension); } else pVOL->iAuxCompCount = 1; } else#endif pVOL->iAuxCompCount = 0; //~MAC MP4V_RETSINGLEBIT(&uiMark);#ifndef NO_ASSERTS assert(uiMark==1);#endif pVOL->iClockRate = getBits (NUMBITS_TIME_RESOLUTION); MP4V_RETSINGLEBIT(&uiMark);#ifndef NO_ASSERTS assert(uiMark==1);#endif iClockRate = pVOL->iClockRate - 1;#ifndef NO_ASSERTS assert (iClockRate < 65536);#endif if(iClockRate>0) { for (g_pVO->m_iNumBitsTimeIncr = 1; g_pVO->m_iNumBitsTimeIncr < NUMBITS_TIME_RESOLUTION; g_pVO->m_iNumBitsTimeIncr++) { if (iClockRate == 1) break; iClockRate = (iClockRate >> 1); } } else g_pVO->m_iNumBitsTimeIncr = 1; MP4V_RETSINGLEBIT(&bFixFrameRate);#ifndef NO_ASSERTS //assert (bFixFrameRate == FALSE);#endif if(bFixFrameRate) { UInt uiFixedVOPTimeIncrement = 1; if(g_pVO->m_iNumBitsTimeIncr!=0) uiFixedVOPTimeIncrement = getBits (g_pVO->m_iNumBitsTimeIncr) + 1; // Save the VOP increment factor (without the + 1) g_iVOPIncFactor = uiFixedVOPTimeIncrement - 1; // Make sure we don't end up with a divide-by-zero error if (!g_iVOPIncFactor) g_iVOPIncFactor = 1;#ifdef ENABLE_PRINTS printf("decodeVOLHead : g_iVOPIncFactor = %d\n", g_iVOPIncFactor);#endif } #ifdef DUAL_MODE if(uiAUsage==2) // shape-only mode { //OBSS_SAIT_991015 if(pVOL->uiVerID == 2) { MP4V_RETSINGLEBIT(&nLocalBit); pVOL->volType = (nLocalBit == 0) ? BASE_LAYER : ENHN_LAYER; pVOL->iEnhnType = 0; //OBSSFIX_BSO pVOL->iHierarchyType = 0; //OBSSFIX_BSO pVOL->ihor_sampling_factor_n = 1; pVOL->ihor_sampling_factor_m = 1; pVOL->iver_sampling_factor_n = 1; pVOL->iver_sampling_factor_m = 1; pVOL->ihor_sampling_factor_n_shape = 1; pVOL->ihor_sampling_factor_m_shape = 1; pVOL->iver_sampling_factor_n_shape = 1; pVOL->iver_sampling_factor_m_shape = 1; if (pVOL->volType == ENHN_LAYER) { pVOL->ihor_sampling_factor_n_shape = getBits (5); pVOL->ihor_sampling_factor_m_shape = getBits (5); pVOL->iver_sampling_factor_n_shape = getBits (5); pVOL->iver_sampling_factor_m_shape = getBits (5); pVOL->ihor_sampling_factor_n = pVOL->ihor_sampling_factor_n_shape; pVOL->ihor_sampling_factor_m = pVOL->ihor_sampling_factor_m_shape; pVOL->iver_sampling_factor_n = pVOL->iver_sampling_factor_n_shape; pVOL->iver_sampling_factor_m = pVOL->iver_sampling_factor_m_shape; } } //~OBSS_SAIT_991015 MP4V_RETSINGLEBIT(&uiResyncMarkerDisable); // default to some values - probably not all needed pVOL->bShapeOnly=TRUE; pVOL->fAUsage=ONE_BIT; pVOL->bAdvPredDisable = 0; pVOL->fQuantizer = Q_H263; //OBSS_SAIT_991015 pVOL->bSadctDisable = 1; pVOL->bNewpredEnable = 0; pVOL->bQuarterSample = 0; //~OBSS_SAIT_991015 pVOL->bDeblockFilterDisable = TRUE; g_pVO->m_uiSprite = 0; pVOL->bNot8Bit = 0; pVOL->bComplexityEstimationDisable = 1; pVOL->bDataPartitioning = 0; pVOL->bReversibleVlc = FALSE; pVOL->bDeblockFilterDisable = TRUE; return 0; }#endif pVOL->bShapeOnly=FALSE; if(uiAUsage==3) uiAUsage=2; pVOL->fAUsage = (AlphaUsage) uiAUsage; if (pVOL->fAUsage == RECTANGLE) { UInt uiMarker; MP4V_RETSINGLEBIT(&uiMarker);#ifndef NO_ASSERTS assert(uiMarker==1);#endif g_pVO->m_ivolWidth = getBits (NUMBITS_VOP_WIDTH); MP4V_RETSINGLEBIT(&uiMarker);#ifndef NO_ASSERTS assert(uiMarker==1);#endif g_pVO->m_ivolHeight = getBits (NUMBITS_VOP_HEIGHT); MP4V_RETSINGLEBIT(&uiMarker);#ifndef NO_ASSERTS assert(uiMarker==1);#endif } MP4V_RETSINGLEBIT(&pVOP->bInterlace); MP4V_RETSINGLEBIT(&pVOL->bAdvPredDisable); // decode sprite info if(pVOL->uiVerID == 1) { UInt *iTmp = &g_pVO->m_uiSprite; MP4V_RETSINGLEBIT(iTmp); } else if(pVOL->uiVerID == 2) g_pVO->m_uiSprite = getBits (2); #ifdef DUAL_MODE if (g_pVO->m_uiSprite == 1) // sprite information { Int iMarker, isprite_hdim, isprite_vdim; Int isprite_left_edge, isprite_top_edge; isprite_hdim = getBits (NUMBITS_SPRITE_HDIM); MP4V_RETSINGLEBIT(&iMarker);#ifndef NO_ASSERTS assert (iMarker == 1);#endif isprite_vdim = getBits (NUMBITS_SPRITE_VDIM); MP4V_RETSINGLEBIT(&iMarker);#ifndef NO_ASSERTS assert (iMarker == 1);#endif MP4V_RETSINGLEBIT(&nLocalBit); isprite_left_edge = (nLocalBit == 0) ? getBits (NUMBITS_SPRITE_LEFT_EDGE - 1) : ((Int)getBits (NUMBITS_SPRITE_LEFT_EDGE - 1) - (1 << 12));#ifndef NO_ASSERTS assert(isprite_left_edge%2 == 0);#endif MP4V_RETSINGLEBIT(&iMarker);#ifndef NO_ASSERTS assert (iMarker == 1);#endif MP4V_RETSINGLEBIT(&nLocalBit); isprite_top_edge = (nLocalBit == 0) ? getBits (NUMBITS_SPRITE_TOP_EDGE - 1) : ((Int)getBits (NUMBITS_SPRITE_LEFT_EDGE - 1) - (1 << 12));#ifndef NO_ASSERTS assert(isprite_top_edge%2 == 0);#endif MP4V_RETSINGLEBIT(&iMarker);#ifndef NO_ASSERTS assert (iMarker == 1);#endif g_pVO->m_rctSpt.left = isprite_left_edge; g_pVO->m_rctSpt.right = isprite_left_edge + isprite_hdim; g_pVO->m_rctSpt.top = isprite_top_edge; g_pVO->m_rctSpt.bottom = isprite_top_edge + isprite_vdim; g_pVO->m_rctSpt.width = isprite_hdim; g_pVO->m_rctSptPieceY = g_pVO->m_rctSpt; //initialization; will be overwritten by first vop header } if (g_pVO->m_uiSprite == 1 || g_pVO->m_uiSprite == 2) // sprite information { m_iNumOfPnts = getBits (NUMBITS_NUM_SPRITE_POINTS);#ifndef NO_ASSERTS if(g_pVO->m_uiSprite == 2) assert (m_iNumOfPnts == 0 || m_iNumOfPnts == 1 || m_iNumOfPnts == 2 || m_iNumOfPnts == 3);#endif m_rgstDstQ = (CSiteD *) malloc (m_iNumOfPnts * sizeof (CSiteD)); m_uiWarpingAccuracy = getBits (NUMBITS_WARPING_ACCURACY); MP4V_RETSINGLEBIT(&bLightChange); } if (g_pVO->m_uiSprite == 1) // sprite information { Bool bsptMode; MP4V_RETSINGLEBIT(&bsptMode); if (bsptMode) g_pVO->m_sptMode = LOW_LATENCY ; else g_pVO->m_sptMode = BASIC_SPRITE ; }#endif #ifdef ENABLE_NON_RECTANGLE_USAGE if (pVOL->fAUsage != RECTANGLE ) { if (pVOL->uiVerID == 1) pVOL->bSadctDisable = TRUE; else MP4V_RETSINGLEBIT(&pVOL->bSadctDisable); }#endif MP4V_RETSINGLEBIT(&pVOL->bNot8Bit); if (pVOL->bNot8Bit) { pVOL->uiQuantPrecision = (UInt) getBits (4); pVOL->nBits = (UInt) getBits (4);#ifndef NO_ASSERTS assert(pVOL->nBits>3);#endif } else { pVOL->uiQuantPrecision = 5; pVOL->nBits = 8; } if (pVOL->fAUsage == EIGHT_BIT) { UInt uiCompMethod, uiLinearComp; MP4V_RETSINGLEBIT(&pVOL->bNoGrayQuantUpdate); MP4V_RETSINGLEBIT(&uiCompMethod); MP4V_RETSINGLEBIT(&uiLinearComp); } // Let use set the number of Weighing Matrices here g_NumWMs = 4; MP4V_RETSINGLEBIT(&pVOL->fQuantizer); if (pVOL->fQuantizer == Q_MPEG) { MP4V_RETSINGLEBIT(&pVOL->bLoadIntraMatrix); if (pVOL->bLoadIntraMatrix) { i = 0; do { iElem = getBits (NUMBITS_QMATRIX); pVOL->rgiIntraQuantizerMatrix [grgiStandardZigzag[i]] = iElem; } while (iElem != 0 && ++i < BLOCK_SQUARE_SIZE); for (j = i; j < BLOCK_SQUARE_SIZE; j++) pVOL->rgiIntraQuantizerMatrix [grgiStandardZigzag[j]] = pVOL->rgiIntraQuantizerMatrix [grgiStandardZigzag[i - 1]]; } else memcpy (pVOL->rgiIntraQuantizerMatrix, rgiDefaultIntraQMatrix, BLOCK_SQUARE_SIZE * sizeof (Int)); MP4V_RETSINGLEBIT(&pVOL->bLoadInterMatrix); if (pVOL->bLoadInterMatrix) { i = 0; do { iElem = getBits (NUMBITS_QMATRIX); pVOL->rgiInterQuantizerMatrix [grgiStandardZigzag[i]] = iElem; } while (iElem != 0 && ++i < BLOCK_SQUARE_SIZE); for (j = i; j < BLOCK_SQUARE_SIZE; j++) pVOL->rgiInterQuantizerMatrix [grgiStandardZigzag[j]] = pVOL->rgiInterQuantizerMatrix [grgiStandardZigzag[i - 1]]; } else memcpy (pVOL->rgiInterQuantizerMatrix, rgiDefaultInterQMatrix, BLOCK_SQUARE_SIZE * sizeof (Int)); if (pVOL->fAUsage == EIGHT_BIT) { for(iAuxComp=0; iAuxComp<pVOL->iAuxCompCount; iAuxComp++ ) // MAC (SB) 2-Dec-99 { MP4V_RETSINGLEBIT(&pVOL->bLoadIntraMatrixAlpha); if (pVOL->bLoadIntraMatrixAlpha)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -