📄 app_encoder_encoder.cpp
字号:
Int iCh = getc(pfPara); if(iCh!='!') { fprintf(stderr, "Old-style parameter format is no longer supported.\n"); fprintf(stderr, "Use convertpar tool to convert you files to the new format.\n"); exit(1); } // NEW STYLE PARAMETER FILE CxParamSet par; char rgBuf[80]; char *pch = fgets(rgBuf, 79, pfPara); if(pch==NULL) fatal_error("Can't read magic number in parameter file"); if(strcmp("!!MS!!!\n", rgBuf)!=0) fatal_error("Bad magic number at start of parameter file"); int iLine; int er = par.Load(pfPara, &iLine); if(er!=ERES_OK) exit(printf("error (%d) in format at line %d of parameter file\n", er, iLine)); fclose(pfPara); // process the parameters GetIVal(&par, "Version", -1, &iVersion); if(iVersion<901 || iVersion>906) fatal_error("Incorrect parameter file version number for this compilation"); GetIVal(&par, "VTC.Enable", -1, &iVTCFlag); if(iVTCFlag) { char *VTCCtlFile; GetSVal(&par, "VTC.Filename", -1, &VTCCtlFile); RunVTCCodec(VTCCtlFile); return 0; } GetIVal(&par, "Source.Width", -1, (Int *)&uiFrmWidth); GetIVal(&par, "Source.Height", -1, (Int *)&uiFrmHeight); GetIVal(&par, "Source.FirstFrame", -1, (Int *)&firstFrm); GetIVal(&par, "Source.LastFrame", -1, (Int *)&lastFrm); fatal_error("Last frame number cannot be smaller than first frame number", lastFrm >= firstFrm); GetIVal(&par, "Source.BitsPerPel", -1, (Int *)&nBits); readBoolParam(&par, "Not8Bit.Enable", -1, &bNot8Bit); GetIVal(&par, "Not8Bit.QuantPrecision", -1, (Int *)&uiQuantPrecision); if(bNot8Bit) fatal_error("When Not8Bit is enabled, the __NBIT_ compile flag must be used.", sizeof(PixelC)!=sizeof(char)); else fatal_error("When Not8Bit is disabled, the __NBIT_ compile flag must not be used.", sizeof(PixelC)==sizeof(char)); if(bNot8Bit==0) { uiQuantPrecision = 5; nBits = 8; } fatal_error("Number of bits per pel is out of range", nBits>=4 && nBits<=12); Int iLen; char *pchTmp; GetSVal(&par, "Source.FilePrefix", -1, &pchTmp); iLen = strlen(pchTmp) + 1; pchPrefix = new char [iLen]; memcpy(pchPrefix, pchTmp, iLen); GetSVal(&par, "Source.Directory", -1, &pchTmp); iLen = strlen(pchTmp) + 1; pchBmpDir = new char [iLen]; memcpy(pchBmpDir, pchTmp, iLen); GetSVal(&par, "Output.Directory.DecodedFrames", -1, &pchTmp); iLen = strlen(pchTmp) + 1; pchOutBmpDir = new char [iLen]; memcpy(pchOutBmpDir, pchTmp, iLen); GetSVal(&par, "Output.Directory.Bitstream", -1, &pchTmp); iLen = strlen(pchTmp) + 1; pchOutStrFile = new char [iLen]; memcpy(pchOutStrFile, pchTmp, iLen); GetSVal(&par, "Sprite.Directory", -1, &pchTmp); iLen = strlen(pchTmp) + 1; pchSptDir = new char [iLen]; memcpy(pchSptDir, pchTmp, iLen); GetSVal(&par, "Sprite.Points.Directory", -1, &pchTmp); iLen = strlen(pchTmp) + 1; pchSptPntDir = new char [iLen]; memcpy(pchSptPntDir, pchTmp, iLen); GetIVal(&par, "Source.ObjectIndex.First", -1, (Int *)&firstVO); //GetIVal(&par, "Source.ObjectIndex.Last", -1, (Int *)&lastVO); lastVO = firstVO; fatal_error("First and last object indices don't make sense", lastVO>=firstVO); nVO = lastVO - firstVO + 1; Bool bCodeSequenceHead = FALSE; UInt uiProfileAndLevel = 0; if(iVersion>=906) { readBoolParam(&par, "Header.EncodeSessionInfo.Enable", -1, &bCodeSequenceHead); GetIVal(&par, "Header.ProfileAndLevel", -1, (Int *)&uiProfileAndLevel); } // allocate per-vo parameters rgiTemporalScalabilityType = new Int [nVO]; rgbSpatialScalability = new Bool [nVO]; rgbScalability = new Bool [nVO]; rgiEnhancementType = new Int [nVO];//OBSSFIX_MODE3 rgiEnhancementTypeSpatial = new Int [nVO];//~OBSSFIX_MODE3 rgfAlphaUsage = new AlphaUsage [nVO]; rgiAlphaShapeExtension = new Int [nVO]; rgbShapeOnly = new Bool [nVO]; rgiBinaryAlphaTH = new Int [nVO]; rgiGrayToBinaryTH = new Int [nVO]; rgbNoCrChange = new Bool [nVO]; rgiBinaryAlphaRR = new Int [nVO]; rgbRoundingControlDisable = new Bool [nVO]; rgiInitialRoundingType = new Int [nVO]; rgiNumPbetweenIVOP = new Int [nVO]; rgiNumBbetweenPVOP = new Int [nVO]; rgiGOVperiod = new Int [nVO]; rgbDeblockFilterDisable = new Bool [nVO]; rgiTSRate = new Int [nVO]; rgiEnhcTSRate = new Int [nVO]; rgfChrType = new ChromType [nVO]; rgbAllowSkippedPMBs = new Bool [nVO]; rgSpriteMode = new SptMode [nVO]; rgbDumpMB = new Bool [nVO]; rgbTrace = new Bool [nVO]; rguiSpriteUsage = new UInt [nVO]; rguiWarpingAccuracy = new UInt [nVO]; rgiNumPnts = new Int [nVO]; // version 2 start rguiVerID = new UInt [nVO]; // version 2 end Int iL; for(iL = BASE_LAYER; iL<=ENHN_LAYER; iL++) { // allocate per-layer parameters rguiRateControl [iL] = new UInt [nVO]; rguiBitsBudget [iL] = new UInt [nVO]; rgbAdvPredDisable [iL] = new Bool [nVO]; rgbErrorResilientDisable [iL] = new Bool [nVO]; rgbDataPartitioning [iL] = new Bool [nVO]; rgbReversibleVlc [iL] = new Bool [nVO]; rgiVPBitTh [iL] = new Int [nVO]; rgbInterlacedCoding [iL] = new Bool [nVO]; rgfQuant [iL] = new Quantizer [nVO]; rgbLoadIntraMatrix [iL] = new Bool [nVO]; rgppiIntraQuantizerMatrix [iL] = new Int * [nVO]; rgbLoadInterMatrix [iL] = new Bool [nVO]; rgppiInterQuantizerMatrix [iL] = new Int * [nVO]; rgiIntraDCSwitchingThr [iL] = new Int [nVO]; rgiIStep [iL] = new Int [nVO]; rgiPStep [iL] = new Int [nVO]; rgiStepBCode [iL] = new Int [nVO]; rgbLoadIntraMatrixAlpha [iL] = new Bool [nVO]; rgppiIntraQuantizerMatrixAlpha [iL] = new Int * [nVO]; rgbLoadInterMatrixAlpha [iL] = new Bool [nVO]; rgppiInterQuantizerMatrixAlpha [iL] = new Int * [nVO]; rgiIStepAlpha [iL] = new Int [nVO]; rgiPStepAlpha [iL] = new Int [nVO]; rgiBStepAlpha [iL] = new Int [nVO]; rgbNoGrayQuantUpdate [iL] = new Bool [nVO]; rguiSearchRange [iL] = new UInt [nVO]; rgbOriginalME [iL] = new Bool [nVO]; rgbComplexityEstimationDisable [iL] = new Bool [nVO]; rgbOpaque [iL] = new Bool [nVO]; rgbTransparent [iL] = new Bool [nVO]; rgbIntraCAE [iL] = new Bool [nVO]; rgbInterCAE [iL] = new Bool [nVO]; rgbNoUpdate [iL] = new Bool [nVO]; rgbUpsampling [iL] = new Bool [nVO]; rgbIntraBlocks [iL] = new Bool [nVO]; rgbInterBlocks [iL] = new Bool [nVO]; rgbInter4vBlocks [iL] = new Bool [nVO]; rgbNotCodedBlocks [iL] = new Bool [nVO]; rgbDCTCoefs [iL] = new Bool [nVO]; rgbDCTLines [iL] = new Bool [nVO]; rgbVLCSymbols [iL] = new Bool [nVO]; rgbVLCBits [iL] = new Bool [nVO]; rgbAPM [iL] = new Bool [nVO]; rgbNPM [iL] = new Bool [nVO]; rgbInterpolateMCQ [iL] = new Bool [nVO]; rgbForwBackMCQ [iL] = new Bool [nVO]; rgbHalfpel2 [iL] = new Bool [nVO]; rgbHalfpel4 [iL] = new Bool [nVO]; rguiVolControlParameters [iL] = new UInt [nVO]; rguiChromaFormat [iL] = new UInt [nVO]; rguiLowDelay [iL] = new UInt [nVO]; rguiVBVParams [iL] = new UInt [nVO]; rguiBitRate [iL] = new UInt [nVO]; rguiVbvBufferSize [iL] = new UInt [nVO]; rguiVbvBufferOccupany [iL] = new UInt [nVO]; rgdFrameFrequency [iL] = new Double [nVO]; rgbTopFieldFirst [iL] = new Bool [nVO]; rgbAlternateScan [iL] = new Bool [nVO]; rgiDirectModeRadius [iL] = new Bool [nVO]; rgiMVFileUsage[iL] = new Int [nVO]; pchMVFileName[iL] = new char * [nVO]; // version 2 start rgbNewpredEnable[iL] = new Bool [nVO]; rgbNewpredSegType[iL] = new Bool [nVO]; pchNewpredRefName[iL] = new char * [nVO]; pchNewpredSlicePoint[iL] = new char * [nVO]; rgbSadctDisable[iL] = new Bool [nVO]; rgbQuarterSample[iL] = new Bool [nVO]; RRVmode[iL] = new RRVmodeStr [nVO]; rguiEstimationMethod [iL] = new UInt [nVO]; rgbSadct [iL] = new Bool [nVO]; rgbQuarterpel [iL] = new Bool [nVO]; // version 2 end } for (iObj = 0; iObj < nVO; iObj++) { // per object alloc rgppiIntraQuantizerMatrix [BASE_LAYER] [iObj] = new Int [BLOCK_SQUARE_SIZE]; rgppiIntraQuantizerMatrix [ENHN_LAYER] [iObj] = new Int [BLOCK_SQUARE_SIZE]; rgppiInterQuantizerMatrix [BASE_LAYER] [iObj] = new Int [BLOCK_SQUARE_SIZE]; rgppiInterQuantizerMatrix [ENHN_LAYER] [iObj] = new Int [BLOCK_SQUARE_SIZE]; rgppiIntraQuantizerMatrixAlpha [BASE_LAYER] [iObj] = new Int [BLOCK_SQUARE_SIZE]; rgppiIntraQuantizerMatrixAlpha [ENHN_LAYER] [iObj] = new Int [BLOCK_SQUARE_SIZE]; rgppiInterQuantizerMatrixAlpha [BASE_LAYER] [iObj] = new Int [BLOCK_SQUARE_SIZE]; rgppiInterQuantizerMatrixAlpha [ENHN_LAYER] [iObj] = new Int [BLOCK_SQUARE_SIZE]; pchMVFileName[BASE_LAYER] [iObj] = NULL; pchMVFileName[ENHN_LAYER] [iObj] = NULL; pchNewpredRefName [BASE_LAYER][iObj] = NULL; pchNewpredRefName [ENHN_LAYER][iObj] = NULL; pchNewpredSlicePoint [BASE_LAYER][iObj] = NULL; pchNewpredSlicePoint [ENHN_LAYER][iObj] = NULL; // per object parameters GetSVal(&par, "Scalability", iObj, &pchTmp); if(strcmp(pchTmp, "Temporal")==0) { bAnyScalability = TRUE; rgbScalability[iObj] = TEMPORAL_SCALABILITY; } else if(strcmp(pchTmp, "Spatial")==0) { bAnyScalability = TRUE; rgbScalability[iObj] = SPATIAL_SCALABILITY; } else if(strcmp(pchTmp, "None")==0) { bAnyScalability = FALSE; rgbScalability[iObj] = NO_SCALABILITY; } else fatal_error("Unknown scalability type"); if(rgbScalability[iObj] == SPATIAL_SCALABILITY || rgbScalability[iObj] == TEMPORAL_SCALABILITY) rgbSpatialScalability[iObj] = TRUE; else rgbSpatialScalability[iObj] = FALSE; } //coded added by Sony, only deals with ONE VO. //Type option of Spatial Scalable Coding //This parameter is used for dicision VOP prediction types of Enhancement layer in Spatial Scalable Coding //If this option is set to 0, Enhancement layer is coded as "PPPPPP......", //else if set to 1 ,It's coded as "PBBBB......." if(rgbScalability[0] == SPATIAL_SCALABILITY) { fatal_error("Spatial scalability currently only works with one VO", nVO==1); GetSVal(&par, "Scalability.Spatial.PredictionType", 0, &pchTmp); if(strcmp(pchTmp, "PPP")==0) iSpatialOption = 1; else if(strcmp(pchTmp, "PBB")==0) iSpatialOption = 0; else fatal_error("Unknown spatial scalability prediction type"); if (iSpatialOption == 1) fprintf(stdout,"Enhancement layer is coded as \"PPPPP.....\"\n"); else fprintf(stdout,"Enhancement layer is coded as \"PBBBB.....\"\n"); } if(bAnyScalability) { //Load enhancement layer (Spatial Scalable) size // should really be inside above if-statement GetIVal(&par, "Scalability.Spatial.Width", 0, (Int *)&uiFrmWidth_SS); GetIVal(&par, "Scalability.Spatial.Height", 0, (Int *)&uiFrmHeight_SS); //load upsampling factor GetIVal(&par, "Scalability.Spatial.HorizFactor.N", 0, (Int *)&uiHor_sampling_n); GetIVal(&par, "Scalability.Spatial.HorizFactor.M", 0, (Int *)&uiHor_sampling_m); GetIVal(&par, "Scalability.Spatial.VertFactor.N", 0, (Int *)&uiVer_sampling_n); GetIVal(&par, "Scalability.Spatial.VertFactor.M", 0, (Int *)&uiVer_sampling_m); if(iVersion>=902) { // version 2 parameters readBoolParam(&par, "Scalability.Spatial.UseRefShape.Enable", 0, (Bool *)&uiUseRefShape); readBoolParam(&par, "Scalability.Spatial.UseRefTexture.Enable", 0, (Bool *)&uiUseRefTexture); GetIVal(&par, "Scalability.Spatial.Shape.HorizFactor.N", 0, (Int *)&uiHor_sampling_n_shape); GetIVal(&par, "Scalability.Spatial.Shape.HorizFactor.M", 0, (Int *)&uiHor_sampling_m_shape); GetIVal(&par, "Scalability.Spatial.Shape.VertFactor.N", 0, (Int *)&uiVer_sampling_n_shape); GetIVal(&par, "Scalability.Spatial.Shape.VertFactor.M", 0, (Int *)&uiVer_sampling_m_shape);//OBSSFIX_MODE3 if(iVersion >=904){ GetSVal(&par, "Scalability.Spatial.EnhancementType", 0, &pchTmp); if(strcmp(pchTmp, "Full") == 0) rgiEnhancementTypeSpatial [0] = 0; else if(strcmp(pchTmp, "PartC") == 0) rgiEnhancementTypeSpatial [0] = 1; else if(strcmp(pchTmp, "PartNC") == 0) rgiEnhancementTypeSpatial [0] = 2; else fatal_error("Unknown Spatial Scalability Enhancement Type."); }//~OBSSFIX_MODE3 } else { // version 2 default values uiUseRefShape = 0; uiUseRefTexture = 0; uiHor_sampling_n_shape = 0; uiHor_sampling_m_shape = 0; uiVer_sampling_n_shape = 0; uiVer_sampling_m_shape = 0;//OBSSFIX_MODE3 rgiEnhancementType[0] = 0; rgiEnhancementTypeSpatial[0] = 0;//~OBSSFIX_MODE3 } } for (iObj = 0; iObj < nVO; iObj++) { if(bAnyScalability) { // temporal scalability // form of temporal scalability indicators // case 0 Enhn P P .... // Base I P P .... // case 1 Enhn B B B B .... // Base I P P .... // case 2 Enhn P B B .... // Base I B P B .... GetIVal(&par, "Scalability.Temporal.PredictionType", iObj, &rgiTemporalScalabilityType [iObj]); fatal_error("Scalability.Temporal.PredictionType must range from 0 to 4", rgiTemporalScalabilityType [iObj]>=0 && rgiTemporalScalabilityType [iObj]<=4); GetSVal(&par, "Scalability.Temporal.EnhancementType", iObj, &pchTmp);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -