1 /*
2 * Copyright (c) 2002 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 /**
22 * @file
23 * MP test source, ported from MPlayer libmpcodecs/vf_test.c
24 */
25
34
37
51 };
52
60
61 #define OFFSET(x) offsetof(MPTestContext, x)
62 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
68
83 };
84
86
88
90 {
91 int i, j;
92
93 for (i = 0; i < 8; i++) {
94 double s = i == 0 ? sqrt(0.125) : 0.5;
95
96 for (j = 0; j < 8; j++)
97 c[i*8+j] = s*cos((
M_PI/8.0)*i*(j+0.5));
98 }
99 }
100
102 {
103 int i, j, k;
104 double tmp[64];
105
106 for (i = 0; i < 8; i++) {
107 for (j = 0; j < 8; j++) {
108 double sum = 0.0;
109
110 for (k = 0; k < 8; k++)
111 sum +=
c[k*8+j] * src[8*i+k];
112
113 tmp[8*i+j] = sum;
114 }
115 }
116
117 for (j = 0; j < 8; j++) {
118 for (i = 0; i < 8; i++) {
119 double sum = 0.0;
120
121 for (k = 0; k < 8; k++)
122 sum +=
c[k*8+i]*tmp[8*k+j];
123
124 dst[dst_linesize*i + j] = av_clip_uint8((int)floor(sum+0.5));
125 }
126 }
127 }
128
130 {
132
133 for (y = 0; y < h; y++)
134 for (x = 0; x < w; x++)
135 dst[x + y*dst_linesize] = color;
136 }
137
139 {
141
142 memset(src, 0, 64*sizeof(int));
144 if (amp)
145 src[freq] = amp;
146 idct(dst, dst_linesize, src);
147 }
148
150 {
151 if (cbp&1)
draw_basis(dst[0] , dst_linesize[0], amp, 1, dc);
152 if (cbp&2)
draw_basis(dst[0]+8 , dst_linesize[0], amp, 1, dc);
153 if (cbp&4)
draw_basis(dst[0]+ 8*dst_linesize[0], dst_linesize[0], amp, 1, dc);
154 if (cbp&8)
draw_basis(dst[0]+8+8*dst_linesize[0], dst_linesize[0], amp, 1, dc);
155 if (cbp&16)
draw_basis(dst[1] , dst_linesize[1], amp, 1, dc);
156 if (cbp&32)
draw_basis(dst[2] , dst_linesize[2], amp, 1, dc);
157 }
158
160 {
161 const int step =
FFMAX(256/(w*h/256), 1);
163
164 for (y = 0; y < h; y += 16) {
165 for (x = 0; x < w; x += 16) {
166 draw_dc(dst + x + y*dst_linesize, dst_linesize, color, 8, 8);
167 color += step;
168 }
169 }
170 }
171
173 {
175
176 for (y = 0; y < 8*16; y += 16) {
177 for (x = 0; x < 8*16; x += 16) {
178 draw_basis(dst + x + y*dst_linesize, dst_linesize, 4*(96+off), freq, 128*8);
179 freq++;
180 }
181 }
182 }
183
185 {
187
188 for (y = 0; y < 16*16; y += 16) {
189 for (x = 0; x < 16*16; x += 16) {
190 draw_basis(dst + x + y*dst_linesize, dst_linesize, 4*amp, 1, 128*8);
191 amp++;
192 }
193 }
194 }
195
197 {
199
200 for (y = 0; y < 16*8; y += 16) {
201 for (x = 0; x < 16*8; x += 16) {
203 dst1[0] = dst[0] + x*2 + y*2*dst_linesize[0];
204 dst1[1] = dst[1] + x + y* dst_linesize[1];
205 dst1[2] = dst[2] + x + y* dst_linesize[2];
206
207 draw_cbp(dst1, dst_linesize, cbp, (64+off)*4, 128*8);
208 cbp++;
209 }
210 }
211 }
212
214 {
216
217 for (y = 0; y < 16*16; y++) {
218 if (y&16)
219 continue;
220 for (x = 0; x < 16*16; x++)
221 dst[x + y*dst_linesize] = x + off*8/(y/32+1);
222 }
223 }
224
226 {
228
229 for (y = off; y < 16*16; y += 16) {
230 for (x = off; x < 16*16; x += 16) {
231 draw_dc(dst + x + y*dst_linesize, dst_linesize, ((x+y)&16) ? color : -color, 16, 16);
232 color++;
233 }
234 }
235 }
236
238 {
240
241 for (y = 0; y < 16*16; y++) {
242 for (x = 0; x < 16*16; x++) {
243 double d = sqrt((x-8*16)*(x-8*16) + (y-8*16)*(y-8*16));
244 double r = d/20 - (int)(d/20);
245 if (r < off/30.0) {
246 dst[x + y*dst_linesize] = 255;
247 dst[x + y*dst_linesize+256] = 0;
248 } else {
249 dst[x + y*dst_linesize] = x;
250 dst[x + y*dst_linesize+256] = x;
251 }
252 }
253 }
254 }
255
257 {
259
263
268
269 return 0;
270 }
271
273 {
277
280
284
285 return 0;
286 }
287
289 {
292 };
293
295 return 0;
296 }
297
299 {
306 int i;
307
311 if (!picref)
313 picref->
pts = test->
pts++;
314
315 // clean image
316 for (i = 0; i < h; i++)
318 for (i = 0; i < ch; i++) {
319 memset(picref->
data[1] + i*picref->
linesize[1], 128, cw);
320 memset(picref->
data[2] + i*picref->
linesize[2], 128, cw);
321 }
322
323 if (tt ==
TEST_ALL && frame%30)
/* draw a black frame at the beginning of each test */
325
326 switch (tt) {
337 }
338
340 }
341
343 {
348 },
350 };
351
356 .priv_class = &mptestsrc_class,
361 };