int avfilter_init_str(AVFilterContext *filter, const char *args)
{
    AVDictionary *options = NULL;
    AVDictionaryEntry *e;
    int ret = 0;
    if (args && *args) {
        if (!filter->filter->priv_class) {
            av_log(filter, AV_LOG_ERROR, "This filter does not take any "
                   "options, but options were provided: %s.\n", args);
            return AVERROR(EINVAL);
        }
#if FF_API_OLD_FILTER_OPTS
        if (!strcmp(filter->filter->name, "scale") &&
            strchr(args, ':') && strchr(args, ':') < strchr(args, '=')) {
            char *copy = av_strdup(args);
            char *p;
            av_log(filter, AV_LOG_WARNING, "The <w>:<h>:flags=<flags> option "
                   "syntax is deprecated. Use either <w>:<h>:<flags> or "
                   "w=<w>:h=<h>:flags=<flags>.\n");
            if (!copy) {
                ret = AVERROR(ENOMEM);
                goto fail;
            }
            p = strrchr(copy, ':');
            if (p) {
                *p++ = 0;
                ret = av_dict_parse_string(&options, p, "=", ":", 0);
            }
            if (ret >= 0)
                ret = process_unnamed_options(filter, &options, copy);
            av_freep(&copy);
            if (ret < 0)
                goto fail;
        } else
#endif
        if (strchr(args, '=')) {
            ret = av_dict_parse_string(&options, args, "=", ":", 0);
            if (ret < 0)
                goto fail;
#if FF_API_OLD_FILTER_OPTS
        } else if (!strcmp(filter->filter->name, "format")     ||
                   !strcmp(filter->filter->name, "noformat")   ||
                   !strcmp(filter->filter->name, "frei0r")     ||
                   !strcmp(filter->filter->name, "frei0r_src") ||
                   !strcmp(filter->filter->name, "ocv")) {
            char *copy = av_strdup(args);
            char *p    = copy;
            int nb_leading = 0;
            if (!copy) {
                ret = AVERROR(ENOMEM);
                goto fail;
            }
            if (!strcmp(filter->filter->name, "frei0r") ||
                !strcmp(filter->filter->name, "ocv"))
                nb_leading = 1;
            else if (!strcmp(filter->filter->name, "frei0r_src"))
                nb_leading = 3;
            while (nb_leading--) {
                p = strchr(p, ':');
                if (!p) {
                    p = copy + strlen(copy);
                    break;
                }
                p++;
            }
            if (strchr(p, ':')) {
                av_log(filter, AV_LOG_WARNING, "This syntax is deprecated. Use "
                       "'|' to separate the list items.\n");
            }
            while ((p = strchr(p, ':')))
                *p++ = '|';
            ret = process_unnamed_options(filter, &options, copy);
            av_freep(&copy);
            if (ret < 0)
                goto fail;
#endif
        } else {
            ret = process_unnamed_options(filter, &options, args);
            if (ret < 0)
                goto fail;
        }
    }
    ret = avfilter_init_dict(filter, &options);
    if (ret < 0)
        goto fail;
    if ((e = av_dict_get(options, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
        av_log(filter, AV_LOG_ERROR, "No such option: %s.\n", e->key);
        ret = AVERROR_OPTION_NOT_FOUND;
        goto fail;
    }
fail:
    av_dict_free(&options);
    return ret;
}
['int avfilter_init_str(AVFilterContext *filter, const char *args)\n{\n    AVDictionary *options = NULL;\n    AVDictionaryEntry *e;\n    int ret = 0;\n    if (args && *args) {\n        if (!filter->filter->priv_class) {\n            av_log(filter, AV_LOG_ERROR, "This filter does not take any "\n                   "options, but options were provided: %s.\\n", args);\n            return AVERROR(EINVAL);\n        }\n#if FF_API_OLD_FILTER_OPTS\n        if (!strcmp(filter->filter->name, "scale") &&\n            strchr(args, \':\') && strchr(args, \':\') < strchr(args, \'=\')) {\n            char *copy = av_strdup(args);\n            char *p;\n            av_log(filter, AV_LOG_WARNING, "The <w>:<h>:flags=<flags> option "\n                   "syntax is deprecated. Use either <w>:<h>:<flags> or "\n                   "w=<w>:h=<h>:flags=<flags>.\\n");\n            if (!copy) {\n                ret = AVERROR(ENOMEM);\n                goto fail;\n            }\n            p = strrchr(copy, \':\');\n            if (p) {\n                *p++ = 0;\n                ret = av_dict_parse_string(&options, p, "=", ":", 0);\n            }\n            if (ret >= 0)\n                ret = process_unnamed_options(filter, &options, copy);\n            av_freep(&copy);\n            if (ret < 0)\n                goto fail;\n        } else\n#endif\n        if (strchr(args, \'=\')) {\n            ret = av_dict_parse_string(&options, args, "=", ":", 0);\n            if (ret < 0)\n                goto fail;\n#if FF_API_OLD_FILTER_OPTS\n        } else if (!strcmp(filter->filter->name, "format")     ||\n                   !strcmp(filter->filter->name, "noformat")   ||\n                   !strcmp(filter->filter->name, "frei0r")     ||\n                   !strcmp(filter->filter->name, "frei0r_src") ||\n                   !strcmp(filter->filter->name, "ocv")) {\n            char *copy = av_strdup(args);\n            char *p    = copy;\n            int nb_leading = 0;\n            if (!copy) {\n                ret = AVERROR(ENOMEM);\n                goto fail;\n            }\n            if (!strcmp(filter->filter->name, "frei0r") ||\n                !strcmp(filter->filter->name, "ocv"))\n                nb_leading = 1;\n            else if (!strcmp(filter->filter->name, "frei0r_src"))\n                nb_leading = 3;\n            while (nb_leading--) {\n                p = strchr(p, \':\');\n                if (!p) {\n                    p = copy + strlen(copy);\n                    break;\n                }\n                p++;\n            }\n            if (strchr(p, \':\')) {\n                av_log(filter, AV_LOG_WARNING, "This syntax is deprecated. Use "\n                       "\'|\' to separate the list items.\\n");\n            }\n            while ((p = strchr(p, \':\')))\n                *p++ = \'|\';\n            ret = process_unnamed_options(filter, &options, copy);\n            av_freep(&copy);\n            if (ret < 0)\n                goto fail;\n#endif\n        } else {\n            ret = process_unnamed_options(filter, &options, args);\n            if (ret < 0)\n                goto fail;\n        }\n    }\n    ret = avfilter_init_dict(filter, &options);\n    if (ret < 0)\n        goto fail;\n    if ((e = av_dict_get(options, "", NULL, AV_DICT_IGNORE_SUFFIX))) {\n        av_log(filter, AV_LOG_ERROR, "No such option: %s.\\n", e->key);\n        ret = AVERROR_OPTION_NOT_FOUND;\n        goto fail;\n    }\nfail:\n    av_dict_free(&options);\n    return ret;\n}', 'char *av_strdup(const char *s)\n{\n    char *ptr = NULL;\n    if (s) {\n        int len = strlen(s) + 1;\n        ptr = av_realloc(NULL, len);\n        if (ptr)\n            memcpy(ptr, s, len);\n    }\n    return ptr;\n}', 'void *av_realloc(void *ptr, size_t size)\n{\n#if CONFIG_MEMALIGN_HACK\n    int diff;\n#endif\n    if (size > (INT_MAX - 16))\n        return NULL;\n#if CONFIG_MEMALIGN_HACK\n    if (!ptr)\n        return av_malloc(size);\n    diff = ((char *)ptr)[-1];\n    return (char *)realloc((char *)ptr - diff, size + diff) + diff;\n#elif HAVE_ALIGNED_MALLOC\n    return _aligned_realloc(ptr, size, 32);\n#else\n    return realloc(ptr, size);\n#endif\n}']