diff options
Diffstat (limited to 'libavfilter/vf_libopencv.c')
-rw-r--r-- | libavfilter/vf_libopencv.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c index 44f0037764..b731a1f6b0 100644 --- a/libavfilter/vf_libopencv.c +++ b/libavfilter/vf_libopencv.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2010 Stefano Sabatini * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -261,17 +261,18 @@ static av_cold int dilate_init(AVFilterContext *ctx, const char *args) const char *buf = args; int ret; - dilate->nb_iterations = 1; - if (args) kernel_str = av_get_token(&buf, "|"); - if ((ret = parse_iplconvkernel(&dilate->kernel, - *kernel_str ? kernel_str : default_kernel_str, - ctx)) < 0) + else + kernel_str = av_strdup(default_kernel_str); + if (!kernel_str) + return AVERROR(ENOMEM); + if ((ret = parse_iplconvkernel(&dilate->kernel, kernel_str, ctx)) < 0) return ret; av_free(kernel_str); - sscanf(buf, "|%d", &dilate->nb_iterations); + if (!buf || sscanf(buf, "|%d", &dilate->nb_iterations) != 1) + dilate->nb_iterations = 1; av_log(ctx, AV_LOG_VERBOSE, "iterations_nb:%d\n", dilate->nb_iterations); if (dilate->nb_iterations <= 0) { av_log(ctx, AV_LOG_ERROR, "Invalid non-positive value '%d' for nb_iterations\n", @@ -322,6 +323,10 @@ static av_cold int init(AVFilterContext *ctx) OCVContext *ocv = ctx->priv; int i; + if (!ocv->name) { + av_log(ctx, AV_LOG_ERROR, "No libopencv filter name specified\n"); + return AVERROR(EINVAL); + } for (i = 0; i < FF_ARRAY_ELEMS(ocv_filter_entries); i++) { OCVFilterEntry *entry = &ocv_filter_entries[i]; if (!strcmp(ocv->name, entry->name)) { @@ -374,7 +379,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) } #define OFFSET(x) offsetof(OCVContext, x) -#define FLAGS AV_OPT_FLAG_VIDEO_PARAM +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM static const AVOption options[] = { { "filter_name", NULL, OFFSET(name), AV_OPT_TYPE_STRING, .flags = FLAGS }, { "filter_params", NULL, OFFSET(params), AV_OPT_TYPE_STRING, .flags = FLAGS }, |