Lift the MAX_BLUR_PASS limit

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui
2019-06-06 07:37:48 +01:00
parent cbb859ba3c
commit abb089e605
14 changed files with 120 additions and 108 deletions

View File

@ -193,13 +193,10 @@ err1:
* Parse a list of convolution kernels.
*
* @param[in] src string to parse
* @param[out] dest pointer to an array of kernels, must points to an array
* of `max` elements.
* @param[in] max maximum number of kernels supported
* @param[out] hasneg whether any of the kernels have negative values
* @return if the `src` string is a valid kernel list string
* @return the kernels
*/
bool parse_blur_kern_lst(const char *src, conv **dest, int max, bool *hasneg) {
struct conv **parse_blur_kern_lst(const char *src, bool *hasneg) {
// TODO just return a predefined kernels, not parse predefined strings...
static const struct {
const char *name;
@ -258,26 +255,33 @@ bool parse_blur_kern_lst(const char *src, conv **dest, int max, bool *hasneg) {
for (unsigned int i = 0;
i < sizeof(CONV_KERN_PREDEF) / sizeof(CONV_KERN_PREDEF[0]); ++i) {
if (!strcmp(CONV_KERN_PREDEF[i].name, src))
return parse_blur_kern_lst(CONV_KERN_PREDEF[i].kern_str, dest,
max, hasneg);
return parse_blur_kern_lst(CONV_KERN_PREDEF[i].kern_str, hasneg);
}
int nkernels = 1;
for (int i = 0; src[i]; i++) {
if (src[i] == ';') {
nkernels++;
}
}
struct conv **ret = ccalloc(nkernels+1, struct conv *); // +1 for NULL terminator
int i = 0;
const char *pc = src;
// Free old kernels
for (i = 0; i < max; ++i) {
free(dest[i]);
dest[i] = NULL;
}
// Continue parsing until the end of source string
i = 0;
while (pc && *pc && i < max - 1) {
while (pc && *pc) {
bool tmp_hasneg;
dest[i] = parse_blur_kern(pc, &pc, &tmp_hasneg);
if (!dest[i]) {
return false;
assert(i < nkernels);
ret[i] = parse_blur_kern(pc, &pc, &tmp_hasneg);
if (!ret[i]) {
for (int j = 0; j < i; j++) {
free(ret[j]);
}
free(ret);
return NULL;
}
i++;
*hasneg |= tmp_hasneg;
@ -290,12 +294,7 @@ bool parse_blur_kern_lst(const char *src, conv **dest, int max, bool *hasneg) {
"removed in future releases");
}
if (*pc) {
log_error("Too many blur kernels!");
return false;
}
return true;
return ret;
}
/**
@ -541,7 +540,7 @@ char *parse_config(options_t *opt, const char *config_file, bool *shadow_enable,
.blur_background_frame = false,
.blur_background_fixed = false,
.blur_background_blacklist = NULL,
.blur_kerns = {NULL},
.blur_kerns = NULL,
.inactive_dim = 0.0,
.inactive_dim_fixed = false,
.invert_color_list = NULL,