avfilter/vf_convolution: improve runtime support for convolution filter
This commit is contained in:
parent
9e8bb9efd9
commit
6c45d34e50
|
@ -709,12 +709,14 @@ static int param_init(AVFilterContext *ctx)
|
||||||
if (!strcmp(ctx->filter->name, "convolution")) {
|
if (!strcmp(ctx->filter->name, "convolution")) {
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
int *matrix = (int *)s->matrix[i];
|
int *matrix = (int *)s->matrix[i];
|
||||||
char *p, *arg, *saveptr = NULL;
|
char *orig, *p, *arg, *saveptr = NULL;
|
||||||
float sum = 0;
|
float sum = 1.f;
|
||||||
|
|
||||||
p = s->matrix_str[i];
|
p = orig = av_strdup(s->matrix_str[i]);
|
||||||
if (p) {
|
if (p) {
|
||||||
s->matrix_length[i] = 0;
|
s->matrix_length[i] = 0;
|
||||||
|
s->rdiv[i] = 0.f;
|
||||||
|
sum = 0.f;
|
||||||
|
|
||||||
while (s->matrix_length[i] < 49) {
|
while (s->matrix_length[i] < 49) {
|
||||||
if (!(arg = av_strtok(p, " |", &saveptr)))
|
if (!(arg = av_strtok(p, " |", &saveptr)))
|
||||||
|
@ -726,6 +728,7 @@ static int param_init(AVFilterContext *ctx)
|
||||||
s->matrix_length[i]++;
|
s->matrix_length[i]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
av_freep(&orig);
|
||||||
if (!(s->matrix_length[i] & 1)) {
|
if (!(s->matrix_length[i] & 1)) {
|
||||||
av_log(ctx, AV_LOG_ERROR, "number of matrix elements must be odd\n");
|
av_log(ctx, AV_LOG_ERROR, "number of matrix elements must be odd\n");
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
|
|
Loading…
Reference in New Issue