]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/opts.c
simplified adressing of most mb based arrays (mb_x + mb_y*s->mb_stride) now instead...
[ffmpeg] / libavcodec / opts.c
index cf5cf0eef72a0e1d5320f89710064875c0f1789f..44a213397f5150a6b5a77af6214cfd46e86f8368 100644 (file)
@@ -2,21 +2,45 @@
  * LGPL
  */
 
-/*
+/**
+ * @file opts.c
+ * options parser.
  * typical parsed command line:
  * msmpeg4:bitrate=720000:qmax=16
  *
  */
 
 #include "avcodec.h"
+#include "os_support.h"
+
+const AVOption avoptions_common[] = {
+    AVOPTION_CODEC_FLAG("bit_exact", "use only bit-exact stuff", flags, CODEC_FLAG_BITEXACT, 0),
+    AVOPTION_CODEC_FLAG("mm_force", "force mm flags", dsp_mask, FF_MM_FORCE, 0),
+#ifdef HAVE_MMX
+    AVOPTION_CODEC_FLAG("mm_mmx", "mask MMX feature", dsp_mask, FF_MM_MMX, 0),
+    AVOPTION_CODEC_FLAG("mm_3dnow", "mask 3DNow feature", dsp_mask, FF_MM_3DNOW, 0),
+    AVOPTION_CODEC_FLAG("mm_mmxext", "mask MMXEXT (MMX2) feature", dsp_mask, FF_MM_MMXEXT, 0),
+    AVOPTION_CODEC_FLAG("mm_sse", "mask SSE feature", dsp_mask, FF_MM_SSE, 0),
+    AVOPTION_CODEC_FLAG("mm_sse2", "mask SSE2 feature", dsp_mask, FF_MM_SSE2, 0),
+#endif
+    AVOPTION_END()
+};
 
-extern const AVOption common_options[2];
-
-const AVOption common_options[2] = {
-    AVOPTION_CODEC_INT("common", "test", bit_rate, 0, 10, 0),
+const AVOption avoptions_workaround_bug[] = {
+    AVOPTION_CODEC_FLAG("bug_autodetect", "workaround bug autodetection", workaround_bugs, FF_BUG_AUTODETECT, 1),
+    AVOPTION_CODEC_FLAG("bug_old_msmpeg4", "workaround old msmpeg4 bug", workaround_bugs, FF_BUG_OLD_MSMPEG4, 0),
+    AVOPTION_CODEC_FLAG("bug_xvid_ilace", "workaround XviD interlace bug", workaround_bugs, FF_BUG_XVID_ILACE, 0),
+    AVOPTION_CODEC_FLAG("bug_ump4", "workaround ump4 bug", workaround_bugs, FF_BUG_UMP4, 0),
+    AVOPTION_CODEC_FLAG("bug_no_padding", "workaround padding bug", workaround_bugs, FF_BUG_NO_PADDING, 0),
+    AVOPTION_CODEC_FLAG("bug_ac_vlc", "workaround ac VLC bug", workaround_bugs, FF_BUG_AC_VLC, 0),
+    AVOPTION_CODEC_FLAG("bug_qpel_chroma", "workaround qpel chroma bug", workaround_bugs, FF_BUG_QPEL_CHROMA, 0),
+    AVOPTION_CODEC_FLAG("bug_std_qpel", "workaround std qpel bug", workaround_bugs, FF_BUG_STD_QPEL, 0),
+    AVOPTION_CODEC_FLAG("bug_qpel_chroma2", "workaround qpel chroma2 bug", workaround_bugs, FF_BUG_QPEL_CHROMA2, 0),
+    AVOPTION_CODEC_FLAG("bug_direct_blocksize", "workaround direct blocksize bug", workaround_bugs, FF_BUG_DIRECT_BLOCKSIZE, 0),
     AVOPTION_END()
 };
 
+
 static int parse_bool(const AVOption *c, char *s, int *var)
 {
     int b = 1; /* by default -on- when present */
@@ -31,7 +55,13 @@ static int parse_bool(const AVOption *c, char *s, int *var)
            return -1;
     }
 
-    *var = b;
+    if (c->type == FF_OPT_TYPE_FLAG) {
+       if (b)
+           *var |= (int)c->min;
+       else
+            *var &= ~(int)c->min;
+    } else
+       *var = b;
     return 0;
 }
 
@@ -69,7 +99,7 @@ static int parse_int(const AVOption* c, char* s, int* var)
     return 0;
 }
 
-static int parse_string(const AVOption *c, char *s, AVCodecContext *avctx, char **var)
+static int parse_string(const AVOption *c, char *s, void* strct, char **var)
 {
     if (!s)
        return -1;
@@ -78,6 +108,7 @@ static int parse_string(const AVOption *c, char *s, AVCodecContext *avctx, char
        int sf, ef, qs;
        float qf;
        if (sscanf(s, "%d,%d,%d,%f", &sf, &ef, &qs, &qf) == 4 && sf < ef) {
+           AVCodecContext *avctx = (AVCodecContext *) strct;
            RcOverride *o;
            avctx->rc_override = av_realloc(avctx->rc_override,
                                            sizeof(RcOverride) * (avctx->rc_override_count + 1));
@@ -96,13 +127,7 @@ static int parse_string(const AVOption *c, char *s, AVCodecContext *avctx, char
     return 0;
 }
 
-/**
- *
- * \param codec  codec for option parsing
- * \param opts   string with options for parsing
- * \param avctx  where to store parsed results
- */
-int avcodec_parse(const AVCodec *codec, const char *opts, AVCodecContext *avctx)
+int avoption_parse(void* strct, const AVOption* list, const char *opts)
 {
     int r = 0;
     char* dopts = av_strdup(opts);
@@ -111,8 +136,8 @@ int avcodec_parse(const AVCodec *codec, const char *opts, AVCodecContext *avctx)
 
        while (str && *str && r == 0) {
            const AVOption *stack[FF_OPT_MAX_DEPTH];
+           const AVOption *c = list;
            int depth = 0;
-           const AVOption *c = codec->options;
            char* e = strchr(str, ':');
            char* p;
            if (e)
@@ -125,9 +150,9 @@ int avcodec_parse(const AVCodec *codec, const char *opts, AVCodecContext *avctx)
             // going through option structures
            for (;;) {
                if (!c->name) {
-                   if (c->sub) {
+                   if (c->help) {
                        stack[depth++] = c;
-                       c = c->sub;
+                       c = (const AVOption*) c->help;
                        assert(depth > FF_OPT_MAX_DEPTH);
                    } else {
                        if (depth == 0)
@@ -137,7 +162,7 @@ int avcodec_parse(const AVCodec *codec, const char *opts, AVCodecContext *avctx)
                    }
                } else {
                    if (!strcmp(c->name, str)) {
-                       void* ptr = (char*)avctx + c->offset;
+                       void* ptr = (char*)strct + c->offset;
 
                        switch (c->type & FF_OPT_TYPE_MASK) {
                        case FF_OPT_TYPE_BOOL:
@@ -150,7 +175,7 @@ int avcodec_parse(const AVCodec *codec, const char *opts, AVCodecContext *avctx)
                            r = parse_int(c, p, (int*)ptr);
                            break;
                        case FF_OPT_TYPE_STRING:
-                           r = parse_string(c, p, avctx, (char**)ptr);
+                           r = parse_string(c, p, strct, (char**)ptr);
                            break;
                        default:
                            assert(0 == 1);