| @@ -21,9 +21,11 @@ · 20 unmodified lines |
| 21 | #include "libavutil/avstring.h" | 21 | #include "libavutil/avstring.h" |
| 22 | #include "libavutil/imgutils.h" | 22 | #include "libavutil/imgutils.h" |
| 23 | #include "libavutil/opt.h" | 23 | #include "libavutil/opt.h" |
| | 24 | #include "libavutil/parseutils.h" |
| 24 | #include "libavutil/pixdesc.h" | 25 | #include "libavutil/pixdesc.h" |
| 25 | | 26 | |
| 26 | #include "avfilter.h" | 27 | #include "avfilter.h" |
| | 28 | #include "drawutils.h" |
| 27 | #include "formats.h" | 29 | #include "formats.h" |
| 28 | #include "internal.h" | 30 | #include "internal.h" |
| 29 | #include "framesync.h" | 31 | #include "framesync.h" |
| @@ -44,6 +46,12 @@ typedef struct StackContext { · 14 unmodified lines |
| 44 | int is_vertical; | 46 | int is_vertical; |
| 45 | int is_horizontal; | 47 | int is_horizontal; |
| 46 | int nb_planes; | 48 | int nb_planes; |
| | 49 | uint8_t fillcolor[4]; |
| | 50 | char *fillcolor_str; |
| | 51 | int fillcolor_enable; |
| | 52 | |
| | 53 | FFDrawContext draw; |
| | 54 | FFDrawColor color; |
| 47 | | 55 | |
| 48 | StackItem *items; | 56 | StackItem *items; |
| 49 | AVFrame **frames; | 57 | AVFrame **frames; |
| @@ -53,8 +61,13 @@ typedef struct StackContext { · 3 unmodified lines |
| 53 | static int query_formats(AVFilterContext *ctx) | 61 | static int query_formats(AVFilterContext *ctx) |
| 54 | { | 62 | { |
| 55 | AVFilterFormats *pix_fmts = NULL; | 63 | AVFilterFormats *pix_fmts = NULL; |
| | 64 | StackContext *s = ctx->priv; |
| 56 | int fmt, ret; | 65 | int fmt, ret; |
| 57 | | 66 | |
| | 67 | if (s->fillcolor_enable) { |
| | 68 | return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0)); |
| | 69 | } |
| | 70 | |
| 58 | for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) { | 71 | for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) { |
| 59 | const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt); | 72 | const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt); |
| 60 | if (!(desc->flags & AV_PIX_FMT_FLAG_PAL || | 73 | if (!(desc->flags & AV_PIX_FMT_FLAG_PAL || |
| @@ -87,6 +100,12 @@ static av_cold int init(AVFilterContext *ctx) · 26 unmodified lines |
| 87 | return AVERROR(ENOMEM); | 100 | return AVERROR(ENOMEM); |
| 88 | | 101 | |
| 89 | if (!strcmp(ctx->filter->name, "xstack")) { | 102 | if (!strcmp(ctx->filter->name, "xstack")) { |
| | 103 | if (strcmp(s->fillcolor_str, "none") && |
| | 104 | av_parse_color(s->fillcolor, s->fillcolor_str, -1, ctx) >= 0) { |
| | 105 | s->fillcolor_enable = 1; |
| | 106 | } else { |
| | 107 | s->fillcolor_enable = 0; |
| | 108 | } |
| 90 | if (!s->layout) { | 109 | if (!s->layout) { |
| 91 | if (s->nb_inputs == 2) { | 110 | if (s->nb_inputs == 2) { |
| 92 | s->layout = av_strdup("0_0|w0_0"); | 111 | s->layout = av_strdup("0_0|w0_0"); |
| @@ -159,6 +178,10 @@ static int process_frame(FFFrameSync *fs) · 66 unmodified lines |
| 159 | out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base); | 178 | out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base); |
| 160 | out->sample_aspect_ratio = outlink->sample_aspect_ratio; | 179 | out->sample_aspect_ratio = outlink->sample_aspect_ratio; |
| 161 | | 180 | |
| | 181 | if (s->fillcolor_enable) |
| | 182 | ff_fill_rectangle(&s->draw, &s->color, out->data, out->linesize, |
| | 183 | 0, 0, outlink->w, outlink->h); |
| | 184 | |
| 162 | ctx->internal->execute(ctx, process_slice, out, NULL, FFMIN(s->nb_inputs, ff_filter_get_nb_threads(ctx))); | 185 | ctx->internal->execute(ctx, process_slice, out, NULL, FFMIN(s->nb_inputs, ff_filter_get_nb_threads(ctx))); |
| 163 | | 186 | |
| 164 | return ff_filter_frame(outlink, out); | 187 | return ff_filter_frame(outlink, out); |
| @@ -234,6 +257,11 @@ static int config_output(AVFilterLink *outlink) · 69 unmodified lines |
| 234 | char *arg3, *p3, *saveptr3 = NULL; | 257 | char *arg3, *p3, *saveptr3 = NULL; |
| 235 | int inw, inh, size; | 258 | int inw, inh, size; |
| 236 | | 259 | |
| | 260 | if (s->fillcolor_enable) { |
| | 261 | ff_draw_init(&s->draw, ctx->inputs[0]->format, 0); |
| | 262 | ff_draw_color(&s->draw, &s->color, s->fillcolor); |
| | 263 | } |
| | 264 | |
| 237 | for (i = 0; i < s->nb_inputs; i++) { | 265 | for (i = 0; i < s->nb_inputs; i++) { |
| 238 | AVFilterLink *inlink = ctx->inputs[i]; | 266 | AVFilterLink *inlink = ctx->inputs[i]; |
| 239 | StackItem *item = &s->items[i]; | 267 | StackItem *item = &s->items[i]; |
| @@ -425,6 +453,7 @@ static const AVOption xstack_options[] = { · 185 unmodified lines |
| 425 | { "inputs", "set number of inputs", OFFSET(nb_inputs), AV_OPT_TYPE_INT, {.i64=2}, 2, INT_MAX, .flags = FLAGS }, | 453 | { "inputs", "set number of inputs", OFFSET(nb_inputs), AV_OPT_TYPE_INT, {.i64=2}, 2, INT_MAX, .flags = FLAGS }, |
| 426 | { "layout", "set custom layout", OFFSET(layout), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, .flags = FLAGS }, | 454 | { "layout", "set custom layout", OFFSET(layout), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, .flags = FLAGS }, |
| 427 | { "shortest", "force termination when the shortest input terminates", OFFSET(shortest), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, .flags = FLAGS }, | 455 | { "shortest", "force termination when the shortest input terminates", OFFSET(shortest), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, .flags = FLAGS }, |
| | 456 | { "fill", "set the color for unused pixels", OFFSET(fillcolor_str), AV_OPT_TYPE_STRING, {.str = "none"}, .flags = FLAGS }, |
| 428 | { NULL }, | 457 | { NULL }, |
| 429 | }; | 458 | }; |
| 430 | | 459 | |