1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include <assert.h>
20 #include <stdint.h>
21 #include <string.h>
22
23 #include "config.h"
31
33 int16_t
basis[64],
int scale)
34 {
35 int i;
36 unsigned int sum = 0;
37
38 for (i = 0; i < 8 * 8; i++) {
39 int b = rem[i] + ((basis[i] * scale +
42 int w = weight[i];
45
46 sum += (w *
b) * (w * b) >> 4;
47 }
48 return sum >> 2;
49 }
50
52 {
53 int i;
54
55 for (i = 0; i < 8 * 8; i++)
56 rem[i] += (basis[i] * scale +
59 }
60
62 {
64
65 for (i = 0; i < 16; i++) {
66 for (j = 0; j < 16; j += 8) {
67 s += pix[0];
68 s += pix[1];
69 s += pix[2];
70 s += pix[3];
71 s += pix[4];
72 s += pix[5];
73 s += pix[6];
74 s += pix[7];
75 pix += 8;
76 }
77 pix += line_size - 16;
78 }
80 }
81
83 {
86
87 for (i = 0; i < 16; i++) {
88 for (j = 0; j < 16; j += 8) {
89 #if 0
90 s += sq[pix[0]];
91 s += sq[pix[1]];
92 s += sq[pix[2]];
93 s += sq[pix[3]];
94 s += sq[pix[4]];
95 s += sq[pix[5]];
96 s += sq[pix[6]];
97 s += sq[pix[7]];
98 #else
99 #if HAVE_FAST_64BIT
100 register uint64_t x = *(uint64_t *) pix;
101 s += sq[x & 0xff];
102 s += sq[(x >> 8) & 0xff];
103 s += sq[(x >> 16) & 0xff];
104 s += sq[(x >> 24) & 0xff];
105 s += sq[(x >> 32) & 0xff];
106 s += sq[(x >> 40) & 0xff];
107 s += sq[(x >> 48) & 0xff];
108 s += sq[(x >> 56) & 0xff];
109 #else
110 register uint32_t x = *(uint32_t *) pix;
111 s += sq[x & 0xff];
112 s += sq[(x >> 8) & 0xff];
113 s += sq[(x >> 16) & 0xff];
114 s += sq[(x >> 24) & 0xff];
115 x = *(uint32_t *) (pix + 4);
116 s += sq[x & 0xff];
117 s += sq[(x >> 8) & 0xff];
118 s += sq[(x >> 16) & 0xff];
119 s += sq[(x >> 24) & 0xff];
120 #endif
121 #endif
122 pix += 8;
123 }
124 pix += line_size - 16;
125 }
127 }
128
129 /* draw the edges of width 'w' of an image of size width, height */
130 // FIXME: Check that this is OK for MPEG-4 interlaced.
132 int w, int h, int sides)
133 {
135 int i;
136
137 /* left and right */
138 for (i = 0; i <
height; i++) {
139 memset(ptr - w, ptr[0], w);
140 memset(ptr + width, ptr[width - 1], w);
142 }
143
144 /* top and bottom + corners */
145 buf -= w;
146 last_line = buf + (height - 1) * wrap;
148 for (i = 0; i < h; i++)
149 // top
150 memcpy(buf - (i + 1) *
wrap,
buf, width + w + w);
152 for (i = 0; i < h; i++)
153 // bottom
154 memcpy(last_line + (i + 1) *
wrap, last_line, width + w + w);
155 }
156
159 {
162
167
170
172
173 if (ARCH_ARM)
175 if (ARCH_PPC)
177 if (ARCH_X86)
179 }