1 : /*
2 : * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 : *
4 : * Use of this source code is governed by a BSD-style license
5 : * that can be found in the LICENSE file in the root of the source
6 : * tree. An additional intellectual property rights grant can be found
7 : * in the file PATENTS. All contributing project authors may
8 : * be found in the AUTHORS file in the root of the source tree.
9 : */
10 :
11 :
12 : /****************************************************************************
13 : * Notes:
14 : *
15 : * This implementation makes use of 16 bit fixed point verio of two multiply
16 : * constants:
17 : * 1. sqrt(2) * cos (pi/8)
18 : * 2. sqrt(2) * sin (pi/8)
19 : * Becuase the first constant is bigger than 1, to maintain the same 16 bit
20 : * fixed point precision as the second one, we use a trick of
21 : * x * a = x + x*(a-1)
22 : * so
23 : * x * sqrt(2) * cos (pi/8) = x + x * (sqrt(2) *cos(pi/8)-1).
24 : **************************************************************************/
25 : static const int cospi8sqrt2minus1 = 20091;
26 : static const int sinpi8sqrt2 = 35468;
27 : static const int rounding = 0;
28 0 : void vp8_short_idct4x4llm_c(short *input, short *output, int pitch)
29 : {
30 : int i;
31 : int a1, b1, c1, d1;
32 :
33 0 : short *ip = input;
34 0 : short *op = output;
35 : int temp1, temp2;
36 0 : int shortpitch = pitch >> 1;
37 :
38 0 : for (i = 0; i < 4; i++)
39 : {
40 0 : a1 = ip[0] + ip[8];
41 0 : b1 = ip[0] - ip[8];
42 :
43 0 : temp1 = (ip[4] * sinpi8sqrt2 + rounding) >> 16;
44 0 : temp2 = ip[12] + ((ip[12] * cospi8sqrt2minus1 + rounding) >> 16);
45 0 : c1 = temp1 - temp2;
46 :
47 0 : temp1 = ip[4] + ((ip[4] * cospi8sqrt2minus1 + rounding) >> 16);
48 0 : temp2 = (ip[12] * sinpi8sqrt2 + rounding) >> 16;
49 0 : d1 = temp1 + temp2;
50 :
51 0 : op[shortpitch*0] = a1 + d1;
52 0 : op[shortpitch*3] = a1 - d1;
53 :
54 0 : op[shortpitch*1] = b1 + c1;
55 0 : op[shortpitch*2] = b1 - c1;
56 :
57 0 : ip++;
58 0 : op++;
59 : }
60 :
61 0 : ip = output;
62 0 : op = output;
63 :
64 0 : for (i = 0; i < 4; i++)
65 : {
66 0 : a1 = ip[0] + ip[2];
67 0 : b1 = ip[0] - ip[2];
68 :
69 0 : temp1 = (ip[1] * sinpi8sqrt2 + rounding) >> 16;
70 0 : temp2 = ip[3] + ((ip[3] * cospi8sqrt2minus1 + rounding) >> 16);
71 0 : c1 = temp1 - temp2;
72 :
73 0 : temp1 = ip[1] + ((ip[1] * cospi8sqrt2minus1 + rounding) >> 16);
74 0 : temp2 = (ip[3] * sinpi8sqrt2 + rounding) >> 16;
75 0 : d1 = temp1 + temp2;
76 :
77 :
78 0 : op[0] = (a1 + d1 + 4) >> 3;
79 0 : op[3] = (a1 - d1 + 4) >> 3;
80 :
81 0 : op[1] = (b1 + c1 + 4) >> 3;
82 0 : op[2] = (b1 - c1 + 4) >> 3;
83 :
84 0 : ip += shortpitch;
85 0 : op += shortpitch;
86 : }
87 0 : }
88 :
89 0 : void vp8_short_idct4x4llm_1_c(short *input, short *output, int pitch)
90 : {
91 : int i;
92 : int a1;
93 0 : short *op = output;
94 0 : int shortpitch = pitch >> 1;
95 0 : a1 = ((input[0] + 4) >> 3);
96 :
97 0 : for (i = 0; i < 4; i++)
98 : {
99 0 : op[0] = a1;
100 0 : op[1] = a1;
101 0 : op[2] = a1;
102 0 : op[3] = a1;
103 0 : op += shortpitch;
104 : }
105 0 : }
106 :
107 0 : void vp8_dc_only_idct_add_c(short input_dc, unsigned char *pred_ptr, unsigned char *dst_ptr, int pitch, int stride)
108 : {
109 0 : int a1 = ((input_dc + 4) >> 3);
110 : int r, c;
111 :
112 0 : for (r = 0; r < 4; r++)
113 : {
114 0 : for (c = 0; c < 4; c++)
115 : {
116 0 : int a = a1 + pred_ptr[c] ;
117 :
118 0 : if (a < 0)
119 0 : a = 0;
120 :
121 0 : if (a > 255)
122 0 : a = 255;
123 :
124 0 : dst_ptr[c] = (unsigned char) a ;
125 : }
126 :
127 0 : dst_ptr += stride;
128 0 : pred_ptr += pitch;
129 : }
130 :
131 0 : }
132 :
133 0 : void vp8_short_inv_walsh4x4_c(short *input, short *output)
134 : {
135 : int i;
136 : int a1, b1, c1, d1;
137 : int a2, b2, c2, d2;
138 0 : short *ip = input;
139 0 : short *op = output;
140 :
141 0 : for (i = 0; i < 4; i++)
142 : {
143 0 : a1 = ip[0] + ip[12];
144 0 : b1 = ip[4] + ip[8];
145 0 : c1 = ip[4] - ip[8];
146 0 : d1 = ip[0] - ip[12];
147 :
148 0 : op[0] = a1 + b1;
149 0 : op[4] = c1 + d1;
150 0 : op[8] = a1 - b1;
151 0 : op[12] = d1 - c1;
152 0 : ip++;
153 0 : op++;
154 : }
155 :
156 0 : ip = output;
157 0 : op = output;
158 :
159 0 : for (i = 0; i < 4; i++)
160 : {
161 0 : a1 = ip[0] + ip[3];
162 0 : b1 = ip[1] + ip[2];
163 0 : c1 = ip[1] - ip[2];
164 0 : d1 = ip[0] - ip[3];
165 :
166 0 : a2 = a1 + b1;
167 0 : b2 = c1 + d1;
168 0 : c2 = a1 - b1;
169 0 : d2 = d1 - c1;
170 :
171 0 : op[0] = (a2 + 3) >> 3;
172 0 : op[1] = (b2 + 3) >> 3;
173 0 : op[2] = (c2 + 3) >> 3;
174 0 : op[3] = (d2 + 3) >> 3;
175 :
176 0 : ip += 4;
177 0 : op += 4;
178 : }
179 0 : }
180 :
181 0 : void vp8_short_inv_walsh4x4_1_c(short *input, short *output)
182 : {
183 : int i;
184 : int a1;
185 0 : short *op = output;
186 :
187 0 : a1 = ((input[0] + 3) >> 3);
188 :
189 0 : for (i = 0; i < 4; i++)
190 : {
191 0 : op[0] = a1;
192 0 : op[1] = a1;
193 0 : op[2] = a1;
194 0 : op[3] = a1;
195 0 : op += 4;
196 : }
197 0 : }
|