📄 configfile.c
字号:
}
// input basicunit represents the number of BUs in a frame
// internal basicunit is the number of MBs in a BU
input->basicunit = ((input->img_height+img->auto_crop_bottom)*(input->img_width+img->auto_crop_right)/256) / input->basicunit;
if ( input->RCEnable && (input->successive_Bframe || input->jumpd) && input->RCUpdateMode == RC_MODE_1 )
{
snprintf(errortext, ET_SIZE, "Use RCUpdateMode = 1 only for all intra or all B-slice coding.");
error (errortext, 500);
}
if ( input->RCEnable && input->BRefPictures == 2 && input->intra_period == 0 && input->RCUpdateMode != RC_MODE_1 )
{
snprintf(errortext, ET_SIZE, "Use RCUpdateMode = 1 for all B-slice coding.");
error (errortext, 500);
}
if ( input->RCEnable && input->HierarchicalCoding && input->RCUpdateMode != RC_MODE_2 && input->RCUpdateMode != RC_MODE_3 )
{
snprintf(errortext, ET_SIZE, "Use RCUpdateMode = 2 or 3 for hierarchical B-picture coding.");
error (errortext, 500);
}
if ( input->RCEnable && (input->RCUpdateMode != RC_MODE_1) && (input->intra_period == 1) )
{
snprintf(errortext, ET_SIZE, "Use RCUpdateMode = 1 for all intra coding.");
error (errortext, 500);
}
}
if ((input->successive_Bframe)&&(input->BRefPictures)&&(input->idr_period)&&(input->pic_order_cnt_type!=0))
{
error("Stored B pictures combined with IDR pictures only supported in Picture Order Count type 0\n",-1000);
}
if( !input->direct_spatial_mv_pred_flag && input->num_ref_frames<2 && input->successive_Bframe >0)
error("temporal direct needs at least 2 ref frames\n",-1000);
// frext
if(input->Transform8x8Mode && input->sp_periodicity /*SP-frames*/)
{
snprintf(errortext, ET_SIZE, "\nThe new 8x8 mode is not implemented for sp-frames.");
error (errortext, 500);
}
if(input->Transform8x8Mode && ( input->ProfileIDC<FREXT_HP && input->ProfileIDC!=FREXT_CAVLC444 ))
{
snprintf(errortext, ET_SIZE, "\nTransform8x8Mode may be used only with ProfileIDC %d to %d.", FREXT_HP, FREXT_Hi444);
error (errortext, 500);
}
if(input->ScalingMatrixPresentFlag && ( input->ProfileIDC<FREXT_HP && input->ProfileIDC!=FREXT_CAVLC444 ))
{
snprintf(errortext, ET_SIZE, "\nScalingMatrixPresentFlag may be used only with ProfileIDC %d to %d.", FREXT_HP, FREXT_Hi444);
error (errortext, 500);
}
if(input->yuv_format==YUV422 && ( input->ProfileIDC < FREXT_Hi422 && input->ProfileIDC!=FREXT_CAVLC444 ))
{
snprintf(errortext, ET_SIZE, "\nFRExt Profile(YUV Format) Error!\nYUV422 can be used only with ProfileIDC %d or %d\n",FREXT_Hi422, FREXT_Hi444);
error (errortext, 500);
}
if(input->yuv_format==YUV444 && ( input->ProfileIDC < FREXT_Hi444 && input->ProfileIDC!=FREXT_CAVLC444 ))
{
snprintf(errortext, ET_SIZE, "\nFRExt Profile(YUV Format) Error!\nYUV444 can be used only with ProfileIDC %d.\n",FREXT_Hi444);
error (errortext, 500);
}
if (input->successive_Bframe && ((input->BiPredMotionEstimation) && (input->search_range < input->BiPredMESearchRange)))
{
snprintf(errortext, ET_SIZE, "\nBiPredMESearchRange must be smaller or equal SearchRange.");
error (errortext, 500);
}
// check consistency
if ( input->ChromaMEEnable && !(input->ChromaMCBuffer) ) {
snprintf(errortext, ET_SIZE, "\nChromaMCBuffer must be set to 1 if ChromaMEEnable is set.");
error (errortext, 500);
}
if ( input->ChromaMEEnable && input->yuv_format == YUV400) {
snprintf(errortext, ET_SIZE, "\nChromaMEEnable cannot be used with YUV400 color format.");
input->ChromaMEEnable = 0;
}
if (input->EnableOpenGOP && input->PicInterlace)
{
snprintf(errortext, ET_SIZE, "Open GOP currently not supported for Field coded pictures.");
error (errortext, 500);
}
if (input->EnableOpenGOP)
input->ReferenceReorder = 1;
input->EPZSGrid = input->EPZSSubPelGrid << 1;
if (input->redundant_pic_flag)
{
if (input->PicInterlace || input->MbInterlace)
{
snprintf(errortext, ET_SIZE, "Redundant pictures cannot be used with interlaced tools.");
error (errortext, 500);
}
if (input->RDPictureDecision)
{
snprintf(errortext, ET_SIZE, "Redundant pictures cannot be used with RDPictureDecision.");
error (errortext, 500);
}
if (input->successive_Bframe)
{
snprintf(errortext, ET_SIZE, "Redundant pictures cannot be used with B frames.");
error (errortext, 500);
}
if (input->PrimaryGOPLength < (1 << input->NumRedundantHierarchy))
{
snprintf(errortext, ET_SIZE, "PrimaryGOPLength must be equal or greater than 2^NumRedundantHierarchy.");
error (errortext, 500);
}
if (input->num_ref_frames < input->PrimaryGOPLength)
{
snprintf(errortext, ET_SIZE, "NumberReferenceFrames must be greater than or equal to PrimaryGOPLength.");
error (errortext, 500);
}
}
if (input->num_ref_frames == 1 && input->successive_Bframe)
{
fprintf( stderr, "\nWarning: B slices used but only one reference allocated within reference buffer.\n");
fprintf( stderr, " Performance may be considerably compromised! \n");
fprintf( stderr, " 2 or more references recommended for use with B slices.\n");
}
if ((input->HierarchicalCoding || input->BRefPictures) && input->successive_Bframe)
{
fprintf( stderr, "\nWarning: Hierarchical coding or Referenced B slices used.\n");
fprintf( stderr, " Make sure that you have allocated enough references\n");
fprintf( stderr, " in reference buffer to achieve best performance.\n");
}
ProfileCheck();
LevelCheck();
}
void PatchInputNoFrames(void)
{
// Tian Dong: May 31, 2002
// If the frames are grouped into two layers, "FramesToBeEncoded" in the config file
// will give the number of frames which are in the base layer. Here we let input->no_frames
// be the total frame numbers.
input->no_frames = 1 + (input->no_frames - 1) * (input->NumFramesInELSubSeq + 1);
}
static void ProfileCheck(void)
{
if((input->ProfileIDC != 66 ) &&
(input->ProfileIDC != 77 ) &&
(input->ProfileIDC != 88 ) &&
(input->ProfileIDC != FREXT_HP ) &&
(input->ProfileIDC != FREXT_Hi10P ) &&
(input->ProfileIDC != FREXT_Hi422 ) &&
(input->ProfileIDC != FREXT_Hi444 ) &&
(input->ProfileIDC != FREXT_CAVLC444 ))
{
snprintf(errortext, ET_SIZE, "Profile must be in\n\n 66 (Baseline),\n 77 (Main),\n 88 (Extended),\n 100 (High),\n 110 (High 10 or High 10 Intra)\n"
" 122 (High 4:2:2 or High 4:2:2 Intra),\n 244 (High 4:4:4 predictive or High 4:4:4 Intra),\n 44 (CAVLC 4:4:4 Intra)\n");
error (errortext, 500);
}
if ((input->partition_mode) && (input->symbol_mode==CABAC))
{
snprintf(errortext, ET_SIZE, "Data partitioning and CABAC is not supported in any profile.");
error (errortext, 500);
}
if (input->redundant_pic_flag)
{
if (input->ProfileIDC != 66)
{
snprintf(errortext, ET_SIZE, "Redundant pictures are only allowed in Baseline profile (ProfileIDC = 66).");
error (errortext, 500);
}
}
if (input->partition_mode)
{
if (input->ProfileIDC != 88)
{
snprintf(errortext, ET_SIZE, "Data partitioning is only allowed in Extended profile (ProfileIDC = 88).");
error (errortext, 500);
}
}
if (input->ChromaIntraDisable && input->FastCrIntraDecision)
{
fprintf( stderr, "\n Warning: ChromaIntraDisable and FastCrIntraDecision cannot be combined together.\n Using only Chroma Intra DC mode.\n");
input->FastCrIntraDecision=0;
}
if ((input->sp_periodicity) && (input->ProfileIDC != 88 ))
{
snprintf(errortext, ET_SIZE, "SP pictures are only allowed in Extended profile (ProfileIDC = 88).");
error (errortext, 500);
}
// baseline
if (input->ProfileIDC == 66 )
{
if ((input->successive_Bframe || input->BRefPictures==2) && input->PReplaceBSlice == 0)
{
snprintf(errortext, ET_SIZE, "B slices are not allowed in Baseline profile (ProfileIDC = 66).");
error (errortext, 500);
}
if (input->WeightedPrediction)
{
snprintf(errortext, ET_SIZE, "Weighted prediction is not allowed in Baseline profile (ProfileIDC = 66).");
error (errortext, 500);
}
if (input->WeightedBiprediction)
{
snprintf(errortext, ET_SIZE, "Weighted prediction is not allowed in Baseline profile (ProfileIDC = 66).");
error (errortext, 500);
}
if (input->symbol_mode == CABAC)
{
snprintf(errortext, ET_SIZE, "CABAC is not allowed in Baseline profile (ProfileIDC = 66).");
error (errortext, 500);
}
}
// main
if (input->ProfileIDC == 77 )
{
if (input->num_slice_groups_minus1)
{
snprintf(errortext, ET_SIZE, "num_slice_groups_minus1>0 (FMO) is not allowed in Main profile (ProfileIDC = 77).");
error (errortext, 500);
}
}
// extended
if (input->ProfileIDC == 88 )
{
if (!input->directInferenceFlag)
{
snprintf(errortext, ET_SIZE, "direct_8x8_inference flag must be equal to 1 in Extended profile (ProfileIDC = 88).");
error (errortext, 500);
}
if (input->symbol_mode == CABAC)
{
snprintf(errortext, ET_SIZE, "CABAC is not allowed in Extended profile (ProfileIDC = 88).");
error (errortext, 500);
}
}
//FRExt
if ( input->separate_colour_plane_flag )
{
if( input->yuv_format!=3 )
{
fprintf( stderr, "\nWarning: SeparateColourPlane has only effect in 4:4:4 chroma mode (YUVFormat=3),\n disabling SeparateColourPlane.");
input->separate_colour_plane_flag = 0;
}
if ( input->ChromaMEEnable )
{
snprintf(errortext, ET_SIZE, "\nChromaMEEnable is not allowed when SeparateColourPlane is enabled.");
error (errortext, 500);
}
}
// CAVLC 4:4:4 Intra
if ( input->ProfileIDC == FREXT_CAVLC444 )
{
if ( input->symbol_mode != CAVLC )
{
snprintf(errortext, ET_SIZE, "\nCABAC is not allowed in CAVLC 4:4:4 Intra profile (ProfileIDC = 44).");
error (errortext, 500);
}
if ( !input->IntraProfile )
{
fprintf (stderr, "\nWarning: ProfileIDC equal to 44 implies an Intra only profile, setting IntraProfile = 1.");
input->IntraProfile = 1;
}
}
// Intra only profiles
if (input->IntraProfile && ( input->ProfileIDC<FREXT_HP && input->ProfileIDC!=FREXT_CAVLC444 ))
{
snprintf(errortext, ET_SIZE, "\nIntraProfile is allowed only with ProfileIDC %d to %d.", FREXT_HP, FREXT_Hi444);
error (errortext, 500);
}
if (input->IntraProfile && !input->idr_period)
{
snprintf(errortext, ET_SIZE, "\nIntraProfile requires IDRPeriod >= 1.");
error (errortext, 500);
}
if (input->IntraProfile && input->intra_period != 1)
{
snprintf(errortext, ET_SIZE, "\nIntraProfile requires IntraPeriod equal 1.");
error (errortext, 500);
}
if (input->IntraProfile && input->num_ref_frames)
{
fprintf( stderr, "\nWarning: Setting NumberReferenceFrames to 0 in IntraProfile.");
input->num_ref_frames = 0;
}
if (input->IntraProfile == 0 && input->num_ref_frames == 0)
{
snprintf(errortext, ET_SIZE, "\nProfiles other than IntraProfile require NumberReferenceFrames > 0.");
error (errortext, 500);
}
}
// Level Limit - - - - - - - - - 1b 10 11 12 13 - - - - - - 20 21 22 - - - - - - -
unsigned int MaxFs [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 99, 396, 396, 396, 0, 0, 0, 0, 0, 0, 396, 792, 1620, 0, 0, 0, 0, 0, 0, 0,
// 30 31 32 - - - - - - - 40 41 42 - - - - - - - 50 51
1620, 3600, 5120, 0, 0, 0, 0, 0, 0, 0, 8192, 8192, 8704, 0, 0, 0, 0, 0, 0, 0, 22080, 36864 };
unsigned getMaxFs (unsigned int levelIdc)
{
unsigned int ret;
if ( (levelIdc < 9) || (levelIdc > 51))
error ("getMaxFs: Unknown LevelIdc", 500);
// in Baseline, Main and Extended: Level 1b is specified with LevelIdc==11 and constrained_set3_flag == 1
ret = MaxFs[levelIdc];
if ( 0 == ret )
error ("getMaxFs: Unknown LevelIdc", 500);
return ret;
}
static void LevelCheck(void)
{
unsigned int PicSizeInMbs = ( (input->img_width + img->auto_crop_right) * (input->img_height + img->auto_crop_bottom) ) >> 8;
if ( (input->LevelIDC>=30) && (input->directInferenceFlag==0))
{
fprintf( stderr, "\nWarning: LevelIDC 3.0 and above require direct_8x8_inference to be set to 1. Please check your settings.\n");
input->directInferenceFlag=1;
}
if ( ((input->LevelIDC<21) || (input->LevelIDC>41)) && (input->PicInterlace > 0 || input->MbInterlace > 0) )
{
snprintf(errortext, ET_SIZE, "\nInterlace modes only supported for LevelIDC in the range of 21 and 41. Please check your settings.\n");
error (errortext, 500);
}
if ( PicSizeInMbs > getMaxFs(input->LevelIDC) )
{
snprintf(errortext, ET_SIZE, "\nPicSizeInMbs exceeds maximum allowed size at specified LevelIdc %d\n", input->LevelIDC);
error (errortext, 500);
}
if (input->IntraProfile && (PicSizeInMbs > 1620) && input->slice_mode != 1)
{
error ("\nIntraProfile with PicSizeInMbs > 1620 requires SliceMode equal 1.", 500);
}
if (input->IntraProfile && (PicSizeInMbs > 1620) && ((unsigned int)input->slice_argument > ( getMaxFs(input->LevelIDC) >> 2 ) ) )
{
//when PicSizeInMbs is greater than 1620, the number of macroblocks in any coded slice shall not exceed MaxFS / 4
snprintf(errortext, ET_SIZE, "\nIntraProfile requires SliceArgument smaller or equal to 1/4 MaxFs at specified LevelIdc %d.", input->LevelIDC);
error (errortext, 500);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -