1 /*
2 * filter.cc --
3 *
4 * FIXME: This file needs a description here.
5 *
6 * Copyright (c) 1996-2002 The Regents of the University of California.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 * A. Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 * B. Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 * C. Neither the names of the copyright holders nor the names of its
18 * contributors may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
22 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 /*
35 * (FIXME from ivs)
36 * This implementation is different from the Stanford one;
37 * I think the rounding is different; so the *.p64 files look funny.
38 * FIXME can make this go faster by accessing memory more efficiently.
39 */
40
41 void P64Decoder::addblkf(short* blk, u_char* in, u_char* out, int stride)
42 {
43 if (((int)in & 3) != 0) {
44 addblkf_slow(blk, in, out, stride);
45 return;
46 }
47 register u_int in0, in3;
48 register u_int in1, in4;
49 register u_int in2, in5;
50
51 in1 = *(u_int*)in;
52 in4 = *(u_int*)(in + 4);
53 in += stride;
54 in2 = *(u_int*)in;
55 in5 = *(u_int*)(in + 4);
56
57 /* first row */
58 *(u_int*)out = in1;
59 *(u_int*)(out + 4) = in4;
60
61 for (int k = 6; --k >= 0; ) {
62 register int t;
63
64 out += stride;
65 in += stride;
66 in0 = in1;
67 in1 = in2;
68 in2 = *(u_int*)in;
69 in3 = in4;
70 in4 = in5;
71 in5 = *(u_int*)(in + 4);
72
73 /* col 1 */
74 u_int w = in1 >> 24;
75 u_int v = w << 24; /* col 0 */
76 w += ((in1 >> 15) & 0x1fe);
77 w += (in1 >> 8) & 0xff;
78 #ifdef notdef
79 w >>= 2;/*FIXME ivs does this*/
80 w <<= 2;
81 #endif
82 w += (in0 >> 16) & 0xff;
83 w += ((in1 >> 15) & 0x1fe);
84 w += (in2 >> 16) & 0xff;
85 v |= (UCLIMIT(blk[1] + (w >> 2)) & 0xff) << 16;
86
87 /* col 2 */
88 w = (in1 >> 16) & 0xff;
89 w += ((in1 >> 7) & 0x1fe);
90 w += in1 & 0xff;
91 #ifdef notdef
92 w >>= 2;/*FIXME ivs does this*/
93 w <<= 2;
94 #endif
95 w += (in0 >> 8) & 0xff;
96 w += ((in1 >> 7) & 0x1fe);
97 w += (in2 >> 8) & 0xff;
98 v |= (UCLIMIT(blk[2] + (w >> 2)) & 0xff) << 8;
99
100 /* col 3 */
101 w = (in1 >> 8) & 0xff;
102 w += (in1 & 0xff) << 1;
103 w += in4 >> 24;
104 #ifdef notdef
105 w >>= 2;/*FIXME ivs does this*/
106 w <<= 2;
107 #endif
108 w += in0 & 0xff;
109 w += (in1 & 0xff) << 1;
110 w += in2 & 0xff;
111 v |= UCLIMIT(blk[3] + (w >> 2)) & 0xff;
112
113 *(u_int*)out = v;
114
115 /* col 4 */
116 w = in1 & 0xff;
117 w += (in4 >> 23) & 0x1fe;
118 w += (in4 >> 16) & 0xff;
119 #ifdef notdef
120 w >>= 2;/*FIXME ivs does this*/
121 w <<= 2;
122 #endif
123 w += in3 >> 24;
124 w += (in4 >> 23) & 0x1fe;
125 w += in5 >> 24;
126 v = (UCLIMIT(blk[4] + w) & 0xff) << 24;
127
128 /* col 5 */
129 w = in4 >> 24;
130 w += (in4 >> 15) & 0x1fe;
131 w += (in4 >> 8) & 0xff;
132 #ifdef notdef
133 w >>= 2;/*FIXME ivs does this*/
134 w <<= 2;
135 #endif
136 w += in3 >> 16;
137 w += (in4 >> 15) & 0x1fe;
138 w += in5 >> 16;
139 v |= (UCLIMIT(blk[5] + w) & 0xff) << 16;
140
141 /* col 6 */
142 w = (in4 >> 16) & 0xff;
143 w += (in4 >> 7) & 0x1fe;
144 w += in4 & 0xff;
145 #ifdef notdef
146 w >>= 2;/*FIXME ivs does this*/
147 w <<= 2;
148 #endif
149 w += in3 >> 8;
150 w += (in4 >> 7) & 0x1fe;
151 w += in5 >> 8;
152 v |= (UCLIMIT(blk[6] + w) & 0xff) << 8;
153
154 /* col 6 */
155 v |= in4 & 0xff;
156
157 *(u_int*)(out + 4) = v;
158 }
159 /* last row */
160 out += stride;
161 *(u_int*)out = *(u_int*)in;
162 *(u_int*)(out + 4) = *(u_int*)(in + 4);
163 }
164
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.