FFmpeg
Loading...
Searching...
No Matches
vsrc_life.c
Go to the documentation of this file.
1/*
2 * Copyright (c) Stefano Sabatini 2010
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (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 GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @file
23 * life video source, based on John Conways' Life Game
24 */
25
26/* #define DEBUG */
27
28#include "libavutil/file.h"
29#include "libavutil/internal.h"
31#include "libavutil/lfg.h"
32#include "libavutil/mem.h"
33#include "libavutil/opt.h"
35#include "libavutil/avstring.h"
36#include "avfilter.h"
37#include "filters.h"
38#include "formats.h"
39#include "video.h"
40
41typedef struct LifeContext {
42 const AVClass *class;
43 int w, h;
44 char *filename;
45 char *rule_str;
46 uint8_t *file_buf;
48
49 /**
50 * The two grid state buffers.
51 *
52 * A 0xFF (ALIVE_CELL) value means the cell is alive (or new born), while
53 * the decreasing values from 0xFE to 0 means the cell is dead; the range
54 * of values is used for the slow death effect, or mold (0xFE means dead,
55 * 0xFD means very dead, 0xFC means very very dead... and 0x00 means
56 * definitely dead/mold).
57 */
58 uint8_t *buf[2];
59
60 uint8_t buf_idx;
61 uint16_t stay_rule; ///< encode the behavior for filled cells
62 uint16_t born_rule; ///< encode the behavior for empty cells
63 uint64_t pts;
67 int stitch;
68 int mold;
69 uint8_t life_color[4];
70 uint8_t death_color[4];
71 uint8_t mold_color[4];
75
76#define ALIVE_CELL 0xFF
77#define OFFSET(x) offsetof(LifeContext, x)
78#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
79
80static const AVOption life_options[] = {
81 { "filename", "set source file", OFFSET(filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
82 { "f", "set source file", OFFSET(filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
83 { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, FLAGS },
84 { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, FLAGS },
85 { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, FLAGS },
86 { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, FLAGS },
87 { "rule", "set rule", OFFSET(rule_str), AV_OPT_TYPE_STRING, {.str = "B3/S23"}, 0, 0, FLAGS },
88 { "random_fill_ratio", "set fill ratio for filling initial grid randomly", OFFSET(random_fill_ratio), AV_OPT_TYPE_DOUBLE, {.dbl=1/M_PHI}, 0, 1, FLAGS },
89 { "ratio", "set fill ratio for filling initial grid randomly", OFFSET(random_fill_ratio), AV_OPT_TYPE_DOUBLE, {.dbl=1/M_PHI}, 0, 1, FLAGS },
90 { "random_seed", "set the seed for filling the initial grid randomly", OFFSET(random_seed), AV_OPT_TYPE_INT64, {.i64=-1}, -1, UINT32_MAX, FLAGS },
91 { "seed", "set the seed for filling the initial grid randomly", OFFSET(random_seed), AV_OPT_TYPE_INT64, {.i64=-1}, -1, UINT32_MAX, FLAGS },
92 { "stitch", "stitch boundaries", OFFSET(stitch), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGS },
93 { "mold", "set mold speed for dead cells", OFFSET(mold), AV_OPT_TYPE_INT, {.i64=0}, 0, 0xFF, FLAGS },
94 { "life_color", "set life color", OFFSET( life_color), AV_OPT_TYPE_COLOR, {.str="white"}, 0, 0, FLAGS },
95 { "death_color", "set death color", OFFSET(death_color), AV_OPT_TYPE_COLOR, {.str="black"}, 0, 0, FLAGS },
96 { "mold_color", "set mold color", OFFSET( mold_color), AV_OPT_TYPE_COLOR, {.str="black"}, 0, 0, FLAGS },
97 { NULL }
98};
99
101
102static int parse_rule(uint16_t *born_rule, uint16_t *stay_rule,
103 const char *rule_str, void *log_ctx)
104{
105 char *tail;
106 const char *p = rule_str;
107 *born_rule = 0;
108 *stay_rule = 0;
109
110 if (strchr("bBsS", *p)) {
111 /* parse rule as a Born / Stay Alive code, see
112 * http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life */
113 do {
114 uint16_t *rule = (*p == 'b' || *p == 'B') ? born_rule : stay_rule;
115 p++;
116 while (*p >= '0' && *p <= '8') {
117 *rule += 1<<(*p - '0');
118 p++;
119 }
120 if (*p != '/')
121 break;
122 p++;
123 } while (strchr("bBsS", *p));
124
125 if (*p)
126 goto error;
127 } else {
128 /* parse rule as a number, expressed in the form STAY|(BORN<<9),
129 * where STAY and BORN encode the corresponding 9-bits rule */
130 long int rule = strtol(rule_str, &tail, 10);
131 if (*tail)
132 goto error;
133 *born_rule = ((1<<9)-1) & rule;
134 *stay_rule = rule >> 9;
135 }
136
137 return 0;
138
139error:
140 av_log(log_ctx, AV_LOG_ERROR, "Invalid rule code '%s' provided\n", rule_str);
141 return AVERROR(EINVAL);
142}
143
144#ifdef DEBUG
145static void show_life_grid(AVFilterContext *ctx)
146{
147 LifeContext *life = ctx->priv;
148 int i, j;
149
150 char *line = av_malloc(life->w + 1);
151 if (!line)
152 return;
153 for (i = 0; i < life->h; i++) {
154 for (j = 0; j < life->w; j++)
155 line[j] = life->buf[life->buf_idx][i*life->w + j] == ALIVE_CELL ? '@' : ' ';
156 line[j] = 0;
157 av_log(ctx, AV_LOG_DEBUG, "%3d: %s\n", i, line);
158 }
159 av_free(line);
160}
161#endif
162
164{
165 LifeContext *life = ctx->priv;
166 uint8_t *buf = life->buf[life->buf_idx];
167 int i, j, k;
168
169 /* fill the output picture with the old grid buffer */
170 for (i = 0; i < life->h; i++) {
171 uint8_t byte = 0;
172 uint8_t *p = picref->data[0] + i * picref->linesize[0];
173 for (k = 0, j = 0; j < life->w; j++) {
174 byte |= (buf[i*life->w+j] == ALIVE_CELL)<<(7-k++);
175 if (k==8 || j == life->w-1) {
176 k = 0;
177 *p++ = byte;
178 byte = 0;
179 }
180 }
181 }
182}
183
184// divide by 255 and round to nearest
185// apply a fast variant: (X+127)/255 = ((X+127)*257+257)>>16 = ((X+128)*257)>>16
186#define FAST_DIV255(x) ((((x) + 128) * 257) >> 16)
187
189{
190 LifeContext *life = ctx->priv;
191 uint8_t *buf = life->buf[life->buf_idx];
192 int i, j;
193
194 /* fill the output picture with the old grid buffer */
195 for (i = 0; i < life->h; i++) {
196 uint8_t *p = picref->data[0] + i * picref->linesize[0];
197 for (j = 0; j < life->w; j++) {
198 uint8_t v = buf[i*life->w + j];
199 if (life->mold && v != ALIVE_CELL) {
200 const uint8_t *c1 = life-> mold_color;
201 const uint8_t *c2 = life->death_color;
202 int death_age = FFMIN((0xff - v) * life->mold, 0xff);
203 *p++ = FAST_DIV255((c2[0] << 8) + ((int)c1[0] - (int)c2[0]) * death_age);
204 *p++ = FAST_DIV255((c2[1] << 8) + ((int)c1[1] - (int)c2[1]) * death_age);
205 *p++ = FAST_DIV255((c2[2] << 8) + ((int)c1[2] - (int)c2[2]) * death_age);
206 } else {
207 const uint8_t *c = v == ALIVE_CELL ? life->life_color : life->death_color;
208 AV_WB24(p, c[0]<<16 | c[1]<<8 | c[2]);
209 p += 3;
210 }
211 }
212 }
213}
214
216{
217 LifeContext *life = ctx->priv;
218 char *p;
219 int ret, i, i0, j, h = 0, w, max_w = 0;
220
221 if ((ret = av_file_map(life->filename, &life->file_buf, &life->file_bufsize,
222 0, ctx)) < 0)
223 return ret;
224 av_freep(&life->filename);
225
226 /* prescan file to get the number of lines and the maximum width */
227 w = 0;
228 for (i = 0; i < life->file_bufsize; i++) {
229 if (life->file_buf[i] == '\n') {
230 h++; max_w = FFMAX(w, max_w); w = 0;
231 } else {
232 w++;
233 }
234 }
235 av_log(ctx, AV_LOG_DEBUG, "h:%d max_w:%d\n", h, max_w);
236
237 if (life->w) {
238 if (max_w > life->w || h > life->h) {
240 "The specified size is %dx%d which cannot contain the provided file size of %dx%d\n",
241 life->w, life->h, max_w, h);
242 return AVERROR(EINVAL);
243 }
244 } else {
245 /* size was not specified, set it to size of the grid */
246 life->w = max_w;
247 life->h = h;
248 }
249
250 if (!(life->buf[0] = av_calloc(life->h * life->w, sizeof(*life->buf[0]))) ||
251 !(life->buf[1] = av_calloc(life->h * life->w, sizeof(*life->buf[1])))) {
252 av_freep(&life->buf[0]);
253 av_freep(&life->buf[1]);
254 return AVERROR(ENOMEM);
255 }
256
257 /* fill buf[0] */
258 p = life->file_buf;
259 for (i0 = 0, i = (life->h - h)/2; i0 < h; i0++, i++) {
260 for (j = (life->w - max_w)/2;; j++) {
261 av_log(ctx, AV_LOG_DEBUG, "%d:%d %c\n", i, j, *p == '\n' ? 'N' : *p);
262 if (*p == '\n') {
263 p++; break;
264 } else
265 life->buf[0][i*life->w + j] = av_isgraph(*(p++)) ? ALIVE_CELL : 0;
266 }
267 }
268 life->buf_idx = 0;
269
270 return 0;
271}
272
274{
275 LifeContext *life = ctx->priv;
276 int ret;
277
278 if (!life->w && !life->filename)
279 av_opt_set(life, "size", "320x240", 0);
280
281 if ((ret = parse_rule(&life->born_rule, &life->stay_rule, life->rule_str, ctx)) < 0)
282 return ret;
283
284 if (!life->mold && memcmp(life->mold_color, "\x00\x00\x00", 3))
286 "Mold color is set while mold isn't, ignoring the color.\n");
287
288 if (!life->filename) {
289 /* fill the grid randomly */
290 int i;
291
292 if (!(life->buf[0] = av_calloc(life->h * life->w, sizeof(*life->buf[0]))) ||
293 !(life->buf[1] = av_calloc(life->h * life->w, sizeof(*life->buf[1])))) {
294 av_freep(&life->buf[0]);
295 av_freep(&life->buf[1]);
296 return AVERROR(ENOMEM);
297 }
298 if (life->random_seed == -1)
300
301 av_lfg_init(&life->lfg, life->random_seed);
302
303 for (i = 0; i < life->w * life->h; i++) {
304 double r = (double)av_lfg_get(&life->lfg) / UINT32_MAX;
305 if (r <= life->random_fill_ratio)
306 life->buf[0][i] = ALIVE_CELL;
307 }
308 life->buf_idx = 0;
309 } else {
310 if ((ret = init_pattern_from_file(ctx)) < 0)
311 return ret;
312 }
313
314 if (life->mold || memcmp(life-> life_color, "\xff\xff\xff", 3)
315 || memcmp(life->death_color, "\x00\x00\x00", 3)) {
316 life->draw = fill_picture_rgb;
317 } else {
319 }
320
322 "s:%dx%d r:%d/%d rule:%s stay_rule:%d born_rule:%d stitch:%d seed:%"PRId64"\n",
323 life->w, life->h, life->frame_rate.num, life->frame_rate.den,
324 life->rule_str, life->stay_rule, life->born_rule, life->stitch,
325 life->random_seed);
326 return 0;
327}
328
330{
331 LifeContext *life = ctx->priv;
332
333 av_file_unmap(life->file_buf, life->file_bufsize);
334 av_freep(&life->rule_str);
335 av_freep(&life->buf[0]);
336 av_freep(&life->buf[1]);
337}
338
339static int config_props(AVFilterLink *outlink)
340{
341 LifeContext *life = outlink->src->priv;
342 FilterLink *l = ff_filter_link(outlink);
343
344 outlink->w = life->w;
345 outlink->h = life->h;
346 outlink->time_base = av_inv_q(life->frame_rate);
347 l->frame_rate = life->frame_rate;
348
349 return 0;
350}
351
353{
354 LifeContext *life = ctx->priv;
355 int i, j;
356 uint8_t *oldbuf = life->buf[ life->buf_idx];
357 uint8_t *newbuf = life->buf[!life->buf_idx];
358
359 enum { NW, N, NE, W, E, SW, S, SE };
360
361 /* evolve the grid */
362 for (i = 0; i < life->h; i++) {
363 for (j = 0; j < life->w; j++) {
364 int pos[8][2], n, alive, cell;
365 if (life->stitch) {
366 pos[NW][0] = (i-1) < 0 ? life->h-1 : i-1; pos[NW][1] = (j-1) < 0 ? life->w-1 : j-1;
367 pos[N ][0] = (i-1) < 0 ? life->h-1 : i-1; pos[N ][1] = j ;
368 pos[NE][0] = (i-1) < 0 ? life->h-1 : i-1; pos[NE][1] = (j+1) == life->w ? 0 : j+1;
369 pos[W ][0] = i ; pos[W ][1] = (j-1) < 0 ? life->w-1 : j-1;
370 pos[E ][0] = i ; pos[E ][1] = (j+1) == life->w ? 0 : j+1;
371 pos[SW][0] = (i+1) == life->h ? 0 : i+1; pos[SW][1] = (j-1) < 0 ? life->w-1 : j-1;
372 pos[S ][0] = (i+1) == life->h ? 0 : i+1; pos[S ][1] = j ;
373 pos[SE][0] = (i+1) == life->h ? 0 : i+1; pos[SE][1] = (j+1) == life->w ? 0 : j+1;
374 } else {
375 pos[NW][0] = (i-1) < 0 ? -1 : i-1; pos[NW][1] = (j-1) < 0 ? -1 : j-1;
376 pos[N ][0] = (i-1) < 0 ? -1 : i-1; pos[N ][1] = j ;
377 pos[NE][0] = (i-1) < 0 ? -1 : i-1; pos[NE][1] = (j+1) == life->w ? -1 : j+1;
378 pos[W ][0] = i ; pos[W ][1] = (j-1) < 0 ? -1 : j-1;
379 pos[E ][0] = i ; pos[E ][1] = (j+1) == life->w ? -1 : j+1;
380 pos[SW][0] = (i+1) == life->h ? -1 : i+1; pos[SW][1] = (j-1) < 0 ? -1 : j-1;
381 pos[S ][0] = (i+1) == life->h ? -1 : i+1; pos[S ][1] = j ;
382 pos[SE][0] = (i+1) == life->h ? -1 : i+1; pos[SE][1] = (j+1) == life->w ? -1 : j+1;
383 }
384
385 /* compute the number of live neighbor cells */
386 n = (pos[NW][0] == -1 || pos[NW][1] == -1 ? 0 : oldbuf[pos[NW][0]*life->w + pos[NW][1]] == ALIVE_CELL) +
387 (pos[N ][0] == -1 || pos[N ][1] == -1 ? 0 : oldbuf[pos[N ][0]*life->w + pos[N ][1]] == ALIVE_CELL) +
388 (pos[NE][0] == -1 || pos[NE][1] == -1 ? 0 : oldbuf[pos[NE][0]*life->w + pos[NE][1]] == ALIVE_CELL) +
389 (pos[W ][0] == -1 || pos[W ][1] == -1 ? 0 : oldbuf[pos[W ][0]*life->w + pos[W ][1]] == ALIVE_CELL) +
390 (pos[E ][0] == -1 || pos[E ][1] == -1 ? 0 : oldbuf[pos[E ][0]*life->w + pos[E ][1]] == ALIVE_CELL) +
391 (pos[SW][0] == -1 || pos[SW][1] == -1 ? 0 : oldbuf[pos[SW][0]*life->w + pos[SW][1]] == ALIVE_CELL) +
392 (pos[S ][0] == -1 || pos[S ][1] == -1 ? 0 : oldbuf[pos[S ][0]*life->w + pos[S ][1]] == ALIVE_CELL) +
393 (pos[SE][0] == -1 || pos[SE][1] == -1 ? 0 : oldbuf[pos[SE][0]*life->w + pos[SE][1]] == ALIVE_CELL);
394 cell = oldbuf[i*life->w + j];
395 alive = 1<<n & (cell == ALIVE_CELL ? life->stay_rule : life->born_rule);
396 if (alive) *newbuf = ALIVE_CELL; // new cell is alive
397 else if (cell) *newbuf = cell - 1; // new cell is dead and in the process of mold
398 else *newbuf = 0; // new cell is definitely dead
399 ff_dlog(ctx, "i:%d j:%d live_neighbors:%d cell:%d -> cell:%d\n", i, j, n, cell, *newbuf);
400 newbuf++;
401 }
402 }
403
404 life->buf_idx = !life->buf_idx;
405}
406
407static int request_frame(AVFilterLink *outlink)
408{
409 LifeContext *life = outlink->src->priv;
410 AVFrame *picref = ff_get_video_buffer(outlink, life->w, life->h);
411 if (!picref)
412 return AVERROR(ENOMEM);
413 picref->sample_aspect_ratio = (AVRational) {1, 1};
414 picref->pts = life->pts++;
415 picref->duration = 1;
416
417 life->draw(outlink->src, picref);
418 evolve(outlink->src);
419#ifdef DEBUG
420 show_life_grid(outlink->src);
421#endif
422 return ff_filter_frame(outlink, picref);
423}
424
426 AVFilterFormatsConfig **cfg_in,
427 AVFilterFormatsConfig **cfg_out)
428{
429 const LifeContext *life = ctx->priv;
430 const enum AVPixelFormat pix_fmts[] = {
433 };
434
435 return ff_set_pixel_formats_from_list2(ctx, cfg_in, cfg_out, pix_fmts);
436}
437
438static const AVFilterPad life_outputs[] = {
439 {
440 .name = "default",
441 .type = AVMEDIA_TYPE_VIDEO,
442 .request_frame = request_frame,
443 .config_props = config_props,
444 },
445};
446
448 .p.name = "life",
449 .p.description = NULL_IF_CONFIG_SMALL("Create life."),
450 .p.priv_class = &life_class,
451 .p.inputs = NULL,
452 .priv_size = sizeof(LifeContext),
453 .init = init,
454 .uninit = uninit,
457};
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition aeval.c:246
static int request_frame(AVFilterLink *outlink)
Definition af_aecho.c:272
#define N
Definition af_mcompand.c:54
const FFFilter ff_vsrc_life
Definition vsrc_life.c:447
#define E
Definition avdct.c:34
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition avfilter.c:1068
Main libavfilter public API header.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_WB16 unsigned int_TMPL byte
Definition bytestream.h:99
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define FLAGS
Definition cmdutils.c:598
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#define SE
Definition dvbsubenc.c:531
Misc file utilities.
#define S(s, c, i)
int ff_set_pixel_formats_from_list2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, const enum AVPixelFormat *fmts)
Definition formats.c:1162
#define SW(val, pdst)
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
Definition opt.h:302
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
Definition opt.h:314
@ AV_OPT_TYPE_INT64
Underlying C type is int64_t.
Definition opt.h:262
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
Definition opt.h:266
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275
@ AV_OPT_TYPE_COLOR
Underlying C type is uint8_t[4].
Definition opt.h:322
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_VERBOSE
Detailed information.
Definition log.h:226
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition rational.h:159
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
static av_const int av_isgraph(int c)
Locale-independent conversion of ASCII isgraph.
Definition avstring.h:210
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
Definition opt.c:887
#define r
Definition input.c:42
#define AV_WB24(p, d)
#define W(a, i, v)
Definition jpegls.h:119
static av_cold void uninit(AVBitStreamFilterContext *ctx)
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
Definition lfg.c:32
static unsigned int av_lfg_get(AVLFG *c)
Get the next random unsigned 32-bit number using an ALFG.
Definition lfg.h:53
#define FILTER_OUTPUTS(array)
Definition filters.h:265
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition filters.h:199
#define AVFILTER_DEFINE_CLASS(fname)
Definition filters.h:478
#define FILTER_QUERY_FUNC2(func)
Definition filters.h:241
#define av_cold
Definition attributes.h:117
void av_file_unmap(uint8_t *bufptr, size_t size)
Unmap or free the buffer bufptr created by av_file_map().
Definition file.c:142
int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, int log_offset, void *log_ctx)
Read the file with name filename, and put its content in a newly allocated buffer or map it with mmap...
Definition file.c:55
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static enum AVPixelFormat pix_fmts[]
Definition libkvazaar.c:296
uint8_t w
Definition llvidencdsp.c:39
#define FFMIN(a, b)
Definition macros.h:49
#define FFMAX(a, b)
Definition macros.h:47
#define M_PHI
Definition mathematics.h:61
void * av_calloc(size_t nmemb, size_t size)
Definition mem.c:264
Memory handling functions.
static const uint64_t c2
Definition murmur3.c:53
static const uint64_t c1
Definition murmur3.c:52
#define av_malloc(s)
Definition ops_static.c:52
AVOptions.
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition pixfmt.h:75
@ AV_PIX_FMT_MONOBLACK
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb.
Definition pixfmt.h:83
static int config_props(AVBitStreamFilterLink *link)
Definition source.c:181
unsigned int pos
Definition spdifenc.c:431
Describe the class of an AVClass context structure.
Definition log.h:76
An instance of a filter.
Definition avfilter.h:273
void * priv
private data for use by the filter
Definition avfilter.h:288
Lists of formats / etc.
Definition avfilter.h:120
A filter pad used for either input or output.
Definition filters.h:40
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition frame.h:574
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition frame.h:493
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
Definition frame.h:569
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition frame.h:517
int64_t duration
Duration of the frame, in the same units as pts.
Definition frame.h:820
Context structure for the Lagged Fibonacci PRNG.
Definition lfg.h:33
AVOption.
Definition opt.h:428
Rational number (pair of numerator and denominator).
Definition rational.h:58
int num
Numerator.
Definition rational.h:59
int den
Denominator.
Definition rational.h:60
uint16_t born_rule
encode the behavior for empty cells
Definition vsrc_life.c:62
uint8_t buf_idx
Definition vsrc_life.c:60
int64_t random_seed
Definition vsrc_life.c:66
uint64_t pts
Definition vsrc_life.c:63
AVLFG lfg
Definition vsrc_life.c:72
AVRational frame_rate
Definition vsrc_life.c:64
size_t file_bufsize
Definition vsrc_life.c:47
double random_fill_ratio
Definition vsrc_life.c:65
uint8_t * buf[2]
The two grid state buffers.
Definition vsrc_life.c:58
uint8_t life_color[4]
Definition vsrc_life.c:69
void(* draw)(AVFilterContext *, AVFrame *)
Definition vsrc_life.c:73
uint16_t stay_rule
encode the behavior for filled cells
Definition vsrc_life.c:61
char * filename
Definition vsrc_life.c:44
char * rule_str
Definition vsrc_life.c:45
uint8_t * file_buf
Definition vsrc_life.c:46
uint8_t death_color[4]
Definition vsrc_life.c:70
uint8_t mold_color[4]
Definition vsrc_life.c:71
In the ELBG jargon, a cell is the set of points that are closest to a codebook entry.
Definition elbg.c:39
#define av_free(p)
#define ff_dlog(a,...)
#define av_freep(p)
#define av_log(a,...)
static void error(const char *err)
static AVFormatContext * ctx
Definition movenc.c:49
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition video.c:89
static int init_pattern_from_file(AVFilterContext *ctx)
Definition vsrc_life.c:215
static int config_props(AVFilterLink *outlink)
Definition vsrc_life.c:339
static const AVOption life_options[]
Definition vsrc_life.c:80
static void evolve(AVFilterContext *ctx)
Definition vsrc_life.c:352
#define FAST_DIV255(x)
Definition vsrc_life.c:186
static void fill_picture_rgb(AVFilterContext *ctx, AVFrame *picref)
Definition vsrc_life.c:188
static int request_frame(AVFilterLink *outlink)
Definition vsrc_life.c:407
static int parse_rule(uint16_t *born_rule, uint16_t *stay_rule, const char *rule_str, void *log_ctx)
Definition vsrc_life.c:102
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition vsrc_life.c:425
static av_cold void uninit(AVFilterContext *ctx)
Definition vsrc_life.c:329
static void fill_picture_monoblack(AVFilterContext *ctx, AVFrame *picref)
Definition vsrc_life.c:163
#define ALIVE_CELL
Definition vsrc_life.c:76
#define OFFSET(x)
Definition vsrc_life.c:77
static const AVFilterPad life_outputs[]
Definition vsrc_life.c:438
static double c[64]