Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: source/libvpx/vp9/common/mips/dspr2/vp9_itrans4_dspr2.c

Issue 1302353004: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <assert.h> 11 #include <assert.h>
12 #include <stdio.h> 12 #include <stdio.h>
13 13
14 #include "./vpx_config.h" 14 #include "./vpx_config.h"
15 #include "./vp9_rtcd.h" 15 #include "./vp9_rtcd.h"
16 #include "vp9/common/vp9_common.h" 16 #include "vp9/common/vp9_common.h"
17 #include "vp9/common/vp9_blockd.h" 17 #include "vp9/common/vp9_blockd.h"
18 #include "vp9/common/vp9_idct.h" 18 #include "vp9/common/vp9_idct.h"
19 #include "vp9/common/mips/dspr2/vp9_common_dspr2.h" 19 #include "vpx_dsp/mips/inv_txfm_dspr2.h"
20 #include "vpx_dsp/txfm_common.h" 20 #include "vpx_dsp/txfm_common.h"
21 #include "vpx_ports/mem.h" 21 #include "vpx_ports/mem.h"
22 22
23 #if HAVE_DSPR2 23 #if HAVE_DSPR2
24 static void vp9_idct4_rows_dspr2(const int16_t *input, int16_t *output) {
25 int16_t step_0, step_1, step_2, step_3;
26 int Temp0, Temp1, Temp2, Temp3;
27 const int const_2_power_13 = 8192;
28 int i;
29
30 for (i = 4; i--; ) {
31 __asm__ __volatile__ (
32 /*
33 temp_1 = (input[0] + input[2]) * cospi_16_64;
34 step_0 = dct_const_round_shift(temp_1);
35
36 temp_2 = (input[0] - input[2]) * cospi_16_64;
37 step_1 = dct_const_round_shift(temp_2);
38 */
39 "lh %[Temp0], 0(%[input]) \n\t"
40 "lh %[Temp1], 4(%[input]) \n\t"
41 "mtlo %[const_2_power_13], $ac0 \n\t"
42 "mthi $zero, $ac0 \n\t"
43 "mtlo %[const_2_power_13], $ac1 \n\t"
44 "mthi $zero, $ac1 \n\t"
45 "add %[Temp2], %[Temp0], %[Temp1] \n\t"
46 "sub %[Temp3], %[Temp0], %[Temp1] \n\t"
47 "madd $ac0, %[Temp2], %[cospi_16_64] \n\t"
48 "lh %[Temp0], 2(%[input]) \n\t"
49 "lh %[Temp1], 6(%[input]) \n\t"
50 "extp %[step_0], $ac0, 31 \n\t"
51 "mtlo %[const_2_power_13], $ac0 \n\t"
52 "mthi $zero, $ac0 \n\t"
53
54 "madd $ac1, %[Temp3], %[cospi_16_64] \n\t"
55 "extp %[step_1], $ac1, 31 \n\t"
56 "mtlo %[const_2_power_13], $ac1 \n\t"
57 "mthi $zero, $ac1 \n\t"
58
59 /*
60 temp1 = input[1] * cospi_24_64 - input[3] * cospi_8_64;
61 step_2 = dct_const_round_shift(temp1);
62 */
63 "madd $ac0, %[Temp0], %[cospi_24_64] \n\t"
64 "msub $ac0, %[Temp1], %[cospi_8_64] \n\t"
65 "extp %[step_2], $ac0, 31 \n\t"
66
67 /*
68 temp2 = input[1] * cospi_8_64 + input[3] * cospi_24_64;
69 step_3 = dct_const_round_shift(temp2);
70 */
71 "madd $ac1, %[Temp0], %[cospi_8_64] \n\t"
72 "madd $ac1, %[Temp1], %[cospi_24_64] \n\t"
73 "extp %[step_3], $ac1, 31 \n\t"
74
75 /*
76 output[0] = step_0 + step_3;
77 output[4] = step_1 + step_2;
78 output[8] = step_1 - step_2;
79 output[12] = step_0 - step_3;
80 */
81 "add %[Temp0], %[step_0], %[step_3] \n\t"
82 "sh %[Temp0], 0(%[output]) \n\t"
83
84 "add %[Temp1], %[step_1], %[step_2] \n\t"
85 "sh %[Temp1], 8(%[output]) \n\t"
86
87 "sub %[Temp2], %[step_1], %[step_2] \n\t"
88 "sh %[Temp2], 16(%[output]) \n\t"
89
90 "sub %[Temp3], %[step_0], %[step_3] \n\t"
91 "sh %[Temp3], 24(%[output]) \n\t"
92
93 : [Temp0] "=&r" (Temp0), [Temp1] "=&r" (Temp1),
94 [Temp2] "=&r" (Temp2), [Temp3] "=&r" (Temp3),
95 [step_0] "=&r" (step_0), [step_1] "=&r" (step_1),
96 [step_2] "=&r" (step_2), [step_3] "=&r" (step_3),
97 [output] "+r" (output)
98 : [const_2_power_13] "r" (const_2_power_13),
99 [cospi_8_64] "r" (cospi_8_64), [cospi_16_64] "r" (cospi_16_64),
100 [cospi_24_64] "r" (cospi_24_64),
101 [input] "r" (input)
102 );
103
104 input += 4;
105 output += 1;
106 }
107 }
108
109 static void vp9_idct4_columns_add_blk_dspr2(int16_t *input, uint8_t *dest,
110 int dest_stride) {
111 int16_t step_0, step_1, step_2, step_3;
112 int Temp0, Temp1, Temp2, Temp3;
113 const int const_2_power_13 = 8192;
114 int i;
115 uint8_t *dest_pix;
116 uint8_t *cm = vpx_ff_cropTbl;
117
118 /* prefetch vpx_ff_cropTbl */
119 prefetch_load(vpx_ff_cropTbl);
120 prefetch_load(vpx_ff_cropTbl + 32);
121 prefetch_load(vpx_ff_cropTbl + 64);
122 prefetch_load(vpx_ff_cropTbl + 96);
123 prefetch_load(vpx_ff_cropTbl + 128);
124 prefetch_load(vpx_ff_cropTbl + 160);
125 prefetch_load(vpx_ff_cropTbl + 192);
126 prefetch_load(vpx_ff_cropTbl + 224);
127
128 for (i = 0; i < 4; ++i) {
129 dest_pix = (dest + i);
130
131 __asm__ __volatile__ (
132 /*
133 temp_1 = (input[0] + input[2]) * cospi_16_64;
134 step_0 = dct_const_round_shift(temp_1);
135
136 temp_2 = (input[0] - input[2]) * cospi_16_64;
137 step_1 = dct_const_round_shift(temp_2);
138 */
139 "lh %[Temp0], 0(%[input]) \n\t"
140 "lh %[Temp1], 4(%[input]) \n\t"
141 "mtlo %[const_2_power_13], $ac0 \n\t"
142 "mthi $zero, $ac0 \n\t"
143 "mtlo %[const_2_power_13], $ac1 \n\t"
144 "mthi $zero, $ac1 \n\t"
145 "add %[Temp2], %[Temp0], %[Temp1] \n\t"
146 "sub %[Temp3], %[Temp0], %[Temp1] \n\t"
147 "madd $ac0, %[Temp2], %[cospi_16_64] \n\t"
148 "lh %[Temp0], 2(%[input]) \n\t"
149 "lh %[Temp1], 6(%[input]) \n\t"
150 "extp %[step_0], $ac0, 31 \n\t"
151 "mtlo %[const_2_power_13], $ac0 \n\t"
152 "mthi $zero, $ac0 \n\t"
153
154 "madd $ac1, %[Temp3], %[cospi_16_64] \n\t"
155 "extp %[step_1], $ac1, 31 \n\t"
156 "mtlo %[const_2_power_13], $ac1 \n\t"
157 "mthi $zero, $ac1 \n\t"
158
159 /*
160 temp1 = input[1] * cospi_24_64 - input[3] * cospi_8_64;
161 step_2 = dct_const_round_shift(temp1);
162 */
163 "madd $ac0, %[Temp0], %[cospi_24_64] \n\t"
164 "msub $ac0, %[Temp1], %[cospi_8_64] \n\t"
165 "extp %[step_2], $ac0, 31 \n\t"
166
167 /*
168 temp2 = input[1] * cospi_8_64 + input[3] * cospi_24_64;
169 step_3 = dct_const_round_shift(temp2);
170 */
171 "madd $ac1, %[Temp0], %[cospi_8_64] \n\t"
172 "madd $ac1, %[Temp1], %[cospi_24_64] \n\t"
173 "extp %[step_3], $ac1, 31 \n\t"
174
175 /*
176 output[0] = step_0 + step_3;
177 output[4] = step_1 + step_2;
178 output[8] = step_1 - step_2;
179 output[12] = step_0 - step_3;
180 */
181 "add %[Temp0], %[step_0], %[step_3] \n\t"
182 "addi %[Temp0], %[Temp0], 8 \n\t"
183 "sra %[Temp0], %[Temp0], 4 \n\t"
184 "lbu %[Temp1], 0(%[dest_pix]) \n\t"
185 "add %[Temp1], %[Temp1], %[Temp0] \n\t"
186 "add %[Temp0], %[step_1], %[step_2] \n\t"
187 "lbux %[Temp2], %[Temp1](%[cm]) \n\t"
188 "sb %[Temp2], 0(%[dest_pix]) \n\t"
189 "addu %[dest_pix], %[dest_pix], %[dest_stride] \n\t"
190
191 "addi %[Temp0], %[Temp0], 8 \n\t"
192 "sra %[Temp0], %[Temp0], 4 \n\t"
193 "lbu %[Temp1], 0(%[dest_pix]) \n\t"
194 "add %[Temp1], %[Temp1], %[Temp0] \n\t"
195 "sub %[Temp0], %[step_1], %[step_2] \n\t"
196 "lbux %[Temp2], %[Temp1](%[cm]) \n\t"
197 "sb %[Temp2], 0(%[dest_pix]) \n\t"
198 "addu %[dest_pix], %[dest_pix], %[dest_stride] \n\t"
199
200 "addi %[Temp0], %[Temp0], 8 \n\t"
201 "sra %[Temp0], %[Temp0], 4 \n\t"
202 "lbu %[Temp1], 0(%[dest_pix]) \n\t"
203 "add %[Temp1], %[Temp1], %[Temp0] \n\t"
204 "sub %[Temp0], %[step_0], %[step_3] \n\t"
205 "lbux %[Temp2], %[Temp1](%[cm]) \n\t"
206 "sb %[Temp2], 0(%[dest_pix]) \n\t"
207 "addu %[dest_pix], %[dest_pix], %[dest_stride] \n\t"
208
209 "addi %[Temp0], %[Temp0], 8 \n\t"
210 "sra %[Temp0], %[Temp0], 4 \n\t"
211 "lbu %[Temp1], 0(%[dest_pix]) \n\t"
212 "add %[Temp1], %[Temp1], %[Temp0] \n\t"
213 "lbux %[Temp2], %[Temp1](%[cm]) \n\t"
214 "sb %[Temp2], 0(%[dest_pix]) \n\t"
215
216 : [Temp0] "=&r" (Temp0), [Temp1] "=&r" (Temp1),
217 [Temp2] "=&r" (Temp2), [Temp3] "=&r" (Temp3),
218 [step_0] "=&r" (step_0), [step_1] "=&r" (step_1),
219 [step_2] "=&r" (step_2), [step_3] "=&r" (step_3),
220 [dest_pix] "+r" (dest_pix)
221 : [const_2_power_13] "r" (const_2_power_13),
222 [cospi_8_64] "r" (cospi_8_64), [cospi_16_64] "r" (cospi_16_64),
223 [cospi_24_64] "r" (cospi_24_64),
224 [input] "r" (input), [cm] "r" (cm), [dest_stride] "r" (dest_stride)
225 );
226
227 input += 4;
228 }
229 }
230
231 void vp9_idct4x4_16_add_dspr2(const int16_t *input, uint8_t *dest,
232 int dest_stride) {
233 DECLARE_ALIGNED(32, int16_t, out[4 * 4]);
234 int16_t *outptr = out;
235 uint32_t pos = 45;
236
237 /* bit positon for extract from acc */
238 __asm__ __volatile__ (
239 "wrdsp %[pos], 1 \n\t"
240 :
241 : [pos] "r" (pos)
242 );
243
244 // Rows
245 vp9_idct4_rows_dspr2(input, outptr);
246
247 // Columns
248 vp9_idct4_columns_add_blk_dspr2(&out[0], dest, dest_stride);
249 }
250
251 void vp9_idct4x4_1_add_dspr2(const int16_t *input, uint8_t *dest,
252 int dest_stride) {
253 int a1, absa1;
254 int r;
255 int32_t out;
256 int t2, vector_a1, vector_a;
257 uint32_t pos = 45;
258 int16_t input_dc = input[0];
259
260 /* bit positon for extract from acc */
261 __asm__ __volatile__ (
262 "wrdsp %[pos], 1 \n\t"
263
264 :
265 : [pos] "r" (pos)
266 );
267
268 out = DCT_CONST_ROUND_SHIFT_TWICE_COSPI_16_64(input_dc);
269 __asm__ __volatile__ (
270 "addi %[out], %[out], 8 \n\t"
271 "sra %[a1], %[out], 4 \n\t"
272
273 : [out] "+r" (out), [a1] "=r" (a1)
274 :
275 );
276
277 if (a1 < 0) {
278 /* use quad-byte
279 * input and output memory are four byte aligned */
280 __asm__ __volatile__ (
281 "abs %[absa1], %[a1] \n\t"
282 "replv.qb %[vector_a1], %[absa1] \n\t"
283
284 : [absa1] "=r" (absa1), [vector_a1] "=r" (vector_a1)
285 : [a1] "r" (a1)
286 );
287
288 for (r = 4; r--;) {
289 __asm__ __volatile__ (
290 "lw %[t2], 0(%[dest]) \n\t"
291 "subu_s.qb %[vector_a], %[t2], %[vector_a1] \n\t"
292 "sw %[vector_a], 0(%[dest]) \n\t"
293 "add %[dest], %[dest], %[dest_stride] \n\t"
294
295 : [t2] "=&r" (t2), [vector_a] "=&r" (vector_a),
296 [dest] "+&r" (dest)
297 : [dest_stride] "r" (dest_stride), [vector_a1] "r" (vector_a1)
298 );
299 }
300 } else {
301 /* use quad-byte
302 * input and output memory are four byte aligned */
303 __asm__ __volatile__ (
304 "replv.qb %[vector_a1], %[a1] \n\t"
305 : [vector_a1] "=r" (vector_a1)
306 : [a1] "r" (a1)
307 );
308
309 for (r = 4; r--;) {
310 __asm__ __volatile__ (
311 "lw %[t2], 0(%[dest]) \n\t"
312 "addu_s.qb %[vector_a], %[t2], %[vector_a1] \n\t"
313 "sw %[vector_a], 0(%[dest]) \n\t"
314 "add %[dest], %[dest], %[dest_stride] \n\t"
315
316 : [t2] "=&r" (t2), [vector_a] "=&r" (vector_a),
317 [dest] "+&r" (dest)
318 : [dest_stride] "r" (dest_stride), [vector_a1] "r" (vector_a1)
319 );
320 }
321 }
322 }
323
324 static void iadst4_dspr2(const int16_t *input, int16_t *output) {
325 int s0, s1, s2, s3, s4, s5, s6, s7;
326 int x0, x1, x2, x3;
327
328 x0 = input[0];
329 x1 = input[1];
330 x2 = input[2];
331 x3 = input[3];
332
333 if (!(x0 | x1 | x2 | x3)) {
334 output[0] = output[1] = output[2] = output[3] = 0;
335 return;
336 }
337
338 s0 = sinpi_1_9 * x0;
339 s1 = sinpi_2_9 * x0;
340 s2 = sinpi_3_9 * x1;
341 s3 = sinpi_4_9 * x2;
342 s4 = sinpi_1_9 * x2;
343 s5 = sinpi_2_9 * x3;
344 s6 = sinpi_4_9 * x3;
345 s7 = x0 - x2 + x3;
346
347 x0 = s0 + s3 + s5;
348 x1 = s1 - s4 - s6;
349 x2 = sinpi_3_9 * s7;
350 x3 = s2;
351
352 s0 = x0 + x3;
353 s1 = x1 + x3;
354 s2 = x2;
355 s3 = x0 + x1 - x3;
356
357 // 1-D transform scaling factor is sqrt(2).
358 // The overall dynamic range is 14b (input) + 14b (multiplication scaling)
359 // + 1b (addition) = 29b.
360 // Hence the output bit depth is 15b.
361 output[0] = dct_const_round_shift(s0);
362 output[1] = dct_const_round_shift(s1);
363 output[2] = dct_const_round_shift(s2);
364 output[3] = dct_const_round_shift(s3);
365 }
366
367 void vp9_iht4x4_16_add_dspr2(const int16_t *input, uint8_t *dest, 24 void vp9_iht4x4_16_add_dspr2(const int16_t *input, uint8_t *dest,
368 int dest_stride, int tx_type) { 25 int dest_stride, int tx_type) {
369 int i, j; 26 int i, j;
370 DECLARE_ALIGNED(32, int16_t, out[4 * 4]); 27 DECLARE_ALIGNED(32, int16_t, out[4 * 4]);
371 int16_t *outptr = out; 28 int16_t *outptr = out;
372 int16_t temp_in[4 * 4], temp_out[4]; 29 int16_t temp_in[4 * 4], temp_out[4];
373 uint32_t pos = 45; 30 uint32_t pos = 45;
374 31
375 /* bit positon for extract from acc */ 32 /* bit positon for extract from acc */
376 __asm__ __volatile__ ( 33 __asm__ __volatile__ (
377 "wrdsp %[pos], 1 \n\t" 34 "wrdsp %[pos], 1 \n\t"
378 : 35 :
379 : [pos] "r" (pos) 36 : [pos] "r" (pos)
380 ); 37 );
381 38
382 switch (tx_type) { 39 switch (tx_type) {
383 case DCT_DCT: // DCT in both horizontal and vertical 40 case DCT_DCT: // DCT in both horizontal and vertical
384 vp9_idct4_rows_dspr2(input, outptr); 41 vpx_idct4_rows_dspr2(input, outptr);
385 vp9_idct4_columns_add_blk_dspr2(&out[0], dest, dest_stride); 42 vpx_idct4_columns_add_blk_dspr2(&out[0], dest, dest_stride);
386 break; 43 break;
387 case ADST_DCT: // ADST in vertical, DCT in horizontal 44 case ADST_DCT: // ADST in vertical, DCT in horizontal
388 vp9_idct4_rows_dspr2(input, outptr); 45 vpx_idct4_rows_dspr2(input, outptr);
389 46
390 outptr = out; 47 outptr = out;
391 48
392 for (i = 0; i < 4; ++i) { 49 for (i = 0; i < 4; ++i) {
393 iadst4_dspr2(outptr, temp_out); 50 iadst4_dspr2(outptr, temp_out);
394 51
395 for (j = 0; j < 4; ++j) 52 for (j = 0; j < 4; ++j)
396 dest[j * dest_stride + i] = 53 dest[j * dest_stride + i] =
397 clip_pixel(ROUND_POWER_OF_TWO(temp_out[j], 4) 54 clip_pixel(ROUND_POWER_OF_TWO(temp_out[j], 4)
398 + dest[j * dest_stride + i]); 55 + dest[j * dest_stride + i]);
399 56
400 outptr += 4; 57 outptr += 4;
401 } 58 }
402 break; 59 break;
403 case DCT_ADST: // DCT in vertical, ADST in horizontal 60 case DCT_ADST: // DCT in vertical, ADST in horizontal
404 for (i = 0; i < 4; ++i) { 61 for (i = 0; i < 4; ++i) {
405 iadst4_dspr2(input, outptr); 62 iadst4_dspr2(input, outptr);
406 input += 4; 63 input += 4;
407 outptr += 4; 64 outptr += 4;
408 } 65 }
409 66
410 for (i = 0; i < 4; ++i) { 67 for (i = 0; i < 4; ++i) {
411 for (j = 0; j < 4; ++j) { 68 for (j = 0; j < 4; ++j) {
412 temp_in[i * 4 + j] = out[j * 4 + i]; 69 temp_in[i * 4 + j] = out[j * 4 + i];
413 } 70 }
414 } 71 }
415 vp9_idct4_columns_add_blk_dspr2(&temp_in[0], dest, dest_stride); 72 vpx_idct4_columns_add_blk_dspr2(&temp_in[0], dest, dest_stride);
416 break; 73 break;
417 case ADST_ADST: // ADST in both directions 74 case ADST_ADST: // ADST in both directions
418 for (i = 0; i < 4; ++i) { 75 for (i = 0; i < 4; ++i) {
419 iadst4_dspr2(input, outptr); 76 iadst4_dspr2(input, outptr);
420 input += 4; 77 input += 4;
421 outptr += 4; 78 outptr += 4;
422 } 79 }
423 80
424 for (i = 0; i < 4; ++i) { 81 for (i = 0; i < 4; ++i) {
425 for (j = 0; j < 4; ++j) 82 for (j = 0; j < 4; ++j)
426 temp_in[j] = out[j * 4 + i]; 83 temp_in[j] = out[j * 4 + i];
427 iadst4_dspr2(temp_in, temp_out); 84 iadst4_dspr2(temp_in, temp_out);
428 85
429 for (j = 0; j < 4; ++j) 86 for (j = 0; j < 4; ++j)
430 dest[j * dest_stride + i] = 87 dest[j * dest_stride + i] =
431 clip_pixel(ROUND_POWER_OF_TWO(temp_out[j], 4) 88 clip_pixel(ROUND_POWER_OF_TWO(temp_out[j], 4)
432 + dest[j * dest_stride + i]); 89 + dest[j * dest_stride + i]);
433 } 90 }
434 break; 91 break;
435 default: 92 default:
436 printf("vp9_short_iht4x4_add_dspr2 : Invalid tx_type\n"); 93 printf("vp9_short_iht4x4_add_dspr2 : Invalid tx_type\n");
437 break; 94 break;
438 } 95 }
439 } 96 }
440 #endif // #if HAVE_DSPR2 97 #endif // #if HAVE_DSPR2
OLDNEW
« no previous file with comments | « source/libvpx/vp9/common/mips/dspr2/vp9_itrans32_dspr2.c ('k') | source/libvpx/vp9/common/mips/dspr2/vp9_itrans8_dspr2.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698