Line data Source code
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 : #include <math.h>
12 :
13 : #include "./vp8_rtcd.h"
14 :
15 0 : void vp8_short_fdct4x4_c(short *input, short *output, int pitch) {
16 : int i;
17 : int a1, b1, c1, d1;
18 0 : short *ip = input;
19 0 : short *op = output;
20 :
21 0 : for (i = 0; i < 4; ++i) {
22 0 : a1 = ((ip[0] + ip[3]) * 8);
23 0 : b1 = ((ip[1] + ip[2]) * 8);
24 0 : c1 = ((ip[1] - ip[2]) * 8);
25 0 : d1 = ((ip[0] - ip[3]) * 8);
26 :
27 0 : op[0] = a1 + b1;
28 0 : op[2] = a1 - b1;
29 :
30 0 : op[1] = (c1 * 2217 + d1 * 5352 + 14500) >> 12;
31 0 : op[3] = (d1 * 2217 - c1 * 5352 + 7500) >> 12;
32 :
33 0 : ip += pitch / 2;
34 0 : op += 4;
35 : }
36 0 : ip = output;
37 0 : op = output;
38 0 : for (i = 0; i < 4; ++i) {
39 0 : a1 = ip[0] + ip[12];
40 0 : b1 = ip[4] + ip[8];
41 0 : c1 = ip[4] - ip[8];
42 0 : d1 = ip[0] - ip[12];
43 :
44 0 : op[0] = (a1 + b1 + 7) >> 4;
45 0 : op[8] = (a1 - b1 + 7) >> 4;
46 :
47 0 : op[4] = ((c1 * 2217 + d1 * 5352 + 12000) >> 16) + (d1 != 0);
48 0 : op[12] = (d1 * 2217 - c1 * 5352 + 51000) >> 16;
49 :
50 0 : ip++;
51 0 : op++;
52 : }
53 0 : }
54 :
55 0 : void vp8_short_fdct8x4_c(short *input, short *output, int pitch) {
56 0 : vp8_short_fdct4x4_c(input, output, pitch);
57 0 : vp8_short_fdct4x4_c(input + 4, output + 16, pitch);
58 0 : }
59 :
60 0 : void vp8_short_walsh4x4_c(short *input, short *output, int pitch) {
61 : int i;
62 : int a1, b1, c1, d1;
63 : int a2, b2, c2, d2;
64 0 : short *ip = input;
65 0 : short *op = output;
66 :
67 0 : for (i = 0; i < 4; ++i) {
68 0 : a1 = ((ip[0] + ip[2]) * 4);
69 0 : d1 = ((ip[1] + ip[3]) * 4);
70 0 : c1 = ((ip[1] - ip[3]) * 4);
71 0 : b1 = ((ip[0] - ip[2]) * 4);
72 :
73 0 : op[0] = a1 + d1 + (a1 != 0);
74 0 : op[1] = b1 + c1;
75 0 : op[2] = b1 - c1;
76 0 : op[3] = a1 - d1;
77 0 : ip += pitch / 2;
78 0 : op += 4;
79 : }
80 :
81 0 : ip = output;
82 0 : op = output;
83 :
84 0 : for (i = 0; i < 4; ++i) {
85 0 : a1 = ip[0] + ip[8];
86 0 : d1 = ip[4] + ip[12];
87 0 : c1 = ip[4] - ip[12];
88 0 : b1 = ip[0] - ip[8];
89 :
90 0 : a2 = a1 + d1;
91 0 : b2 = b1 + c1;
92 0 : c2 = b1 - c1;
93 0 : d2 = a1 - d1;
94 :
95 0 : a2 += a2 < 0;
96 0 : b2 += b2 < 0;
97 0 : c2 += c2 < 0;
98 0 : d2 += d2 < 0;
99 :
100 0 : op[0] = (a2 + 3) >> 3;
101 0 : op[4] = (b2 + 3) >> 3;
102 0 : op[8] = (c2 + 3) >> 3;
103 0 : op[12] = (d2 + 3) >> 3;
104 :
105 0 : ip++;
106 0 : op++;
107 : }
108 0 : }
|