| 1983 | // |
| 1984 | |
| 1985 | static void wav2Decode( |
| 1986 | unsigned short *in, // io: values are transformed in place |
| 1987 | int nx, // i : x size |
| 1988 | int ox, // i : x offset |
| 1989 | int ny, // i : y size |
| 1990 | int oy, // i : y offset |
| 1991 | unsigned short mx) // i : maximum in[x][y] value |
| 1992 | { |
| 1993 | bool w14 = (mx < (1 << 14)); |
| 1994 | int n = (nx > ny) ? ny : nx; |
| 1995 | int p = 1; |
| 1996 | int p2; |
| 1997 | |
| 1998 | // |
| 1999 | // Search max level |
| 2000 | // |
| 2001 | |
| 2002 | while (p <= n) p <<= 1; |
| 2003 | |
| 2004 | p >>= 1; |
| 2005 | p2 = p; |
| 2006 | p >>= 1; |
| 2007 | |
| 2008 | // |
| 2009 | // Hierarchical loop on smaller dimension n |
| 2010 | // |
| 2011 | |
| 2012 | while (p >= 1) { |
| 2013 | unsigned short *py = in; |
| 2014 | unsigned short *ey = in + oy * (ny - p2); |
| 2015 | int oy1 = oy * p; |
| 2016 | int oy2 = oy * p2; |
| 2017 | int ox1 = ox * p; |
| 2018 | int ox2 = ox * p2; |
| 2019 | unsigned short i00, i01, i10, i11; |
| 2020 | |
| 2021 | // |
| 2022 | // Y loop |
| 2023 | // |
| 2024 | |
| 2025 | for (; py <= ey; py += oy2) { |
| 2026 | unsigned short *px = py; |
| 2027 | unsigned short *ex = py + ox * (nx - p2); |
| 2028 | |
| 2029 | // |
| 2030 | // X loop |
| 2031 | // |
| 2032 | |
| 2033 | for (; px <= ex; px += ox2) { |
| 2034 | unsigned short *p01 = px + ox1; |
| 2035 | unsigned short *p10 = px + oy1; |
| 2036 | unsigned short *p11 = p10 + ox1; |
| 2037 | |
| 2038 | // |
| 2039 | // 2D wavelet decoding |
| 2040 | // |
| 2041 | |
| 2042 | if (w14) { |
no test coverage detected