Mercurial > libavcodec.hg
diff opt.c @ 3702:7e7d8a3fe080 libavcodec
make AVOptions default value field work.
Patch by Panagiotis Issaris % takis P issaris A uhasselt P be %
Original thread:
Date: Sep 8, 2006 3:22 PM
Subject: [Ffmpeg-devel] [PATCH 1/2] Enable usage of AVOption default value
author | gpoirier |
---|---|
date | Sun, 10 Sep 2006 20:21:40 +0000 |
parents | 25493c849d70 |
children | 301d975b69e3 |
line wrap: on
line diff
--- a/opt.c Sun Sep 10 18:16:19 2006 +0000 +++ b/opt.c Sun Sep 10 20:21:40 2006 +0000 @@ -299,3 +299,40 @@ } return 0; } + +void av_opt_set_defaults(void *s) +{ + AVOption *opt = NULL; + while ((opt = av_next_option(s, opt)) != NULL) { + switch(opt->type) { + case FF_OPT_TYPE_CONST: + /* Nothing to be done here */ + break; + case FF_OPT_TYPE_FLAGS: + case FF_OPT_TYPE_INT: { + int val; + val = opt->default_val; + av_set_int(s, opt->name, val); + } + break; + case FF_OPT_TYPE_FLOAT: { + double val; + val = opt->default_val; + av_set_double(s, opt->name, val); + } + break; + case FF_OPT_TYPE_RATIONAL: { + AVRational val; + val = av_d2q(opt->default_val, INT_MAX); + av_set_q(s, opt->name, val); + } + break; + case FF_OPT_TYPE_STRING: + /* Cannot set default for string as default_val is of type * double */ + break; + default: + av_log(s, AV_LOG_DEBUG, "AVOption type %d of option %s not implemented yet\n", opt->type, opt->name); + } + } +} +