int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque)

#endif

{

    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, '=')) {

            /* old w:h:flags=<flags> syntax */

            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_options(filter, &options, copy);

            av_freep(&copy);



            if (ret < 0)

                goto fail;

        } 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")        ||

                   !strcmp(filter->filter->name, "pan")        ||

                   !strcmp(filter->filter->name, "pp")         ||

                   !strcmp(filter->filter->name, "aevalsrc")) {

            /* a hack for compatibility with the old syntax

             * replace colons with |s */

            char *copy = av_strdup(args);

            char *p    = copy;

            int nb_leading = 0; // number of leading colons to skip

            int deprecated = 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++;

            }



            deprecated = strchr(p, ':') != NULL;



            if (!strcmp(filter->filter->name, "aevalsrc")) {

                deprecated = 0;

                while ((p = strchr(p, ':')) && p[1] != ':') {

                    const char *epos = strchr(p + 1, '=');

                    const char *spos = strchr(p + 1, ':');

                    const int next_token_is_opt = epos && (!spos || epos < spos);

                    if (next_token_is_opt) {

                        p++;

                        break;

                    }

                    /* next token does not contain a '=', assume a channel expression */

                    deprecated = 1;

                    *p++ = '|';

                }

                if (p && *p == ':') { // double sep '::' found

                    deprecated = 1;

                    memmove(p, p + 1, strlen(p));

                }

            } else

            while ((p = strchr(p, ':')))

                *p++ = '|';



            if (deprecated)

                av_log(filter, AV_LOG_WARNING, "This syntax is deprecated. Use "

                       "'|' to separate the list items.\n");



            av_log(filter, AV_LOG_DEBUG, "compat: called with args=[%s]\n", copy);

            ret = process_options(filter, &options, copy);

            av_freep(&copy);



            if (ret < 0)

                goto fail;

#endif

        } else {

#if CONFIG_MP_FILTER

            if (!strcmp(filter->filter->name, "mp")) {

                char *escaped;



                if (!strncmp(args, "filter=", 7))

                    args += 7;

                ret = av_escape(&escaped, args, ":=", AV_ESCAPE_MODE_BACKSLASH, 0);

                if (ret < 0) {

                    av_log(filter, AV_LOG_ERROR, "Unable to escape MPlayer filters arg '%s'\n", args);

                    goto fail;

                }

                ret = process_options(filter, &options, escaped);

                av_free(escaped);

            } else

#endif

            ret = process_options(filter, &options, args);

            if (ret < 0)

                goto fail;

        }

    }



    if (filter->filter->priv_class) {

        ret = av_opt_set_dict(filter->priv, &options);

        if (ret < 0) {

            av_log(filter, AV_LOG_ERROR, "Error applying options to the filter.\n");

            goto fail;

        }

    }



    if (filter->filter->init_opaque)

        ret = filter->filter->init_opaque(filter, opaque);

    else if (filter->filter->init)

        ret = filter->filter->init(filter);

    else if (filter->filter->init_dict)

        ret = filter->filter->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_filter(AVFilterContext *filter, const char *args, void *opaque)

#endif

{

    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, '=')) {

            

            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_options(filter, &options, copy);

            av_freep(&copy);



            if (ret < 0)

                goto fail;

        } 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")        ||

                   !strcmp(filter->filter->name, "pan")        ||

                   !strcmp(filter->filter->name, "pp")         ||

                   !strcmp(filter->filter->name, "aevalsrc")) {

            



            char *copy = av_strdup(args);

            char *p    = copy;

            int nb_leading = 0; 

            int deprecated = 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++;

            }



            deprecated = strchr(p, ':') != NULL;



            if (!strcmp(filter->filter->name, "aevalsrc")) {

                deprecated = 0;

                while ((p = strchr(p, ':')) && p[1] != ':') {

                    const char *epos = strchr(p + 1, '=');

                    const char *spos = strchr(p + 1, ':');

                    const int next_token_is_opt = epos && (!spos || epos < spos);

                    if (next_token_is_opt) {

                        p++;

                        break;

                    }

                    

                    deprecated = 1;

                    *p++ = '|';

                }

                if (p && *p == ':') { 

                    deprecated = 1;

                    memmove(p, p + 1, strlen(p));

                }

            } else

            while ((p = strchr(p, ':')))

                *p++ = '|';



            if (deprecated)

                av_log(filter, AV_LOG_WARNING, "This syntax is deprecated. Use "

                       "'|' to separate the list items.\n");



            av_log(filter, AV_LOG_DEBUG, "compat: called with args=[%s]\n", copy);

            ret = process_options(filter, &options, copy);

            av_freep(&copy);



            if (ret < 0)

                goto fail;

#endif

        } else {

#if CONFIG_MP_FILTER

            if (!strcmp(filter->filter->name, "mp")) {

                char *escaped;



                if (!strncmp(args, "filter=", 7))

                    args += 7;

                ret = av_escape(&escaped, args, ":=", AV_ESCAPE_MODE_BACKSLASH, 0);

                if (ret < 0) {

                    av_log(filter, AV_LOG_ERROR, "Unable to escape MPlayer filters arg '%s'\n", args);

                    goto fail;

                }

                ret = process_options(filter, &options, escaped);

                av_free(escaped);

            } else

#endif

            ret = process_options(filter, &options, args);

            if (ret < 0)

                goto fail;

        }

    }



    if (filter->filter->priv_class) {

        ret = av_opt_set_dict(filter->priv, &options);

        if (ret < 0) {

            av_log(filter, AV_LOG_ERROR, "Error applying options to the filter.\n");

            goto fail;

        }

    }



    if (filter->filter->init_opaque)

        ret = filter->filter->init_opaque(filter, opaque);

    else if (filter->filter->init)

        ret = filter->filter->init(filter);

    else if (filter->filter->init_dict)

        ret = filter->filter->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 FUNC_0(AVFilterContext *VAR_0, const char *VAR_1, void *VAR_2)

#endif

{

    AVDictionary *options = NULL;

    AVDictionaryEntry *e;

    int VAR_3=0;



    if (VAR_1 && *VAR_1) {

        if (!VAR_0->VAR_0->priv_class) {

            av_log(VAR_0, AV_LOG_ERROR, "This VAR_0 does not take any "

                   "options, but options were provided: %s.\n", VAR_1);

            return AVERROR(EINVAL);

        }



#if FF_API_OLD_FILTER_OPTS

        if (!strcmp(VAR_0->VAR_0->name, "scale") &&

            strchr(VAR_1, ':') < strchr(VAR_1, '=')) {

            

            char *copy = av_strdup(VAR_1);

            char *p;



            av_log(VAR_0, 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) {

                VAR_3 = AVERROR(ENOMEM);

                goto VAR_4;

            }



            p = strrchr(copy, ':');

            if (p) {

                *p++ = 0;

                VAR_3 = av_dict_parse_string(&options, p, "=", ":", 0);

            }

            if (VAR_3 >= 0)

                VAR_3 = process_options(VAR_0, &options, copy);

            av_freep(&copy);



            if (VAR_3 < 0)

                goto VAR_4;

        } else if (!strcmp(VAR_0->VAR_0->name, "format")     ||

                   !strcmp(VAR_0->VAR_0->name, "noformat")   ||

                   !strcmp(VAR_0->VAR_0->name, "frei0r")     ||

                   !strcmp(VAR_0->VAR_0->name, "frei0r_src") ||

                   !strcmp(VAR_0->VAR_0->name, "ocv")        ||

                   !strcmp(VAR_0->VAR_0->name, "pan")        ||

                   !strcmp(VAR_0->VAR_0->name, "pp")         ||

                   !strcmp(VAR_0->VAR_0->name, "aevalsrc")) {

            



            char *copy = av_strdup(VAR_1);

            char *p    = copy;

            int nb_leading = 0; 

            int deprecated = 0;



            if (!copy) {

                VAR_3 = AVERROR(ENOMEM);

                goto VAR_4;

            }



            if (!strcmp(VAR_0->VAR_0->name, "frei0r") ||

                !strcmp(VAR_0->VAR_0->name, "ocv"))

                nb_leading = 1;

            else if (!strcmp(VAR_0->VAR_0->name, "frei0r_src"))

                nb_leading = 3;



            while (nb_leading--) {

                p = strchr(p, ':');

                if (!p) {

                    p = copy + strlen(copy);

                    break;

                }

                p++;

            }



            deprecated = strchr(p, ':') != NULL;



            if (!strcmp(VAR_0->VAR_0->name, "aevalsrc")) {

                deprecated = 0;

                while ((p = strchr(p, ':')) && p[1] != ':') {

                    const char *epos = strchr(p + 1, '=');

                    const char *spos = strchr(p + 1, ':');

                    const int next_token_is_opt = epos && (!spos || epos < spos);

                    if (next_token_is_opt) {

                        p++;

                        break;

                    }

                    

                    deprecated = 1;

                    *p++ = '|';

                }

                if (p && *p == ':') { 

                    deprecated = 1;

                    memmove(p, p + 1, strlen(p));

                }

            } else

            while ((p = strchr(p, ':')))

                *p++ = '|';



            if (deprecated)

                av_log(VAR_0, AV_LOG_WARNING, "This syntax is deprecated. Use "

                       "'|' to separate the list items.\n");



            av_log(VAR_0, AV_LOG_DEBUG, "compat: called with VAR_1=[%s]\n", copy);

            VAR_3 = process_options(VAR_0, &options, copy);

            av_freep(&copy);



            if (VAR_3 < 0)

                goto VAR_4;

#endif

        } else {

#if CONFIG_MP_FILTER

            if (!strcmp(VAR_0->VAR_0->name, "mp")) {

                char *escaped;



                if (!strncmp(VAR_1, "VAR_0=", 7))

                    VAR_1 += 7;

                VAR_3 = av_escape(&escaped, VAR_1, ":=", AV_ESCAPE_MODE_BACKSLASH, 0);

                if (VAR_3 < 0) {

                    av_log(VAR_0, AV_LOG_ERROR, "Unable to escape MPlayer filters arg '%s'\n", VAR_1);

                    goto VAR_4;

                }

                VAR_3 = process_options(VAR_0, &options, escaped);

                av_free(escaped);

            } else

#endif

            VAR_3 = process_options(VAR_0, &options, VAR_1);

            if (VAR_3 < 0)

                goto VAR_4;

        }

    }



    if (VAR_0->VAR_0->priv_class) {

        VAR_3 = av_opt_set_dict(VAR_0->priv, &options);

        if (VAR_3 < 0) {

            av_log(VAR_0, AV_LOG_ERROR, "Error applying options to the VAR_0.\n");

            goto VAR_4;

        }

    }



    if (VAR_0->VAR_0->init_opaque)

        VAR_3 = VAR_0->VAR_0->init_opaque(VAR_0, VAR_2);

    else if (VAR_0->VAR_0->init)

        VAR_3 = VAR_0->VAR_0->init(VAR_0);

    else if (VAR_0->VAR_0->init_dict)

        VAR_3 = VAR_0->VAR_0->init_dict(VAR_0, &options);

    if (VAR_3 < 0)

        goto VAR_4;



    if ((e = av_dict_get(options, "", NULL, AV_DICT_IGNORE_SUFFIX))) {

        av_log(VAR_0, AV_LOG_ERROR, "No such option: %s.\n", e->key);

        VAR_3 = AVERROR_OPTION_NOT_FOUND;

        goto VAR_4;

    }



VAR_4:

    FUNC_1(&options);



    return VAR_3;

}

int FUNC_0(AVFilterContext *VAR_0, const char *VAR_1, void *VAR_2)
#endif
{ AVDictionary *options = NULL; AVDictionaryEntry *e; int VAR_3=0; if (VAR_1 && *VAR_1) { if (!VAR_0->VAR_0->priv_class) { av_log(VAR_0, AV_LOG_ERROR, "This VAR_0 does not take any "
"options, but options were provided: %s.\n", VAR_1); return AVERROR(EINVAL); } #if FF_API_OLD_FILTER_OPTS
if (!strcmp(VAR_0->VAR_0->name, "scale") &&
strchr(VAR_1, ':') < strchr(VAR_1, '=')) { char *copy = av_strdup(VAR_1); char *p; av_log(VAR_0, 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) { VAR_3 = AVERROR(ENOMEM); goto VAR_4; } p = strrchr(copy, ':'); if (p) { *p++ = 0; VAR_3 = av_dict_parse_string(&options, p, "=", ":", 0); } if (VAR_3 >= 0)
VAR_3 = process_options(VAR_0, &options, copy); av_freep(&copy); if (VAR_3 < 0)
goto VAR_4; } else if (!strcmp(VAR_0->VAR_0->name, "format")     || !strcmp(VAR_0->VAR_0->name, "noformat")   ||
!strcmp(VAR_0->VAR_0->name, "frei0r")     ||
!strcmp(VAR_0->VAR_0->name, "frei0r_src") ||
!strcmp(VAR_0->VAR_0->name, "ocv")        ||
!strcmp(VAR_0->VAR_0->name, "pan")        ||
!strcmp(VAR_0->VAR_0->name, "pp")         ||
!strcmp(VAR_0->VAR_0->name, "aevalsrc")) { char *copy = av_strdup(VAR_1); char *p    = copy; int nb_leading = 0; int deprecated = 0; if (!copy) { VAR_3 = AVERROR(ENOMEM); goto VAR_4; } if (!strcmp(VAR_0->VAR_0->name, "frei0r") ||
!strcmp(VAR_0->VAR_0->name, "ocv"))
nb_leading = 1; else if (!strcmp(VAR_0->VAR_0->name, "frei0r_src"))
nb_leading = 3; while (nb_leading--) { p = strchr(p, ':'); if (!p) { p = copy + strlen(copy); break; } p++; } deprecated = strchr(p, ':') != NULL; if (!strcmp(VAR_0->VAR_0->name, "aevalsrc")) { deprecated = 0; while ((p = strchr(p, ':')) && p[1] != ':') { const char *epos = strchr(p + 1, '='); const char *spos = strchr(p + 1, ':'); const int next_token_is_opt = epos && (!spos || epos < spos); if (next_token_is_opt) { p++; break; } deprecated = 1; *p++ = '|'; } if (p && *p == ':') { deprecated = 1; memmove(p, p + 1, strlen(p)); } } else while ((p = strchr(p, ':')))
*p++ = '|'; if (deprecated)
av_log(VAR_0, AV_LOG_WARNING, "This syntax is deprecated. Use "
"'|' to separate the list items.\n"); av_log(VAR_0, AV_LOG_DEBUG, "compat: called with VAR_1=[%s]\n", copy); VAR_3 = process_options(VAR_0, &options, copy); av_freep(&copy); if (VAR_3 < 0)
goto VAR_4; #endif
} else { #if CONFIG_MP_FILTER
if (!strcmp(VAR_0->VAR_0->name, "mp")) { char *escaped; if (!strncmp(VAR_1, "VAR_0=", 7))
VAR_1 += 7; VAR_3 = av_escape(&escaped, VAR_1, ":=", AV_ESCAPE_MODE_BACKSLASH, 0); if (VAR_3 < 0) { av_log(VAR_0, AV_LOG_ERROR, "Unable to escape MPlayer filters arg '%s'\n", VAR_1); goto VAR_4; } VAR_3 = process_options(VAR_0, &options, escaped); av_free(escaped); } else #endif
VAR_3 = process_options(VAR_0, &options, VAR_1); if (VAR_3 < 0)
goto VAR_4; } } if (VAR_0->VAR_0->priv_class) { VAR_3 = av_opt_set_dict(VAR_0->priv, &options); if (VAR_3 < 0) { av_log(VAR_0, AV_LOG_ERROR, "Error applying options to the VAR_0.\n"); goto VAR_4; } } if (VAR_0->VAR_0->init_opaque)
VAR_3 = VAR_0->VAR_0->init_opaque(VAR_0, VAR_2); else if (VAR_0->VAR_0->init)
VAR_3 = VAR_0->VAR_0->init(VAR_0); else if (VAR_0->VAR_0->init_dict)
VAR_3 = VAR_0->VAR_0->init_dict(VAR_0, &options); if (VAR_3 < 0)
goto VAR_4; if ((e = av_dict_get(options, "", NULL, AV_DICT_IGNORE_SUFFIX))) { av_log(VAR_0, AV_LOG_ERROR, "No such option: %s.\n", e->key); VAR_3 = AVERROR_OPTION_NOT_FOUND; goto VAR_4; } VAR_4:
FUNC_1(&options); return VAR_3; }