FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
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"

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 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 av_cold 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 ff_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 OFFSET (   x)    offsetof(LifeContext, x)

Definition at line 76 of file vsrc_life.c.

Definition at line 77 of file vsrc_life.c.

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

Definition at line 368 of file vsrc_life.c.

Referenced by fill_picture_rgb().

Function Documentation

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

Definition at line 101 of file vsrc_life.c.

Referenced by init().

static int init_pattern_from_file ( AVFilterContext ctx)
static

Definition at line 162 of file vsrc_life.c.

Referenced by init().

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 220 of file vsrc_life.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 269 of file vsrc_life.c.

static int config_props ( AVFilterLink outlink)
static

Definition at line 279 of file vsrc_life.c.

static void evolve ( AVFilterContext ctx)
static

Definition at line 290 of file vsrc_life.c.

Referenced by request_frame().

static void fill_picture_monoblack ( AVFilterContext ctx,
AVFrame picref 
)
static

Definition at line 345 of file vsrc_life.c.

Referenced by query_formats().

static void fill_picture_rgb ( AVFilterContext ctx,
AVFrame picref 
)
static

Definition at line 370 of file vsrc_life.c.

Referenced by query_formats().

static int request_frame ( AVFilterLink outlink)
static

Definition at line 397 of file vsrc_life.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 414 of file vsrc_life.c.

Variable Documentation

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), AV_OPT_TYPE_COLOR, {.str="white"}, CHAR_MIN, CHAR_MAX, FLAGS },
{ "death_color", "set death color", OFFSET(death_color), AV_OPT_TYPE_COLOR, {.str="black"}, CHAR_MIN, CHAR_MAX, FLAGS },
{ "mold_color", "set mold color", OFFSET( mold_color), AV_OPT_TYPE_COLOR, {.str="black"}, CHAR_MIN, CHAR_MAX, FLAGS },
{ NULL }
}

Definition at line 79 of file vsrc_life.c.

const AVFilterPad life_outputs[]
static
Initial value:
= {
{
.name = "default",
.request_frame = request_frame,
.config_props = config_props,
},
{ NULL}
}

Definition at line 430 of file vsrc_life.c.

AVFilter ff_vsrc_life
Initial value:
= {
.name = "life",
.description = NULL_IF_CONFIG_SMALL("Create life."),
.priv_size = sizeof(LifeContext),
.priv_class = &life_class,
.init = init,
.inputs = NULL,
}

Definition at line 440 of file vsrc_life.c.