📄 configfile.c
字号:
}
if ( *(input->slice_group_id+i) > input->num_slice_groups_minus1 )
{
fclose(sgfile);
snprintf(errortext, ET_SIZE, "Error while reading slice group config file: slice_group_id not allowed (line %d)", i + 1);
error (errortext, 500);
}
fscanf(sgfile,"%*[^\n]");
}
}
break;
default:
// we should not get here
error ("Wrong slice group type while reading config file", 500);
break;
}
// close file again
fclose(sgfile);
}
/*!
***********************************************************************
* \brief
* Checks the input parameters for consistency.
***********************************************************************
*/
static void PatchInp (void)
{
int bitdepth_qp_scale = 6*(input->BitDepthLuma - 8);
// These variables are added for FMO
int i,j;
int storedBplus1;
TestEncoderParams(bitdepth_qp_scale);
if (input->FrameRate == 0.0)
input->FrameRate = INIT_FRAME_RATE;
// Set block sizes
// Skip/Direct16x16
input->part_size[0][0] = 4;
input->part_size[0][1] = 4;
// 16x16
input->part_size[1][0] = 4;
input->part_size[1][1] = 4;
// 16x8
input->part_size[2][0] = 4;
input->part_size[2][1] = 2;
// 8x16
input->part_size[3][0] = 2;
input->part_size[3][1] = 4;
// 8x8
input->part_size[4][0] = 2;
input->part_size[4][1] = 2;
// 8x4
input->part_size[5][0] = 2;
input->part_size[5][1] = 1;
// 4x8
input->part_size[6][0] = 1;
input->part_size[6][1] = 2;
// 4x4
input->part_size[7][0] = 1;
input->part_size[7][1] = 1;
input->blocktype_lut[0][0] = 7; // 4x4
input->blocktype_lut[0][1] = 6; // 4x8
input->blocktype_lut[1][0] = 5; // 8x4
input->blocktype_lut[1][1] = 4; // 8x8
input->blocktype_lut[1][3] = 3; // 8x16
input->blocktype_lut[3][1] = 2; // 16x8
input->blocktype_lut[3][3] = 1; // 16x16
for (j = 0; j<8;j++)
{
for (i = 0; i<2; i++)
{
input->blc_size[j][i] = input->part_size[j][i] * BLOCK_SIZE;
}
}
if (input->idr_period && input->intra_delay && input->idr_period <= input->intra_delay)
{
snprintf(errortext, ET_SIZE, " IntraDelay cannot be larger than or equal to IDRPeriod.");
error (errortext, 500);
}
if (input->idr_period && input->intra_delay && input->EnableIDRGOP == 0)
{
snprintf(errortext, ET_SIZE, " IntraDelay can only be used with only 1 IDR or with EnableIDRGOP=1.");
error (errortext, 500);
}
storedBplus1 = (input->BRefPictures ) ? input->successive_Bframe + 1: 1;
if (input->Log2MaxFNumMinus4 == -1)
{
log2_max_frame_num_minus4 = iClip3(0,12, (int) (CeilLog2(input->no_frames * storedBplus1) - 4));
}
else
log2_max_frame_num_minus4 = input->Log2MaxFNumMinus4;
max_frame_num = 1 << (log2_max_frame_num_minus4 + 4);
if (log2_max_frame_num_minus4 == 0 && input->num_ref_frames == 16)
{
snprintf(errortext, ET_SIZE, " NumberReferenceFrames=%d and Log2MaxFNumMinus4=%d may lead to an invalid value of frame_num.", input->num_ref_frames, input-> Log2MaxFNumMinus4);
error (errortext, 500);
}
// set proper log2_max_pic_order_cnt_lsb_minus4.
if (input->Log2MaxPOCLsbMinus4 == - 1)
log2_max_pic_order_cnt_lsb_minus4 = iClip3(0,12, (int) (CeilLog2( 2*input->no_frames * (input->jumpd + 1)) - 4));
else
log2_max_pic_order_cnt_lsb_minus4 = input->Log2MaxPOCLsbMinus4;
max_pic_order_cnt_lsb = 1 << (log2_max_pic_order_cnt_lsb_minus4 + 4);
if (((1<<(log2_max_pic_order_cnt_lsb_minus4 + 3)) < input->jumpd * 4) && input->Log2MaxPOCLsbMinus4 != -1)
error("log2_max_pic_order_cnt_lsb_minus4 might not be sufficient for encoding. Increase value.",400);
// B picture consistency check
if(input->successive_Bframe > input->jumpd)
{
snprintf(errortext, ET_SIZE, "Number of B-frames %d can not exceed the number of frames skipped", input->successive_Bframe);
error (errortext, 400);
}
// Direct Mode consistency check
if(input->successive_Bframe && input->direct_spatial_mv_pred_flag != DIR_SPATIAL && input->direct_spatial_mv_pred_flag != DIR_TEMPORAL)
{
snprintf(errortext, ET_SIZE, "Unsupported direct mode=%d, use TEMPORAL=0 or SPATIAL=1", input->direct_spatial_mv_pred_flag);
error (errortext, 400);
}
if (input->PicInterlace>0 || input->MbInterlace>0)
{
if (input->directInferenceFlag==0)
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=open(input->infile, OPENFLAGS_READ))==-1)
{
snprintf(errortext, ET_SIZE, "Input file %s does not exist",input->infile);
error (errortext, 500);
}
if (strlen (input->ReconFile) > 0 && (p_dec=open(input->ReconFile, OPENFLAGS_WRITE, OPEN_PERMISSIONS))==-1)
{
snprintf(errortext, ET_SIZE, "Error open file %s", input->ReconFile);
error (errortext, 500);
}
#if TRACE
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);
}
#endif
if (input->img_width % 16 != 0)
{
img->auto_crop_right = 16-(input->img_width % 16);
}
else
{
img->auto_crop_right=0;
}
if (input->PicInterlace || input->MbInterlace)
{
if (input->img_height % 2 != 0)
{
error ("even number of lines required for interlaced coding", 500);
}
if (input->img_height % 32 != 0)
{
img->auto_crop_bottom = 32-(input->img_height % 32);
}
else
{
img->auto_crop_bottom=0;
}
}
else
{
if (input->img_height % 16 != 0)
{
img->auto_crop_bottom = 16-(input->img_height % 16);
}
else
{
img->auto_crop_bottom=0;
}
}
if (img->auto_crop_bottom || img->auto_crop_right)
{
fprintf (stderr, "Warning: Automatic cropping activated: Coded frame Size: %dx%d\n", input->img_width+img->auto_crop_right, input->img_height+img->auto_crop_bottom);
}
if ((input->slice_mode==1)&&(input->MbInterlace!=0))
{
if ((input->slice_argument%2)!=0)
{
fprintf ( stderr, "Warning: slice border within macroblock pair. ");
if (input->slice_argument > 1)
{
input->slice_argument--;
}
else
{
input->slice_argument++;
}
fprintf ( stderr, "Using %d MBs per slice.\n", input->slice_argument);
}
}
// read the slice group configuration file. Only for types 0, 2 or 6
if ( 0 != input->num_slice_groups_minus1 )
{
read_slice_group_info();
}
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 && input->MbInterlace != FRAME_MB_PAIR_CODING)
{
snprintf (errortext, ET_SIZE, "Unsupported MbInterlace=%d, use frame based coding=0 or field based coding=1 or adaptive=2 or frame MB pair only=3",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 || input->ProfileIDC==FREXT_CAVLC444 ))
{
snprintf(errortext, ET_SIZE, "Fast Mode Decision methods does not support FREX Profiles");
error (errortext, 500);
}
if ( (input->MEErrorMetric[Q_PEL] == ERROR_SATD && input->MEErrorMetric[H_PEL] == ERROR_SAD && input->MEErrorMetric[F_PEL] == ERROR_SAD)
&& input->SearchMode > FAST_FULL_SEARCH && input->SearchMode < EPZS)
{
snprintf(errortext, ET_SIZE, "MEDistortionQPel=2, MEDistortionHPel=0, MEDistortionFPel=0 is not allowed when SearchMode 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->jumpd) && input->RCUpdateMode == RC_MODE_1 )
{
snprintf(errortext, ET_SIZE, "Use RC_MODE_1 only for all-intra coding.");
error (errortext, 500);
}
if ( 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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -