📄 app_encoder_encoder.cpp
字号:
readBoolParam(&par, "Complexity.UpSampling.Enable", iLayerObj, &rgbUpsampling[iLayer][iObj]); readBoolParam(&par, "Complexity.IntraBlocks.Enable", iLayerObj, &rgbIntraBlocks[iLayer][iObj]); readBoolParam(&par, "Complexity.InterBlocks.Enable", iLayerObj, &rgbInterBlocks[iLayer][iObj]); readBoolParam(&par, "Complexity.Inter4VBlocks.Enable", iLayerObj, &rgbInter4vBlocks[iLayer][iObj]); readBoolParam(&par, "Complexity.NotCodedBlocks.Enable", iLayerObj, &rgbNotCodedBlocks[iLayer][iObj]); readBoolParam(&par, "Complexity.DCTCoefs.Enable", iLayerObj, &rgbDCTCoefs[iLayer][iObj]); readBoolParam(&par, "Complexity.DCTLines.Enable", iLayerObj, &rgbDCTLines[iLayer][iObj]); readBoolParam(&par, "Complexity.VLCSymbols.Enable", iLayerObj, &rgbVLCSymbols[iLayer][iObj]); readBoolParam(&par, "Complexity.VLCBits.Enable", iLayerObj, &rgbVLCBits[iLayer][iObj]); readBoolParam(&par, "Complexity.APM.Enable", iLayerObj, &rgbAPM[iLayer][iObj]); readBoolParam(&par, "Complexity.NPM.Enable", iLayerObj, &rgbNPM[iLayer][iObj]); readBoolParam(&par, "Complexity.InterpMCQ.Enable", iLayerObj, &rgbInterpolateMCQ[iLayer][iObj]); readBoolParam(&par, "Complexity.ForwBackMCQ.Enable", iLayerObj, &rgbForwBackMCQ[iLayer][iObj]); readBoolParam(&par, "Complexity.HalfPel2.Enable", iLayerObj, &rgbHalfpel2[iLayer][iObj]); readBoolParam(&par, "Complexity.HalfPel4.Enable", iLayerObj, &rgbHalfpel4[iLayer][iObj]); // START: Complexity Estimation syntax support - Update version 2 - Massimo Ravasi (EPFL) - 11 Nov 1999 if(iVersion>=902) // version 2 GetIVal(&par, "Complexity.EstimationMethod", iLayerObj, (Int *)(&rguiEstimationMethod[iLayer][iObj])); else rguiEstimationMethod[iLayer][iObj] = 0; if(rguiEstimationMethod[iLayer][iObj] == 1) { readBoolParam(&par, "Complexity.SADCT.Enable", iLayerObj, &rgbSadct[iLayer][iObj]); readBoolParam(&par, "Complexity.QuarterPel.Enable", iLayerObj, &rgbQuarterpel[iLayer][iObj]); } else { rgbSadct[iLayer][iObj] = 0; rgbQuarterpel[iLayer][iObj] = 0; } if ( ! (rgbOpaque[iLayer][iObj] || rgbTransparent[iLayer][iObj] || rgbIntraCAE[iLayer][iObj] || rgbInterCAE[iLayer][iObj] || rgbNoUpdate[iLayer][iObj] || rgbUpsampling[iLayer][iObj] || rgbIntraBlocks[iLayer][iObj] || rgbInterBlocks[iLayer][iObj] || rgbInter4vBlocks[iLayer][iObj] || rgbNotCodedBlocks[iLayer][iObj] || rgbDCTCoefs[iLayer][iObj] || rgbDCTLines[iLayer][iObj] || rgbVLCSymbols[iLayer][iObj] || rgbVLCBits[iLayer][iObj] || rgbAPM[iLayer][iObj] || rgbNPM[iLayer][iObj] || rgbInterpolateMCQ[iLayer][iObj] || rgbForwBackMCQ[iLayer][iObj] || rgbHalfpel2[iLayer][iObj] || rgbHalfpel4[iLayer][iObj] || rguiEstimationMethod[iLayer][iObj] || rgbSadct[iLayer][iObj] || rgbQuarterpel[iLayer][iObj]) ) { fprintf(stderr,"Complexity estimation is enabled,\n" "but no corresponding flag is enabled."); exit(1); } // END: Complexity Estimation syntax support - Update version 2 } else { rgbOpaque[iLayer][iObj] = 0; rgbTransparent[iLayer][iObj] = 0; rgbIntraCAE[iLayer][iObj] = 0; rgbInterCAE[iLayer][iObj] = 0; rgbNoUpdate[iLayer][iObj] = 0; rgbUpsampling[iLayer][iObj] = 0; rgbIntraBlocks[iLayer][iObj] = 0; rgbInterBlocks[iLayer][iObj] = 0; rgbInter4vBlocks[iLayer][iObj] = 0; rgbNotCodedBlocks[iLayer][iObj] = 0; rgbDCTCoefs[iLayer][iObj] = 0; rgbDCTLines[iLayer][iObj] = 0; rgbVLCSymbols[iLayer][iObj] = 0; rgbVLCBits[iLayer][iObj] = 0; rgbAPM[iLayer][iObj] = 0; rgbNPM[iLayer][iObj] = 0; rgbInterpolateMCQ[iLayer][iObj] = 0; rgbForwBackMCQ[iLayer][iObj] = 0; rgbHalfpel2[iLayer][iObj] = 0; rgbHalfpel4[iLayer][iObj] = 0; // START: Complexity Estimation syntax support - Update version 2 - Massimo Ravasi (EPFL) - 11 Nov 1999 rguiEstimationMethod[iLayer][iObj] = 0; rgbSadct[iLayer][iObj] = 0; rgbQuarterpel[iLayer][iObj] = 0; // END: Complexity Estimation syntax support - Update version 2 } GetDVal(&par, "Source.FrameRate", iLayerObj, &rgdFrameFrequency[iLayer][iObj]); fatal_error("Source.FrameRate is invalid", rgdFrameFrequency[iLayer][iObj] > 0.0); readBoolParam(&par, "Motion.Interlaced.TopFieldFirst.Enable", iLayerObj, &rgbTopFieldFirst [iLayer] [iObj]); readBoolParam(&par, "Motion.Interlaced.AlternativeScan.Enable", iLayerObj, &rgbAlternateScan[iLayer][iObj]); GetIVal(&par, "Motion.SearchRange.DirectMode", iLayerObj, &rgiDirectModeRadius[iLayer][iObj]); GetSVal(&par, "Motion.ReadWriteMVs", iLayerObj, &pchTmp); if(strcmp(pchTmp, "Off")==0) rgiMVFileUsage[iLayer][iObj] = 0; else if(strcmp(pchTmp, "Read")==0) rgiMVFileUsage[iLayer][iObj] = 1; else if(strcmp(pchTmp, "Write")==0) rgiMVFileUsage[iLayer][iObj] = 2; else fatal_error("Unknown mode for Motion.ReadWriteMVs"); if(rgiMVFileUsage[iLayer][iObj]!=0) { GetSVal(&par, "Motion.ReadWriteMVs.Filename", iLayerObj, &pchTmp); iLen = strlen(pchTmp) + 1; pchMVFileName [iLayer] [iObj] = new char [iLen]; memcpy(pchMVFileName [iLayer] [iObj], pchTmp, iLen); } Bool bVolControlEnable; readBoolParam(&par, "VOLControl.Enable", iLayerObj, &bVolControlEnable); rguiVolControlParameters[iLayer][iObj] = (UInt)bVolControlEnable; GetIVal(&par, "VOLControl.ChromaFormat", iLayerObj, (Int *)&rguiChromaFormat[iLayer][iObj]); GetIVal(&par, "VOLControl.LowDelay", iLayerObj, (Int *)&rguiLowDelay[iLayer][iObj]); Bool bVBVParams; readBoolParam(&par, "VOLControl.VBVParams.Enable", iLayerObj, &bVBVParams); rguiVBVParams[iLayer][iObj] = (UInt)bVBVParams; GetIVal(&par, "VOLControl.Bitrate", iLayerObj, (Int *)&rguiBitRate[iLayer][iObj]); GetIVal(&par, "VOLControl.VBVBuffer.Size", iLayerObj, (Int *)&rguiVbvBufferSize[iLayer][iObj]); GetIVal(&par, "VOLControl.VBVBuffer.Occupancy", iLayerObj, (Int *)&rguiVbvBufferOccupany[iLayer][iObj]); // version 2 start if(iVersion>=902) { readBoolParam(&par, "Newpred.Enable", iLayerObj, &rgbNewpredEnable [iLayer][iObj]); GetSVal(&par, "Newpred.SegmentType", iLayerObj, &pchTmp); if(strcmp(pchTmp, "VideoPacket")==0) rgbNewpredSegType [iLayer][iObj] = 0; else if(strcmp(pchTmp, "VOP")==0) rgbNewpredSegType [iLayer][iObj] = 1; else fatal_error("Unknown value for Newpred.SegmentType"); GetSVal(&par, "Newpred.Filename", iLayerObj, &pchTmp); iLen = strlen(pchTmp) + 1; pchNewpredRefName [iLayer][iObj] = new char [iLen]; memcpy(pchNewpredRefName [iLayer][iObj], pchTmp, iLen); GetSVal(&par, "Newpred.SliceList", iLayerObj, &pchTmp); iLen = strlen(pchTmp) + 1; pchNewpredSlicePoint [iLayer][iObj] = new char [iLen]; memcpy(pchNewpredSlicePoint [iLayer][iObj], pchTmp, iLen); Bool bTmp; readBoolParam(&par, "Texture.SADCT.Enable", iLayerObj, &bTmp); rgbSadctDisable [iLayer][iObj] = !bTmp; readBoolParam(&par, "Motion.QuarterSample.Enable", iLayerObj, &rgbQuarterSample [iLayer] [iObj]); readBoolParam(&par, "RRVMode.Enable", iLayerObj, &bTmp); RRVmode[iLayer][iObj].iOnOff = (Int)bTmp; GetIVal(&par, "RRVMode.Cycle", iLayerObj, &RRVmode[iLayer][iObj].iCycle); // START: Complexity Estimation syntax support - Update version 2 - Massimo Ravasi (EPFL) - 11 Nov 1999 // moved in if(bComplexityEnable) { ... } block above /*if(bComplexityEnable) { // complexity estimation GetIVal(&par, "Complexity.EstimationMethod", iLayerObj, (Int *)(&rguiEstimationMethod[iLayer][iObj])); readBoolParam(&par, "Complexity.SADCT.Enable", iLayerObj, &rgbSadct[iLayer][iObj]); readBoolParam(&par, "Complexity.QuarterPel.Enable", iLayerObj, &rgbQuarterpel[iLayer][iObj]); } */ // END: Complexity Estimation syntax support - Update version 2 } else { rgbNewpredEnable [iLayer][iObj] = 0; rgbNewpredSegType [iLayer][iObj] = 0; rgbSadctDisable [iLayer][iObj] = 1; rgbQuarterSample [iLayer][iObj] = 0; RRVmode[iLayer][iObj].iOnOff = 0; RRVmode[iLayer][iObj].iCycle = 0; // START: Complexity Estimation syntax support - Update version 2 - Massimo Ravasi (EPFL) - 11 Nov 1999 // moved in if(bComplexityEnable) { ... } block above /* rguiEstimationMethod[iLayer][iObj] = 0; rgbSadct[iLayer][iObj] = 0; rgbQuarterpel[iLayer][iObj] = 0; */ // END: Complexity Estimation syntax support - Update version 2 } // version 2 end } } // should have used this at top instead of all the extra variables // but too much work now to change - swinder SessionEncoderArgList args; args.uiFrmWidth = uiFrmWidth; // frame width args.uiFrmHeight = uiFrmHeight; // frame height args.iFirstFrm = firstFrm; // first frame number args.iLastFrm = lastFrm; // last frame number args.bNot8Bit = bNot8Bit; // NBIT args.uiQuantPrecision = uiQuantPrecision; // NBIT args.nBits = nBits; // NBIT args.iFirstVO = firstVO; // first VOP index args.iLastVO = lastVO; // last VOP index args.rguiVerID = rguiVerID; // Version ID // GMC args.rgbSpatialScalability = rgbSpatialScalability; // spatial scalability indicator args.rgiTemporalScalabilityType = rgiTemporalScalabilityType; // temporal scalability formation case args.rgiEnhancementType = rgiEnhancementType; // enhancement_type for scalability//OBSSFIX_MODE3 args.rgiEnhancementTypeSpatial= rgiEnhancementTypeSpatial; // enhancement_type for scalability//~OBSSFIX_MODE3 args.rguiRateControl = rguiRateControl; // rate control type args.rguiBudget = rguiBitsBudget; // for rate control args.rgfAlphaUsage = rgfAlphaUsage;// alpha usage for each VOP. 0: binary, 1: 8-bit args.rgiAlphaShapeExtension = rgiAlphaShapeExtension; // MAC-V2 (SB) args.rgbShapeOnly = rgbShapeOnly; // shape only mode args.rgiBinaryAlphaTH = rgiBinaryAlphaTH; args.rgiBinaryAlphaRR = rgiBinaryAlphaRR; // refresh rate args.rgiGrayToBinaryTH = rgiGrayToBinaryTH; args.rgbNoCrChange = rgbNoCrChange; args.rguiSearchRange = rguiSearchRange; // motion search range args.rgbOriginalForME = rgbOriginalME; // flag indicating whether use the original previous VOP for ME args.rgbAdvPredDisable = rgbAdvPredDisable; // no advanced MC (currenly = obmc, later = obmc + 8x8) args.rgbQuarterSample = rgbQuarterSample; // QuarterSample, mwi args.bCodeSequenceHead = bCodeSequenceHead; args.uiProfileAndLevel = uiProfileAndLevel; // complexity estimation args.rgbComplexityEstimationDisable = rgbComplexityEstimationDisable; args.rguiEstimationMethod = rguiEstimationMethod; args.rgbOpaque = rgbOpaque; args.rgbTransparent = rgbTransparent; args.rgbIntraCAE = rgbIntraCAE; args.rgbInterCAE = rgbInterCAE; args.rgbNoUpdate = rgbNoUpdate; args.rgbUpsampling = rgbUpsampling; args.rgbIntraBlocks = rgbIntraBlocks; args.rgbInterBlocks = rgbInterBlocks; args.rgbInter4vBlocks = rgbInter4vBlocks; args.rgbNotCodedBlocks = rgbNotCodedBlocks; args.rgbDCTCoefs = rgbDCTCoefs; args.rgbDCTLines = rgbDCTLines; args.rgbVLCSymbols = rgbVLCSymbols; args.rgbVLCBits = rgbVLCBits; args.rgbAPM = rgbAPM; args.rgbNPM = rgbNPM; args.rgbInterpolateMCQ = rgbInterpolateMCQ; args.rgbForwBackMCQ = rgbForwBackMCQ; args.rgbHalfpel2 = rgbHalfpel2; args.rgbHalfpel4 = rgbHalfpel4; args.rgbSadct = rgbSadct; args.rgbQuarterpel = rgbQuarterpel; args.rguiVolControlParameters = rguiVolControlParameters; args.rguiChromaFormat = rguiChromaFormat; args.rguiLowDelay = rguiLowDelay; args.rguiVBVParams = rguiVBVParams; args.rguiBitRate = rguiBitRate; args.rguiVbvBufferSize = rguiVbvBufferSize; args.rguiVbvBufferOccupany = rguiVbvBufferOccupany; args.rgdFrameFrequency = rgdFrameFrequency; // Frame Frequency args.rgbInterlacedCoding = rgbInterlacedCoding; // interlace coding flag args.rgbTopFieldFirst = rgbTopFieldFirst; // top field first flag args.rgbAlternateScan = rgbAlternateScan; // alternate scan flag args.rgbSadctDisable = rgbSadctDisable; args.rgiDirectModeRadius = rgiDirectModeRadius; // direct mode search radius args.rgiMVFileUsage = rgiMVFileUsage; // 0- not used, 1: read from motion file, 2- write to motion file args.pchMVFileName = &pchMVFileName[0]; // Motion vector filenames args.rgbNewpredEnable = rgbNewpredEnable; args.rgbNewpredSegmentType = rgbNewpredSegType; args.rgcNewpredRefName = pchNewpredRefName; args.rgcNewpredSlicePoint = pchNewpredSlicePoint; args.RRVmode = RRVmode;//RESYNC_MARKER_FIX args.rgbResyncMarkerDisable = rgbErrorResilientDisable;//~RESYNC_MARKER_FIX args.rgbVPBitTh = rgiVPBitTh; // Bit threshold for video packet spacing control args.rgbDataPartitioning = rgbDataPartitioning; // data partitioning args.rgbReversibleVlc = rgbReversibleVlc; // reversible VLC args.rgfQuant = rgfQuant; // quantizer selection, either H.263 or MPEG args.rgbLoadIntraMatrix = rgbLoadIntraMatrix; // load user-defined intra Q-Matrix args.rgppiIntraQuantizerMatrix = rgppiIntraQuantizerMatrix; // Intra Q-Matrix args.rgbLoadInterMatrix = rgbLoadInterMatrix; // load user-defined inter Q-Matrix args.rgppiInterQuantizerMatrix = rgppiInterQuantizerMatrix; // Inter Q-Matrix args.rgiIntraDCSwitchingThr = rgiIntraDCSwitchingThr; //threshold to code dc as ac when pred. is on args.rgiStepI = rgiIStep; // I-VOP quantization stepsize args.rgiStepP = rgiPStep; // P-VOP quantization stepsize args.rgbLoadIntraMatrixAlpha = rgbLoadIntraMatrixAlpha; args.rgppiIntraQuantizerMatrixAlpha = rgppiIntraQuantizerMatrixAlpha; args.rgbLoadInterMatrixAlpha = rgbLoadInterMatrixAlpha; args.rgppiInterQuantizerMatrixAlpha = rgppiInterQuantizerMatrixAlpha; args.rgiStepIAlpha = rgiIStepAlpha; // I-VOP quantization stepsize for Alpha args.rgiStepPAlpha = rgiPStepAlpha; // P-VOP quantization stepsize for Alpha args.rgiStepBAlpha = rgiBStepAlpha; // B-VOP quantization stepsize for Alpha args.rgbNoAlphaQuantUpdate = rgbNoGrayQuantUpdate; // discouple gray quant update with tex. quant args.rgiStepB = rgiStepBCode; // quantization stepsize for B-VOP args.rgiNumOfBbetweenPVOP = rgiNumBbetweenPVOP; // no of B-VOPs between P-VOPs args.rgiNumOfPbetweenIVOP = rgiNumPbetweenIVOP; // no of P-VOPs between I-VOPs args.rgiGOVperiod = rgiGOVperiod; args.rgbDeblockFilterDisable = rgbDeblockFilterDisable; //deblocking filter disable args.rgbAllowSkippedPMBs = rgbAllowSkippedPMBs; args.pchPrefix = pchPrefix; // prefix name of the movie args.pchBmpFiles = pchBmpDir; // bmp file directory location args.rgfChrType = rgfChrType; // input chrominance type. 0 - 4:4:4, 1 - 4:2:2, 0 - 4:2:0 args.pchOutBmpFiles = pchOutBmpDir; // quantized frame file directory args.pchOutStrFiles = pchOutStrFile; // output bitstream file args.rgiTemporalRate = rgiTSRate; // temporal subsampling rate args.rgiEnhcTemporalRate = rgiEnhcTSRate; // temporal subsampling rate for enhancement layer args.rgbDumpMB = rgbDumpMB; args.rgbTrace = rgbTrace; args.rgbRoundingControlDisable = rgbRoundingControlDisable; args.rgiInitialRoundingType = rgiInitialRoundingType; args.rguiSpriteUsage = rguiSpriteUsage; // sprite usage args.rguiWarpingAccuracy = rguiWarpingAccuracy; // warping accuracy args.rgNumOfPnts = rgiNumPnts; // number of points for sprite, 0 for stationary and -1 for no sprite args.pchSptDir = pchSptDir; // sprite directory args.pchSptPntDir = pchSptPntDir; // sprite point file args.pSpriteMode = rgSpriteMode; // sprite reconstruction mode args.iSpatialOption = iSpatialOption; args.uiFrameWidth_SS = uiFrmWidth_SS; args.uiFrameHeight_SS = uiFrmHeight_SS; args.uiHor_sampling_n = uiHor_sampling_n; args.uiHor_sampling_m = uiHor_sampling_m; args.uiVer_sampling_n = uiVer_sampling_n; args.uiVer_sampling_m = uiVer_sampling_m; args.uiUse_ref_shape = uiUseRefShape; args.uiUse_ref_texture = uiUseRefTexture; args.uiHor_sampling_n_shape = uiHor_sampling_n_shape; args.uiHor_sampling_m_shape = uiHor_sampling_m_shape; args.uiVer_sampling_n_shape = uiVer_sampling_n_shape; args.uiVer_sampling_m_shape = uiVer_sampling_m_shape; CSessionEncoder* penc = new CSessionEncoder (&args);#ifdef __PC_COMPILER_ Int tickBegin = ::GetTickCount ();#endif // __PC_COMPILER_ penc->encode();#ifdef __PC_COMPILER_ Int tickAfter = ::GetTickCount (); Int nFrames = 1 + (lastFrm - firstFrm) / rgiTSRate [0]; printf ("Total time: %d\n", tickAfter - tickBegin); Double dAverage = (Double) (tickAfter - tickBegin) / (Double) nFrames; printf ("Total frame %d\tAverage time: %.6lf\n", nFrames, dAverage); printf ("FPS %.6lf\n", 1000.0 / dAverage);#endif // __PC_COMPILER_ delete penc; for (Int iLayer = BASE_LAYER; iLayer <= ENHN_LAYER; iLayer++) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -