Mercurial > hg > wm
comparison 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 |
comparison
equal
deleted
inserted
replaced
2:b92f06d9a967 | 3:acb6967ee76d |
---|---|
16 if (strcmp(filter_file, filter_name)) { | 16 if (strcmp(filter_file, filter_name)) { |
17 if (filter_name) | 17 if (filter_name) |
18 strcpy(filter_file, filter_name); | 18 strcpy(filter_file, filter_name); |
19 else | 19 else |
20 strcpy(filter_file, "filter.dat"); | 20 strcpy(filter_file, "filter.dat"); |
21 | |
21 /* memory leak here - there is no function unload_filters() */ | 22 /* memory leak here - there is no function unload_filters() */ |
22 dwt_allfilters = load_filters(filter_file); | 23 dwt_allfilters = load_filters(filter_file); |
24 | |
23 if (!dwt_allfilters) { | 25 if (!dwt_allfilters) { |
24 fprintf(stderr, "init_dwt(): unable to open filter definition file %s\n", filter_file); | 26 fprintf(stderr, "init_dwt(): unable to open filter definition file %s\n", filter_file); |
25 return; | 27 return; |
26 } | 28 } |
27 } | 29 } |
290 filter[k++] = 0.0; | 292 filter[k++] = 0.0; |
291 | 293 |
292 return filterlength; | 294 return filterlength; |
293 } | 295 } |
294 | 296 |
295 void dwt_param_filter(double alpha[], int n) { | 297 |
298 | |
299 void dwt_param_filter(double alpha[], int param_len[]) { | |
296 FilterGH filter; | 300 FilterGH filter; |
297 int i; | 301 int i; |
298 | 302 int param_len_sum = 0; |
299 filter = malloc(sizeof(struct FilterGHStruct)); | |
300 #ifdef DEBUG | |
301 if (!filter) { | |
302 fprintf(stderr, "dwt_param_filter(): malloc failed()\n"); | |
303 return; | |
304 } | |
305 #endif | |
306 | |
307 filter->type = FTOrtho; | |
308 filter->name = "param"; | |
309 | |
310 filter->g = new_filter(2 * (n + 1)); | |
311 filter->g->type = FTSymm; | |
312 filter->g->hipass = 1; | |
313 filter->g->len = gen_param_filter(filter->g->data, n, alpha, FILTERG); | |
314 filter->g->start = -filter->g->len / 2; | |
315 filter->g->end = filter->g->len / 2 - 1; | |
316 | |
317 filter->h = new_filter(2 * (n + 1)); | |
318 filter->h->type = FTSymm; | |
319 filter->h->hipass = 0; | |
320 filter->h->len = gen_param_filter(filter->h->data, n, alpha, FILTERH); | |
321 filter->h->start = -filter->h->len / 2; | |
322 filter->h->end = filter->h->len / 2 - 1; | |
323 | 303 |
324 #ifdef DEBUG | 304 #ifdef DEBUG |
325 if (dwt_levels <= 0) { | 305 if (dwt_levels <= 0) { |
326 fprintf(stderr, "dwt_pollen_filter(): level invalid - set to zero\n"); | 306 fprintf(stderr, "dwt_param_filter(): level invalid - set to zero\n"); |
327 return; | 307 return; |
328 } | 308 } |
329 #endif | 309 #endif |
330 | 310 |
331 #ifdef DEBUG | 311 #ifdef DEBUG |
332 if (!dwt_filters) { | 312 if (!dwt_filters) { |
333 fprintf(stderr, "dwt_pollen_filter(): wm_dwt not initialized, call init_dwt() first\n"); | 313 fprintf(stderr, "dwt_param_filter(): wm_dwt not initialized, call init_dwt() first\n"); |
334 return; | 314 return; |
335 } | 315 } |
336 #endif | 316 #endif |
337 | 317 |
338 for (i = 0; i < dwt_levels + 1; i++) | 318 |
319 for (i = 0; i < dwt_levels + 1; i++) { | |
320 | |
321 filter = malloc(sizeof(struct FilterGHStruct)); | |
322 #ifdef DEBUG | |
323 if (!filter) { | |
324 fprintf(stderr, "dwt_param_filter(): malloc failed()\n"); | |
325 return; | |
326 } | |
327 #endif | |
328 | |
329 filter->type = FTOrtho; | |
330 filter->name = "param"; | |
331 | |
332 filter->g = new_filter(2 * (param_len[i] + 1)); | |
333 filter->g->type = FTSymm; | |
334 filter->g->hipass = 1; | |
335 filter->g->len = gen_param_filter(filter->g->data, | |
336 param_len[i], &alpha[param_len_sum], | |
337 FILTERG); | |
338 filter->g->start = -filter->g->len / 2; | |
339 filter->g->end = filter->g->len / 2 - 1; | |
340 | |
341 filter->h = new_filter(2 * (param_len[i] + 1)); | |
342 filter->h->type = FTSymm; | |
343 filter->h->hipass = 0; | |
344 filter->h->len = gen_param_filter(filter->h->data, | |
345 param_len[i], &alpha[param_len_sum], | |
346 FILTERH); | |
347 filter->h->start = -filter->h->len / 2; | |
348 filter->h->end = filter->h->len / 2 - 1; | |
349 | |
350 filter->gi = 0; | |
351 filter->hi = 0; | |
352 | |
339 dwt_filters[i] = filter; | 353 dwt_filters[i] = filter; |
354 | |
355 param_len_sum += param_len[i]; | |
356 } | |
340 } | 357 } |
341 | 358 |
342 void done_dwt() { | 359 void done_dwt() { |
343 } | 360 } |