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

Showing the changes to libavfilter/vf_convolution.c (1 of 2 files). Show all

Unified · Split

libavfilter/vf_convolution.c+11−4
@@ -63,10 +63,10 @@ static const AVOption convolution_options[] = { · 62 unmodified lines
6363 { "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 },
6464 { "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 },
6565 { "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},
67− { "1rdiv", "set rdiv for 2nd plane", OFFSET(rdiv[1]), 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=1.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},
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=0.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=0.0}, 0.0, INT_MAX, FLAGS},
7070 { "0bias", "set bias for 1st plane", OFFSET(bias[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS},
7171 { "1bias", "set bias for 2nd plane", OFFSET(bias[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS},
7272 { "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
965965 for (i = 0; i < 4; i++) {
966966 int *matrix = (int *)s->matrix[i];
967967 char *p, *arg, *saveptr = NULL;
968+ float sum = 0;
968969
969970 p = s->matrix_str[i];
970971 while (s->matrix_length[i] < 49) {
@@ -973,6 +974,7 @@ static av_cold int init(AVFilterContext *ctx) · 2 unmodified lines
973974
974975 p = NULL;
975976 sscanf(arg, "%d", &matrix[s->matrix_length[i]]);
977+ sum += matrix[s->matrix_length[i]];
976978 s->matrix_length[i]++;
977979 }
978980
@@ -998,6 +1000,11 @@ static av_cold int init(AVFilterContext *ctx) · 19 unmodified lines
9981000 return AVERROR(EINVAL);
9991001 }
10001002
1003+ if (sum == 0)
1004+ sum = 1;
1005+ if (s->rdiv[i] == 0)
1006+ s->rdiv[i] = 1. / sum;
1007+
10011008 if (s->copy[i] && (s->rdiv[i] != 1. || s->bias[i] != 0.))
10021009 s->copy[i] = 0;
10031010 }

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