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