[FFmpeg-devel] [PATCH 5/5] fftools/ffmpeg: add special syntax for loading filter options from files

Anton Khirnov anton at khirnov.net
Mon Jan 23 13:34:32 EET 2023


Quoting Anton Khirnov (2023-01-20 20:31:32)
> +static int filter_opt_apply(AVFilterContext *f, const char *key, const char *val)
> +{
> +    const AVOption *o;
> +    int ret;
> +
> +    ret = av_opt_set(f, key, val, AV_OPT_SEARCH_CHILDREN);
> +    if (ret >= 0)
> +        return 0;
> +
> +    if (ret == AVERROR_OPTION_NOT_FOUND && key[0] == '/')
> +        o = av_opt_find(f, key + 1, NULL, 0, AV_OPT_SEARCH_CHILDREN);
> +    if (!o)
> +        goto err_apply;
> +
> +    // key is a valid option name prefixed with '/'
> +    // interpret value as a path from which to load the actual option value
> +    key++;
> +
> +    if (o->type == AV_OPT_TYPE_BINARY) {
> +        uint8_t *data;
> +        int      len;
> +
> +        ret = read_binary(val, &data, &len);
> +        if (ret < 0)
> +            goto err_load;
> +
> +        ret = av_opt_set_bin(f, key, data, len, AV_OPT_SEARCH_CHILDREN);
> +        av_freep(&data);
> +    } else {
> +        char *data = file_read(val);
> +        if (!val) {

should be s/val/data/
fixed locally

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list