60 #define OFFSET(x) offsetof(CellAutoContext, x)
61 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
75 {
"random_seed",
"set the seed for filling the initial grid randomly",
OFFSET(random_seed),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, UINT32_MAX,
FLAGS },
76 {
"seed",
"set the seed for filling the initial grid randomly",
OFFSET(random_seed),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, UINT32_MAX,
FLAGS },
96 for (i = 0; i < cellauto->
w; i++)
97 line[i] = row[i] ?
'@' :
' ';
114 if (w > cellauto->
w) {
116 "The specified width is %d which cannot contain the provided string width of %d\n",
123 cellauto->
h = (double)cellauto->
w *
M_PHI;
132 for (i = (cellauto->
w - w)/2;; i++) {
134 if (*p ==
'\n' || !*p)
169 cellauto->
class = &cellauto_class;
187 av_log(ctx,
AV_LOG_ERROR,
"Only one of the filename or pattern options can be used\n");
194 }
else if (cellauto->
pattern) {
209 for (i = 0; i < cellauto->
w; i++) {
211 if (r <= cellauto->random_fill_ratio)
212 cellauto->
buf[i] = 1;
217 "s:%dx%d r:%d/%d rule:%d stitch:%d scroll:%d full:%d seed:%u\n",
218 cellauto->
w, cellauto->
h, frame_rate.
num, frame_rate.
den,
237 outlink->
w = cellauto->
w;
238 outlink->
h = cellauto->
h;
255 for (i = 0; i < cellauto->
w; i++) {
257 pos[NW] = i-1 < 0 ? cellauto->
w-1 : i-1;
259 pos[NE] = i+1 == cellauto->
w ? 0 : i+1;
260 v = prev_row[pos[NW]]<<2 | prev_row[pos[
N]]<<1 | prev_row[pos[NE]];
263 v|= i-1 >= 0 ? prev_row[i-1]<<2 : 0;
264 v|= prev_row[i ]<<1 ;
265 v|= i+1 < cellauto->
w ? prev_row[i+1] : 0;
267 row[i] = !!(cellauto->
rule & (1<<
v));
268 av_dlog(ctx,
"i:%d context:%c%c%c -> cell:%d\n", i,
269 v&4?
'@':
' ', v&2?
'@':
' ', v&1?
'@':
' ', row[i]);
278 int i, j, k, row_idx = 0;
286 for (i = 0; i < cellauto->
h; i++) {
288 uint8_t *row = cellauto->
buf + row_idx*cellauto->
w;
290 for (k = 0, j = 0; j < cellauto->
w; j++) {
291 byte |= row[j]<<(7-k++);
292 if (k==8 || j == cellauto->
w-1) {
298 row_idx = (row_idx + 1) % cellauto->
h;
311 for (i = 0; i < cellauto->
h-1; i++)
317 picref->
pts = cellauto->
pts++;
321 show_cellauto_row(outlink->
src);
347 .description =
NULL_IF_CONFIG_SMALL(
"Create pattern generated by an elementary cellular automaton."),
354 .priv_class = &cellauto_class,