Revision bec89a84 libavcodec/opts.c

View differences:

libavcodec/opts.c
12 12

  
13 13
#include "avcodec.h"
14 14

  
15
extern const AVOption common_options[2];
16

  
17
const AVOption common_options[2] = {
18
    AVOPTION_CODEC_INT("common", "test", bit_rate, 0, 10, 0),
15
#ifdef HAVE_MMX
16
extern const AVOption common_options[3 + 5];
17
#else
18
extern const AVOption common_options[3];
19
#endif
20

  
21
const AVOption common_options[] = {
22
    AVOPTION_CODEC_FLAG("bit_exact", "use only bit-exact stuff", flags, CODEC_FLAG_BITEXACT, 0),
23
    AVOPTION_CODEC_FLAG("mm_force", "force mm flags", dsp_mask, FF_MM_FORCE, 0),
24
#ifdef HAVE_MMX
25
    AVOPTION_CODEC_FLAG("mm_mmx", "mask MMX feature", dsp_mask, FF_MM_MMX, 0),
26
    AVOPTION_CODEC_FLAG("mm_3dnow", "mask 3DNow feature", dsp_mask, FF_MM_3DNOW, 0),
27
    AVOPTION_CODEC_FLAG("mm_mmxext", "mask MMXEXT (MMX2) feature", dsp_mask, FF_MM_MMXEXT, 0),
28
    AVOPTION_CODEC_FLAG("mm_sse", "mask SSE feature", dsp_mask, FF_MM_SSE, 0),
29
    AVOPTION_CODEC_FLAG("mm_sse2", "mask SSE2 feature", dsp_mask, FF_MM_SSE2, 0),
30
#endif
19 31
    AVOPTION_END()
20 32
};
21 33

  
......
71 83
    return 0;
72 84
}
73 85

  
74
static int parse_string(const AVOption *c, char *s, AVCodecContext *avctx, char **var)
86
static int parse_string(const AVOption *c, char *s, void* strct, char **var)
75 87
{
76 88
    if (!s)
77 89
	return -1;
......
80 92
	int sf, ef, qs;
81 93
	float qf;
82 94
	if (sscanf(s, "%d,%d,%d,%f", &sf, &ef, &qs, &qf) == 4 && sf < ef) {
95
	    AVCodecContext *avctx = (AVCodecContext *) strct;
83 96
	    RcOverride *o;
84 97
	    avctx->rc_override = av_realloc(avctx->rc_override,
85 98
					    sizeof(RcOverride) * (avctx->rc_override_count + 1));
......
98 111
    return 0;
99 112
}
100 113

  
101
/**
102
 *
103
 * \param codec  codec for option parsing
104
 * \param opts   string with options for parsing
105
 * \param avctx  where to store parsed results
106
 */
107
int avcodec_parse(const AVCodec *codec, const char *opts, AVCodecContext *avctx)
114
int avoption_parse(void* strct, const AVOption* list, const char *opts)
108 115
{
109 116
    int r = 0;
110 117
    char* dopts = av_strdup(opts);
......
113 120

  
114 121
	while (str && *str && r == 0) {
115 122
	    const AVOption *stack[FF_OPT_MAX_DEPTH];
123
	    const AVOption *c = list;
116 124
	    int depth = 0;
117
	    const AVOption *c = codec->options;
118 125
	    char* e = strchr(str, ':');
119 126
	    char* p;
120 127
	    if (e)
......
127 134
            // going through option structures
128 135
	    for (;;) {
129 136
		if (!c->name) {
130
		    if (c->sub) {
137
		    if (c->help) {
131 138
			stack[depth++] = c;
132
			c = c->sub;
139
			c = (const AVOption*) c->help;
133 140
			assert(depth > FF_OPT_MAX_DEPTH);
134 141
		    } else {
135 142
			if (depth == 0)
......
139 146
		    }
140 147
		} else {
141 148
		    if (!strcmp(c->name, str)) {
142
			void* ptr = (char*)avctx + c->offset;
149
			void* ptr = (char*)strct + c->offset;
143 150

  
144 151
			switch (c->type & FF_OPT_TYPE_MASK) {
145 152
			case FF_OPT_TYPE_BOOL:
......
152 159
			    r = parse_int(c, p, (int*)ptr);
153 160
			    break;
154 161
			case FF_OPT_TYPE_STRING:
155
			    r = parse_string(c, p, avctx, (char**)ptr);
162
			    r = parse_string(c, p, strct, (char**)ptr);
156 163
			    break;
157 164
			default:
158 165
			    assert(0 == 1);

Also available in: Unified diff