1 /*
2 * Discrete wavelet transform
3 * Copyright (c) 2007 Kamil Nowosad
4 * Copyright (c) 2013 Nicolas Bertrand <nicoinattendu@gmail.com>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #include <inttypes.h>
24 #include <stdio.h>
25
27
29
31
33
38
41 fprintf(stderr, "ff_jpeg2000_dwt_init failed\n");
42 return 1;
43 }
46 fprintf(stderr, "ff_dwt_encode failed\n");
47 return 1;
48 }
50 // pre-scaling to simulate dequantization which places the binary point at 1 bit above from LSB
51 for (j = 0; j<
s->linelen[decomp_levels-1][0] *
s->linelen[decomp_levels-1][1]; j++)
53 }
56 fprintf(stderr, "ff_dwt_encode failed\n");
57 return 1;
58 }
61 fprintf(stderr, "mismatch at %d (%d != %d) decomp:%d border %d %d %d %d\n",
62 j,
array[j],
ref[j],decomp_levels, border[0][0], border[0][1], border[1][0], border[1][1]);
63 return 2;
64 }
67 }
69
70 printf(
"%s, decomp:%2d border %3d %3d %3d %3d milli-err2:%9"PRId64
"\n",
72 decomp_levels, border[0][0], border[0][1], border[1][0], border[1][1],
73 1000*err2 / ((border[0][1] - border[0][0])*(border[1][1] - border[1][0])));
74
75 return 0;
76 }
77
78 static int test_dwtf(
float *
array,
float *
ref,
int border[2][2],
int decomp_levels,
float max_diff) {
81 double err2 = 0;
82
85 fprintf(stderr, "ff_jpeg2000_dwt_init failed\n");
86 return 1;
87 }
90 fprintf(stderr, "ff_dwt_encode failed\n");
91 return 1;
92 }
95 fprintf(stderr, "ff_dwt_encode failed\n");
96 return 1;
97 }
100 fprintf(stderr, "mismatch at %d (%f != %f) decomp:%d border %d %d %d %d\n",
101 j,
array[j],
ref[j],decomp_levels, border[0][0], border[0][1], border[1][0], border[1][1]);
102 return 2;
103 }
106 }
108
109 printf(
"9/7f, decomp:%2d border %3d %3d %3d %3d err2:%20.3f\n",
110 decomp_levels, border[0][0], border[0][1], border[1][0], border[1][1],
111 err2 / ((border[0][1] - border[0][0])*(border[1][1] - border[1][0])));
112
113 return 0;
114 }
115
120
124 int border[2][2];
125 int ret, decomp_levels;
126
128
131
132 for (
i = 0;
i < 100;
i++) {
133 for (j=0; j<4; j++)
135 if (border[0][0] >= border[0][1] || border[1][0] >= border[1][1])
136 continue;
138
148 }
149
150 return 0;
151 }