Commit a46ae8d7 authored by lu_zero's avatar lu_zero

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

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@7601 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent bef78f37
...@@ -31,9 +31,9 @@ ...@@ -31,9 +31,9 @@
#include "eval.h" #include "eval.h"
//FIXME order them and do a bin search //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 AVClass *c= *(AVClass**)v; //FIXME silly way of storing AVClass
AVOption *o= c->option; const AVOption *o= c->option;
for(;o && o->name; o++){ for(;o && o->name; o++){
if(!strcmp(o->name, name) && (!unit || !strcmp(o->unit, unit)) ) 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){ ...@@ -42,14 +42,14 @@ static AVOption *find_opt(void *v, const char *name, const char *unit){
return NULL; 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; if(last && last[1].name) return ++last;
else if(last) return NULL; else if(last) return NULL;
else return (*(AVClass**)obj)->option; else return (*(AVClass**)obj)->option;
} }
static AVOption *av_set_number(void *obj, const char *name, double num, int den, int64_t intnum){ static const AVOption *av_set_number(void *obj, const char *name, double num, int den, int64_t intnum){
AVOption *o= find_opt(obj, name, NULL); const AVOption *o= find_opt(obj, name, NULL);
void *dst; void *dst;
if(!o || o->offset<=0) if(!o || o->offset<=0)
return NULL; return NULL;
...@@ -76,10 +76,10 @@ static AVOption *av_set_number(void *obj, const char *name, double num, int den, ...@@ -76,10 +76,10 @@ static AVOption *av_set_number(void *obj, const char *name, double num, int den,
return o; 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 AVClass *c= *(AVClass**)v; //FIXME silly way of storing AVClass
AVOption *o= c->option; const AVOption *o= c->option;
AVOption *ret=NULL; const AVOption *ret=NULL;
for(;o && o->name; o++){ for(;o && o->name; o++){
if(o->type != FF_OPT_TYPE_CONST && o->unit && !strcmp(o->unit, unit)){ if(o->type != FF_OPT_TYPE_CONST && o->unit && !strcmp(o->unit, unit)){
...@@ -108,8 +108,8 @@ static const char *const_names[]={ ...@@ -108,8 +108,8 @@ static const char *const_names[]={
0 0
}; };
AVOption *av_set_string(void *obj, const char *name, const char *val){ const AVOption *av_set_string(void *obj, const char *name, const char *val){
AVOption *o= find_opt(obj, name, NULL); const AVOption *o= find_opt(obj, name, NULL);
if(o && o->offset==0 && o->type == FF_OPT_TYPE_CONST && o->unit){ if(o && o->offset==0 && o->type == FF_OPT_TYPE_CONST && o->unit){
return set_all_opt(obj, o->unit, o->default_val); 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){ ...@@ -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); d = ff_eval2(buf, const_values, const_names, NULL, NULL, NULL, NULL, NULL, &error);
if(isnan(d)) { 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) if(o_named && o_named->type == FF_OPT_TYPE_CONST)
d= o_named->default_val; d= o_named->default_val;
else if(!strcmp(buf, "default")) d= o->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){ ...@@ -162,15 +162,15 @@ AVOption *av_set_string(void *obj, const char *name, const char *val){
return o; 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); 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); 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); 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){ ...@@ -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 a buffer which is used for returning non string values as strings, can be NULL
* @param buf_len allocated length in bytes of buf * @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){ const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len){
AVOption *o= find_opt(obj, name, NULL); const AVOption *o= find_opt(obj, name, NULL);
void *dst; void *dst;
if(!o || o->offset<=0) if(!o || o->offset<=0)
return NULL; return NULL;
...@@ -205,8 +205,8 @@ const char *av_get_string(void *obj, const char *name, AVOption **o_out, char *b ...@@ -205,8 +205,8 @@ const char *av_get_string(void *obj, const char *name, AVOption **o_out, char *b
return buf; return buf;
} }
static int av_get_number(void *obj, const char *name, AVOption **o_out, double *num, int *den, int64_t *intnum){ static int av_get_number(void *obj, const char *name, const AVOption **o_out, double *num, int *den, int64_t *intnum){
AVOption *o= find_opt(obj, name, NULL); const AVOption *o= find_opt(obj, name, NULL);
void *dst; void *dst;
if(!o || o->offset<=0) if(!o || o->offset<=0)
goto error; goto error;
...@@ -230,7 +230,7 @@ error: ...@@ -230,7 +230,7 @@ error:
return -1; 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; int64_t intnum=1;
double num=1; double num=1;
int den=1; int den=1;
...@@ -239,7 +239,7 @@ double av_get_double(void *obj, const char *name, AVOption **o_out){ ...@@ -239,7 +239,7 @@ double av_get_double(void *obj, const char *name, AVOption **o_out){
return num*intnum/den; 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; int64_t intnum=1;
double num=1; double num=1;
int den=1; int den=1;
...@@ -251,7 +251,7 @@ AVRational av_get_q(void *obj, const char *name, AVOption **o_out){ ...@@ -251,7 +251,7 @@ AVRational av_get_q(void *obj, const char *name, AVOption **o_out){
return av_d2q(num*intnum/den, 1<<24); 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; int64_t intnum=1;
double num=1; double num=1;
int den=1; int den=1;
...@@ -260,9 +260,9 @@ int64_t av_get_int(void *obj, const char *name, AVOption **o_out){ ...@@ -260,9 +260,9 @@ int64_t av_get_int(void *obj, const char *name, AVOption **o_out){
return num*intnum/den; 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))){ while((opt= av_next_option(obj, opt))){
if(!(opt->flags & (AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM))) 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){ ...@@ -345,7 +345,7 @@ int av_opt_show(void *obj, void *av_log_obj){
*/ */
void av_opt_set_defaults(void *s) void av_opt_set_defaults(void *s)
{ {
AVOption *opt = NULL; const AVOption *opt = NULL;
while ((opt = av_next_option(s, opt)) != NULL) { while ((opt = av_next_option(s, opt)) != NULL) {
switch(opt->type) { switch(opt->type) {
case FF_OPT_TYPE_CONST: case FF_OPT_TYPE_CONST:
......
...@@ -68,15 +68,15 @@ typedef struct AVOption { ...@@ -68,15 +68,15 @@ typedef struct AVOption {
} AVOption; } AVOption;
AVOption *av_set_string(void *obj, const char *name, const char *val); const AVOption *av_set_string(void *obj, const char *name, const char *val);
AVOption *av_set_double(void *obj, const char *name, double n); const AVOption *av_set_double(void *obj, const char *name, double n);
AVOption *av_set_q(void *obj, const char *name, AVRational n); const AVOption *av_set_q(void *obj, const char *name, AVRational n);
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);
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);
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 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);
const char *av_get_string(void *obj, const char *name, AVOption **o_out, char *buf, int buf_len); const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len);
AVOption *av_next_option(void *obj, AVOption *last); const AVOption *av_next_option(void *obj, const AVOption *last);
int av_opt_show(void *obj, void *av_log_obj); int av_opt_show(void *obj, void *av_log_obj);
void av_opt_set_defaults(void *s); void av_opt_set_defaults(void *s);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment