1 /*
2 * Generate a synthetic YUV video sequence suitable for codec testing.
3 * NOTE: No floats are used to guarantee bitexact output.
4 *
5 * Copyright (c) 2002 Fabrice Bellard
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 #include <stdlib.h>
25 #include <stdint.h>
26 #include <stdio.h>
27
29
30 static unsigned int myrnd(
unsigned int *seed_ptr,
int n)
31 {
33
36 if (n == 256) {
38 } else {
40 }
43 }
44
48
50 #define FRAC_ONE (1 << FRAC_BITS)
51
52 /* cosine approximate with 1-x^2 */
54 {
55 int v, neg;
59 neg = 0;
61 neg = -1;
63 }
65 v = (v ^ neg) - neg;
66 return v;
67 }
68
70
75
77
78 static unsigned int seed = 1;
79
81 {
82 int r,
g,
b, x, y,
i, dx, dy, x1, y1;
83 unsigned int seed1;
84
85 if (num == 0) {
94 }
95 }
96
97 /* first a moving background with gradients */
98 /* test motion estimation */
101 for (y = 0; y <
h; y++) {
102 for (x = 0; x <
w; x++) {
109 }
110 }
111
112 /* then some noise with very high intensity to test saturation */
113 seed1 = num;
114 for (y = 0; y <
NOISE_W; y++) {
115 for (x = 0; x <
NOISE_W; x++) {
120 }
121 }
122
123 /* then moving objects */
127 for (y = 0; y < p->
h; y++) {
128 for (x = 0; x < p->
w; x++) {
132 /* add a per object noise */
137 }
138 }
141 }
142 }
143
145 {
146 printf(
"usage: %s file|dir [w=%i] [h=%i]\n"
147 "generate a test video stream\n",
149 exit(1);
150 }
151
152 int main(
int argc,
char **argv)
153 {
155 char buf[1024];
156 int isdir = 0;
157
158 if (argc < 2 || argc > 4) {
160 }
161
162 if (!freopen(argv[1], "wb", stdout))
163 isdir = 1;
164
166 if(argc > 2) {
169 }
171 if(argc > 3) {
174 }
175
180
183 if (isdir) {
184 snprintf(buf,
sizeof(buf),
"%s%02d.pgm", argv[1],
i);
186 } else {
188 }
189 }
190
192 return 0;
193 }