History

avfilter/vf_convolution: make rdiv set to 0 more useful

Use 0 for signaling that rdiv will be calculated from sum of all matrix elements.

Paul B Mahol committed 8 years ago

Commit 4f484ed1 parent 92a0a6b2 files · +12 −4Browse files

Unified · Split

2 files
  1. doc/filters.texi +1 −0
  2. libavfilter/vf_convolution.c +11 −4
doc/filters.texi+1−0
@@ -6401,6 +6401,7 @@ Matrix is sequence of 9, 25 or 49 signed integers. · 6400 unmodified lines
6401@item 2rdiv6401@item 2rdiv
6402@item 3rdiv6402@item 3rdiv
6403Set multiplier for calculated value for each plane.6403Set multiplier for calculated value for each plane.
6404If unset or 0, it will be sum of all matrix elements.
6404 6405
6405@item 0bias6406@item 0bias
6406@item 1bias6407@item 1bias
libavfilter/vf_convolution.c+11−4
@@ -63,10 +63,10 @@ static const AVOption convolution_options[] = { · 62 unmodified lines
63 { "1m", "set matrix for 2nd plane", OFFSET(matrix_str[1]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS },63 { "1m", "set matrix for 2nd plane", OFFSET(matrix_str[1]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS },
64 { "2m", "set matrix for 3rd plane", OFFSET(matrix_str[2]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS },64 { "2m", "set matrix for 3rd plane", OFFSET(matrix_str[2]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS },
65 { "3m", "set matrix for 4th plane", OFFSET(matrix_str[3]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS },65 { "3m", "set matrix for 4th plane", OFFSET(matrix_str[3]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS },
66 { "0rdiv", "set rdiv for 1st plane", OFFSET(rdiv[0]), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, INT_MAX, FLAGS},66 { "0rdiv", "set rdiv for 1st plane", OFFSET(rdiv[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS},
67 { "1rdiv", "set rdiv for 2nd plane", OFFSET(rdiv[1]), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, INT_MAX, FLAGS},67 { "1rdiv", "set rdiv for 2nd plane", OFFSET(rdiv[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS},
68 { "2rdiv", "set rdiv for 3rd plane", OFFSET(rdiv[2]), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, INT_MAX, FLAGS},68 { "2rdiv", "set rdiv for 3rd plane", OFFSET(rdiv[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS},
69 { "3rdiv", "set rdiv for 4th plane", OFFSET(rdiv[3]), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, INT_MAX, FLAGS},69 { "3rdiv", "set rdiv for 4th plane", OFFSET(rdiv[3]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS},
70 { "0bias", "set bias for 1st plane", OFFSET(bias[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS},70 { "0bias", "set bias for 1st plane", OFFSET(bias[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS},
71 { "1bias", "set bias for 2nd plane", OFFSET(bias[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS},71 { "1bias", "set bias for 2nd plane", OFFSET(bias[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS},
72 { "2bias", "set bias for 3rd plane", OFFSET(bias[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS},72 { "2bias", "set bias for 3rd plane", OFFSET(bias[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS},
@@ -965,6 +965,7 @@ static av_cold int init(AVFilterContext *ctx) · 892 unmodified lines
965 for (i = 0; i < 4; i++) {965 for (i = 0; i < 4; i++) {
966 int *matrix = (int *)s->matrix[i];966 int *matrix = (int *)s->matrix[i];
967 char *p, *arg, *saveptr = NULL;967 char *p, *arg, *saveptr = NULL;
968 float sum = 0;
968 969
969 p = s->matrix_str[i];970 p = s->matrix_str[i];
970 while (s->matrix_length[i] < 49) {971 while (s->matrix_length[i] < 49) {
@@ -973,6 +974,7 @@ static av_cold int init(AVFilterContext *ctx) · 2 unmodified lines
973 974
974 p = NULL;975 p = NULL;
975 sscanf(arg, "%d", &matrix[s->matrix_length[i]]);976 sscanf(arg, "%d", &matrix[s->matrix_length[i]]);
977 sum += matrix[s->matrix_length[i]];
976 s->matrix_length[i]++;978 s->matrix_length[i]++;
977 }979 }
978 980
@@ -998,6 +1000,11 @@ static av_cold int init(AVFilterContext *ctx) · 19 unmodified lines
998 return AVERROR(EINVAL);1000 return AVERROR(EINVAL);
999 }1001 }
1000 1002
1003 if (sum == 0)
1004 sum = 1;
1005 if (s->rdiv[i] == 0)
1006 s->rdiv[i] = 1. / sum;
1007
1001 if (s->copy[i] && (s->rdiv[i] != 1. || s->bias[i] != 0.))1008 if (s->copy[i] && (s->rdiv[i] != 1. || s->bias[i] != 0.))
1002 s->copy[i] = 0;1009 s->copy[i] = 0;
1003 }1010 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t