📄 configfile.c
字号:
for (i=0;i<mapunit_height*mb_width;i++)
{
fscanf(sgfile,"%d", &tmp);
input->slice_group_id[i]= (byte) tmp;
if ( *(input->slice_group_id+i) > input->num_slice_groups_minus1 )
{
snprintf(errortext, ET_SIZE, "Error read slice group information from file %s", input->SliceGroupConfigFileName);
error (errortext, 500);
}
fscanf(sgfile,"%*[^\n]");
}
}
fclose(sgfile);
}
}
if (input->ReferenceReorder && (input->PicInterlace || input->MbInterlace))
{
snprintf(errortext, ET_SIZE, "ReferenceReorder Not supported with Interlace encoding methods\n");
error (errortext, 400);
}
if (input->PocMemoryManagement && (input->PicInterlace || input->MbInterlace))
{
snprintf(errortext, ET_SIZE, "PocMemoryManagement not supported with Interlace encoding methods\n");
error (errortext, 400);
}
// frame/field consistency check
if (input->PicInterlace != FRAME_CODING && input->PicInterlace != ADAPTIVE_CODING && input->PicInterlace != FIELD_CODING)
{
snprintf (errortext, ET_SIZE, "Unsupported PicInterlace=%d, use frame based coding=0 or field based coding=1 or adaptive=2",input->PicInterlace);
error (errortext, 400);
}
// frame/field consistency check
if (input->MbInterlace != FRAME_CODING && input->MbInterlace != ADAPTIVE_CODING && input->MbInterlace != FIELD_CODING)
{
snprintf (errortext, ET_SIZE, "Unsupported MbInterlace=%d, use frame based coding=0 or field based coding=1 or adaptive=2",input->MbInterlace);
error (errortext, 400);
}
if ((!input->rdopt)&&(input->MbInterlace))
{
snprintf(errortext, ET_SIZE, "MB AFF is not compatible with non-rd-optimized coding.");
error (errortext, 500);
}
/*if (input->rdopt>2)
{
snprintf(errortext, ET_SIZE, "RDOptimization=3 mode has been deactivated do to diverging of real and simulated decoders.");
error (errortext, 500);
}*/
// check RDoptimization mode and profile. FMD does not support Frex Profiles.
if (input->rdopt==2 && input->ProfileIDC>=FREXT_HP)
{
snprintf(errortext, ET_SIZE, "Fast Mode Decision methods does not support FREX Profiles");
error (errortext, 500);
}
#ifdef ADAPTIVE_FD_SD_CODING
if (input->APEC_in_FD_and_SD!=0)
{
if(input->rdopt!=1)
{
snprintf(errortext, ET_SIZE, "Adaptive prediction error coding is only supported in combination with RD-Optimization in the High complexity mode");
error (errortext, 500);
}
if(input->symbol_mode==0)
error ("APEC is not compatible with CAVLC.",0);
#ifdef USE_INTRA_MDDT
if(input->UseIntraMDDT)
error ("APEC is not compatible with Intra MDDT",0);
#endif
}
#endif
#ifdef ADAPTIVE_FILTER
if ((input->UseAdaptiveFilter) && (input->MbInterlace!=0 || input->PicInterlace!=0))
{
snprintf(errortext, ET_SIZE, "Adaptive interpolation filter is not supported in combination with interlace mode");
error (errortext, 500);
}
#ifdef EIGHTH_PEL
if(input->UseAdaptiveFilter>1 && input->mv_res==1)
{
error (" UseAdaptiveFilter > 1 is not compatible with 1/8-pel MC.",0);
}
else
#endif
if(input->UseAdaptiveFilter && (input->WeightedPrediction > 0 || input->WeightedBiprediction > 0 || input->UseWeightedReferenceME > 0))
{
input->WeightedBiprediction = 0;
input->WeightedBiprediction = 0;
input->UseWeightedReferenceME = 0;
printf("Weighted Prediction is set to 0 due to UseAdaptiveFilter\n");
}
#endif
#ifdef RDO_Q
if(input->UseRDO_Q)
{
#ifdef ADAPTIVE_FD_SD_CODING
if(input->APEC_in_FD_and_SD)
error ("RDO_Q is not compatible with APEC",0);
#endif
/*if(input->AdaptiveRounding)
{
printf("NOTE : AdaptiveRounding is set to 0 due to UseRDO_Q\n");
input->AdaptiveRounding = 0;
}*/
}
#endif
#ifdef MV_COMPETITION
if (input->mv_competition > 0)
{
if ((input->PicInterlace > 0) && (input->MbInterlace>0))
error ("**Competition of motion vector predictors** is not compatible with **interlace coding**",0);
if (input->rdopt != 1)
error ("**Competition of motion vector predictors** is not compatible with **RdOpt != 1 parameter**",0);
}
#endif
#ifdef SWITCHED_FILTERS
if((input->UseHPFilter == HPF_SIFO) && (input->PicInterlace > 0) && (input->MbInterlace > 0))
error ("Switched filters are not compatible with interlace coding", 0);
#endif
#ifdef INTERNAL_BIT_DEPTH_INCREASE
if ( (input->BitDepthLuma - input->InputBitDepth) != 0 || (input->BitDepthChroma - input->InputBitDepth) != 0)
{
if (input->InputBitDepth > min(input->BitDepthLuma, input->BitDepthChroma))
error ("InputBitDepth shall be not greater than min(BitDepthLuma, BitDepthChroma).",0);
if (input->ProfileIDC<FREXT_HP)
{
if (input->ProfileIDC<77)
{
input->symbol_mode = UVLC;
}
input->ProfileIDC = FREXT_HP;
input->Transform8x8Mode = 0;
input->ScalingMatrixPresentFlag = 0;
}
#ifdef USE_INTRA_MDDT
if(input->UseIntraMDDT)
error ("IBDI is not compatible with Intra MDDT",0);
#endif
}
#endif
// the two HEX FME schemes support FAST Subpel ME. EPZS does not but works fine with
// Hadamard reduction with similar speed up. Subpel FME may be added at a later stage
// for this scheme for further speed increase.
if (input->hadamard == 2 && input->FMEnable != 0 && input->FMEnable != 3)
{
snprintf(errortext, ET_SIZE, "UseHadamard=2 is not allowed when UseFME is set to 1 or 2.");
error (errortext, 500);
}
// Tian Dong: May 31, 2002
// The number of frames in one sub-seq in enhanced layer should not exceed
// the number of reference frame number.
if ( input->NumFramesInELSubSeq >= input->num_ref_frames || input->NumFramesInELSubSeq < 0 )
{
snprintf(errortext, ET_SIZE, "NumFramesInELSubSeq (%d) is out of range [0,%d).", input->NumFramesInELSubSeq, input->num_ref_frames);
error (errortext, 500);
}
// Tian Dong: Enhanced GOP is not supported in bitstream mode. September, 2002
if ( input->NumFramesInELSubSeq > 0 && input->of_mode == PAR_OF_ANNEXB )
{
snprintf(errortext, ET_SIZE, "Enhanced GOP is not supported in bitstream mode and RTP mode yet.");
error (errortext, 500);
}
// Tian Dong (Sept 2002)
// The AFF is not compatible with spare picture for the time being.
if ((input->PicInterlace || input->MbInterlace) && input->SparePictureOption == TRUE)
{
snprintf(errortext, ET_SIZE, "AFF is not compatible with spare picture.");
error (errortext, 500);
}
// Only the RTP mode is compatible with spare picture for the time being.
if (input->of_mode != PAR_OF_RTP && input->SparePictureOption == TRUE)
{
snprintf(errortext, ET_SIZE, "Only RTP output mode is compatible with spare picture features.");
error (errortext, 500);
}
if( (input->WeightedPrediction > 0 || input->WeightedBiprediction > 0) && (input->MbInterlace))
{
snprintf(errortext, ET_SIZE, "Weighted prediction coding is not supported for MB AFF currently.");
error (errortext, 500);
}
if ( input->NumFramesInELSubSeq > 0 && input->WeightedPrediction > 0)
{
snprintf(errortext, ET_SIZE, "Enhanced GOP is not supported in weighted prediction coding mode yet.");
error (errortext, 500);
}
//! the number of slice groups is forced to be 1 for slice group type 3-5
if(input->num_slice_groups_minus1 > 0)
{
if( (input->slice_group_map_type >= 3) && (input->slice_group_map_type<=5) )
input->num_slice_groups_minus1 = 1;
}
// Rate control
if(input->RCEnable)
{
if ( ((input->img_height+img->auto_crop_bottom)*(input->img_width+img->auto_crop_right)/256)%input->basicunit!=0)
{
snprintf(errortext, ET_SIZE, "Frame size in macroblocks must be a multiple of BasicUnit.");
error (errortext, 500);
}
}
if ((input->successive_Bframe)&&(input->BRefPictures)&&(input->idr_enable)&&(input->intra_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_Hi444))
{
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_Hi444))
{
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)
{
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)
{
snprintf(errortext, ET_SIZE, "\nFRExt Profile(YUV Format) Error!\nYUV444 can be used only with ProfileIDC %d.\n",FREXT_Hi444);
error (errortext, 500);
}
// Residue Color Transform
if(input->yuv_format!=YUV444 && input->residue_transform_flag)
{
snprintf(errortext, ET_SIZE, "\nResidue color transform is supported only in YUV444.");
error (errortext, 500);
}
if ((input->BiPredMotionEstimation) && (input->search_range < input->BiPredMESearchRange))
{
snprintf(errortext, ET_SIZE, "\nBiPredMESearchRange must be smaller or equal SearchRange.");
error (errortext, 500);
}
if (input->EnableOpenGOP)
input->ReferenceReorder = 1;
if (input->EnableOpenGOP && input->PicInterlace)
{
snprintf(errortext, ET_SIZE, "Open GOP currently not supported for Field coded pictures.");
error (errortext, 500);
}
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);
}
}
#ifdef EIGHTH_PEL
if (input->mv_res < 0 || input->mv_res > 1)
{
snprintf(errortext, ET_SIZE, "\nMVResolution must be eather 0 or 1.");
error (errortext, 500);
}
img->mv_res = input->mv_res;
#endif
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);
if ( input->NumFrameIn2ndIGOP )
input->NumFrameIn2ndIGOP = 1+(input->NumFrameIn2ndIGOP-1) * (input->NumFramesInELSubSeq+1);
FirstFrameIn2ndIGOP = input->no_frames;
}
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 ))
{
snprintf(errortext, ET_SIZE, "Profile must be baseline(66)/main(77)/extended(88) or FRExt (%d to %d).", FREXT_HP,FREXT_Hi444);
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.");
error (errortext, 500);
}
}
if (input->partition_mode)
{
if (input->ProfileIDC != 88)
{
snprintf(errortext, ET_SIZE, "Data partitioning is only allowed in extended profile.");
error (errortext, 500);
}
}
// baseline
if (input->ProfileIDC == 66 )
{
if (input->successive_Bframe || input->BRefPictures==2)
{
snprintf(errortext, ET_SIZE, "B pictures are not allowed in baseline.");
error (errortext, 500);
}
if (input->sp_periodicity)
{
snprintf(errortext, ET_SIZE, "SP pictures are not allowed in baseline.");
error (errortext, 500);
}
if (input->WeightedPrediction)
{
snprintf(errortext, ET_SIZE, "Weighted prediction is not allowed in baseline.");
error (errortext, 500);
}
if (input->WeightedBiprediction)
{
snprintf(errortext, ET_SIZE, "Weighted prediction is not allowed in baseline.");
error (errortext, 500);
}
if (input->symbol_mode == CABAC)
{
snprintf(errortext, ET_SIZE, "CABAC is not allowed in baseline.");
error (errortext, 500);
}
}
// main
if (input->ProfileIDC == 77 )
{
if (input->sp_periodicity)
{
snprintf(errortext, ET_SIZE, "SP pictures are not allowed in main.");
error (errortext, 500);
}
if (input->num_slice_groups_minus1)
{
snprintf(errortext, ET_SIZE, "num_slice_groups_minus1>0 (FMO) is not allowed in main.");
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.");
error (errortext, 500);
}
if (input->symbol_mode == CABAC)
{
snprintf(errortext, ET_SIZE, "CABAC is not allowed in extended.");
error (errortext, 500);
}
}
}
static void LevelCheck(void)
{
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 2.1 and 4.1. Please check your settings.\n");
error (errortext, 500);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -