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"
30
33 {
35 unsigned int sum = 0;
36
37 for (
i = 0;
i < 8 * 8;
i++) {
44
45 sum += (
w *
b) * (
w *
b) >> 4;
46 }
47 return sum >> 2;
48 }
49
51 {
53
54 for (
i = 0;
i < 8 * 8;
i++)
58 }
59
60 static int pix_sum_c(
const uint8_t *pix,
int line_size)
61 {
63
64 for (
i = 0;
i < 16;
i++) {
65 for (j = 0; j < 16; j += 8) {
74 pix += 8;
75 }
76 pix += line_size - 16;
77 }
79 }
80
82 {
85
86 for (
i = 0;
i < 16;
i++) {
87 for (j = 0; j < 16; j += 8) {
88 #if HAVE_FAST_64BIT
89 register uint64_t x = *(uint64_t *) pix;
91 s += sq[(x >> 8) & 0xff];
92 s += sq[(x >> 16) & 0xff];
93 s += sq[(x >> 24) & 0xff];
94 s += sq[(x >> 32) & 0xff];
95 s += sq[(x >> 40) & 0xff];
96 s += sq[(x >> 48) & 0xff];
97 s += sq[(x >> 56) & 0xff];
98 #else
99 register uint32_t x = *(uint32_t *) pix;
101 s += sq[(x >> 8) & 0xff];
102 s += sq[(x >> 16) & 0xff];
103 s += sq[(x >> 24) & 0xff];
104 x = *(uint32_t *) (pix + 4);
106 s += sq[(x >> 8) & 0xff];
107 s += sq[(x >> 16) & 0xff];
108 s += sq[(x >> 24) & 0xff];
109 #endif
110 pix += 8;
111 }
112 pix += line_size - 16;
113 }
115 }
116
117 /* draw the edges of width 'w' of an image of size width, height */
118 // FIXME: Check that this is OK for MPEG-4 interlaced.
120 int w,
int h,
int sides)
121 {
122 uint8_t *ptr = buf, *last_line;
124
125 /* left and right */
127 memset(ptr -
w, ptr[0],
w);
130 }
131
132 /* top and bottom + corners */
136 for (
i = 0;
i <
h;
i++)
137 // top
140 for (
i = 0;
i <
h;
i++)
141 // bottom
142 memcpy(last_line + (
i + 1) *
wrap, last_line,
width +
w +
w);
143 }
144
145 /* 2x2 -> 1x1 */
147 const uint8_t *
src,
int src_wrap,
149 {
151 const uint8_t *
s1, *
s2;
153
159 d[0] = (
s1[0] +
s1[1] +
s2[0] +
s2[1] + 2) >> 2;
160 d[1] = (
s1[2] +
s1[3] +
s2[2] +
s2[3] + 2) >> 2;
161 d[2] = (
s1[4] +
s1[5] +
s2[4] +
s2[5] + 2) >> 2;
162 d[3] = (
s1[6] +
s1[7] +
s2[6] +
s2[7] + 2) >> 2;
166 }
168 d[0] = (
s1[0] +
s1[1] +
s2[0] +
s2[1] + 2) >> 2;
172 }
174 dst += dst_wrap;
175 }
176 }
177
178 /* 4x4 -> 1x1 */
180 const uint8_t *
src,
int src_wrap,
182 {
186
197 s4[0] +
s4[1] +
s4[2] +
s4[3] + 8) >> 4;
203 }
205 dst += dst_wrap;
206 }
207 }
208
209 /* 8x8 -> 1x1 */
211 const uint8_t *
src,
int src_wrap,
213 {
215
219 for (
i = 0;
i < 8;
i++) {
223 }
224 *(dst++) = (
tmp + 32) >> 6;
225 src += 8 - 8 * src_wrap;
226 }
228 dst += dst_wrap -
width;
229 }
230 }
231
234 {
237
242
245
247
248 #if ARCH_ARM
250 #elif ARCH_PPC
252 #elif ARCH_X86
254 #elif ARCH_MIPS
256 #endif
257 }