Revision bc2a1c34 libavcodec/opt.c

View differences:

libavcodec/opt.c
31 31
#include "eval.h"
32 32

  
33 33
//FIXME order them and do a bin search
34
static const AVOption *find_opt(void *v, const char *name, const char *unit){
34
const AVOption *av_find_opt(void *v, const char *name, const char *unit, int mask, int flags){
35 35
    AVClass *c= *(AVClass**)v; //FIXME silly way of storing AVClass
36 36
    const AVOption *o= c->option;
37 37

  
38 38
    for(;o && o->name; o++){
39
        if(!strcmp(o->name, name) && (!unit || !strcmp(o->unit, unit)) )
39
        if(!strcmp(o->name, name) && (!unit || !strcmp(o->unit, unit)) && (o->flags & mask) == flags )
40 40
            return o;
41 41
    }
42 42
    return NULL;
......
49 49
}
50 50

  
51 51
static const AVOption *av_set_number(void *obj, const char *name, double num, int den, int64_t intnum){
52
    const AVOption *o= find_opt(obj, name, NULL);
52
    const AVOption *o= av_find_opt(obj, name, NULL, 0, 0);
53 53
    void *dst;
54 54
    if(!o || o->offset<=0)
55 55
        return NULL;
......
109 109
};
110 110

  
111 111
const AVOption *av_set_string(void *obj, const char *name, const char *val){
112
    const AVOption *o= find_opt(obj, name, NULL);
112
    const AVOption *o= av_find_opt(obj, name, NULL, 0, 0);
113 113
    if(o && o->offset==0 && o->type == FF_OPT_TYPE_CONST && o->unit){
114 114
        return set_all_opt(obj, o->unit, o->default_val);
115 115
    }
......
133 133

  
134 134
            d = ff_eval2(buf, const_values, const_names, NULL, NULL, NULL, NULL, NULL, &error);
135 135
            if(isnan(d)) {
136
                const AVOption *o_named= find_opt(obj, buf, o->unit);
136
                const AVOption *o_named= av_find_opt(obj, buf, o->unit, 0, 0);
137 137
                if(o_named && o_named->type == FF_OPT_TYPE_CONST)
138 138
                    d= o_named->default_val;
139 139
                else if(!strcmp(buf, "default")) d= o->default_val;
......
180 180
 * @param buf_len allocated length in bytes of buf
181 181
 */
182 182
const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len){
183
    const AVOption *o= find_opt(obj, name, NULL);
183
    const AVOption *o= av_find_opt(obj, name, NULL, 0, 0);
184 184
    void *dst;
185 185
    if(!o || o->offset<=0)
186 186
        return NULL;
......
206 206
}
207 207

  
208 208
static int av_get_number(void *obj, const char *name, const AVOption **o_out, double *num, int *den, int64_t *intnum){
209
    const AVOption *o= find_opt(obj, name, NULL);
209
    const AVOption *o= av_find_opt(obj, name, NULL, 0, 0);
210 210
    void *dst;
211 211
    if(!o || o->offset<=0)
212 212
        goto error;

Also available in: Unified diff