-#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);
+#if X264_BUILD >= 161
+ } else if (ret == X264_PARAM_ALLOC_FAILED) {
+ av_log(avctx, AV_LOG_ERROR,
+ "out of memory parsing option '%s': '%s'\n", opt, param);
+ ret = AVERROR(ENOMEM);
+#endif
+ } else {
+ av_log(avctx, AV_LOG_ERROR,
+ "bad value for '%s': '%s'\n", opt, param);
+ ret = AVERROR(EINVAL);
+ }
+ }
+
+ return ret;
+}