pysvp64db: fix traversal
[openpower-isa.git] / media / video / libvpx / vp8_dct4x4_ref.c
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 #include <stdint.h>
13 #include <stdio.h>
14
15 #include "vp8_rtcd.h"
16
17 void vp8_short_fdct4x4_c(int16_t *input, int16_t *output, int32_t pitch) {
18 int i;
19 int a1, b1, c1, d1;
20 short *ip = input;
21 short *op = output;
22
23 for (i = 0; i < 4; ++i) {
24 a1 = ((ip[0] + ip[3]));
25 b1 = ((ip[1] + ip[2]));
26 c1 = ((ip[1] - ip[2]));
27 d1 = ((ip[0] - ip[3]));
28
29 a1 *= 8;
30 b1 *= 8;
31 c1 *= 8;
32 d1 *= 8;
33 //printf("a1 = %08x\tb1 = %08x\tc1 = %08x\td1 = %08x\n", a1, b1, c1, d1);
34
35 op[0] = a1 + b1;
36 op[2] = a1 - b1;
37 //printf("op[0] = %04x\top[2] = %04x\n", (uint16_t)op[0], (uint16_t)op[2]);
38
39 op[1] = (c1 * 2217 + d1 * 5352 + 14500) >> 12;
40 op[3] = (d1 * 2217 - c1 * 5352 + 7500) >> 12;
41 //printf("op[1] = %04x\top[3] = %04x\n", (uint16_t)op[1], (uint16_t)op[3]);
42
43 ip += pitch / 2;
44 op += 4;
45 }
46 ip = output;
47 op = output;
48 for (i = 0; i < 4; ++i) {
49 a1 = ip[0] + ip[12];
50 b1 = ip[4] + ip[8];
51 c1 = ip[4] - ip[8];
52 d1 = ip[0] - ip[12];
53 //printf("a1 = %08x\tb1 = %08x\tc1 = %08x\td1 = %08x\n", a1, b1, c1, d1);
54
55 op[0] = (a1 + b1 + 7) >> 4;
56 op[8] = (a1 - b1 + 7) >> 4;
57 //printf("op[%d] = %08x\top[%d] = %08x\n", i, op[0], i+8, op[8]);
58
59 op[4] = ((c1 * 2217 + d1 * 5352 + 12000) >> 16) + (d1 != 0);
60 op[12] = (d1 * 2217 - c1 * 5352 + 51000) >> 16;
61 //printf("op[%d] = %04x\top[%d] = %04x\n", i+4, (uint16_t)op[4], i+12, (uint16_t)op[12]);
62
63 ip++;
64 op++;
65 }
66 }