📄 encoder.cpp
字号:
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);
fatal_error("First and last object indices don't make sense", lastVO>=firstVO);
nVO = lastVO - firstVO + 1;
// allocate per-vo parameters
rgiTemporalScalabilityType = new Int [nVO];
rgbSpatialScalability = new Bool [nVO];
rgbScalability = new Bool [nVO];
rgiEnhancementType = new Int [nVO];
rgfAlphaUsage = new AlphaUsage [nVO];
rgbShapeOnly = new Bool [nVO];
rgiBinaryAlphaTH = 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];
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];
}
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;
// 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);
}
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);
if(strcmp(pchTmp, "Full")==0)
rgiEnhancementType [iObj] = 0;
else if(strcmp(pchTmp, "PartC")==0)
rgiEnhancementType [iObj] = 1;
else if(strcmp(pchTmp, "PartNC")==0)
rgiEnhancementType [iObj] = 2;
else
fatal_error("Unknown temporal scalability enhancement type");
}
// alpha usage
GetSVal(&par, "Alpha.Type", iObj, &pchTmp);
rgbShapeOnly[iObj] = FALSE;
if(strcmp(pchTmp, "None")==0)
rgfAlphaUsage[iObj] = RECTANGLE;
else if(strcmp(pchTmp, "Binary")==0)
rgfAlphaUsage[iObj] = ONE_BIT;
else if(strcmp(pchTmp, "Gray")==0)
rgfAlphaUsage[iObj] = EIGHT_BIT;
else if(strcmp(pchTmp, "ShapeOnly")==0)
{
rgbShapeOnly[iObj] = TRUE;
rgfAlphaUsage[iObj] = ONE_BIT;
}
else
fatal_error("Unknown alpha type");
GetIVal(&par, "Alpha.Binary.RoundingThreshold", iObj, &rgiBinaryAlphaTH [iObj]);
fatal_error("Binary rounding threshold must be >= 0", rgiBinaryAlphaTH [iObj] >= 0);
Bool bSizeConvEnable;
readBoolParam(&par, "Alpha.Binary.SizeConversion.Enable", iObj, &bSizeConvEnable);
rgbNoCrChange [iObj] = !bSizeConvEnable;
if (rgiBinaryAlphaTH [iObj] == 0 && rgbNoCrChange [iObj] == 0)
{
printf("Size conversion was disabled since binary rounding threshold is zero");
rgbNoCrChange [iObj] = TRUE;
}
GetIVal(&par, "ErrorResil.AlphaRefreshRate", iObj, &rgiBinaryAlphaRR [iObj]);
fatal_error("Alpha refresh rate must be >= 0", rgiBinaryAlphaRR [iObj] >= 0);
Bool bRoundingControlEnable;
readBoolParam(&par, "Motion.RoundingControl.Enable", iObj, &bRoundingControlEnable);
rgbRoundingControlDisable [iObj] = !bRoundingControlEnable;
GetIVal(&par, "Motion.RoundingControl.StartValue", iObj, &rgiInitialRoundingType [iObj]);
fatal_error("Rounding control start value must be either 0 or 1",
rgiInitialRoundingType [iObj]==0 || rgiInitialRoundingType [iObj]==1);
GetIVal(&par, "Motion.PBetweenICount", iObj, &rgiNumPbetweenIVOP [iObj]);
if(rgiNumPbetweenIVOP [iObj] < 0)
rgiNumPbetweenIVOP [iObj] = lastFrm - firstFrm + 1; //only 1 I at the beginning
GetIVal(&par, "Motion.BBetweenPCount", iObj, &rgiNumBbetweenPVOP [iObj]);
fatal_error("Motion.BBetweenPCount must be >= 0", rgiNumBbetweenPVOP [iObj]>=0);
//number of VOP between GOV header
//CAUTION:GOV period is not used in spatial scalable coding
Bool bGOVEnable;
readBoolParam(&par, "GOV.Enable", iObj, &bGOVEnable);
if(!bGOVEnable)
rgiGOVperiod[iObj] = 0;
else
GetIVal(&par, "GOV.Period", iObj, &rgiGOVperiod[iObj]);
Bool bDeblockingFilterEnable;
readBoolParam(&par, "Motion.DeblockingFilter.Enable", iObj, &bDeblockingFilterEnable);
rgbDeblockFilterDisable[iObj] = !bDeblockingFilterEnable;
GetSVal(&par, "Source.Format", iObj, &pchTmp);
if(strcmp(pchTmp, "444")==0)
rgfChrType[iObj] = FOUR_FOUR_FOUR;
else if(strcmp(pchTmp, "422")==0)
rgfChrType[iObj] = FOUR_TWO_TWO;
else if(strcmp(pchTmp, "420")==0)
rgfChrType[iObj] = FOUR_TWO_ZERO;
else
fatal_error("Unrecognised source format");
GetSVal(&par, "Sprite.Type", iObj, &pchTmp);
if(strcmp(pchTmp, "None")==0)
rguiSpriteUsage[iObj] = 0;
else if(strcmp(pchTmp, "Static")==0)
rguiSpriteUsage[iObj] = 1;
else
fatal_error("Unknown value for Sprite.Type");
if (rgbScalability [iObj] == TRUE && rguiSpriteUsage[iObj]==1)
fatal_error("Sprite and scalability modes cannot be combined");
GetSVal(&par, "Sprite.WarpAccuracy", iObj, &pchTmp);
if(strcmp(pchTmp, "1/2")==0)
rguiWarpingAccuracy[iObj] = 0;
else if(strcmp(pchTmp, "1/4")==0)
rguiWarpingAccuracy[iObj] = 1;
else if(strcmp(pchTmp, "1/8")==0)
rguiWarpingAccuracy[iObj] = 2;
else if(strcmp(pchTmp, "1/16")==0)
rguiWarpingAccuracy[iObj] = 3;
else
fatal_error("Unknown value for Sprite.WarpAccuracy");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -