1 /* private functions ------------------------------------------------------- */
2 
3 /* scatter 4*4*4*4 block to strided array */
4 static void
5 _t2(scatter, Scalar, 4)(const Scalar* q, Scalar* p, int sx, int sy, int sz, int sw)
6 {
7   uint x, y, z, w;
8   for (w = 0; w < 4; w++, p += sw - 4 * sz)
9     for (z = 0; z < 4; z++, p += sz - 4 * sy)
10       for (y = 0; y < 4; y++, p += sy - 4 * sx)
11         for (x = 0; x < 4; x++, p += sx)
12           *p = *q++;
13 }
14 
15 /* scatter nx*ny*nz*nw block to strided array */
16 static void
17 _t2(scatter_partial, Scalar, 4)(const Scalar* q, Scalar* p, uint nx, uint ny, uint nz, uint nw, int sx, int sy, int sz, int sw)
18 {
19   uint x, y, z, w;
20   for (w = 0; w < nw; w++, p += sw - (ptrdiff_t)nz * sz, q += 16 * (4 - nz))
21     for (z = 0; z < nz; z++, p += sz - (ptrdiff_t)ny * sy, q += 4 * (4 - ny))
22       for (y = 0; y < ny; y++, p += sy - (ptrdiff_t)nx * sx, q += 1 * (4 - nx))
23         for (x = 0; x < nx; x++, p += sx, q++)
24           *p = *q;
25 }
26 
27 /* inverse decorrelating 4D transform */
28 static void
29 _t2(inv_xform, Int, 4)(Int* p)
30 {
31   uint x, y, z, w;
32   /* transform along w */
33   for (z = 0; z < 4; z++)
34     for (y = 0; y < 4; y++)
35       for (x = 0; x < 4; x++)
36         _t1(inv_lift, Int)(p + 1 * x + 4 * y + 16 * z, 64);
37   /* transform along z */
38   for (y = 0; y < 4; y++)
39     for (x = 0; x < 4; x++)
40       for (w = 0; w < 4; w++)
41         _t1(inv_lift, Int)(p + 64 * w + 1 * x + 4 * y, 16);
42   /* transform along y */
43   for (x = 0; x < 4; x++)
44     for (w = 0; w < 4; w++)
45       for (z = 0; z < 4; z++)
46         _t1(inv_lift, Int)(p + 16 * z + 64 * w + 1 * x, 4);
47   /* transform along x */
48   for (w = 0; w < 4; w++)
49     for (z = 0; z < 4; z++)
50       for (y = 0; y < 4; y++)
51         _t1(inv_lift, Int)(p + 4 * y + 16 * z + 64 * w, 1);
52 }
53 
54 /* public functions -------------------------------------------------------- */
55 
56 /* decode 4*4*4*4 floating-point block and store at p using strides (sx, sy, sz, sw) */
57 uint
58 _t2(zfp_decode_block_strided, Scalar, 4)(zfp_stream* stream, Scalar* p, int sx, int sy, int sz, int sw)
59 {
60   /* decode contiguous block */
61   cache_align_(Scalar fblock[256]);
62   uint bits = _t2(zfp_decode_block, Scalar, 4)(stream, fblock);
63   /* scatter block to strided array */
64   _t2(scatter, Scalar, 4)(fblock, p, sx, sy, sz, sw);
65   return bits;
66 }
67 
68 /* decode nx*ny*nz*nw floating-point block and store at p using strides (sx, sy, sz, sw) */
69 uint
70 _t2(zfp_decode_partial_block_strided, Scalar, 4)(zfp_stream* stream, Scalar* p, uint nx, uint ny, uint nz, uint nw, int sx, int sy, int sz, int sw)
71 {
72   /* decode contiguous block */
73   cache_align_(Scalar fblock[256]);
74   uint bits = _t2(zfp_decode_block, Scalar, 4)(stream, fblock);
75   /* scatter block to strided array */
76   _t2(scatter_partial, Scalar, 4)(fblock, p, nx, ny, nz, nw, sx, sy, sz, sw);
77   return bits;
78 }
79