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)
171 av_log(ctx,
AV_LOG_ERROR,
"Only one of the filename or pattern options can be used\n");
178 }
else if (cellauto->
pattern) {
193 for (i = 0; i < cellauto->
w; i++) {
195 if (r <= cellauto->random_fill_ratio)
196 cellauto->
buf[i] = 1;
201 "s:%dx%d r:%d/%d rule:%d stitch:%d scroll:%d full:%d seed:%u\n",
221 outlink->
w = cellauto->
w;
222 outlink->
h = cellauto->
h;
239 for (i = 0; i < cellauto->
w; i++) {
241 pos[NW] = i-1 < 0 ? cellauto->
w-1 : i-1;
243 pos[NE] = i+1 == cellauto->
w ? 0 : i+1;
244 v = prev_row[pos[NW]]<<2 | prev_row[pos[
N]]<<1 | prev_row[pos[NE]];
247 v|= i-1 >= 0 ? prev_row[i-1]<<2 : 0;
248 v|= prev_row[i ]<<1 ;
249 v|= i+1 < cellauto->
w ? prev_row[i+1] : 0;
251 row[i] = !!(cellauto->
rule & (1<<
v));
252 av_dlog(ctx,
"i:%d context:%c%c%c -> cell:%d\n", i,
253 v&4?
'@':
' ', v&2?
'@':
' ', v&1?
'@':
' ', row[i]);
262 int i, j, k, row_idx = 0;
270 for (i = 0; i < cellauto->
h; i++) {
272 uint8_t *row = cellauto->
buf + row_idx*cellauto->
w;
274 for (k = 0, j = 0; j < cellauto->
w; j++) {
275 byte |= row[j]<<(7-k++);
276 if (k==8 || j == cellauto->
w-1) {
282 row_idx = (row_idx + 1) % cellauto->
h;
296 for (i = 0; i < cellauto->
h-1; i++)
302 picref->
pts = cellauto->
pts++;
305 show_cellauto_row(outlink->
src);
329 .description =
NULL_IF_CONFIG_SMALL(
"Create pattern generated by an elementary cellular automaton."),
331 .priv_class = &cellauto_class,