| 82 | } |
| 83 | |
| 84 | static av_cold int init(AVFilterContext *ctx) |
| 85 | { |
| 86 | StackContext *s = ctx->priv; |
| 87 | int i, ret; |
| 88 | |
| 89 | if (!strcmp(ctx->filter->name, "vstack")) |
| 90 | s->is_vertical = 1; |
| 91 | |
| 92 | if (!strcmp(ctx->filter->name, "hstack")) |
| 93 | s->is_horizontal = 1; |
| 94 | |
| 95 | if (!strcmp(ctx->filter->name, "xstack")) { |
| 96 | int is_grid; |
| 97 | if (strcmp(s->fillcolor_str, "none") && |
| 98 | av_parse_color(s->fillcolor, s->fillcolor_str, -1, ctx) >= 0) { |
| 99 | s->fillcolor_enable = 1; |
| 100 | } else { |
| 101 | s->fillcolor_enable = 0; |
| 102 | } |
| 103 | is_grid = s->nb_grid_rows && s->nb_grid_columns; |
| 104 | if (s->layout && is_grid) { |
| 105 | av_log(ctx, AV_LOG_ERROR, "Both layout and grid were specified. Only one is allowed.\n"); |
| 106 | return AVERROR(EINVAL); |
| 107 | } |
| 108 | if (!s->layout && !is_grid) { |
| 109 | if (s->nb_inputs == 2) { |
| 110 | s->nb_grid_rows = 1; |
| 111 | s->nb_grid_columns = 2; |
| 112 | is_grid = 1; |
| 113 | } else { |
| 114 | av_log(ctx, AV_LOG_ERROR, "No layout or grid specified.\n"); |
| 115 | return AVERROR(EINVAL); |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | if (is_grid) |
| 120 | s->nb_inputs = s->nb_grid_rows * s->nb_grid_columns; |
| 121 | } |
| 122 | |
| 123 | s->frames = av_calloc(s->nb_inputs, sizeof(*s->frames)); |
| 124 | if (!s->frames) |
| 125 | return AVERROR(ENOMEM); |
| 126 | |
| 127 | s->items = av_calloc(s->nb_inputs, sizeof(*s->items)); |
| 128 | if (!s->items) |
| 129 | return AVERROR(ENOMEM); |
| 130 | |
| 131 | for (i = 0; i < s->nb_inputs; i++) { |
| 132 | AVFilterPad pad = { 0 }; |
| 133 | |
| 134 | pad.type = AVMEDIA_TYPE_VIDEO; |
| 135 | pad.name = av_asprintf("input%d", i); |
| 136 | if (!pad.name) |
| 137 | return AVERROR(ENOMEM); |
| 138 | |
| 139 | if ((ret = ff_append_inpad_free_name(ctx, &pad)) < 0) |
| 140 | return ret; |
| 141 | } |
nothing calls this directly
no test coverage detected