Mercurial > hg > wm
diff Meerwald/dwt.c @ 3:acb6967ee76d
update to 0.5
author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
---|---|
date | Tue, 14 Aug 2007 21:11:21 +0200 |
parents | be303a3f5ea8 |
children | f83ef905a63d |
line wrap: on
line diff
--- a/Meerwald/dwt.c Tue Aug 14 19:59:48 2007 +0200 +++ b/Meerwald/dwt.c Tue Aug 14 21:11:21 2007 +0200 @@ -18,8 +18,10 @@ strcpy(filter_file, filter_name); else strcpy(filter_file, "filter.dat"); + /* memory leak here - there is no function unload_filters() */ dwt_allfilters = load_filters(filter_file); + if (!dwt_allfilters) { fprintf(stderr, "init_dwt(): unable to open filter definition file %s\n", filter_file); return; @@ -292,51 +294,66 @@ return filterlength; } -void dwt_param_filter(double alpha[], int n) { + + +void dwt_param_filter(double alpha[], int param_len[]) { FilterGH filter; int i; - - filter = malloc(sizeof(struct FilterGHStruct)); -#ifdef DEBUG - if (!filter) { - fprintf(stderr, "dwt_param_filter(): malloc failed()\n"); - return; - } -#endif - - filter->type = FTOrtho; - filter->name = "param"; - - filter->g = new_filter(2 * (n + 1)); - filter->g->type = FTSymm; - filter->g->hipass = 1; - filter->g->len = gen_param_filter(filter->g->data, n, alpha, FILTERG); - filter->g->start = -filter->g->len / 2; - filter->g->end = filter->g->len / 2 - 1; - - filter->h = new_filter(2 * (n + 1)); - filter->h->type = FTSymm; - filter->h->hipass = 0; - filter->h->len = gen_param_filter(filter->h->data, n, alpha, FILTERH); - filter->h->start = -filter->h->len / 2; - filter->h->end = filter->h->len / 2 - 1; + int param_len_sum = 0; #ifdef DEBUG if (dwt_levels <= 0) { - fprintf(stderr, "dwt_pollen_filter(): level invalid - set to zero\n"); + fprintf(stderr, "dwt_param_filter(): level invalid - set to zero\n"); return; } #endif #ifdef DEBUG if (!dwt_filters) { - fprintf(stderr, "dwt_pollen_filter(): wm_dwt not initialized, call init_dwt() first\n"); + fprintf(stderr, "dwt_param_filter(): wm_dwt not initialized, call init_dwt() first\n"); return; } #endif - for (i = 0; i < dwt_levels + 1; i++) + + for (i = 0; i < dwt_levels + 1; i++) { + + filter = malloc(sizeof(struct FilterGHStruct)); +#ifdef DEBUG + if (!filter) { + fprintf(stderr, "dwt_param_filter(): malloc failed()\n"); + return; + } +#endif + + filter->type = FTOrtho; + filter->name = "param"; + + filter->g = new_filter(2 * (param_len[i] + 1)); + filter->g->type = FTSymm; + filter->g->hipass = 1; + filter->g->len = gen_param_filter(filter->g->data, + param_len[i], &alpha[param_len_sum], + FILTERG); + filter->g->start = -filter->g->len / 2; + filter->g->end = filter->g->len / 2 - 1; + + filter->h = new_filter(2 * (param_len[i] + 1)); + filter->h->type = FTSymm; + filter->h->hipass = 0; + filter->h->len = gen_param_filter(filter->h->data, + param_len[i], &alpha[param_len_sum], + FILTERH); + filter->h->start = -filter->h->len / 2; + filter->h->end = filter->h->len / 2 - 1; + + filter->gi = 0; + filter->hi = 0; + dwt_filters[i] = filter; + + param_len_sum += param_len[i]; + } } void done_dwt() {