const AVOption *av_opt_next(void *obj, const AVOption *last)
{
AVClass *class = *(AVClass**)obj;
- if (!last && class->option && class->option[0].name)
+ if (!last && class && class->option && class->option[0].name)
return class->option;
if (last && last[1].name)
return ++last;
if (!val && (o->type != AV_OPT_TYPE_STRING &&
o->type != AV_OPT_TYPE_PIXEL_FMT && o->type != AV_OPT_TYPE_SAMPLE_FMT &&
o->type != AV_OPT_TYPE_IMAGE_SIZE && o->type != AV_OPT_TYPE_VIDEO_RATE &&
- o->type != AV_OPT_TYPE_DURATION))
+ o->type != AV_OPT_TYPE_DURATION && o->type != AV_OPT_TYPE_COLOR))
return AVERROR(EINVAL);
dst = ((uint8_t*)target_obj) + o->offset;
av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as duration\n", val);
return ret;
}
+ break;
+ case AV_OPT_TYPE_COLOR:
+ if (!val) {
+ return 0;
+ } else {
+ ret = av_parse_color(dst, val, -1, obj);
+ if (ret < 0)
+ av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as color\n", val);
+ return ret;
+ }
}
av_log(obj, AV_LOG_ERROR, "Invalid option type.\n");
i64 / 3600000000, (int)((i64 / 60000000) % 60),
(int)((i64 / 1000000) % 60), (int)(i64 % 1000000));
break;
+ case AV_OPT_TYPE_COLOR:
+ ret = snprintf(buf, sizeof(buf), "0x%02x%02x%02x%02x", ((int *)dst)[0], ((int *)dst)[1], ((int *)dst)[2], ((int *)dst)[3]);
+ break;
default:
return AVERROR(EINVAL);
}
case AV_OPT_TYPE_DURATION:
av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "<duration>");
break;
+ case AV_OPT_TYPE_COLOR:
+ av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "<color>");
+ break;
case AV_OPT_TYPE_CONST:
default:
av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "");
av_opt_set_q(s, opt->name, val, 0);
}
break;
+ case AV_OPT_TYPE_COLOR:
case AV_OPT_TYPE_STRING:
case AV_OPT_TYPE_IMAGE_SIZE:
case AV_OPT_TYPE_VIDEO_RATE:
case AV_OPT_TYPE_FLOAT:
case AV_OPT_TYPE_DOUBLE:
case AV_OPT_TYPE_DURATION:
+ case AV_OPT_TYPE_COLOR:
break;
case AV_OPT_TYPE_STRING:
range->component_min = 0;
enum AVPixelFormat pix_fmt;
enum AVSampleFormat sample_fmt;
int64_t duration;
+ uint8_t color[4];
} TestContext;
#define OFFSET(x) offsetof(TestContext, x)
{"sample_fmt", "set samplefmt", OFFSET(sample_fmt), AV_OPT_TYPE_SAMPLE_FMT, {.i64 = AV_SAMPLE_FMT_NONE}, -1, AV_SAMPLE_FMT_NB-1},
{"video_rate", "set videorate", OFFSET(video_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0 },
{"duration", "set duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, INT64_MAX},
+{"color", "set color", OFFSET(color), AV_OPT_TYPE_COLOR, {.str = "pink"}, 0, 0},
{NULL},
};
"duration=bogus",
"duration=123.45",
"duration=1\\:23\\:45.67",
+ "color=blue",
+ "color=0x223300",
+ "color=0x42FF07AA",
};
test_ctx.class = &test_class;