The common code will be used in QSV based stack filters.
Showing the changes to libavfilter (3 of 3 files). Show all
Unified · Split
| @@ -0,0 +1,355 @@ | |||
| 1 | /* | ||
| 2 | * This file is part of FFmpeg. | ||
| 3 | * | ||
| 4 | * FFmpeg is free software; you can redistribute it and/or | ||
| 5 | * modify it under the terms of the GNU Lesser General Public | ||
| 6 | * License as published by the Free Software Foundation; either | ||
| 7 | * version 2.1 of the License, or (at your option) any later version. | ||
| 8 | * | ||
| 9 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 12 | * Lesser General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU Lesser General Public | ||
| 15 | * License along with FFmpeg; if not, write to the Free Software | ||
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 17 | */ | ||
| 18 | |||
| 19 | #define OFFSET(x) offsetof(StackHWContext, x) | ||
| 20 | #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM) | ||
| 21 | |||
| 22 | #define SET_OUTPUT_REGION(region, rx, ry, rw, rh) do { \ | ||
| 23 | region->x = rx; \ | ||
| 24 | region->y = ry; \ | ||
| 25 | region->width = rw; \ | ||
| 26 | region->height = rh; \ | ||
| 27 | } while (0) | ||
| 28 | |||
| 29 | static int init_framesync(AVFilterContext *avctx) | ||
| 30 | { | ||
| 31 | StackBaseContext *sctx = avctx->priv; | ||
| 32 | int ret; | ||
| 33 | |||
| 34 | ret = ff_framesync_init(&sctx->fs, avctx, avctx->nb_inputs); | ||
| 35 | if (ret < 0) | ||
| 36 | return ret; | ||
| 37 | |||
| 38 | sctx->fs.on_event = process_frame; | ||
| 39 | sctx->fs.opaque = sctx; | ||
| 40 | |||
| 41 | for (int i = 0; i < sctx->nb_inputs; i++) { | ||
| 42 | FFFrameSyncIn *in = &sctx->fs.in[i]; | ||
| 43 | |||
| 44 | in->before = EXT_STOP; | ||
| 45 | in->after = sctx->shortest ? EXT_STOP : EXT_INFINITY; | ||
| 46 | in->sync = 1; | ||
| 47 | in->time_base = avctx->inputs[i]->time_base; | ||
| 48 | } | ||
| 49 | |||
| 50 | return ff_framesync_configure(&sctx->fs); | ||
| 51 | } | ||
| 52 | |||
| 53 | static int config_comm_output(AVFilterLink *outlink) | ||
| 54 | { | ||
| 55 | AVFilterContext *avctx = outlink->src; | ||
| 56 | StackBaseContext *sctx = avctx->priv; | ||
| 57 | AVFilterLink *inlink0 = avctx->inputs[0]; | ||
| 58 | int width, height, ret; | ||
| 59 | |||
| 60 | if (sctx->mode == STACK_H) { | ||
| 61 | height = sctx->tile_height; | ||
| 62 | width = 0; | ||
| 63 | |||
| 64 | if (!height) | ||
| 65 | height = inlink0->h; | ||
| 66 | |||
| 67 | for (int i = 0; i < sctx->nb_inputs; i++) { | ||
| 68 | AVFilterLink *inlink = avctx->inputs[i]; | ||
| 69 | StackItemRegion *region = &sctx->regions[i]; | ||
| 70 | |||
| 71 | SET_OUTPUT_REGION(region, width, 0, av_rescale(height, inlink->w, inlink->h), height); | ||
| 72 | width += av_rescale(height, inlink->w, inlink->h); | ||
| 73 | } | ||
| 74 | } else if (sctx->mode == STACK_V) { | ||
| 75 | height = 0; | ||
| 76 | width = sctx->tile_width; | ||
| 77 | |||
| 78 | if (!width) | ||
| 79 | width = inlink0->w; | ||
| 80 | |||
| 81 | for (int i = 0; i < sctx->nb_inputs; i++) { | ||
| 82 | AVFilterLink *inlink = avctx->inputs[i]; | ||
| 83 | StackItemRegion *region = &sctx->regions[i]; | ||
| 84 | |||
| 85 | SET_OUTPUT_REGION(region, 0, height, width, av_rescale(width, inlink->h, inlink->w)); | ||
| 86 | height += av_rescale(width, inlink->h, inlink->w); | ||
| 87 | } | ||
| 88 | } else if (sctx->nb_grid_rows && sctx->nb_grid_columns) { | ||
| 89 | int xpos = 0, ypos = 0; | ||
| 90 | int ow, oh, k = 0; | ||
| 91 | |||
| 92 | ow = sctx->tile_width; | ||
| 93 | oh = sctx->tile_height; | ||
| 94 | |||
| 95 | if (!ow || !oh) { | ||
| 96 | ow = avctx->inputs[0]->w; | ||
| 97 | oh = avctx->inputs[0]->h; | ||
| 98 | } | ||
| 99 | |||
| 100 | for (int i = 0; i < sctx->nb_grid_columns; i++) { | ||
| 101 | ypos = 0; | ||
| 102 | |||
| 103 | for (int j = 0; j < sctx->nb_grid_rows; j++) { | ||
| 104 | StackItemRegion *region = &sctx->regions[k++]; | ||
| 105 | |||
| 106 | SET_OUTPUT_REGION(region, xpos, ypos, ow, oh); | ||
| 107 | ypos += oh; | ||
| 108 | } | ||
| 109 | |||
| 110 | xpos += ow; | ||
| 111 | } | ||
| 112 | |||
| 113 | width = ow * sctx->nb_grid_columns; | ||
| 114 | height = oh * sctx->nb_grid_rows; | ||
| 115 | } else { | ||
| 116 | char *arg, *p = sctx->layout, *saveptr = NULL; | ||
| 117 | char *arg2, *p2, *saveptr2 = NULL; | ||
| 118 | char *arg3, *p3, *saveptr3 = NULL; | ||
| 119 | int xpos, ypos, size; | ||
| 120 | int ow, oh; | ||
| 121 | |||
| 122 | width = 0; | ||
| 123 | height = 0; | ||
| 124 | |||
| 125 | for (int i = 0; i < sctx->nb_inputs; i++) { | ||
| 126 | AVFilterLink *inlink = avctx->inputs[i]; | ||
| 127 | StackItemRegion *region = &sctx->regions[i]; | ||
| 128 | |||
| 129 | ow = inlink->w; | ||
| 130 | oh = inlink->h; | ||
| 131 | |||
| 132 | if (!(arg = av_strtok(p, "|", &saveptr))) | ||
| 133 | return AVERROR(EINVAL); | ||
| 134 | |||
| 135 | p = NULL; | ||
| 136 | p2 = arg; | ||
| 137 | xpos = ypos = 0; | ||
| 138 | |||
| 139 | for (int j = 0; j < 3; j++) { | ||
| 140 | if (!(arg2 = av_strtok(p2, "_", &saveptr2))) { | ||
| 141 | if (j == 2) | ||
| 142 | break; | ||
| 143 | else | ||
| 144 | return AVERROR(EINVAL); | ||
| 145 | } | ||
| 146 | |||
| 147 | p2 = NULL; | ||
| 148 | p3 = arg2; | ||
| 149 | |||
| 150 | if (j == 2) { | ||
| 151 | if ((ret = av_parse_video_size(&ow, &oh, p3)) < 0) { | ||
| 152 | av_log(avctx, AV_LOG_ERROR, "Invalid size '%s'\n", p3); | ||
| 153 | return ret; | ||
| 154 | } | ||
| 155 | |||
| 156 | break; | ||
| 157 | } | ||
| 158 | |||
| 159 | while ((arg3 = av_strtok(p3, "+", &saveptr3))) { | ||
| 160 | p3 = NULL; | ||
| 161 | if (sscanf(arg3, "w%d", &size) == 1) { | ||
| 162 | if (size == i || size < 0 || size >= sctx->nb_inputs) | ||
| 163 | return AVERROR(EINVAL); | ||
| 164 | |||
| 165 | if (!j) | ||
| 166 | xpos += sctx->regions[size].width; | ||
| 167 | else | ||
| 168 | ypos += sctx->regions[size].width; | ||
| 169 | } else if (sscanf(arg3, "h%d", &size) == 1) { | ||
| 170 | if (size == i || size < 0 || size >= sctx->nb_inputs) | ||
| 171 | return AVERROR(EINVAL); | ||
| 172 | |||
| 173 | if (!j) | ||
| 174 | xpos += sctx->regions[size].height; | ||
| 175 | else | ||
| 176 | ypos += sctx->regions[size].height; | ||
| 177 | } else if (sscanf(arg3, "%d", &size) == 1) { | ||
| 178 | if (size < 0) | ||
| 179 | return AVERROR(EINVAL); | ||
| 180 | |||
| 181 | if (!j) | ||
| 182 | xpos += size; | ||
| 183 | else | ||
| 184 | ypos += size; | ||
| 185 | } else { | ||
| 186 | return AVERROR(EINVAL); | ||
| 187 | } | ||
| 188 | } | ||
| 189 | } | ||
| 190 | |||
| 191 | SET_OUTPUT_REGION(region, xpos, ypos, ow, oh); | ||
| 192 | width = FFMAX(width, xpos + ow); | ||
| 193 | height = FFMAX(height, ypos + oh); | ||
| 194 | } | ||
| 195 | |||
| 196 | } | ||
| 197 | |||
| 198 | outlink->w = width; | ||
| 199 | outlink->h = height; | ||
| 200 | outlink->frame_rate = inlink0->frame_rate; | ||
| 201 | outlink->sample_aspect_ratio = inlink0->sample_aspect_ratio; | ||
| 202 | |||
| 203 | for (int i = 1; i < sctx->nb_inputs; i++) { | ||
| 204 | AVFilterLink *inlink = avctx->inputs[i]; | ||
| 205 | if (outlink->frame_rate.num != inlink->frame_rate.num || | ||
| 206 | outlink->frame_rate.den != inlink->frame_rate.den) { | ||
| 207 | av_log(avctx, AV_LOG_VERBOSE, | ||
| 208 | "Video inputs have different frame rates, output will be VFR\n"); | ||
| 209 | outlink->frame_rate = av_make_q(1, 0); | ||
| 210 | break; | ||
| 211 | } | ||
| 212 | } | ||
| 213 | |||
| 214 | ret = init_framesync(avctx); | ||
| 215 | if (ret < 0) | ||
| 216 | return ret; | ||
| 217 | |||
| 218 | outlink->time_base = sctx->fs.time_base; | ||
| 219 | |||
| 220 | return 0; | ||
| 221 | } | ||
| 222 | |||
| 223 | static int stack_init(AVFilterContext *avctx) | ||
| 224 | { | ||
| 225 | StackBaseContext *sctx = avctx->priv; | ||
| 226 | int ret; | ||
| 227 | |||
| 228 | if (!strcmp(avctx->filter->name, HSTACK_NAME)) | ||
| 229 | sctx->mode = STACK_H; | ||
| 230 | else if (!strcmp(avctx->filter->name, VSTACK_NAME)) | ||
| 231 | sctx->mode = STACK_V; | ||
| 232 | else { | ||
| 233 | int is_grid; | ||
| 234 | |||
| 235 | av_assert0(strcmp(avctx->filter->name, XSTACK_NAME) == 0); | ||
| 236 | sctx->mode = STACK_X; | ||
| 237 | is_grid = sctx->nb_grid_rows && sctx->nb_grid_columns; | ||
| 238 | |||
| 239 | if (sctx->layout && is_grid) { | ||
| 240 | av_log(avctx, AV_LOG_ERROR, "Both layout and grid were specified. Only one is allowed.\n"); | ||
| 241 | return AVERROR(EINVAL); | ||
| 242 | } | ||
| 243 | |||
| 244 | if (!sctx->layout && !is_grid) { | ||
| 245 | if (sctx->nb_inputs == 2) { | ||
| 246 | sctx->nb_grid_rows = 1; | ||
| 247 | sctx->nb_grid_columns = 2; | ||
| 248 | is_grid = 1; | ||
| 249 | } else { | ||
| 250 | av_log(avctx, AV_LOG_ERROR, "No layout or grid specified.\n"); | ||
| 251 | return AVERROR(EINVAL); | ||
| 252 | } | ||
| 253 | } | ||
| 254 | |||
| 255 | if (is_grid) | ||
| 256 | sctx->nb_inputs = sctx->nb_grid_rows * sctx->nb_grid_columns; | ||
| 257 | |||
| 258 | if (strcmp(sctx->fillcolor_str, "none") && | ||
| 259 | av_parse_color(sctx->fillcolor, sctx->fillcolor_str, -1, avctx) >= 0) { | ||
| 260 | sctx->fillcolor_enable = 1; | ||
| 261 | } else { | ||
| 262 | sctx->fillcolor_enable = 0; | ||
| 263 | } | ||
| 264 | } | ||
| 265 | |||
| 266 | for (int i = 0; i < sctx->nb_inputs; i++) { | ||
| 267 | AVFilterPad pad = { 0 }; | ||
| 268 | |||
| 269 | pad.type = AVMEDIA_TYPE_VIDEO; | ||
| 270 | pad.name = av_asprintf("input%d", i); | ||
| 271 | |||
| 272 | if (!pad.name) | ||
| 273 | return AVERROR(ENOMEM); | ||
| 274 | |||
| 275 | if ((ret = ff_append_inpad_free_name(avctx, &pad)) < 0) | ||
| 276 | return ret; | ||
| 277 | } | ||
| 278 | |||
| 279 | sctx->regions = av_calloc(sctx->nb_inputs, sizeof(*sctx->regions)); | ||
| 280 | if (!sctx->regions) | ||
| 281 | return AVERROR(ENOMEM); | ||
| 282 | |||
| 283 | return 0; | ||
| 284 | } | ||
| 285 | |||
| 286 | static av_cold void stack_uninit(AVFilterContext *avctx) | ||
| 287 | { | ||
| 288 | StackBaseContext *sctx = avctx->priv; | ||
| 289 | |||
| 290 | av_freep(&sctx->regions); | ||
| 291 | ff_framesync_uninit(&sctx->fs); | ||
| 292 | } | ||
| 293 | |||
| 294 | static int stack_activate(AVFilterContext *avctx) | ||
| 295 | { | ||
| 296 | StackBaseContext *sctx = avctx->priv; | ||
| 297 | return ff_framesync_activate(&sctx->fs); | ||
| 298 | } | ||
| 299 | |||
| 300 | static const AVFilterPad stack_outputs[] = { | ||
| 301 | { | ||
| 302 | .name = "default", | ||
| 303 | .type = AVMEDIA_TYPE_VIDEO, | ||
| 304 | .config_props = config_output, | ||
| 305 | }, | ||
| 306 | }; | ||
| 307 | |||
| 308 | #define STACK_COMMON_OPTS \ | ||
| 309 | { "inputs", "Set number of inputs", OFFSET(base.nb_inputs), AV_OPT_TYPE_INT, { .i64 = 2 }, 2, UINT16_MAX, .flags = FLAGS }, \ | ||
| 310 | { "shortest", "Force termination when the shortest input terminates", OFFSET(base.shortest), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, | ||
| 311 | |||
| 312 | #define DEFINE_HSTACK_OPTIONS(api) \ | ||
| 313 | static const AVOption hstack_##api##_options[] = { \ | ||
| 314 | STACK_COMMON_OPTS \ | ||
| 315 | { "height", "Set output height (0 to use the height of input 0)", OFFSET(base.tile_height), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, UINT16_MAX, FLAGS }, \ | ||
| 316 | { NULL } \ | ||
| 317 | } | ||
| 318 | |||
| 319 | #define DEFINE_VSTACK_OPTIONS(api) \ | ||
| 320 | static const AVOption vstack_##api##_options[] = { \ | ||
| 321 | STACK_COMMON_OPTS \ | ||
| 322 | { "width", "Set output width (0 to use the width of input 0)", OFFSET(base.tile_width), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, UINT16_MAX, FLAGS }, \ | ||
| 323 | { NULL } \ | ||
| 324 | } | ||
| 325 | |||
| 326 | #define DEFINE_XSTACK_OPTIONS(api) \ | ||
| 327 | static const AVOption xstack_##api##_options[] = { \ | ||
| 328 | STACK_COMMON_OPTS \ | ||
| 329 | { "layout", "Set custom layout", OFFSET(base.layout), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, .flags = FLAGS }, \ | ||
| 330 | { "grid", "set fixed size grid layout", OFFSET(base.nb_grid_columns), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, .flags = FLAGS }, \ | ||
| 331 | { "grid_tile_size", "set tile size in grid layout", OFFSET(base.tile_width), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, .flags = FLAGS }, \ | ||
| 332 | { "fill", "Set the color for unused pixels", OFFSET(base.fillcolor_str), AV_OPT_TYPE_STRING, {.str = "none"}, .flags = FLAGS }, \ | ||
| 333 | { NULL } \ | ||
| 334 | } | ||
| 335 | |||
| 336 | #define DEFINE_STACK_FILTER(category, api, capi) \ | ||
| 337 | static const AVClass category##_##api##_class = { \ | ||
| 338 | .class_name = #category "_" #api, \ | ||
| 339 | .item_name = av_default_item_name, \ | ||
| 340 | .option = category##_##api##_options, \ | ||
| 341 | .version = LIBAVUTIL_VERSION_INT, \ | ||
| 342 | }; \ | ||
| 343 | const AVFilter ff_vf_##category##_##api = { \ | ||
| 344 | .name = #category "_" #api, \ | ||
| 345 | .description = NULL_IF_CONFIG_SMALL(#capi " " #category), \ | ||
| 346 | .priv_size = sizeof(StackHWContext), \ | ||
| 347 | .priv_class = &category##_##api##_class, \ | ||
| 348 | .init = api##_stack_init, \ | ||
| 349 | .uninit = api##_stack_uninit, \ | ||
| 350 | .activate = stack_activate, \ | ||
| 351 | FILTER_QUERY_FUNC(api##_stack_query_formats), \ | ||
| 352 | FILTER_OUTPUTS(stack_outputs), \ | ||
| 353 | .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, \ | ||
| 354 | .flags = AVFILTER_FLAG_DYNAMIC_INPUTS, \ | ||
| 355 | } | ||
| @@ -0,0 +1,60 @@ | |||
| 1 | /* | ||
| 2 | * This file is part of FFmpeg. | ||
| 3 | * | ||
| 4 | * FFmpeg is free software; you can redistribute it and/or | ||
| 5 | * modify it under the terms of the GNU Lesser General Public | ||
| 6 | * License as published by the Free Software Foundation; either | ||
| 7 | * version 2.1 of the License, or (at your option) any later version. | ||
| 8 | * | ||
| 9 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 12 | * Lesser General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU Lesser General Public | ||
| 15 | * License along with FFmpeg; if not, write to the Free Software | ||
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 17 | */ | ||
| 18 | |||
| 19 | #ifndef AVFILTER_STACK_INTERNAL_H | ||
| 20 | #define AVFILTER_STACK_INTERNAL_H | ||
| 21 | |||
| 22 | enum { | ||
| 23 | STACK_H = 0, | ||
| 24 | STACK_V = 1, | ||
| 25 | STACK_X = 2 | ||
| 26 | }; | ||
| 27 | |||
| 28 | typedef struct StackItemRegion { | ||
| 29 | int x; | ||
| 30 | int y; | ||
| 31 | int width; | ||
| 32 | int height; | ||
| 33 | } StackItemRegion; | ||
| 34 | |||
| 35 | typedef struct StackBaseContext { | ||
| 36 | HWContext hwctx; /**< must be the first field */ | ||
| 37 | |||
| 38 | FFFrameSync fs; | ||
| 39 | int mode; | ||
| 40 | uint8_t fillcolor[4]; | ||
| 41 | int fillcolor_enable; | ||
| 42 | StackItemRegion *regions; | ||
| 43 | |||
| 44 | /* Options */ | ||
| 45 | int nb_inputs; | ||
| 46 | int shortest; | ||
| 47 | int tile_width; | ||
| 48 | int tile_height; | ||
| 49 | int nb_grid_columns; | ||
| 50 | int nb_grid_rows; | ||
| 51 | char *layout; | ||
| 52 | char *fillcolor_str; | ||
| 53 | } StackBaseContext; | ||
| 54 | |||
| 55 | static int config_comm_output(AVFilterLink *outlink); | ||
| 56 | static int stack_init(AVFilterContext *avctx); | ||
| 57 | static av_cold void stack_uninit(AVFilterContext *avctx); | ||
| 58 | static int stack_activate(AVFilterContext *avctx); | ||
| 59 | |||
| 60 | #endif /* AVFILTER_STACK_INTERNAL_H */ | ||
| @@ -42,33 +42,17 @@ · 41 unmodified lines | |||
| 42 | #include "framesync.h" | 42 | #include "framesync.h" |
| 43 | #include "vaapi_vpp.h" | 43 | #include "vaapi_vpp.h" |
| 44 | 44 | ||
| 45 | #define OFFSET(x) offsetof(StackVAAPIContext, x) | 45 | #define HSTACK_NAME "hstack_vaapi" |
| 46 | #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM) | 46 | #define VSTACK_NAME "vstack_vaapi" |
| 47 | 47 | #define XSTACK_NAME "xstack_vaapi" | |
| 48 | enum { | 48 | #define HWContext VAAPIVPPContext |
| 49 | STACK_VAAPI_H = 0, | 49 | #define StackHWContext StackVAAPIContext |
| 50 | STACK_VAAPI_V = 1, | 50 | #include "stack_internal.h" |
| 51 | STACK_VAAPI_X = 2 | ||
| 52 | }; | ||
| 53 | 51 | ||
| 54 | typedef struct StackVAAPIContext { | 52 | typedef struct StackVAAPIContext { |
| 55 | VAAPIVPPContext vppctx; /**< must be the first field */ | 53 | StackBaseContext base; |
| 56 | 54 | ||
| 57 | FFFrameSync fs; | ||
| 58 | int mode; | ||
| 59 | VARectangle *rects; | 55 | VARectangle *rects; |
| 60 | uint8_t fillcolor[4]; | ||
| 61 | int fillcolor_enable; | ||
| 62 | |||
| 63 | /* Options */ | ||
| 64 | int nb_inputs; | ||
| 65 | int shortest; | ||
| 66 | int tile_width; | ||
| 67 | int tile_height; | ||
| 68 | int nb_grid_columns; | ||
| 69 | int nb_grid_rows; | ||
| 70 | char *layout; | ||
| 71 | char *fillcolor_str; | ||
| 72 | } StackVAAPIContext; | 56 | } StackVAAPIContext; |
| 73 | 57 | ||
| 74 | static int process_frame(FFFrameSync *fs) | 58 | static int process_frame(FFFrameSync *fs) |
| @@ -122,14 +106,14 @@ static int process_frame(FFFrameSync *fs) · 47 unmodified lines | |||
| 122 | params[i].surface = (VASurfaceID)(uintptr_t)iframe->data[3]; | 106 | params[i].surface = (VASurfaceID)(uintptr_t)iframe->data[3]; |
| 123 | params[i].output_region = &sctx->rects[i]; | 107 | params[i].output_region = &sctx->rects[i]; |
| 124 | 108 | ||
| 125 | if (sctx->fillcolor_enable) | 109 | if (sctx->base.fillcolor_enable) |
| 126 | params[i].output_background_color = (sctx->fillcolor[3] << 24 | | 110 | params[i].output_background_color = (sctx->base.fillcolor[3] << 24 | |
| 127 | sctx->fillcolor[0] << 16 | | 111 | sctx->base.fillcolor[0] << 16 | |
| 128 | sctx->fillcolor[1] << 8 | | 112 | sctx->base.fillcolor[1] << 8 | |
| 129 | sctx->fillcolor[2]); | 113 | sctx->base.fillcolor[2]); |
| 130 | } | 114 | } |
| 131 | 115 | ||
| 132 | oframe->pts = av_rescale_q(sctx->fs.pts, sctx->fs.time_base, outlink->time_base); | 116 | oframe->pts = av_rescale_q(sctx->base.fs.pts, sctx->base.fs.time_base, outlink->time_base); |
| 133 | oframe->sample_aspect_ratio = outlink->sample_aspect_ratio; | 117 | oframe->sample_aspect_ratio = outlink->sample_aspect_ratio; |
| 134 | 118 | ||
| 135 | ret = ff_vaapi_vpp_render_pictures(avctx, params, avctx->nb_inputs, oframe); | 119 | ret = ff_vaapi_vpp_render_pictures(avctx, params, avctx->nb_inputs, oframe); |
| @@ -147,37 +131,6 @@ fail: · 11 unmodified lines | |||
| 147 | return ret; | 131 | return ret; |
| 148 | } | 132 | } |
| 149 | 133 | ||
| 150 | static int init_framesync(AVFilterContext *avctx) | ||
| 151 | { | ||
| 152 | StackVAAPIContext *sctx = avctx->priv; | ||
| 153 | int ret; | ||
| 154 | |||
| 155 | ret = ff_framesync_init(&sctx->fs, avctx, avctx->nb_inputs); | ||
| 156 | if (ret < 0) | ||
| 157 | return ret; | ||
| 158 | |||
| 159 | sctx->fs.on_event = process_frame; | ||
| 160 | sctx->fs.opaque = sctx; | ||
| 161 | |||
| 162 | for (int i = 0; i < sctx->nb_inputs; i++) { | ||
| 163 | FFFrameSyncIn *in = &sctx->fs.in[i]; | ||
| 164 | |||
| 165 | in->before = EXT_STOP; | ||
| 166 | in->after = sctx->shortest ? EXT_STOP : EXT_INFINITY; | ||
| 167 | in->sync = 1; | ||
| 168 | in->time_base = avctx->inputs[i]->time_base; | ||
| 169 | } | ||
| 170 | |||
| 171 | return ff_framesync_configure(&sctx->fs); | ||
| 172 | } | ||
| 173 | |||
| 174 | #define SET_INPUT_REGION(rect, rx, ry, rw, rh) do { \ | ||
| 175 | rect->x = rx; \ | ||
| 176 | rect->y = ry; \ | ||
| 177 | rect->width = rw; \ | ||
| 178 | rect->height = rh; \ | ||
| 179 | } while (0) | ||
| 180 | |||
| 181 | static int config_output(AVFilterLink *outlink) | 134 | static int config_output(AVFilterLink *outlink) |
| 182 | { | 135 | { |
| 183 | AVFilterContext *avctx = outlink->src; | 136 | AVFilterContext *avctx = outlink->src; |
| @@ -185,7 +138,7 @@ static int config_output(AVFilterLink *outlink) · 1 unmodified line | |||
| 185 | VAAPIVPPContext *vppctx = avctx->priv; | 138 | VAAPIVPPContext *vppctx = avctx->priv; |
| 186 | AVFilterLink *inlink0 = avctx->inputs[0]; | 139 | AVFilterLink *inlink0 = avctx->inputs[0]; |
| 187 | AVHWFramesContext *hwfc0 = NULL; | 140 | AVHWFramesContext *hwfc0 = NULL; |
| 188 | int width, height, ret; | 141 | int ret; |
| 189 | 142 | ||
| 190 | if (inlink0->format != AV_PIX_FMT_VAAPI || !inlink0->hw_frames_ctx || !inlink0->hw_frames_ctx->data) { | 143 | if (inlink0->format != AV_PIX_FMT_VAAPI || !inlink0->hw_frames_ctx || !inlink0->hw_frames_ctx->data) { |
| 191 | av_log(avctx, AV_LOG_ERROR, "Software pixel format is not supported.\n"); | 144 | av_log(avctx, AV_LOG_ERROR, "Software pixel format is not supported.\n"); |
| @@ -194,7 +147,7 @@ static int config_output(AVFilterLink *outlink) · 2 unmodified lines | |||
| 194 | 147 | ||
| 195 | hwfc0 = (AVHWFramesContext *)inlink0->hw_frames_ctx->data; | 148 | hwfc0 = (AVHWFramesContext *)inlink0->hw_frames_ctx->data; |
| 196 | 149 | ||
| 197 | for (int i = 1; i < sctx->nb_inputs; i++) { | 150 | for (int i = 1; i < sctx->base.nb_inputs; i++) { |
| 198 | AVFilterLink *inlink = avctx->inputs[i]; | 151 | AVFilterLink *inlink = avctx->inputs[i]; |
| 199 | AVHWFramesContext *hwfc = NULL; | 152 | AVHWFramesContext *hwfc = NULL; |
| 200 | 153 | ||
| @@ -219,168 +172,19 @@ static int config_output(AVFilterLink *outlink) · 18 unmodified lines | |||
| 219 | ff_vaapi_vpp_config_input(inlink0); | 172 | ff_vaapi_vpp_config_input(inlink0); |
| 220 | vppctx->output_format = hwfc0->sw_format; | 173 | vppctx->output_format = hwfc0->sw_format; |
| 221 | 174 | ||
| 222 | if (sctx->mode == STACK_VAAPI_H) { | 175 | ret = config_comm_output(outlink); |
| 223 | height = sctx->tile_height; | ||
| 224 | width = 0; | ||
| 225 | |||
| 226 | if (!height) | ||
| 227 | height = inlink0->h; | ||
| 228 | |||
| 229 | for (int i = 0; i < sctx->nb_inputs; i++) { | ||
| 230 | AVFilterLink *inlink = avctx->inputs[i]; | ||
| 231 | VARectangle *rect = &sctx->rects[i]; | ||
| 232 | |||
| 233 | SET_INPUT_REGION(rect, width, 0, av_rescale(height, inlink->w, inlink->h), height); | ||
| 234 | width += av_rescale(height, inlink->w, inlink->h); | ||
| 235 | } | ||
| 236 | } else if (sctx->mode == STACK_VAAPI_V) { | ||
| 237 | height = 0; | ||
| 238 | width = sctx->tile_width; | ||
| 239 | |||
| 240 | if (!width) | ||
| 241 | width = inlink0->w; | ||
| 242 | |||
| 243 | for (int i = 0; i < sctx->nb_inputs; i++) { | ||
| 244 | AVFilterLink *inlink = avctx->inputs[i]; | ||
| 245 | VARectangle *rect = &sctx->rects[i]; | ||
| 246 | |||
| 247 | SET_INPUT_REGION(rect, 0, height, width, av_rescale(width, inlink->h, inlink->w)); | ||
| 248 | height += av_rescale(width, inlink->h, inlink->w); | ||
| 249 | } | ||
| 250 | } else if (sctx->nb_grid_rows && sctx->nb_grid_columns) { | ||
| 251 | int xpos = 0, ypos = 0; | ||
| 252 | int ow, oh, k = 0; | ||
| 253 | |||
| 254 | ow = sctx->tile_width; | ||
| 255 | oh = sctx->tile_height; | ||
| 256 | |||
| 257 | if (!ow || !oh) { | ||
| 258 | ow = avctx->inputs[0]->w; | ||
| 259 | oh = avctx->inputs[0]->h; | ||
| 260 | } | ||
| 261 | |||
| 262 | for (int i = 0; i < sctx->nb_grid_columns; i++) { | ||
| 263 | ypos = 0; | ||
| 264 | |||
| 265 | for (int j = 0; j < sctx->nb_grid_rows; j++) { | ||
| 266 | VARectangle *rect = &sctx->rects[k++]; | ||
| 267 | |||
| 268 | SET_INPUT_REGION(rect, xpos, ypos, ow, oh); | ||
| 269 | ypos += oh; | ||
| 270 | } | ||
| 271 | |||
| 272 | xpos += ow; | ||
| 273 | } | ||
| 274 | |||
| 275 | width = ow * sctx->nb_grid_columns; | ||
| 276 | height = oh * sctx->nb_grid_rows; | ||
| 277 | } else { | ||
| 278 | char *arg, *p = sctx->layout, *saveptr = NULL; | ||
| 279 | char *arg2, *p2, *saveptr2 = NULL; | ||
| 280 | char *arg3, *p3, *saveptr3 = NULL; | ||
| 281 | int xpos, ypos, size; | ||
| 282 | int ow, oh; | ||
| 283 | |||
| 284 | width = avctx->inputs[0]->w; | ||
| 285 | height = avctx->inputs[0]->h; | ||
| 286 | |||
| 287 | for (int i = 0; i < sctx->nb_inputs; i++) { | ||
| 288 | AVFilterLink *inlink = avctx->inputs[i]; | ||
| 289 | VARectangle *rect = &sctx->rects[i]; | ||
| 290 | |||
| 291 | ow = inlink->w; | ||
| 292 | oh = inlink->h; | ||
| 293 | |||
| 294 | if (!(arg = av_strtok(p, "|", &saveptr))) | ||
| 295 | return AVERROR(EINVAL); | ||
| 296 | |||
| 297 | p = NULL; | ||
| 298 | p2 = arg; | ||
| 299 | xpos = ypos = 0; | ||
| 300 | |||
| 301 | for (int j = 0; j < 3; j++) { | ||
| 302 | if (!(arg2 = av_strtok(p2, "_", &saveptr2))) { | ||
| 303 | if (j == 2) | ||
| 304 | break; | ||
| 305 | else | ||
| 306 | return AVERROR(EINVAL); | ||
| 307 | } | ||
| 308 | |||
| 309 | p2 = NULL; | ||
| 310 | p3 = arg2; | ||
| 311 | |||
| 312 | if (j == 2) { | ||
| 313 | if ((ret = av_parse_video_size(&ow, &oh, p3)) < 0) { | ||
| 314 | av_log(avctx, AV_LOG_ERROR, "Invalid size '%s'\n", p3); | ||
| 315 | return ret; | ||
| 316 | } | ||
| 317 | |||
| 318 | break; | ||
| 319 | } | ||
| 320 | |||
| 321 | while ((arg3 = av_strtok(p3, "+", &saveptr3))) { | ||
| 322 | p3 = NULL; | ||
| 323 | if (sscanf(arg3, "w%d", &size) == 1) { | ||
| 324 | if (size == i || size < 0 || size >= sctx->nb_inputs) | ||
| 325 | return AVERROR(EINVAL); | ||
| 326 | |||
| 327 | if (!j) | ||
| 328 | xpos += sctx->rects[size].width; | ||
| 329 | else | ||
| 330 | ypos += sctx->rects[size].width; | ||
| 331 | } else if (sscanf(arg3, "h%d", &size) == 1) { | ||
| 332 | if (size == i || size < 0 || size >= sctx->nb_inputs) | ||
| 333 | return AVERROR(EINVAL); | ||
| 334 | |||
| 335 | if (!j) | ||
| 336 | xpos += sctx->rects[size].height; | ||
| 337 | else | ||
| 338 | ypos += sctx->rects[size].height; | ||
| 339 | } else if (sscanf(arg3, "%d", &size) == 1) { | ||
| 340 | if (size < 0) | ||
| 341 | return AVERROR(EINVAL); | ||
| 342 | |||
| 343 | if (!j) | ||
| 344 | xpos += size; | ||
| 345 | else | ||
| 346 | ypos += size; | ||
| 347 | } else { | ||
| 348 | return AVERROR(EINVAL); | ||
| 349 | } | ||
| 350 | } | ||
| 351 | } | ||
| 352 | |||
| 353 | SET_INPUT_REGION(rect, xpos, ypos, ow, oh); | ||
| 354 | width = FFMAX(width, xpos + ow); | ||
| 355 | height = FFMAX(height, ypos + oh); | ||
| 356 | } | ||
| 357 | |||
| 358 | } | ||
| 359 | |||
| 360 | outlink->w = width; | ||
| 361 | outlink->h = height; | ||
| 362 | outlink->frame_rate = inlink0->frame_rate; | ||
| 363 | outlink->sample_aspect_ratio = inlink0->sample_aspect_ratio; | ||
| 364 | |||
| 365 | for (int i = 1; i < sctx->nb_inputs; i++) { | ||
| 366 | AVFilterLink *inlink = avctx->inputs[i]; | ||
| 367 | if (outlink->frame_rate.num != inlink->frame_rate.num || | ||
| 368 | outlink->frame_rate.den != inlink->frame_rate.den) { | ||
| 369 | av_log(avctx, AV_LOG_VERBOSE, | ||
| 370 | "Video inputs have different frame rates, output will be VFR\n"); | ||
| 371 | outlink->frame_rate = av_make_q(1, 0); | ||
| 372 | break; | ||
| 373 | } | ||
| 374 | } | ||
| 375 | |||
| 376 | ret = init_framesync(avctx); | ||
| 377 | if (ret < 0) | 176 | if (ret < 0) |
| 378 | return ret; | 177 | return ret; |
| 379 | 178 | ||
| 380 | outlink->time_base = sctx->fs.time_base; | 179 | for (int i = 0; i < sctx->base.nb_inputs; i++) { |
| 180 | sctx->rects[i].x = sctx->base.regions[i].x; | ||
| 181 | sctx->rects[i].y = sctx->base.regions[i].y; | ||
| 182 | sctx->rects[i].width = sctx->base.regions[i].width; | ||
| 183 | sctx->rects[i].height = sctx->base.regions[i].height; | ||
| 184 | } | ||
| 381 | 185 | ||
| 382 | vppctx->output_width = width; | 186 | vppctx->output_width = outlink->w; |
| 383 | vppctx->output_height = height; | 187 | vppctx->output_height = outlink->h; |
| 384 | 188 | ||
| 385 | return ff_vaapi_vpp_config_output(outlink); | 189 | return ff_vaapi_vpp_config_output(outlink); |
| 386 | } | 190 | } |
| @@ -391,59 +195,12 @@ static int vaapi_stack_init(AVFilterContext *avctx) · 4 unmodified lines | |||
| 391 | VAAPIVPPContext *vppctx = avctx->priv; | 195 | VAAPIVPPContext *vppctx = avctx->priv; |
| 392 | int ret; | 196 | int ret; |
| 393 | 197 | ||
| 394 | if (!strcmp(avctx->filter->name, "hstack_vaapi")) | 198 | ret = stack_init(avctx); |
| 395 | sctx->mode = STACK_VAAPI_H; | 199 | if (ret) |
| 396 | else if (!strcmp(avctx->filter->name, "vstack_vaapi")) | 200 | return ret; |
| 397 | sctx->mode = STACK_VAAPI_V; | ||
| 398 | else { | ||
| 399 | int is_grid; | ||
| 400 | |||
| 401 | av_assert0(strcmp(avctx->filter->name, "xstack_vaapi") == 0); | ||
| 402 | sctx->mode = STACK_VAAPI_X; | ||
| 403 | is_grid = sctx->nb_grid_rows && sctx->nb_grid_columns; | ||
| 404 | |||
| 405 | if (sctx->layout && is_grid) { | ||
| 406 | av_log(avctx, AV_LOG_ERROR, "Both layout and grid were specified. Only one is allowed.\n"); | ||
| 407 | return AVERROR(EINVAL); | ||
| 408 | } | ||
| 409 | |||
| 410 | if (!sctx->layout && !is_grid) { | ||
| 411 | if (sctx->nb_inputs == 2) { | ||
| 412 | sctx->nb_grid_rows = 1; | ||
| 413 | sctx->nb_grid_columns = 2; | ||
| 414 | is_grid = 1; | ||
| 415 | } else { | ||
| 416 | av_log(avctx, AV_LOG_ERROR, "No layout or grid specified.\n"); | ||
| 417 | return AVERROR(EINVAL); | ||
| 418 | } | ||
| 419 | } | ||
| 420 | |||
| 421 | if (is_grid) | ||
| 422 | sctx->nb_inputs = sctx->nb_grid_rows * sctx->nb_grid_columns; | ||
| 423 | |||
| 424 | if (strcmp(sctx->fillcolor_str, "none") && | ||
| 425 | av_parse_color(sctx->fillcolor, sctx->fillcolor_str, -1, avctx) >= 0) { | ||
| 426 | sctx->fillcolor_enable = 1; | ||
| 427 | } else { | ||
| 428 | sctx->fillcolor_enable = 0; | ||
| 429 | } | ||
| 430 | } | ||
| 431 | |||
| 432 | for (int i = 0; i < sctx->nb_inputs; i++) { | ||
| 433 | AVFilterPad pad = { 0 }; | ||
| 434 | |||
| 435 | pad.type = AVMEDIA_TYPE_VIDEO; | ||
| 436 | pad.name = av_asprintf("input%d", i); | ||
| 437 | |||
| 438 | if (!pad.name) | ||
| 439 | return AVERROR(ENOMEM); | ||
| 440 | |||
| 441 | if ((ret = ff_append_inpad_free_name(avctx, &pad)) < 0) | ||
| 442 | return ret; | ||
| 443 | } | ||
| 444 | 201 | ||
| 445 | /* stack region */ | 202 | /* stack region */ |
| 446 | sctx->rects = av_calloc(sctx->nb_inputs, sizeof(*sctx->rects)); | 203 | sctx->rects = av_calloc(sctx->base.nb_inputs, sizeof(*sctx->rects)); |
| 447 | if (!sctx->rects) | 204 | if (!sctx->rects) |
| 448 | return AVERROR(ENOMEM); | 205 | return AVERROR(ENOMEM); |
| 449 | 206 | ||
| @@ -457,14 +214,9 @@ static av_cold void vaapi_stack_uninit(AVFilterContext *avctx) · 7 unmodified lines | |||
| 457 | { | 214 | { |
| 458 | StackVAAPIContext *sctx = avctx->priv; | 215 | StackVAAPIContext *sctx = avctx->priv; |
| 459 | 216 | ||
| 460 | ff_framesync_uninit(&sctx->fs); | 217 | stack_uninit(avctx); |
| 461 | av_freep(&sctx->rects); | ||
| 462 | } | ||
| 463 | 218 | ||
| 464 | static int vaapi_stack_activate(AVFilterContext *avctx) | 219 | av_freep(&sctx->rects); |
| 465 | { | ||
| 466 | StackVAAPIContext *sctx = avctx->priv; | ||
| 467 | return ff_framesync_activate(&sctx->fs); | ||
| 468 | } | 220 | } |
| 469 | 221 | ||
| 470 | static int vaapi_stack_query_formats(AVFilterContext *avctx) | 222 | static int vaapi_stack_query_formats(AVFilterContext *avctx) |
| @@ -477,98 +229,25 @@ static int vaapi_stack_query_formats(AVFilterContext *avctx) · 6 unmodified lines | |||
| 477 | return ff_set_common_formats_from_list(avctx, pixel_formats); | 229 | return ff_set_common_formats_from_list(avctx, pixel_formats); |
| 478 | } | 230 | } |
| 479 | 231 | ||
| 480 | static const AVFilterPad vaapi_stack_outputs[] = { | 232 | #include "stack_internal.c" |
| 481 | { | ||
| 482 | .name = "default", | ||
| 483 | .type = AVMEDIA_TYPE_VIDEO, | ||
| 484 | .config_props = config_output, | ||
| 485 | }, | ||
| 486 | }; | ||
| 487 | |||
| 488 | #define STACK_COMMON_OPTS \ | ||
| 489 | { "inputs", "Set number of inputs", OFFSET(nb_inputs), AV_OPT_TYPE_INT, { .i64 = 2 }, 2, UINT16_MAX, .flags = FLAGS }, \ | ||
| 490 | { "shortest", "Force termination when the shortest input terminates", OFFSET(shortest), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, | ||
| 491 | 233 | ||
| 492 | #if CONFIG_HSTACK_VAAPI_FILTER | 234 | #if CONFIG_HSTACK_VAAPI_FILTER |
| 493 | 235 | ||
| 494 | static const AVOption hstack_vaapi_options[] = { | 236 | DEFINE_HSTACK_OPTIONS(vaapi); |
| 495 | STACK_COMMON_OPTS | 237 | DEFINE_STACK_FILTER(hstack, vaapi, "VA-API"); |
| 496 | |||
| 497 | { "height", "Set output height (0 to use the height of input 0)", OFFSET(tile_height), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, UINT16_MAX, FLAGS }, | ||
| 498 | { NULL } | ||
| 499 | }; | ||
| 500 | |||
| 501 | AVFILTER_DEFINE_CLASS(hstack_vaapi); | ||
| 502 | |||
| 503 | const AVFilter ff_vf_hstack_vaapi = { | ||
| 504 | .name = "hstack_vaapi", | ||
| 505 | .description = NULL_IF_CONFIG_SMALL("VA-API hstack."), | ||
| 506 | .priv_size = sizeof(StackVAAPIContext), | ||
| 507 | .priv_class = &hstack_vaapi_class, | ||
| 508 | .init = vaapi_stack_init, | ||
| 509 | .uninit = vaapi_stack_uninit, | ||
| 510 | .activate = vaapi_stack_activate, | ||
| 511 | FILTER_QUERY_FUNC(vaapi_stack_query_formats), | ||
| 512 | FILTER_OUTPUTS(vaapi_stack_outputs), | ||
| 513 | .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, | ||
| 514 | .flags = AVFILTER_FLAG_DYNAMIC_INPUTS, | ||
| 515 | }; | ||
| 516 | 238 | ||
| 517 | #endif | 239 | #endif |
| 518 | 240 | ||
| 519 | #if CONFIG_VSTACK_VAAPI_FILTER | 241 | #if CONFIG_VSTACK_VAAPI_FILTER |
| 520 | 242 | ||
| 521 | static const AVOption vstack_vaapi_options[] = { | 243 | DEFINE_VSTACK_OPTIONS(vaapi); |
| 522 | STACK_COMMON_OPTS | 244 | DEFINE_STACK_FILTER(vstack, vaapi, "VA-API"); |
| 523 | |||
| 524 | { "width", "Set output width (0 to use the width of input 0)", OFFSET(tile_width), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, UINT16_MAX, FLAGS }, | ||
| 525 | { NULL } | ||
| 526 | }; | ||
| 527 | |||
| 528 | AVFILTER_DEFINE_CLASS(vstack_vaapi); | ||
| 529 | |||
| 530 | const AVFilter ff_vf_vstack_vaapi = { | ||
| 531 | .name = "vstack_vaapi", | ||
| 532 | .description = NULL_IF_CONFIG_SMALL("VA-API vstack."), | ||
| 533 | .priv_size = sizeof(StackVAAPIContext), | ||
| 534 | .priv_class = &vstack_vaapi_class, | ||
| 535 | .init = vaapi_stack_init, | ||
| 536 | .uninit = vaapi_stack_uninit, | ||
| 537 | .activate = vaapi_stack_activate, | ||
| 538 | FILTER_QUERY_FUNC(vaapi_stack_query_formats), | ||
| 539 | FILTER_OUTPUTS(vaapi_stack_outputs), | ||
| 540 | .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, | ||
| 541 | .flags = AVFILTER_FLAG_DYNAMIC_INPUTS, | ||
| 542 | }; | ||
| 543 | 245 | ||
| 544 | #endif | 246 | #endif |
| 545 | 247 | ||
| 546 | #if CONFIG_XSTACK_VAAPI_FILTER | 248 | #if CONFIG_XSTACK_VAAPI_FILTER |
| 547 | 249 | ||
| 548 | static const AVOption xstack_vaapi_options[] = { | 250 | DEFINE_XSTACK_OPTIONS(vaapi); |
| 549 | STACK_COMMON_OPTS | 251 | DEFINE_STACK_FILTER(xstack, vaapi, "VA-API"); |
| 550 | |||
| 551 | { "layout", "Set custom layout", OFFSET(layout), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, .flags = FLAGS }, | ||
| 552 | { "grid", "set fixed size grid layout", OFFSET(nb_grid_columns), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, .flags = FLAGS }, | ||
| 553 | { "grid_tile_size", "set tile size in grid layout", OFFSET(tile_width), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, .flags = FLAGS }, | ||
| 554 | { "fill", "Set the color for unused pixels", OFFSET(fillcolor_str), AV_OPT_TYPE_STRING, {.str = "none"}, .flags = FLAGS }, | ||
| 555 | { NULL } | ||
| 556 | }; | ||
| 557 | |||
| 558 | AVFILTER_DEFINE_CLASS(xstack_vaapi); | ||
| 559 | |||
| 560 | const AVFilter ff_vf_xstack_vaapi = { | ||
| 561 | .name = "xstack_vaapi", | ||
| 562 | .description = NULL_IF_CONFIG_SMALL("VA-API xstack."), | ||
| 563 | .priv_size = sizeof(StackVAAPIContext), | ||
| 564 | .priv_class = &xstack_vaapi_class, | ||
| 565 | .init = vaapi_stack_init, | ||
| 566 | .uninit = vaapi_stack_uninit, | ||
| 567 | .activate = vaapi_stack_activate, | ||
| 568 | FILTER_OUTPUTS(vaapi_stack_outputs), | ||
| 569 | FILTER_QUERY_FUNC(vaapi_stack_query_formats), | ||
| 570 | .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, | ||
| 571 | .flags = AVFILTER_FLAG_DYNAMIC_INPUTS, | ||
| 572 | }; | ||
| 573 | 252 | ||
| 574 | #endif | 253 | #endif |