Constantize AVOption, solve few warnings, patch from flameeyes@gentoo.org aka "the other Diego"

Originally committed as revision 7601 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Luca Barbato 2007-01-21 12:32:01 +00:00
parent 5ecfa9f5fc
commit f8a32f450a
2 changed files with 33 additions and 33 deletions

View File

@ -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 @@ static AVOption *find_opt(void *v, const char *name, const char *unit){
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 @@ static AVOption *av_set_number(void *obj, const char *name, double num, int den,
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 @@ static const char *const_names[]={
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 @@ AVOption *av_set_string(void *obj, const char *name, const char *val){
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 @@ AVOption *av_set_string(void *obj, const char *name, const char *val){
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 @@ AVOption *av_set_int(void *obj, const char *name, int64_t n){
* @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 @@ const char *av_get_string(void *obj, const char *name, AVOption **o_out, char *b
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 @@ error:
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 @@ double av_get_double(void *obj, const char *name, AVOption **o_out){
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 @@ AVRational av_get_q(void *obj, const char *name, AVOption **o_out){
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 @@ int64_t av_get_int(void *obj, const char *name, AVOption **o_out){
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 @@ int av_opt_show(void *obj, void *av_log_obj){
*/
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:

View File

@ -68,15 +68,15 @@ typedef struct AVOption {
} 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);