2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
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.
11 #include "./vp8_rtcd.h"
13 /****************************************************************************
16 * This implementation makes use of 16 bit fixed point verio of two multiply
18 * 1. sqrt(2) * cos (pi/8)
19 * 2. sqrt(2) * sin (pi/8)
20 * Becuase the first constant is bigger than 1, to maintain the same 16 bit
21 * fixed point precision as the second one, we use a trick of
24 * x * sqrt(2) * cos (pi/8) = x + x * (sqrt(2) *cos(pi/8)-1).
25 **************************************************************************/
26 static const int cospi8sqrt2minus1
= 20091;
27 static const int sinpi8sqrt2
= 35468;
29 void vp8_short_idct4x4llm_c(short *input
, unsigned char *pred_ptr
,
30 int pred_stride
, unsigned char *dst_ptr
,
42 for (i
= 0; i
< 4; i
++)
47 temp1
= (ip
[4] * sinpi8sqrt2
) >> 16;
48 temp2
= ip
[12] + ((ip
[12] * cospi8sqrt2minus1
) >> 16);
51 temp1
= ip
[4] + ((ip
[4] * cospi8sqrt2minus1
) >> 16);
52 temp2
= (ip
[12] * sinpi8sqrt2
) >> 16;
55 op
[shortpitch
*0] = a1
+ d1
;
56 op
[shortpitch
*3] = a1
- d1
;
58 op
[shortpitch
*1] = b1
+ c1
;
59 op
[shortpitch
*2] = b1
- c1
;
68 for (i
= 0; i
< 4; i
++)
73 temp1
= (ip
[1] * sinpi8sqrt2
) >> 16;
74 temp2
= ip
[3] + ((ip
[3] * cospi8sqrt2minus1
) >> 16);
77 temp1
= ip
[1] + ((ip
[1] * cospi8sqrt2minus1
) >> 16);
78 temp2
= (ip
[3] * sinpi8sqrt2
) >> 16;
82 op
[0] = (a1
+ d1
+ 4) >> 3;
83 op
[3] = (a1
- d1
+ 4) >> 3;
85 op
[1] = (b1
+ c1
+ 4) >> 3;
86 op
[2] = (b1
- c1
+ 4) >> 3;
93 for (r
= 0; r
< 4; r
++)
95 for (c
= 0; c
< 4; c
++)
97 int a
= ip
[c
] + pred_ptr
[c
] ;
105 dst_ptr
[c
] = (unsigned char) a
;
108 dst_ptr
+= dst_stride
;
109 pred_ptr
+= pred_stride
;
113 void vp8_dc_only_idct_add_c(short input_dc
, unsigned char *pred_ptr
,
114 int pred_stride
, unsigned char *dst_ptr
,
117 int a1
= ((input_dc
+ 4) >> 3);
120 for (r
= 0; r
< 4; r
++)
122 for (c
= 0; c
< 4; c
++)
124 int a
= a1
+ pred_ptr
[c
] ;
132 dst_ptr
[c
] = (unsigned char) a
;
135 dst_ptr
+= dst_stride
;
136 pred_ptr
+= pred_stride
;
141 void vp8_short_inv_walsh4x4_c(short *input
, short *mb_dqcoeff
)
150 for (i
= 0; i
< 4; i
++)
168 for (i
= 0; i
< 4; i
++)
180 op
[0] = (a2
+ 3) >> 3;
181 op
[1] = (b2
+ 3) >> 3;
182 op
[2] = (c2
+ 3) >> 3;
183 op
[3] = (d2
+ 3) >> 3;
189 for(i
= 0; i
< 16; i
++)
191 mb_dqcoeff
[i
* 16] = output
[i
];
195 void vp8_short_inv_walsh4x4_1_c(short *input
, short *mb_dqcoeff
)
200 a1
= ((input
[0] + 3) >> 3);
201 for(i
= 0; i
< 16; i
++)
203 mb_dqcoeff
[i
* 16] = a1
;