John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1 | /* |
John Koleszar | c2140b8 | 2010-09-09 08:16:39 -0400 | [diff] [blame] | 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 3 | * |
John Koleszar | 94c52e4 | 2010-06-18 12:39:21 -0400 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license |
John Koleszar | 09202d8 | 2010-06-04 16:19:40 -0400 | [diff] [blame] | 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 |
John Koleszar | 94c52e4 | 2010-06-18 12:39:21 -0400 | [diff] [blame] | 7 | * in the file PATENTS. All contributing project authors may |
John Koleszar | 09202d8 | 2010-06-04 16:19:40 -0400 | [diff] [blame] | 8 | * be found in the AUTHORS file in the root of the source tree. |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | |
| 12 | #include <math.h> |
Yaowu Xu | 5b42ae0 | 2010-12-01 15:50:14 -0800 | [diff] [blame] | 13 | #include "vpx_ports/config.h" |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 14 | void vp8_short_fdct4x4_c(short *input, short *output, int pitch) |
| 15 | { |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 16 | int i; |
| 17 | int a1, b1, c1, d1; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 18 | short *ip = input; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 19 | short *op = output; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 20 | |
| 21 | for (i = 0; i < 4; i++) |
| 22 | { |
Yaowu Xu | 5b42ae0 | 2010-12-01 15:50:14 -0800 | [diff] [blame] | 23 | #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 Xu | d0dd01b | 2010-06-16 12:52:18 -0700 | [diff] [blame] | 29 | 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 Xu | 5b42ae0 | 2010-12-01 15:50:14 -0800 | [diff] [blame] | 33 | #endif |
Yaowu Xu | d0dd01b | 2010-06-16 12:52:18 -0700 | [diff] [blame] | 34 | op[0] = a1 + b1; |
| 35 | op[2] = a1 - b1; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 36 | |
Yaowu Xu | d0dd01b | 2010-06-16 12:52:18 -0700 | [diff] [blame] | 37 | op[1] = (c1 * 2217 + d1 * 5352 + 14500)>>12; |
| 38 | op[3] = (d1 * 2217 - c1 * 5352 + 7500)>>12; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 39 | |
| 40 | ip += pitch / 2; |
| 41 | op += 4; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 42 | |
Yaowu Xu | d0dd01b | 2010-06-16 12:52:18 -0700 | [diff] [blame] | 43 | } |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 44 | ip = output; |
| 45 | op = output; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 46 | for (i = 0; i < 4; i++) |
| 47 | { |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 48 | 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 Xu | d0dd01b | 2010-06-16 12:52:18 -0700 | [diff] [blame] | 53 | op[0] = ( a1 + b1 + 7)>>4; |
| 54 | op[8] = ( a1 - b1 + 7)>>4; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 55 | |
Yaowu Xu | d0dd01b | 2010-06-16 12:52:18 -0700 | [diff] [blame] | 56 | op[4] =((c1 * 2217 + d1 * 5352 + 12000)>>16) + (d1!=0); |
| 57 | op[12] = (d1 * 2217 - c1 * 5352 + 51000)>>16; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 58 | |
| 59 | ip++; |
| 60 | op++; |
| 61 | } |
| 62 | } |
| 63 | |
Yaowu Xu | d0dd01b | 2010-06-16 12:52:18 -0700 | [diff] [blame] | 64 | void vp8_short_fdct8x4_c(short *input, short *output, int pitch) |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 65 | { |
Yaowu Xu | d0dd01b | 2010-06-16 12:52:18 -0700 | [diff] [blame] | 66 | vp8_short_fdct4x4_c(input, output, pitch); |
| 67 | vp8_short_fdct4x4_c(input + 4, output + 16, pitch); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | void 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 Xu | b62d093 | 2010-06-28 22:03:43 -0700 | [diff] [blame] | 78 | |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 79 | for (i = 0; i < 4; i++) |
| 80 | { |
Yaowu Xu | 5b42ae0 | 2010-12-01 15:50:14 -0800 | [diff] [blame] | 81 | #if !CONFIG_EXTEND_QRANGE |
Yaowu Xu | b62d093 | 2010-06-28 22:03:43 -0700 | [diff] [blame] | 82 | 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 Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 86 | |
Yaowu Xu | b62d093 | 2010-06-28 22:03:43 -0700 | [diff] [blame] | 87 | op[0] = a1 + d1 + (a1!=0); |
Yaowu Xu | 5b42ae0 | 2010-12-01 15:50:14 -0800 | [diff] [blame] | 88 | #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 Xu | b62d093 | 2010-06-28 22:03:43 -0700 | [diff] [blame] | 97 | op[1] = b1 + c1; |
| 98 | op[2] = b1 - c1; |
| 99 | op[3] = a1 - d1; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 100 | ip += pitch / 2; |
| 101 | op += 4; |
| 102 | } |
| 103 | |
| 104 | ip = output; |
| 105 | op = output; |
| 106 | |
| 107 | for (i = 0; i < 4; i++) |
| 108 | { |
Yaowu Xu | b62d093 | 2010-06-28 22:03:43 -0700 | [diff] [blame] | 109 | a1 = ip[0] + ip[8]; |
| 110 | d1 = ip[4] + ip[12]; |
| 111 | c1 = ip[4] - ip[12]; |
| 112 | b1 = ip[0] - ip[8]; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 113 | |
Yaowu Xu | b62d093 | 2010-06-28 22:03:43 -0700 | [diff] [blame] | 114 | a2 = a1 + d1; |
| 115 | b2 = b1 + c1; |
| 116 | c2 = b1 - c1; |
| 117 | d2 = a1 - d1; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 118 | |
Yaowu Xu | b62d093 | 2010-06-28 22:03:43 -0700 | [diff] [blame] | 119 | a2 += a2<0; |
| 120 | b2 += b2<0; |
| 121 | c2 += c2<0; |
| 122 | d2 += d2<0; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 123 | |
Yaowu Xu | 5b42ae0 | 2010-12-01 15:50:14 -0800 | [diff] [blame] | 124 | #if !CONFIG_EXTEND_QRANGE |
Yaowu Xu | b62d093 | 2010-06-28 22:03:43 -0700 | [diff] [blame] | 125 | op[0] = (a2+3) >> 3; |
| 126 | op[4] = (b2+3) >> 3; |
| 127 | op[8] = (c2+3) >> 3; |
| 128 | op[12]= (d2+3) >> 3; |
Yaowu Xu | 5b42ae0 | 2010-12-01 15:50:14 -0800 | [diff] [blame] | 129 | #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 Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 135 | ip++; |
| 136 | op++; |
| 137 | } |
| 138 | } |