annotate Meerwald/coeff.c @ 13:cbecc570129d

cleanup warnings
author Peter Meerwald <pmeerw@cosy.sbg.ac.at>
date Mon, 30 Jun 2008 15:43:16 +0200
parents acb6967ee76d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
1 #include "wm.h"
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
2 #include "coeff.h"
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
3
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
4 double **alloc_coeffs(int cols, int rows) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
5 double **p;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
6 int i;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
7
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
8 p = (double **)malloc(rows * sizeof(double *));
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
9 if (!p) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
10 #ifdef DEBUG
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
11 fprintf(stderr, "alloc_coeffs(): malloc() failed\n");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
12 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
13 #else
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
14 return NULL;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
15 #endif
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
16 }
3
acb6967ee76d update to 0.5
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 0
diff changeset
17 p[0] = malloc(rows * cols * sizeof(double));
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
18 if (!p[0]) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
19 #ifdef DEBUG
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
20 fprintf(stderr, "alloc_coeffs(): malloc() failed\n");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
21 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
22 #else
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
23 free(p);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
24 return NULL;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
25 #endif
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
26 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
27 for (i = 1; i < rows; i++) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
28 p[i] = &(p[0][i * cols]);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
29 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
30
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
31 return p;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
32 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
33
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
34 void free_coeffs(double **coeffs) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
35 free(coeffs[0]);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
36 free(coeffs);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
37 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
38
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
39 double **alloc_coeffs_8x8() {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
40 return alloc_coeffs(8, 8);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
41 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
42
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
43 void print_coeffs_8x8(double **coeffs) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
44 int i, j;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
45
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
46 for (i = 0; i < 8; i++) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
47 for (j = 0; j < 8; j++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
48 fprintf(stderr, "%8.2f ", coeffs[i][j]);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
49 fprintf(stderr, "\n");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
50 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
51 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
52
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
53 void print_coeffs(double **coeffs, int c, int r, int w, int h) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
54 int i, j;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
55 double *p;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
56
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
57 #ifdef DEBUG
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
58 if (!coeffs) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
59 fprintf(stderr, "print_coeffs(): NULL pixels\n");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
60 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
61 if (w <= 0 || h <= 0 || c < 0 || r < 0) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
62 fprintf(stderr, "print_coeffs(): block dimension out of range\n");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
63 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
64 #endif
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
65
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
66 for (j = r; j < r + h; j++) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
67 p = &coeffs[j][c];
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
68 for (i = 0; i < w; i++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
69 fprintf(stderr, "%8.2f ", *(p++));
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
70 fprintf(stderr, "\n");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
71 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
72 }

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.