# HG changeset patch # User lu_zero # Date 1169382721 0 # Node ID e10acab2322a14e62bf192ace39d6d09fec52a90 # Parent db099de6638fc49f5025231e31a0ce0ad8e8c1cb Constantize AVOption, solve few warnings, patch from flameeyes@gentoo.org aka "the other Diego" diff -r db099de6638f -r e10acab2322a opt.c --- a/opt.c Sun Jan 21 12:27:53 2007 +0000 +++ b/opt.c Sun Jan 21 12:32:01 2007 +0000 @@ -31,9 +31,9 @@ #include "eval.h" //FIXME order them and do a bin search -static AVOption *find_opt(void *v, const char *name, const char *unit){ +static const AVOption *find_opt(void *v, const char *name, const char *unit){ AVClass *c= *(AVClass**)v; //FIXME silly way of storing AVClass - AVOption *o= c->option; + const AVOption *o= c->option; for(;o && o->name; o++){ if(!strcmp(o->name, name) && (!unit || !strcmp(o->unit, unit)) ) @@ -42,14 +42,14 @@ return NULL; } -AVOption *av_next_option(void *obj, AVOption *last){ +const AVOption *av_next_option(void *obj, const AVOption *last){ if(last && last[1].name) return ++last; else if(last) return NULL; else return (*(AVClass**)obj)->option; } -static AVOption *av_set_number(void *obj, const char *name, double num, int den, int64_t intnum){ - AVOption *o= find_opt(obj, name, NULL); +static const AVOption *av_set_number(void *obj, const char *name, double num, int den, int64_t intnum){ + const AVOption *o= find_opt(obj, name, NULL); void *dst; if(!o || o->offset<=0) return NULL; @@ -76,10 +76,10 @@ return o; } -static AVOption *set_all_opt(void *v, const char *unit, double d){ +static const AVOption *set_all_opt(void *v, const char *unit, double d){ AVClass *c= *(AVClass**)v; //FIXME silly way of storing AVClass - AVOption *o= c->option; - AVOption *ret=NULL; + const AVOption *o= c->option; + const AVOption *ret=NULL; for(;o && o->name; o++){ if(o->type != FF_OPT_TYPE_CONST && o->unit && !strcmp(o->unit, unit)){ @@ -108,8 +108,8 @@ 0 }; -AVOption *av_set_string(void *obj, const char *name, const char *val){ - AVOption *o= find_opt(obj, name, NULL); +const AVOption *av_set_string(void *obj, const char *name, const char *val){ + const AVOption *o= find_opt(obj, name, NULL); if(o && o->offset==0 && o->type == FF_OPT_TYPE_CONST && o->unit){ return set_all_opt(obj, o->unit, o->default_val); } @@ -133,7 +133,7 @@ d = ff_eval2(buf, const_values, const_names, NULL, NULL, NULL, NULL, NULL, &error); if(isnan(d)) { - AVOption *o_named= find_opt(obj, buf, o->unit); + const AVOption *o_named= find_opt(obj, buf, o->unit); if(o_named && o_named->type == FF_OPT_TYPE_CONST) d= o_named->default_val; else if(!strcmp(buf, "default")) d= o->default_val; @@ -162,15 +162,15 @@ return o; } -AVOption *av_set_double(void *obj, const char *name, double n){ +const AVOption *av_set_double(void *obj, const char *name, double n){ return av_set_number(obj, name, n, 1, 1); } -AVOption *av_set_q(void *obj, const char *name, AVRational n){ +const AVOption *av_set_q(void *obj, const char *name, AVRational n){ return av_set_number(obj, name, n.num, n.den, 1); } -AVOption *av_set_int(void *obj, const char *name, int64_t n){ +const AVOption *av_set_int(void *obj, const char *name, int64_t n){ return av_set_number(obj, name, 1, 1, n); } @@ -179,8 +179,8 @@ * @param buf a buffer which is used for returning non string values as strings, can be NULL * @param buf_len allocated length in bytes of buf */ -const char *av_get_string(void *obj, const char *name, AVOption **o_out, char *buf, int buf_len){ - AVOption *o= find_opt(obj, name, NULL); +const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len){ + const AVOption *o= find_opt(obj, name, NULL); void *dst; if(!o || o->offset<=0) return NULL; @@ -205,8 +205,8 @@ return buf; } -static int av_get_number(void *obj, const char *name, AVOption **o_out, double *num, int *den, int64_t *intnum){ - AVOption *o= find_opt(obj, name, NULL); +static int av_get_number(void *obj, const char *name, const AVOption **o_out, double *num, int *den, int64_t *intnum){ + const AVOption *o= find_opt(obj, name, NULL); void *dst; if(!o || o->offset<=0) goto error; @@ -230,7 +230,7 @@ return -1; } -double av_get_double(void *obj, const char *name, AVOption **o_out){ +double av_get_double(void *obj, const char *name, const AVOption **o_out){ int64_t intnum=1; double num=1; int den=1; @@ -239,7 +239,7 @@ return num*intnum/den; } -AVRational av_get_q(void *obj, const char *name, AVOption **o_out){ +AVRational av_get_q(void *obj, const char *name, const AVOption **o_out){ int64_t intnum=1; double num=1; int den=1; @@ -251,7 +251,7 @@ return av_d2q(num*intnum/den, 1<<24); } -int64_t av_get_int(void *obj, const char *name, AVOption **o_out){ +int64_t av_get_int(void *obj, const char *name, const AVOption **o_out){ int64_t intnum=1; double num=1; int den=1; @@ -260,9 +260,9 @@ return num*intnum/den; } -static void opt_list(void *obj, void *av_log_obj, char *unit) +static void opt_list(void *obj, void *av_log_obj, const char *unit) { - AVOption *opt=NULL; + const AVOption *opt=NULL; while((opt= av_next_option(obj, opt))){ if(!(opt->flags & (AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM))) @@ -345,7 +345,7 @@ */ void av_opt_set_defaults(void *s) { - AVOption *opt = NULL; + const AVOption *opt = NULL; while ((opt = av_next_option(s, opt)) != NULL) { switch(opt->type) { case FF_OPT_TYPE_CONST: diff -r db099de6638f -r e10acab2322a opt.h --- a/opt.h Sun Jan 21 12:27:53 2007 +0000 +++ b/opt.h Sun Jan 21 12:32:01 2007 +0000 @@ -68,15 +68,15 @@ } AVOption; -AVOption *av_set_string(void *obj, const char *name, const char *val); -AVOption *av_set_double(void *obj, const char *name, double n); -AVOption *av_set_q(void *obj, const char *name, AVRational n); -AVOption *av_set_int(void *obj, const char *name, int64_t n); -double av_get_double(void *obj, const char *name, AVOption **o_out); -AVRational av_get_q(void *obj, const char *name, AVOption **o_out); -int64_t av_get_int(void *obj, const char *name, AVOption **o_out); -const char *av_get_string(void *obj, const char *name, AVOption **o_out, char *buf, int buf_len); -AVOption *av_next_option(void *obj, AVOption *last); +const AVOption *av_set_string(void *obj, const char *name, const char *val); +const AVOption *av_set_double(void *obj, const char *name, double n); +const AVOption *av_set_q(void *obj, const char *name, AVRational n); +const AVOption *av_set_int(void *obj, const char *name, int64_t n); +double av_get_double(void *obj, const char *name, const AVOption **o_out); +AVRational av_get_q(void *obj, const char *name, const AVOption **o_out); +int64_t av_get_int(void *obj, const char *name, const AVOption **o_out); +const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len); +const AVOption *av_next_option(void *obj, const AVOption *last); int av_opt_show(void *obj, void *av_log_obj); void av_opt_set_defaults(void *s);