一种简单的输入参数管理方法
//! Maps parameter name to its address, type etc.
typedef struct {
char *TokenName; //!< name
void *Place; //!< address
int Type; //!< type: 0-int, 1-char[], 2-double
double Default; //!< default value
int param_limits; //!< 0: no limits, 1: both min and max, 2: only min (i.e. no negatives), 3: special case for QPs since min needs bitdepth_qp_scale
double min_limit;
double max_limit;
int char_size; //!< Dimension of type char[]
} Mapping;
TokenNake 保存参数的字符串名字, Place 是指向参数保存位置的指针,后边的参数是关于此参数的描述。
初始化时的操作
Mapping Map[] = {
{"ProfileIDC", &cfgparams.ProfileIDC, 0, (double) PROFILE_IDC, 0, 0.0, 0.0, },
{"IntraProfile", &cfgparams.IntraProfile, 0, 0.0, 1, 0.0, 1.0, },
{"LevelIDC", &cfgparams.LevelIDC, 0, (double) LEVEL_IDC, 0, 0.0, 0.0, },
{"FrameRate", &cfgparams.source.frame_rate, 2, (double) INIT_FRAME_RATE, 1, 0.0, 480.0, },
{"Enable32Pulldown", &cfgparams.enable_32_pulldown, 0, 0.0, 1, 0.0, 2.0, },
{"ResendSPS", &cfgparams.ResendSPS, 0, 0.0, 1, 0.0, 3.0, },
{"StartFrame", &cfgparams.start_frame, 0, 0.0, 2, 0.0, 0.0, },
{"IntraPeriod", &cfgparams.intra_period, 0, 0.0, 2, 0.0, 0.0, },
{"IDRPeriod", &cfgparams.idr_period, 0, 0.0, 2, 0.0, 0.0, },
{"IntraDelay", &cfgparams.intra_delay, 0, 0.0, 2, 0.0, 0.0, },
{"AdaptiveIntraPeriod", &cfgparams.adaptive_intra_period, 0, 0.0, 1, 0.0, 1.0, },
{"AdaptiveIDRPeriod", &cfgparams.adaptive_idr_period, 0, 0.0, 1, 0.0, 2.0, },
{"EnableOpenGOP", &cfgparams.EnableOpenGOP, 0, 0.0, 1, 0.0, 1.0, },
其中保存参数的位置是一个结构体内的对应元素。