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