FFmpeg
Data Structures | Macros | Functions | Variables
vsrc_life.c File Reference
#include "libavutil/file.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/lfg.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/random_seed.h"
#include "libavutil/avstring.h"
#include "avfilter.h"
#include "filters.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 void fill_picture_monoblack (AVFilterContext *ctx, AVFrame *picref)
 
static void fill_picture_rgb (AVFilterContext *ctx, AVFrame *picref)
 
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 int request_frame (AVFilterLink *outlink)
 
static int query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 

Variables

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

Detailed Description

life video source, based on John Conways' Life Game

Definition in file vsrc_life.c.

Macro Definition Documentation

◆ ALIVE_CELL

#define ALIVE_CELL   0xFF

Definition at line 76 of file vsrc_life.c.

◆ OFFSET

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

Definition at line 77 of file vsrc_life.c.

◆ FLAGS

Definition at line 78 of file vsrc_life.c.

◆ FAST_DIV255

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

Definition at line 186 of file vsrc_life.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( life  )

◆ parse_rule()

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

Definition at line 102 of file vsrc_life.c.

Referenced by init().

◆ fill_picture_monoblack()

static void fill_picture_monoblack ( AVFilterContext ctx,
AVFrame picref 
)
static

Definition at line 163 of file vsrc_life.c.

Referenced by init().

◆ fill_picture_rgb()

static void fill_picture_rgb ( AVFilterContext ctx,
AVFrame picref 
)
static

Definition at line 188 of file vsrc_life.c.

Referenced by init(), and query_formats().

◆ init_pattern_from_file()

static int init_pattern_from_file ( AVFilterContext ctx)
static

Definition at line 215 of file vsrc_life.c.

Referenced by init().

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 273 of file vsrc_life.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 329 of file vsrc_life.c.

◆ config_props()

static int config_props ( AVFilterLink outlink)
static

Definition at line 339 of file vsrc_life.c.

◆ evolve()

static void evolve ( AVFilterContext ctx)
static

Definition at line 352 of file vsrc_life.c.

Referenced by request_frame().

◆ request_frame()

static int request_frame ( AVFilterLink outlink)
static

Definition at line 407 of file vsrc_life.c.

◆ query_formats()

static int query_formats ( const AVFilterContext ctx,
AVFilterFormatsConfig **  cfg_in,
AVFilterFormatsConfig **  cfg_out 
)
static

Definition at line 425 of file vsrc_life.c.

Variable Documentation

◆ life_options

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, INT_MAX, FLAGS },
{ "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, FLAGS },
{ "rule", "set rule", OFFSET(rule_str), AV_OPT_TYPE_STRING, {.str = "B3/S23"}, 0, 0, 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_INT64, {.i64=-1}, -1, UINT32_MAX, FLAGS },
{ "seed", "set the seed for filling the initial grid randomly", OFFSET(random_seed), AV_OPT_TYPE_INT64, {.i64=-1}, -1, UINT32_MAX, FLAGS },
{ "stitch", "stitch boundaries", OFFSET(stitch), AV_OPT_TYPE_BOOL, {.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"}, 0, 0, FLAGS },
{ "death_color", "set death color", OFFSET(death_color), AV_OPT_TYPE_COLOR, {.str="black"}, 0, 0, FLAGS },
{ "mold_color", "set mold color", OFFSET( mold_color), AV_OPT_TYPE_COLOR, {.str="black"}, 0, 0, FLAGS },
{ NULL }
}

Definition at line 80 of file vsrc_life.c.

◆ life_outputs

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

Definition at line 438 of file vsrc_life.c.

◆ ff_vsrc_life

const 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,
}

Definition at line 447 of file vsrc_life.c.

config_props
static int config_props(AVFilterLink *outlink)
Definition: vsrc_life.c:339
OFFSET
#define OFFSET(x)
Definition: vsrc_life.c:77
M_PHI
#define M_PHI
Definition: mathematics.h:61
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
Definition: opt.h:315
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vsrc_life.c:329
w
uint8_t w
Definition: llviddspenc.c:38
FLAGS
#define FLAGS
Definition: vsrc_life.c:78
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
Definition: opt.h:267
AV_OPT_TYPE_INT64
@ AV_OPT_TYPE_INT64
Underlying C type is int64_t.
Definition: opt.h:263
query_formats
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition: vsrc_life.c:425
life_outputs
static const AVFilterPad life_outputs[]
Definition: vsrc_life.c:438
init
static av_cold int init(AVFilterContext *ctx)
Definition: vsrc_life.c:273
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
NULL
#define NULL
Definition: coverity.c:32
AV_OPT_TYPE_COLOR
@ AV_OPT_TYPE_COLOR
Underlying C type is uint8_t[4].
Definition: opt.h:323
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
Definition: opt.h:303
inputs
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: filter_design.txt:243
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
LifeContext
Definition: vsrc_life.c:41
FILTER_QUERY_FUNC2
#define FILTER_QUERY_FUNC2(func)
Definition: filters.h:239
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: vsrc_life.c:407
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
AV_OPT_TYPE_STRING
@ 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:276