blob: 69a882c898d904615da708465107e47e6fad6e6f [file] [log] [blame]
John Koleszar0ea50ce2010-05-18 11:58:33 -04001/*
John Koleszarc2140b82010-09-09 08:16:39 -04002 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
John Koleszar0ea50ce2010-05-18 11:58:33 -04003 *
John Koleszar94c52e42010-06-18 12:39:21 -04004 * Use of this source code is governed by a BSD-style license
John Koleszar09202d82010-06-04 16:19:40 -04005 * 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
John Koleszar94c52e42010-06-18 12:39:21 -04007 * in the file PATENTS. All contributing project authors may
John Koleszar09202d82010-06-04 16:19:40 -04008 * be found in the AUTHORS file in the root of the source tree.
John Koleszar0ea50ce2010-05-18 11:58:33 -04009 */
10
11
12#include <math.h>
Yaowu Xu5b42ae02010-12-01 15:50:14 -080013#include "vpx_ports/config.h"
John Koleszar0ea50ce2010-05-18 11:58:33 -040014void vp8_short_fdct4x4_c(short *input, short *output, int pitch)
15{
John Koleszar0ea50ce2010-05-18 11:58:33 -040016 int i;
17 int a1, b1, c1, d1;
John Koleszar0ea50ce2010-05-18 11:58:33 -040018 short *ip = input;
John Koleszar0ea50ce2010-05-18 11:58:33 -040019 short *op = output;
John Koleszar0ea50ce2010-05-18 11:58:33 -040020
21 for (i = 0; i < 4; i++)
22 {
Yaowu Xu5b42ae02010-12-01 15:50:14 -080023#if CONFIG_EXTEND_QRANGE
24 a1 = ((ip[0] + ip[3])<<5);
25 b1 = ((ip[1] + ip[2])<<5);
26 c1 = ((ip[1] - ip[2])<<5);
27 d1 = ((ip[0] - ip[3])<<5);
28#else
Yaowu Xud0dd01b2010-06-16 12:52:18 -070029 a1 = ((ip[0] + ip[3])<<3);
30 b1 = ((ip[1] + ip[2])<<3);
31 c1 = ((ip[1] - ip[2])<<3);
32 d1 = ((ip[0] - ip[3])<<3);
Yaowu Xu5b42ae02010-12-01 15:50:14 -080033#endif
Yaowu Xud0dd01b2010-06-16 12:52:18 -070034 op[0] = a1 + b1;
35 op[2] = a1 - b1;
John Koleszar0ea50ce2010-05-18 11:58:33 -040036
Yaowu Xud0dd01b2010-06-16 12:52:18 -070037 op[1] = (c1 * 2217 + d1 * 5352 + 14500)>>12;
38 op[3] = (d1 * 2217 - c1 * 5352 + 7500)>>12;
John Koleszar0ea50ce2010-05-18 11:58:33 -040039
40 ip += pitch / 2;
41 op += 4;
John Koleszar0ea50ce2010-05-18 11:58:33 -040042
Yaowu Xud0dd01b2010-06-16 12:52:18 -070043 }
John Koleszar0ea50ce2010-05-18 11:58:33 -040044 ip = output;
45 op = output;
John Koleszar0ea50ce2010-05-18 11:58:33 -040046 for (i = 0; i < 4; i++)
47 {
John Koleszar0ea50ce2010-05-18 11:58:33 -040048 a1 = ip[0] + ip[12];
49 b1 = ip[4] + ip[8];
50 c1 = ip[4] - ip[8];
51 d1 = ip[0] - ip[12];
52
Yaowu Xud0dd01b2010-06-16 12:52:18 -070053 op[0] = ( a1 + b1 + 7)>>4;
54 op[8] = ( a1 - b1 + 7)>>4;
John Koleszar0ea50ce2010-05-18 11:58:33 -040055
Yaowu Xud0dd01b2010-06-16 12:52:18 -070056 op[4] =((c1 * 2217 + d1 * 5352 + 12000)>>16) + (d1!=0);
57 op[12] = (d1 * 2217 - c1 * 5352 + 51000)>>16;
John Koleszar0ea50ce2010-05-18 11:58:33 -040058
59 ip++;
60 op++;
61 }
62}
63
Yaowu Xud0dd01b2010-06-16 12:52:18 -070064void vp8_short_fdct8x4_c(short *input, short *output, int pitch)
John Koleszar0ea50ce2010-05-18 11:58:33 -040065{
Yaowu Xud0dd01b2010-06-16 12:52:18 -070066 vp8_short_fdct4x4_c(input, output, pitch);
67 vp8_short_fdct4x4_c(input + 4, output + 16, pitch);
John Koleszar0ea50ce2010-05-18 11:58:33 -040068}
69
70void vp8_short_walsh4x4_c(short *input, short *output, int pitch)
71{
72 int i;
73 int a1, b1, c1, d1;
74 int a2, b2, c2, d2;
75 short *ip = input;
76 short *op = output;
77
Yaowu Xub62d0932010-06-28 22:03:43 -070078
John Koleszar0ea50ce2010-05-18 11:58:33 -040079 for (i = 0; i < 4; i++)
80 {
Yaowu Xu5b42ae02010-12-01 15:50:14 -080081#if !CONFIG_EXTEND_QRANGE
Yaowu Xub62d0932010-06-28 22:03:43 -070082 a1 = ((ip[0] + ip[2])<<2);
83 d1 = ((ip[1] + ip[3])<<2);
84 c1 = ((ip[1] - ip[3])<<2);
85 b1 = ((ip[0] - ip[2])<<2);
John Koleszar0ea50ce2010-05-18 11:58:33 -040086
Yaowu Xub62d0932010-06-28 22:03:43 -070087 op[0] = a1 + d1 + (a1!=0);
Yaowu Xu5b42ae02010-12-01 15:50:14 -080088#else
89 a1 = ((ip[0] + ip[2]));
90 d1 = ((ip[1] + ip[3]));
91 c1 = ((ip[1] - ip[3]));
92 b1 = ((ip[0] - ip[2]));
93
94
95 op[0] = a1 + d1;
96#endif
Yaowu Xub62d0932010-06-28 22:03:43 -070097 op[1] = b1 + c1;
98 op[2] = b1 - c1;
99 op[3] = a1 - d1;
John Koleszar0ea50ce2010-05-18 11:58:33 -0400100 ip += pitch / 2;
101 op += 4;
102 }
103
104 ip = output;
105 op = output;
106
107 for (i = 0; i < 4; i++)
108 {
Yaowu Xub62d0932010-06-28 22:03:43 -0700109 a1 = ip[0] + ip[8];
110 d1 = ip[4] + ip[12];
111 c1 = ip[4] - ip[12];
112 b1 = ip[0] - ip[8];
John Koleszar0ea50ce2010-05-18 11:58:33 -0400113
Yaowu Xub62d0932010-06-28 22:03:43 -0700114 a2 = a1 + d1;
115 b2 = b1 + c1;
116 c2 = b1 - c1;
117 d2 = a1 - d1;
John Koleszar0ea50ce2010-05-18 11:58:33 -0400118
Yaowu Xub62d0932010-06-28 22:03:43 -0700119 a2 += a2<0;
120 b2 += b2<0;
121 c2 += c2<0;
122 d2 += d2<0;
John Koleszar0ea50ce2010-05-18 11:58:33 -0400123
Yaowu Xu5b42ae02010-12-01 15:50:14 -0800124#if !CONFIG_EXTEND_QRANGE
Yaowu Xub62d0932010-06-28 22:03:43 -0700125 op[0] = (a2+3) >> 3;
126 op[4] = (b2+3) >> 3;
127 op[8] = (c2+3) >> 3;
128 op[12]= (d2+3) >> 3;
Yaowu Xu5b42ae02010-12-01 15:50:14 -0800129#else
130 op[0] = (a2+1) >> 2;
131 op[4] = (b2+1) >> 2;
132 op[8] = (c2+1) >> 2;
133 op[12]= (d2+1) >> 2;
134#endif
John Koleszar0ea50ce2010-05-18 11:58:33 -0400135 ip++;
136 op++;
137 }
138}