summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorStefano Sabatini <stefano.sabatini-lala@poste.it>2008-12-15 22:48:10 +0000
committerStefano Sabatini <stefano.sabatini-lala@poste.it>2008-12-15 22:48:10 +0000
commit301cc4f37050ed5c08aec8de6d4e22ede2ce9a9f (patch)
treeb0818f2e33dad696fec0994be22d588e03ff2999 /libavcodec
parenta59d44fdf47f0584f919cc5b7440741e40c28c6d (diff)
Implement the av_set_number2() internal function, which makes possible
to distinguish between a not found option failure and a not valid value failure. Originally committed as revision 16156 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/opt.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/libavcodec/opt.c b/libavcodec/opt.c
index 7932d5a84e..d42c0b9c42 100644
--- a/libavcodec/opt.c
+++ b/libavcodec/opt.c
@@ -47,15 +47,17 @@ const AVOption *av_next_option(void *obj, const AVOption *last){
else return (*(AVClass**)obj)->option;
}
-static const AVOption *av_set_number(void *obj, const char *name, double num, int den, int64_t intnum){
+static int av_set_number2(void *obj, const char *name, double num, int den, int64_t intnum, const AVOption **o_out){
const AVOption *o= av_find_opt(obj, name, NULL, 0, 0);
void *dst;
+ if(o_out)
+ *o_out= o;
if(!o || o->offset<=0)
- return NULL;
+ return AVERROR(ENOENT);
if(o->max*den < num*intnum || o->min*den > num*intnum) {
av_log(NULL, AV_LOG_ERROR, "Value %lf for parameter '%s' out of range\n", num, name);
- return NULL;
+ return AVERROR(ERANGE);
}
dst= ((uint8_t*)obj) + o->offset;
@@ -71,9 +73,17 @@ static const AVOption *av_set_number(void *obj, const char *name, double num, in
else *(AVRational*)dst= av_d2q(num*intnum/den, 1<<24);
break;
default:
- return NULL;
+ return AVERROR(EINVAL);
}
- return o;
+ return 0;
+}
+
+static const AVOption *av_set_number(void *obj, const char *name, double num, int den, int64_t intnum){
+ const AVOption *o = NULL;
+ if (av_set_number2(obj, name, num, den, intnum, &o) < 0)
+ return NULL;
+ else
+ return o;
}
static const double const_values[]={