8 * typical parsed command line:
9 * msmpeg4:bitrate=720000:qmax=16
14 #include "os_support.h"
16 const AVOption avoptions_common[] = {
17 AVOPTION_CODEC_FLAG("bit_exact", "use only bit-exact stuff", flags, CODEC_FLAG_BITEXACT, 0),
18 AVOPTION_CODEC_FLAG("mm_force", "force mm flags", dsp_mask, FF_MM_FORCE, 0),
20 AVOPTION_CODEC_FLAG("mm_mmx", "mask MMX feature", dsp_mask, FF_MM_MMX, 0),
21 AVOPTION_CODEC_FLAG("mm_3dnow", "mask 3DNow feature", dsp_mask, FF_MM_3DNOW, 0),
22 AVOPTION_CODEC_FLAG("mm_mmxext", "mask MMXEXT (MMX2) feature", dsp_mask, FF_MM_MMXEXT, 0),
23 AVOPTION_CODEC_FLAG("mm_sse", "mask SSE feature", dsp_mask, FF_MM_SSE, 0),
24 AVOPTION_CODEC_FLAG("mm_sse2", "mask SSE2 feature", dsp_mask, FF_MM_SSE2, 0),
29 const AVOption avoptions_workaround_bug[] = {
30 AVOPTION_CODEC_FLAG("bug_autodetect", "workaround bug autodetection", workaround_bugs, FF_BUG_AUTODETECT, 1),
31 AVOPTION_CODEC_FLAG("bug_old_msmpeg4", "workaround old msmpeg4 bug", workaround_bugs, FF_BUG_OLD_MSMPEG4, 0),
32 AVOPTION_CODEC_FLAG("bug_xvid_ilace", "workaround XviD interlace bug", workaround_bugs, FF_BUG_XVID_ILACE, 0),
33 AVOPTION_CODEC_FLAG("bug_ump4", "workaround ump4 bug", workaround_bugs, FF_BUG_UMP4, 0),
34 AVOPTION_CODEC_FLAG("bug_no_padding", "workaround padding bug", workaround_bugs, FF_BUG_NO_PADDING, 0),
35 AVOPTION_CODEC_FLAG("bug_ac_vlc", "workaround ac VLC bug", workaround_bugs, FF_BUG_AC_VLC, 0),
36 AVOPTION_CODEC_FLAG("bug_qpel_chroma", "workaround qpel chroma bug", workaround_bugs, FF_BUG_QPEL_CHROMA, 0),
37 AVOPTION_CODEC_FLAG("bug_std_qpel", "workaround std qpel bug", workaround_bugs, FF_BUG_STD_QPEL, 0),
38 AVOPTION_CODEC_FLAG("bug_qpel_chroma2", "workaround qpel chroma2 bug", workaround_bugs, FF_BUG_QPEL_CHROMA2, 0),
39 AVOPTION_CODEC_FLAG("bug_direct_blocksize", "workaround direct blocksize bug", workaround_bugs, FF_BUG_DIRECT_BLOCKSIZE, 0),
44 static int parse_bool(const AVOption *c, char *s, int *var)
46 int b = 1; /* by default -on- when present */
48 if (!strcasecmp(s, "off") || !strcasecmp(s, "false")
51 else if (!strcasecmp(s, "on") || !strcasecmp(s, "true")
58 if (c->type == FF_OPT_TYPE_FLAG) {
68 static int parse_double(const AVOption *c, char *s, double *var)
74 if (c->min != c->max) {
75 if (d < c->min || d > c->max) {
76 fprintf(stderr, "Option: %s double value: %f out of range <%f, %f>\n",
77 c->name, d, c->min, c->max);
85 static int parse_int(const AVOption* c, char* s, int* var)
91 if (c->min != c->max) {
92 if (i < (int)c->min || i > (int)c->max) {
93 fprintf(stderr, "Option: %s integer value: %d out of range <%d, %d>\n",
94 c->name, i, (int)c->min, (int)c->max);
102 static int parse_string(const AVOption *c, char *s, void* strct, char **var)
107 if (c->type == FF_OPT_TYPE_RCOVERRIDE) {
110 if (sscanf(s, "%d,%d,%d,%f", &sf, &ef, &qs, &qf) == 4 && sf < ef) {
111 AVCodecContext *avctx = (AVCodecContext *) strct;
113 avctx->rc_override = av_realloc(avctx->rc_override,
114 sizeof(RcOverride) * (avctx->rc_override_count + 1));
115 o = avctx->rc_override + avctx->rc_override_count++;
119 o->quality_factor = qf;
121 //printf("parsed Rc: %d,%d,%d,%f (%d)\n", sf,ef,qs,qf, avctx->rc_override_count);
123 printf("incorrect/unparsable Rc: \"%s\"\n", s);
130 int avoption_parse(void* strct, const AVOption* list, const char *opts)
133 char* dopts = av_strdup(opts);
137 while (str && *str && r == 0) {
138 const AVOption *stack[FF_OPT_MAX_DEPTH];
139 const AVOption *c = list;
141 char* e = strchr(str, ':');
146 p = strchr(str, '=');
150 // going through option structures
155 c = (const AVOption*) c->help;
156 assert(depth > FF_OPT_MAX_DEPTH);
164 if (!strcmp(c->name, str)) {
165 void* ptr = (char*)strct + c->offset;
167 switch (c->type & FF_OPT_TYPE_MASK) {
168 case FF_OPT_TYPE_BOOL:
169 r = parse_bool(c, p, (int*)ptr);
171 case FF_OPT_TYPE_DOUBLE:
172 r = parse_double(c, p, (double*)ptr);
174 case FF_OPT_TYPE_INT:
175 r = parse_int(c, p, (int*)ptr);
177 case FF_OPT_TYPE_STRING:
178 r = parse_string(c, p, strct, (char**)ptr);