return 0;
}
-#define OPT_STR(opt, param) \
- do { \
- int ret; \
- if ((ret = x264_param_parse(&x4->params, opt, param)) < 0) { \
- if(ret == X264_PARAM_BAD_NAME) \
- av_log(avctx, AV_LOG_ERROR, \
- "bad option '%s': '%s'\n", opt, param); \
- else \
- av_log(avctx, AV_LOG_ERROR, \
- "bad value for '%s': '%s'\n", opt, param); \
- return -1; \
- } \
- } while (0)
+static int parse_opts(AVCodecContext *avctx, const char *opt, const char *param)
+{
+ X264Context *x4 = avctx->priv_data;
+ int ret;
+
+ if ((ret = x264_param_parse(&x4->params, opt, param)) < 0) {
+ if (ret == X264_PARAM_BAD_NAME) {
+ av_log(avctx, AV_LOG_ERROR,
+ "bad option '%s': '%s'\n", opt, param);
+ ret = AVERROR(EINVAL);
+ } else {
+ av_log(avctx, AV_LOG_ERROR,
+ "bad value for '%s': '%s'\n", opt, param);
+ ret = AVERROR(EINVAL);
+ }
+ }
+
+ return ret;
+}
static int convert_pix_fmt(enum AVPixelFormat pix_fmt)
{
X264Context *x4 = avctx->priv_data;
AVCPBProperties *cpb_props;
int sw,sh;
+ int ret;
if (avctx->global_quality > 0)
av_log(avctx, AV_LOG_WARNING, "-qscale is ignored, -crf is recommended.\n");
while(p){
char param[4096]={0}, val[4096]={0};
if(sscanf(p, "%4095[^:=]=%4095[^:]", param, val) == 1){
- OPT_STR(param, "1");
- }else
- OPT_STR(param, val);
+ ret = parse_opts(avctx, param, "1");
+ if (ret < 0)
+ return ret;
+ } else {
+ ret = parse_opts(avctx, param, val);
+ if (ret < 0)
+ return ret;
+ }
p= strchr(p, ':');
p+=!!p;
}