| 2127 | // |
| 2128 | |
| 2129 | static void wav2Decode( |
| 2130 | unsigned short *in, // io: values are transformed in place |
| 2131 | int nx, // i : x size |
| 2132 | int ox, // i : x offset |
| 2133 | int ny, // i : y size |
| 2134 | int oy, // i : y offset |
| 2135 | unsigned short mx) // i : maximum in[x][y] value |
| 2136 | { |
| 2137 | bool w14 = (mx < (1 << 14)); |
| 2138 | int n = (nx > ny) ? ny : nx; |
| 2139 | int p = 1; |
| 2140 | int p2; |
| 2141 | |
| 2142 | // |
| 2143 | // Search max level |
| 2144 | // |
| 2145 | |
| 2146 | while (p <= n) p <<= 1; |
| 2147 | |
| 2148 | p >>= 1; |
| 2149 | p2 = p; |
| 2150 | p >>= 1; |
| 2151 | |
| 2152 | // |
| 2153 | // Hierarchical loop on smaller dimension n |
| 2154 | // |
| 2155 | |
| 2156 | while (p >= 1) { |
| 2157 | unsigned short *py = in; |
| 2158 | unsigned short *ey = in + oy * (ny - p2); |
| 2159 | int oy1 = oy * p; |
| 2160 | int oy2 = oy * p2; |
| 2161 | int ox1 = ox * p; |
| 2162 | int ox2 = ox * p2; |
| 2163 | unsigned short i00, i01, i10, i11; |
| 2164 | |
| 2165 | // |
| 2166 | // Y loop |
| 2167 | // |
| 2168 | |
| 2169 | for (; py <= ey; py += oy2) { |
| 2170 | unsigned short *px = py; |
| 2171 | unsigned short *ex = py + ox * (nx - p2); |
| 2172 | |
| 2173 | // |
| 2174 | // X loop |
| 2175 | // |
| 2176 | |
| 2177 | for (; px <= ex; px += ox2) { |
| 2178 | unsigned short *p01 = px + ox1; |
| 2179 | unsigned short *p10 = px + oy1; |
| 2180 | unsigned short *p11 = p10 + ox1; |
| 2181 | |
| 2182 | // |
| 2183 | // 2D wavelet decoding |
| 2184 | // |
| 2185 | |
| 2186 | if (w14) { |
no test coverage detected