59 #define OFFSET(x) offsetof(CellAutoContext, x)
60 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
74 {
"random_seed",
"set the seed for filling the initial grid randomly",
OFFSET(random_seed),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, UINT32_MAX,
FLAGS },
75 {
"seed",
"set the seed for filling the initial grid randomly",
OFFSET(random_seed),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, UINT32_MAX,
FLAGS },
95 for (i = 0; i < cellauto->
w; i++)
96 line[i] = row[i] ?
'@' :
' ';
113 if (w > cellauto->
w) {
115 "The specified width is %d which cannot contain the provided string width of %d\n",
122 cellauto->
h = (double)cellauto->
w *
M_PHI;
131 for (i = (cellauto->
w - w)/2;; i++) {
133 if (*p ==
'\n' || !*p)
136 cellauto->
buf[i] = !!isgraph(*(p++));
168 cellauto->
class = &cellauto_class;
186 av_log(ctx,
AV_LOG_ERROR,
"Only one of the filename or pattern options can be used\n");
193 }
else if (cellauto->
pattern) {
208 for (i = 0; i < cellauto->
w; i++) {
210 if (r <= cellauto->random_fill_ratio)
211 cellauto->
buf[i] = 1;
216 "s:%dx%d r:%d/%d rule:%d stitch:%d scroll:%d full:%d seed:%u\n",
217 cellauto->
w, cellauto->
h, frame_rate.
num, frame_rate.
den,
236 outlink->
w = cellauto->
w;
237 outlink->
h = cellauto->
h;
254 for (i = 0; i < cellauto->
w; i++) {
256 pos[NW] = i-1 < 0 ? cellauto->
w-1 : i-1;
258 pos[NE] = i+1 == cellauto->
w ? 0 : i+1;
259 v = prev_row[pos[NW]]<<2 | prev_row[pos[
N]]<<1 | prev_row[pos[NE]];
262 v|= i-1 >= 0 ? prev_row[i-1]<<2 : 0;
263 v|= prev_row[i ]<<1 ;
264 v|= i+1 < cellauto->
w ? prev_row[i+1] : 0;
266 row[i] = !!(cellauto->
rule & (1<<v));
267 av_dlog(ctx,
"i:%d context:%c%c%c -> cell:%d\n", i,
268 v&4?
'@':
' ', v&2?
'@':
' ', v&1?
'@':
' ', row[i]);
277 int i, j, k, row_idx = 0;
285 for (i = 0; i < cellauto->
h; i++) {
287 uint8_t *row = cellauto->
buf + row_idx*cellauto->
w;
289 for (k = 0, j = 0; j < cellauto->
w; j++) {
290 byte |= row[j]<<(7-k++);
291 if (k==8 || j == cellauto->
w-1) {
297 row_idx = (row_idx + 1) % cellauto->
h;
310 for (i = 0; i < cellauto->
h-1; i++)
316 picref->
pts = cellauto->
pts++;
320 show_cellauto_row(outlink->
src);
346 .description =
NULL_IF_CONFIG_SMALL(
"Create pattern generated by an elementary cellular automaton."),
353 .priv_class = &cellauto_class,