Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
michael@0 | 3 | * |
michael@0 | 4 | * Use of this source code is governed by a BSD-style license |
michael@0 | 5 | * that can be found in the LICENSE file in the root of the source |
michael@0 | 6 | * tree. An additional intellectual property rights grant can be found |
michael@0 | 7 | * in the file PATENTS. All contributing project authors may |
michael@0 | 8 | * be found in the AUTHORS file in the root of the source tree. |
michael@0 | 9 | */ |
michael@0 | 10 | |
michael@0 | 11 | |
michael@0 | 12 | #include <math.h> |
michael@0 | 13 | |
michael@0 | 14 | void vp8_short_fdct4x4_c(short *input, short *output, int pitch) |
michael@0 | 15 | { |
michael@0 | 16 | int i; |
michael@0 | 17 | int a1, b1, c1, d1; |
michael@0 | 18 | short *ip = input; |
michael@0 | 19 | short *op = output; |
michael@0 | 20 | |
michael@0 | 21 | for (i = 0; i < 4; i++) |
michael@0 | 22 | { |
michael@0 | 23 | a1 = ((ip[0] + ip[3]) * 8); |
michael@0 | 24 | b1 = ((ip[1] + ip[2]) * 8); |
michael@0 | 25 | c1 = ((ip[1] - ip[2]) * 8); |
michael@0 | 26 | d1 = ((ip[0] - ip[3]) * 8); |
michael@0 | 27 | |
michael@0 | 28 | op[0] = a1 + b1; |
michael@0 | 29 | op[2] = a1 - b1; |
michael@0 | 30 | |
michael@0 | 31 | op[1] = (c1 * 2217 + d1 * 5352 + 14500)>>12; |
michael@0 | 32 | op[3] = (d1 * 2217 - c1 * 5352 + 7500)>>12; |
michael@0 | 33 | |
michael@0 | 34 | ip += pitch / 2; |
michael@0 | 35 | op += 4; |
michael@0 | 36 | |
michael@0 | 37 | } |
michael@0 | 38 | ip = output; |
michael@0 | 39 | op = output; |
michael@0 | 40 | for (i = 0; i < 4; i++) |
michael@0 | 41 | { |
michael@0 | 42 | a1 = ip[0] + ip[12]; |
michael@0 | 43 | b1 = ip[4] + ip[8]; |
michael@0 | 44 | c1 = ip[4] - ip[8]; |
michael@0 | 45 | d1 = ip[0] - ip[12]; |
michael@0 | 46 | |
michael@0 | 47 | op[0] = ( a1 + b1 + 7)>>4; |
michael@0 | 48 | op[8] = ( a1 - b1 + 7)>>4; |
michael@0 | 49 | |
michael@0 | 50 | op[4] =((c1 * 2217 + d1 * 5352 + 12000)>>16) + (d1!=0); |
michael@0 | 51 | op[12] = (d1 * 2217 - c1 * 5352 + 51000)>>16; |
michael@0 | 52 | |
michael@0 | 53 | ip++; |
michael@0 | 54 | op++; |
michael@0 | 55 | } |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | void vp8_short_fdct8x4_c(short *input, short *output, int pitch) |
michael@0 | 59 | { |
michael@0 | 60 | vp8_short_fdct4x4_c(input, output, pitch); |
michael@0 | 61 | vp8_short_fdct4x4_c(input + 4, output + 16, pitch); |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | void vp8_short_walsh4x4_c(short *input, short *output, int pitch) |
michael@0 | 65 | { |
michael@0 | 66 | int i; |
michael@0 | 67 | int a1, b1, c1, d1; |
michael@0 | 68 | int a2, b2, c2, d2; |
michael@0 | 69 | short *ip = input; |
michael@0 | 70 | short *op = output; |
michael@0 | 71 | |
michael@0 | 72 | |
michael@0 | 73 | for (i = 0; i < 4; i++) |
michael@0 | 74 | { |
michael@0 | 75 | a1 = ((ip[0] + ip[2]) * 4); |
michael@0 | 76 | d1 = ((ip[1] + ip[3]) * 4); |
michael@0 | 77 | c1 = ((ip[1] - ip[3]) * 4); |
michael@0 | 78 | b1 = ((ip[0] - ip[2]) * 4); |
michael@0 | 79 | |
michael@0 | 80 | op[0] = a1 + d1 + (a1!=0); |
michael@0 | 81 | op[1] = b1 + c1; |
michael@0 | 82 | op[2] = b1 - c1; |
michael@0 | 83 | op[3] = a1 - d1; |
michael@0 | 84 | ip += pitch / 2; |
michael@0 | 85 | op += 4; |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | ip = output; |
michael@0 | 89 | op = output; |
michael@0 | 90 | |
michael@0 | 91 | for (i = 0; i < 4; i++) |
michael@0 | 92 | { |
michael@0 | 93 | a1 = ip[0] + ip[8]; |
michael@0 | 94 | d1 = ip[4] + ip[12]; |
michael@0 | 95 | c1 = ip[4] - ip[12]; |
michael@0 | 96 | b1 = ip[0] - ip[8]; |
michael@0 | 97 | |
michael@0 | 98 | a2 = a1 + d1; |
michael@0 | 99 | b2 = b1 + c1; |
michael@0 | 100 | c2 = b1 - c1; |
michael@0 | 101 | d2 = a1 - d1; |
michael@0 | 102 | |
michael@0 | 103 | a2 += a2<0; |
michael@0 | 104 | b2 += b2<0; |
michael@0 | 105 | c2 += c2<0; |
michael@0 | 106 | d2 += d2<0; |
michael@0 | 107 | |
michael@0 | 108 | op[0] = (a2+3) >> 3; |
michael@0 | 109 | op[4] = (b2+3) >> 3; |
michael@0 | 110 | op[8] = (c2+3) >> 3; |
michael@0 | 111 | op[12]= (d2+3) >> 3; |
michael@0 | 112 | |
michael@0 | 113 | ip++; |
michael@0 | 114 | op++; |
michael@0 | 115 | } |
michael@0 | 116 | } |