summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2021-10-23 14:47:11 +0200
committerPaul B Mahol <onemda@gmail.com>2021-10-23 14:51:42 +0200
commit6c45d34e505f7ef93e07db4a616e7b98d1490102 (patch)
treef916d1cccd2c2a10ec99bf2fa70ec72f1d3c8bb3 /libavfilter
parent9e8bb9efd9f06d6bb879f0c07dd48ea5c33ac376 (diff)
avfilter/vf_convolution: improve runtime support for convolution filter
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/vf_convolution.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libavfilter/vf_convolution.c b/libavfilter/vf_convolution.c
index 47b59de421..6e6fe0d887 100644
--- a/libavfilter/vf_convolution.c
+++ b/libavfilter/vf_convolution.c
@@ -709,12 +709,14 @@ static int param_init(AVFilterContext *ctx)
if (!strcmp(ctx->filter->name, "convolution")) {
for (i = 0; i < 4; i++) {
int *matrix = (int *)s->matrix[i];
- char *p, *arg, *saveptr = NULL;
- float sum = 0;
+ char *orig, *p, *arg, *saveptr = NULL;
+ float sum = 1.f;
- p = s->matrix_str[i];
+ p = orig = av_strdup(s->matrix_str[i]);
if (p) {
s->matrix_length[i] = 0;
+ s->rdiv[i] = 0.f;
+ sum = 0.f;
while (s->matrix_length[i] < 49) {
if (!(arg = av_strtok(p, " |", &saveptr)))
@@ -726,6 +728,7 @@ static int param_init(AVFilterContext *ctx)
s->matrix_length[i]++;
}
+ av_freep(&orig);
if (!(s->matrix_length[i] & 1)) {
av_log(ctx, AV_LOG_ERROR, "number of matrix elements must be odd\n");
return AVERROR(EINVAL);