📄 configfile.c
字号:
printf("\nDirectInferenceFlag set to 1 due to interlace coding.");
input->directInferenceFlag=1;
}
if (input->PicInterlace>0)
{
if (input->IntraBottom!=0 && input->IntraBottom!=1)
{
snprintf(errortext, ET_SIZE, "Incorrect value %d for IntraBottom. Use 0 (disable) or 1 (enable).", input->IntraBottom);
error (errortext, 400);
}
}
// Cabac/UVLC consistency check
if (input->symbol_mode != UVLC && input->symbol_mode != CABAC)
{
snprintf (errortext, ET_SIZE, "Unsupported symbol mode=%d, use UVLC=0 or CABAC=1",input->symbol_mode);
error (errortext, 400);
}
// Open Files
if ((p_in=fopen(input->infile,"rb"))==NULL)
{
snprintf(errortext, ET_SIZE, "Input file %s does not exist",input->infile);
error (errortext, 500);
}
if (strlen (input->ReconFile) > 0 && (p_dec=fopen(input->ReconFile, "wb"))==NULL)
{
snprintf(errortext, ET_SIZE, "Error open file %s", input->ReconFile);
error (errortext, 500);
}
if (strlen (input->TraceFile) > 0 && (p_trace=fopen(input->TraceFile,"w"))==NULL)
{
snprintf(errortext, ET_SIZE, "Error open file %s", input->TraceFile);
error (errortext, 500);
}
// add check for MAXSLICEGROUPIDS
if(input->num_slice_groups_minus1>=MAXSLICEGROUPIDS)
{
snprintf(errortext, ET_SIZE, "num_slice_groups_minus1 exceeds MAXSLICEGROUPIDS");
error (errortext, 500);
}
// Following codes are to read slice group configuration from SliceGroupConfigFileName for slice group type 0,2 or 6
if( (input->num_slice_groups_minus1!=0)&&
((input->slice_group_map_type == 0) || (input->slice_group_map_type == 2) || (input->slice_group_map_type == 6)) )
{
if (strlen (input->SliceGroupConfigFileName) > 0 && (sgfile=fopen(input->SliceGroupConfigFileName,"r"))==NULL)
{
snprintf(errortext, ET_SIZE, "Error open file %s", input->SliceGroupConfigFileName);
error (errortext, 500);
}
else
{
if (input->slice_group_map_type == 0)
{
input->run_length_minus1=(int *)malloc(sizeof(int)*(input->num_slice_groups_minus1+1));
// each line contains one 'run_length_minus1' value
for(i=0;i<=input->num_slice_groups_minus1;i++)
{
fscanf(sgfile,"%d",(input->run_length_minus1+i));
fscanf(sgfile,"%*[^\n]");
}
}
else if (input->slice_group_map_type == 2)
{
input->top_left=(int *)malloc(sizeof(int)*input->num_slice_groups_minus1);
input->bottom_right=(int *)malloc(sizeof(int)*input->num_slice_groups_minus1);
// every two lines contain 'top_left' and 'bottom_right' value
for(i=0;i<input->num_slice_groups_minus1;i++)
{
fscanf(sgfile,"%d",(input->top_left+i));
fscanf(sgfile,"%*[^\n]");
fscanf(sgfile,"%d",(input->bottom_right+i));
fscanf(sgfile,"%*[^\n]");
}
}
else if (input->slice_group_map_type == 6)
{
frame_mb_only = !(input->PicInterlace || input->MbInterlace);
mb_width= input->img_width/16;
mb_height= input->img_height/16;
mapunit_height=mb_height/(2-frame_mb_only);
input->slice_group_id=(int * ) malloc(sizeof(int)*mapunit_height*mb_width);
// each line contains slice_group_id for one Macroblock
for (i=0;i<mapunit_height*mb_width;i++)
{
fscanf(sgfile,"%d",(input->slice_group_id+i));
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);
}
}
// 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->WeightedPrediction < 0 || input->WeightedPrediction > 1 )
{
snprintf (errortext, ET_SIZE, "\nWeightedPrediction=%d is not allowed.Select 0 (normal) or 1 (explicit)",input->WeightedPrediction);
error (errortext, 400);
}
if (input->WeightedBiprediction < 0 || input->WeightedBiprediction > 2 )
{
snprintf (errortext, ET_SIZE, "\nWeightedBiprediction=%d is not allowed.Select 0 (normal), 1 (explicit), or 2 (implicit)",input->WeightedBiprediction);
error (errortext, 400);
}
if (input->PicInterlace || input->MbInterlace)
{
if (input->img_height % 32 != 0 )
{
snprintf(errortext, ET_SIZE, "Unsupported image format y=%d, must be a multiple of 32 for adaptive frame/field",input->img_height);
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);
}
// 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_reference_frames || input->NumFramesInELSubSeq < 0 )
{
snprintf(errortext, ET_SIZE, "NumFramesInELSubSeq (%d) is out of range [0,%d).", input->NumFramesInELSubSeq, input->num_reference_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))
{
printf("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*input->img_width/256)%input->basicunit!=0)
{
snprintf(errortext, ET_SIZE, "Basic unit is not defined correctly.");
error (errortext, 500);
}
}
if ((input->successive_Bframe)&&(input->StoredBPictures)&&(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_type && input->num_reference_frames<2 && input->successive_Bframe >0)
error("temporal direct needs at least 2 ref frames\n",-1000);
ProfileCheck();
LevelCheck();
}
void PatchInputNoFrames()
{
// 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()
{
if ((input->ProfileIDC != 66 ) && (input->ProfileIDC != 77 ) && (input->ProfileIDC != 88 ))
{
snprintf(errortext, ET_SIZE, "Profile must be baseline(66)/main(77)/extended(88).");
error (errortext, 500);
}
// baseline
if (input->ProfileIDC == 66 )
{
if (input->successive_Bframe)
{
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->partition_mode)
{
snprintf(errortext, ET_SIZE, "Data partitioning is 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->partition_mode)
{
snprintf(errortext, ET_SIZE, "Data partitioning is 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);
}
if (input->redundant_slice_flag)
{
snprintf(errortext, ET_SIZE, "Redundant pictures are 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()
{
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -