vsrc_life.c File Reference

life video source, based on John Conways' Life Game More...

#include "libavutil/file.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/lfg.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "libavutil/random_seed.h"
#include "libavutil/avstring.h"
#include "avfilter.h"
#include "internal.h"
#include "formats.h"
#include "video.h"
Include dependency graph for vsrc_life.c:

Go to the source code of this file.

Data Structures

struct  LifeContext
 

Macros

#define ALIVE_CELL   0xFF
 
#define OFFSET(x)   offsetof(LifeContext, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define PARSE_COLOR(name)
 
#define FAST_DIV255(x)   ((((x) + 128) * 257) >> 16)
 

Functions

 AVFILTER_DEFINE_CLASS (life)
 
static int parse_rule (uint16_t *born_rule, uint16_t *stay_rule, const char *rule_str, void *log_ctx)
 
static int init_pattern_from_file (AVFilterContext *ctx)
 
static int init (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int config_props (AVFilterLink *outlink)
 
static void evolve (AVFilterContext *ctx)
 
static void fill_picture_monoblack (AVFilterContext *ctx, AVFrame *picref)
 
static void fill_picture_rgb (AVFilterContext *ctx, AVFrame *picref)
 
static int request_frame (AVFilterLink *outlink)
 
static int query_formats (AVFilterContext *ctx)
 

Variables

static const AVOption life_options []
 
static const AVFilterPad life_outputs []
 
AVFilter avfilter_vsrc_life
 

Detailed Description

life video source, based on John Conways' Life Game

Definition in file vsrc_life.c.

Macro Definition Documentation

#define ALIVE_CELL   0xFF
#define FAST_DIV255 (   x)    ((((x) + 128) * 257) >> 16)

Definition at line 384 of file vsrc_life.c.

Referenced by fill_picture_rgb().

Definition at line 80 of file vsrc_life.c.

#define OFFSET (   x)    offsetof(LifeContext, x)

Definition at line 79 of file vsrc_life.c.

#define PARSE_COLOR (   name)
Value:
do { \
if ((ret = av_parse_color(life->name ## _color, life->name ## _color_str, -1, ctx))) { \
av_log(ctx, AV_LOG_ERROR, "Invalid " #name " color '%s'\n", \
life->name ## _color_str); \
} \
av_freep(&life->name ## _color_str); \
} while (0)
const char * name
Definition: avisynth_c.h:675
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
Definition: mem.c:198
initialize output if(nPeaks >3)%at least 3 peaks in spectrum for trying to find f0 nf0peaks
int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen, void *log_ctx)
Put the RGBA values that correspond to color_string in rgba_color.
Definition: parseutils.c:337
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:246
ret
Definition: avfilter.c:821
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:148
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame This method is called when a frame is wanted on an output For an it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return it should return

Referenced by init().

Function Documentation

AVFILTER_DEFINE_CLASS ( life  )
static int config_props ( AVFilterLink outlink)
static

Definition at line 295 of file vsrc_life.c.

static void evolve ( AVFilterContext ctx)
static

Definition at line 306 of file vsrc_life.c.

Referenced by request_frame().

static void fill_picture_monoblack ( AVFilterContext ctx,
AVFrame picref 
)
static

Definition at line 361 of file vsrc_life.c.

Referenced by query_formats().

static void fill_picture_rgb ( AVFilterContext ctx,
AVFrame picref 
)
static

Definition at line 386 of file vsrc_life.c.

Referenced by query_formats().

static int init ( AVFilterContext ctx)
static

Definition at line 223 of file vsrc_life.c.

static int init_pattern_from_file ( AVFilterContext ctx)
static

Definition at line 165 of file vsrc_life.c.

Referenced by init().

static int parse_rule ( uint16_t *  born_rule,
uint16_t *  stay_rule,
const char *  rule_str,
void log_ctx 
)
static

Definition at line 104 of file vsrc_life.c.

Referenced by init().

static int query_formats ( AVFilterContext ctx)
static

Definition at line 430 of file vsrc_life.c.

static int request_frame ( AVFilterLink outlink)
static

Definition at line 413 of file vsrc_life.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 285 of file vsrc_life.c.

Variable Documentation

AVFilter avfilter_vsrc_life
Initial value:
= {
.name = "life",
.description = NULL_IF_CONFIG_SMALL("Create life."),
.priv_size = sizeof(LifeContext),
.init = init,
.priv_class = &life_class,
}
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:117
static const AVFilterPad life_outputs[]
Definition: vsrc_life.c:446
static int query_formats(AVFilterContext *ctx)
Definition: vsrc_life.c:430
static av_cold void uninit(AVFilterContext *ctx)
Definition: vsrc_life.c:285
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int init(AVFilterContext *ctx)
Definition: vsrc_life.c:223
NULL
Definition: eval.c:55
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs

Definition at line 456 of file vsrc_life.c.

const AVOption life_options[]
static
Initial value:
= {
{ "filename", "set source file", OFFSET(filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
{ "f", "set source file", OFFSET(filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
{ "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, FLAGS },
{ "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, FLAGS },
{ "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
{ "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
{ "rule", "set rule", OFFSET(rule_str), AV_OPT_TYPE_STRING, {.str = "B3/S23"}, CHAR_MIN, CHAR_MAX, FLAGS },
{ "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 },
{ "ratio", "set fill ratio for filling initial grid randomly", OFFSET(random_fill_ratio), AV_OPT_TYPE_DOUBLE, {.dbl=1/M_PHI}, 0, 1, FLAGS },
{ "random_seed", "set the seed for filling the initial grid randomly", OFFSET(random_seed), AV_OPT_TYPE_INT, {.i64=-1}, -1, UINT32_MAX, FLAGS },
{ "seed", "set the seed for filling the initial grid randomly", OFFSET(random_seed), AV_OPT_TYPE_INT, {.i64=-1}, -1, UINT32_MAX, FLAGS },
{ "stitch", "stitch boundaries", OFFSET(stitch), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS },
{ "mold", "set mold speed for dead cells", OFFSET(mold), AV_OPT_TYPE_INT, {.i64=0}, 0, 0xFF, FLAGS },
{ "life_color", "set life color", OFFSET( life_color_str), AV_OPT_TYPE_STRING, {.str="white"}, CHAR_MIN, CHAR_MAX, FLAGS },
{ "death_color", "set death color", OFFSET(death_color_str), AV_OPT_TYPE_STRING, {.str="black"}, CHAR_MIN, CHAR_MAX, FLAGS },
{ "mold_color", "set mold color", OFFSET( mold_color_str), AV_OPT_TYPE_STRING, {.str="black"}, CHAR_MIN, CHAR_MAX, FLAGS },
{ NULL },
}
output residual component w
#define OFFSET(x)
Definition: vsrc_life.c:79
#define FLAGS
Definition: vsrc_life.c:80
NULL
Definition: eval.c:55
#define M_PHI
Definition: mathematics.h:43
offset must point to AVRational
Definition: opt.h:233
offset must point to two consecutive integers
Definition: opt.h:230

Definition at line 82 of file vsrc_life.c.

const AVFilterPad life_outputs[]
static
Initial value:
= {
{
.name = "default",
.request_frame = request_frame,
.config_props = config_props,
},
{ NULL}
}
static int request_frame(AVFilterLink *outlink)
Definition: vsrc_life.c:413
static int config_props(AVFilterLink *outlink)
Definition: vsrc_life.c:295
NULL
Definition: eval.c:55

Definition at line 446 of file vsrc_life.c.