media/libvpx/vp8/common/idctllm.c

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 /****************************************************************************
michael@0 13 * Notes:
michael@0 14 *
michael@0 15 * This implementation makes use of 16 bit fixed point verio of two multiply
michael@0 16 * constants:
michael@0 17 * 1. sqrt(2) * cos (pi/8)
michael@0 18 * 2. sqrt(2) * sin (pi/8)
michael@0 19 * Becuase the first constant is bigger than 1, to maintain the same 16 bit
michael@0 20 * fixed point precision as the second one, we use a trick of
michael@0 21 * x * a = x + x*(a-1)
michael@0 22 * so
michael@0 23 * x * sqrt(2) * cos (pi/8) = x + x * (sqrt(2) *cos(pi/8)-1).
michael@0 24 **************************************************************************/
michael@0 25 static const int cospi8sqrt2minus1 = 20091;
michael@0 26 static const int sinpi8sqrt2 = 35468;
michael@0 27
michael@0 28 void vp8_short_idct4x4llm_c(short *input, unsigned char *pred_ptr,
michael@0 29 int pred_stride, unsigned char *dst_ptr,
michael@0 30 int dst_stride)
michael@0 31 {
michael@0 32 int i;
michael@0 33 int r, c;
michael@0 34 int a1, b1, c1, d1;
michael@0 35 short output[16];
michael@0 36 short *ip = input;
michael@0 37 short *op = output;
michael@0 38 int temp1, temp2;
michael@0 39 int shortpitch = 4;
michael@0 40
michael@0 41 for (i = 0; i < 4; i++)
michael@0 42 {
michael@0 43 a1 = ip[0] + ip[8];
michael@0 44 b1 = ip[0] - ip[8];
michael@0 45
michael@0 46 temp1 = (ip[4] * sinpi8sqrt2) >> 16;
michael@0 47 temp2 = ip[12] + ((ip[12] * cospi8sqrt2minus1) >> 16);
michael@0 48 c1 = temp1 - temp2;
michael@0 49
michael@0 50 temp1 = ip[4] + ((ip[4] * cospi8sqrt2minus1) >> 16);
michael@0 51 temp2 = (ip[12] * sinpi8sqrt2) >> 16;
michael@0 52 d1 = temp1 + temp2;
michael@0 53
michael@0 54 op[shortpitch*0] = a1 + d1;
michael@0 55 op[shortpitch*3] = a1 - d1;
michael@0 56
michael@0 57 op[shortpitch*1] = b1 + c1;
michael@0 58 op[shortpitch*2] = b1 - c1;
michael@0 59
michael@0 60 ip++;
michael@0 61 op++;
michael@0 62 }
michael@0 63
michael@0 64 ip = output;
michael@0 65 op = output;
michael@0 66
michael@0 67 for (i = 0; i < 4; i++)
michael@0 68 {
michael@0 69 a1 = ip[0] + ip[2];
michael@0 70 b1 = ip[0] - ip[2];
michael@0 71
michael@0 72 temp1 = (ip[1] * sinpi8sqrt2) >> 16;
michael@0 73 temp2 = ip[3] + ((ip[3] * cospi8sqrt2minus1) >> 16);
michael@0 74 c1 = temp1 - temp2;
michael@0 75
michael@0 76 temp1 = ip[1] + ((ip[1] * cospi8sqrt2minus1) >> 16);
michael@0 77 temp2 = (ip[3] * sinpi8sqrt2) >> 16;
michael@0 78 d1 = temp1 + temp2;
michael@0 79
michael@0 80
michael@0 81 op[0] = (a1 + d1 + 4) >> 3;
michael@0 82 op[3] = (a1 - d1 + 4) >> 3;
michael@0 83
michael@0 84 op[1] = (b1 + c1 + 4) >> 3;
michael@0 85 op[2] = (b1 - c1 + 4) >> 3;
michael@0 86
michael@0 87 ip += shortpitch;
michael@0 88 op += shortpitch;
michael@0 89 }
michael@0 90
michael@0 91 ip = output;
michael@0 92 for (r = 0; r < 4; r++)
michael@0 93 {
michael@0 94 for (c = 0; c < 4; c++)
michael@0 95 {
michael@0 96 int a = ip[c] + pred_ptr[c] ;
michael@0 97
michael@0 98 if (a < 0)
michael@0 99 a = 0;
michael@0 100
michael@0 101 if (a > 255)
michael@0 102 a = 255;
michael@0 103
michael@0 104 dst_ptr[c] = (unsigned char) a ;
michael@0 105 }
michael@0 106 ip += 4;
michael@0 107 dst_ptr += dst_stride;
michael@0 108 pred_ptr += pred_stride;
michael@0 109 }
michael@0 110 }
michael@0 111
michael@0 112 void vp8_dc_only_idct_add_c(short input_dc, unsigned char *pred_ptr,
michael@0 113 int pred_stride, unsigned char *dst_ptr,
michael@0 114 int dst_stride)
michael@0 115 {
michael@0 116 int a1 = ((input_dc + 4) >> 3);
michael@0 117 int r, c;
michael@0 118
michael@0 119 for (r = 0; r < 4; r++)
michael@0 120 {
michael@0 121 for (c = 0; c < 4; c++)
michael@0 122 {
michael@0 123 int a = a1 + pred_ptr[c] ;
michael@0 124
michael@0 125 if (a < 0)
michael@0 126 a = 0;
michael@0 127
michael@0 128 if (a > 255)
michael@0 129 a = 255;
michael@0 130
michael@0 131 dst_ptr[c] = (unsigned char) a ;
michael@0 132 }
michael@0 133
michael@0 134 dst_ptr += dst_stride;
michael@0 135 pred_ptr += pred_stride;
michael@0 136 }
michael@0 137
michael@0 138 }
michael@0 139
michael@0 140 void vp8_short_inv_walsh4x4_c(short *input, short *mb_dqcoeff)
michael@0 141 {
michael@0 142 short output[16];
michael@0 143 int i;
michael@0 144 int a1, b1, c1, d1;
michael@0 145 int a2, b2, c2, d2;
michael@0 146 short *ip = input;
michael@0 147 short *op = output;
michael@0 148
michael@0 149 for (i = 0; i < 4; i++)
michael@0 150 {
michael@0 151 a1 = ip[0] + ip[12];
michael@0 152 b1 = ip[4] + ip[8];
michael@0 153 c1 = ip[4] - ip[8];
michael@0 154 d1 = ip[0] - ip[12];
michael@0 155
michael@0 156 op[0] = a1 + b1;
michael@0 157 op[4] = c1 + d1;
michael@0 158 op[8] = a1 - b1;
michael@0 159 op[12] = d1 - c1;
michael@0 160 ip++;
michael@0 161 op++;
michael@0 162 }
michael@0 163
michael@0 164 ip = output;
michael@0 165 op = output;
michael@0 166
michael@0 167 for (i = 0; i < 4; i++)
michael@0 168 {
michael@0 169 a1 = ip[0] + ip[3];
michael@0 170 b1 = ip[1] + ip[2];
michael@0 171 c1 = ip[1] - ip[2];
michael@0 172 d1 = ip[0] - ip[3];
michael@0 173
michael@0 174 a2 = a1 + b1;
michael@0 175 b2 = c1 + d1;
michael@0 176 c2 = a1 - b1;
michael@0 177 d2 = d1 - c1;
michael@0 178
michael@0 179 op[0] = (a2 + 3) >> 3;
michael@0 180 op[1] = (b2 + 3) >> 3;
michael@0 181 op[2] = (c2 + 3) >> 3;
michael@0 182 op[3] = (d2 + 3) >> 3;
michael@0 183
michael@0 184 ip += 4;
michael@0 185 op += 4;
michael@0 186 }
michael@0 187
michael@0 188 for(i = 0; i < 16; i++)
michael@0 189 {
michael@0 190 mb_dqcoeff[i * 16] = output[i];
michael@0 191 }
michael@0 192 }
michael@0 193
michael@0 194 void vp8_short_inv_walsh4x4_1_c(short *input, short *mb_dqcoeff)
michael@0 195 {
michael@0 196 int i;
michael@0 197 int a1;
michael@0 198
michael@0 199 a1 = ((input[0] + 3) >> 3);
michael@0 200 for(i = 0; i < 16; i++)
michael@0 201 {
michael@0 202 mb_dqcoeff[i * 16] = a1;
michael@0 203 }
michael@0 204 }

mercurial