const AVOption *o = av_opt_find2(obj, name, NULL, 0,
search_flags, &target_obj);
int min, max;
- const AVClass *class = *(AVClass **)obj;
if (!o || !target_obj)
return AVERROR_OPTION_NOT_FOUND;
return AVERROR(EINVAL);
}
-#if LIBAVUTIL_VERSION_MAJOR < 54
- if (class->version && class->version < AV_VERSION_INT(52, 11, 100)) {
- min = -1;
- max = nb_fmts-1;
- } else
-#endif
- {
- min = FFMAX(o->min, -1);
- max = FFMIN(o->max, nb_fmts-1);
- }
+ min = FFMAX(o->min, -1);
+ max = FFMIN(o->max, nb_fmts-1);
+
if (fmt < min || fmt > max) {
av_log(obj, AV_LOG_ERROR,
"Value %d for parameter '%s' out of %s format range [%d - %d]\n",
}
#endif
+int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, int search_flags)
+{
+ void *target_obj;
+ AVDictionary **dst;
+ const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);
+
+ if (!o || !target_obj)
+ return AVERROR_OPTION_NOT_FOUND;
+ if (o->flags & AV_OPT_FLAG_READONLY)
+ return AVERROR(EINVAL);
+
+ dst = (AVDictionary **)(((uint8_t *)target_obj) + o->offset);
+ av_dict_free(dst);
+ av_dict_copy(dst, val, 0);
+
+ return 0;
+}
+
int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
{
void *dst, *target_obj;
return 0;
}
+int av_opt_get_dict_val(void *obj, const char *name, int search_flags, AVDictionary **out_val)
+{
+ void *target_obj;
+ AVDictionary *src;
+ const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);
+
+ if (!o || !target_obj)
+ return AVERROR_OPTION_NOT_FOUND;
+ if (o->type != AV_OPT_TYPE_DICT)
+ return AVERROR(EINVAL);
+
+ src = *(AVDictionary **)(((uint8_t *)target_obj) + o->offset);
+ av_dict_copy(out_val, src, 0);
+
+ return 0;
+}
+
int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name)
{
const AVOption *field = av_opt_find(obj, field_name, NULL, 0, 0);
void av_opt_set_defaults2(void *s, int mask, int flags)
{
#endif
- const AVClass *class = *(AVClass **)s;
const AVOption *opt = NULL;
- while ((opt = av_opt_next(s, opt)) != NULL) {
+ while ((opt = av_opt_next(s, opt))) {
void *dst = ((uint8_t*)s) + opt->offset;
#if FF_API_OLD_AVOPTIONS
if ((opt->flags & mask) != flags)
set_string_video_rate(s, opt, opt->default_val.str, dst);
break;
case AV_OPT_TYPE_PIXEL_FMT:
-#if LIBAVUTIL_VERSION_MAJOR < 54
- if (class->version && class->version < AV_VERSION_INT(52, 10, 100))
- av_opt_set(s, opt->name, opt->default_val.str, 0);
- else
-#endif
- write_number(s, opt, dst, 1, 1, opt->default_val.i64);
+ write_number(s, opt, dst, 1, 1, opt->default_val.i64);
break;
case AV_OPT_TYPE_SAMPLE_FMT:
-#if LIBAVUTIL_VERSION_MAJOR < 54
- if (class->version && class->version < AV_VERSION_INT(52, 10, 100))
- av_opt_set(s, opt->name, opt->default_val.str, 0);
- else
-#endif
- write_number(s, opt, dst, 1, 1, opt->default_val.i64);
+ write_number(s, opt, dst, 1, 1, opt->default_val.i64);
break;
case AV_OPT_TYPE_BINARY:
- /* Cannot set default for binary */
+ case AV_OPT_TYPE_DICT:
+ /* Cannot set defaults for these types */
break;
default:
av_log(s, AV_LOG_DEBUG, "AVOption type %d of option %s not implemented yet\n", opt->type, opt->name);
void av_opt_free(void *obj)
{
const AVOption *o = NULL;
- while ((o = av_opt_next(obj, o)))
- if (o->type == AV_OPT_TYPE_STRING || o->type == AV_OPT_TYPE_BINARY)
+ while ((o = av_opt_next(obj, o))) {
+ switch (o->type) {
+ case AV_OPT_TYPE_STRING:
+ case AV_OPT_TYPE_BINARY:
av_freep((uint8_t *)obj + o->offset);
+ break;
+
+ case AV_OPT_TYPE_DICT:
+ av_dict_free((AVDictionary **)(((uint8_t *)obj) + o->offset));
+ break;
+
+ default:
+ break;
+ }
+ }
}
int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags)