21#include "config_components.h"
75 if (
s->fillcolor_enable) {
89 if (!strcmp(
ctx->filter->name,
"vstack"))
92 if (!strcmp(
ctx->filter->name,
"hstack"))
95 if (!strcmp(
ctx->filter->name,
"xstack")) {
97 if (strcmp(
s->fillcolor_str,
"none") &&
99 s->fillcolor_enable = 1;
101 s->fillcolor_enable = 0;
103 is_grid =
s->nb_grid_rows &&
s->nb_grid_columns;
104 if (
s->layout && is_grid) {
108 if (!
s->layout && !is_grid) {
109 if (
s->nb_inputs == 2) {
111 s->nb_grid_columns = 2;
120 s->nb_inputs =
s->nb_grid_rows *
s->nb_grid_columns;
123 s->frames =
av_calloc(
s->nb_inputs,
sizeof(*
s->frames));
131 for (
i = 0;
i <
s->nb_inputs;
i++) {
151 const int start = (
s->nb_inputs * job ) / nb_jobs;
152 const int end = (
s->nb_inputs * (job+1)) / nb_jobs;
154 for (
int i = start;
i < end;
i++) {
157 for (
int p = 0; p <
s->nb_planes; p++) {
178 for (
i = 0;
i <
s->nb_inputs;
i++) {
189 if (
s->fillcolor_enable)
191 0, 0, outlink->
w, outlink->
h);
216 if (
s->is_vertical) {
217 for (
i = 0;
i <
s->nb_inputs;
i++) {
242 }
else if (
s->is_horizontal) {
243 for (
i = 0;
i <
s->nb_inputs;
i++) {
269 }
else if (
s->nb_grid_rows &&
s->nb_grid_columns) {
270 int inw = 0, inh = 0;
275 for (
i = 0;
i <
s->nb_grid_rows;
i++, inh += row_height) {
276 row_height =
ctx->inputs[
i *
s->nb_grid_columns]->h;
278 for (
int j = 0; j <
s->nb_grid_columns; j++, k++) {
282 if (
ctx->inputs[k]->h != row_height) {
284 k,
ctx->inputs[k]->h, row_height);
300 item->
y[0] = item->
y[3] = inh;
302 if (inw > INT_MAX -
ctx->inputs[k]->w)
304 inw +=
ctx->inputs[k]->w;
306 if (
height > INT_MAX - row_height)
317 char *
arg, *p =
s->layout, *saveptr =
NULL;
318 char *arg2, *p2, *saveptr2 =
NULL;
319 char *arg3, *p3, *saveptr3 =
NULL;
322 if (
s->fillcolor_enable) {
332 for (
i = 0;
i <
s->nb_inputs;
i++) {
351 for (
int j = 0; j < 2; j++) {
352 if (!(arg2 =
av_strtok(p2,
"_", &saveptr2)))
357 while ((arg3 =
av_strtok(p3,
"+", &saveptr3))) {
359 if (sscanf(arg3,
"w%d", &
size) == 1) {
364 if (inw > INT_MAX -
ctx->inputs[
size]->w)
368 if (inh > INT_MAX -
ctx->inputs[
size]->w)
372 }
else if (sscanf(arg3,
"h%d", &
size) == 1) {
377 if (inw > INT_MAX -
ctx->inputs[
size]->h)
381 if (inh > INT_MAX -
ctx->inputs[
size]->h)
385 }
else if (sscanf(arg3,
"%d", &
size) == 1) {
390 if (inw > INT_MAX -
size)
394 if (inh > INT_MAX -
size)
409 item->
y[0] = item->
y[3] = inh;
411 if (inlink->
w > INT_MAX - inw || inlink->
h > INT_MAX - inh)
425 for (
i = 1;
i <
s->nb_inputs;
i++) {
430 "Video inputs have different frame rates, output will be VFR\n");
443 for (
i = 0;
i <
s->nb_inputs;
i++) {
473#define OFFSET(x) offsetof(StackContext, x)
474#define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
477 {
"shortest",
"force termination when the shortest input terminates",
OFFSET(shortest),
AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, .flags =
FLAGS },
491#if CONFIG_HSTACK_FILTER
496 .p.priv_class = &stack_class,
508#if CONFIG_VSTACK_FILTER
513 .p.priv_class = &stack_class,
525#if CONFIG_XSTACK_FILTER
527static const AVOption xstack_options[] = {
531 {
"shortest",
"force termination when the shortest input terminates",
OFFSET(shortest),
AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, .flags =
FLAGS },
541 .p.priv_class = &xstack_class,
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static const AVFilterPad outputs[]
const FFFilter ff_vf_hstack
const FFFilter ff_vf_vstack
const FFFilter ff_vf_xstack
int ff_append_inpad_free_name(AVFilterContext *f, AVFilterPad *p)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Main libavfilter public API header.
char * av_asprintf(const char *fmt,...)
#define i(width, name, range_min, range_max)
#define fs(width, name, subs,...)
#define AV_CEIL_RSHIFT(a, b)
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color.
AVFilterFormats * ff_draw_supported_pixel_formats(unsigned flags)
Return the list of pixel formats supported by the draw functions.
void ff_fill_rectangle(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_x, int dst_y, int w, int h)
Fill a rectangle with an uniform color.
int ff_draw_init_from_link(FFDrawContext *draw, const AVFilterLink *link, unsigned flags)
Init a draw context, taking the format, colorspace and range from the given filter link.
int(* init)(AVBSFContext *ctx)
static av_always_inline int process_frame(AVTextFormatContext *tfc, InputFile *ifile, AVFrame *frame, const AVPacket *pkt, int *packet_new)
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, unsigned get)
Get the current frame in an input.
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
int ff_framesync_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in)
Initialize a frame sync structure.
@ EXT_INFINITY
Extend the frame to infinity.
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static AVRational av_make_q(int num, int den)
Create an AVRational.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
static int config_output(AVBitStreamFilterLink *outlink)
#define FILTER_OUTPUTS(array)
#define AVFILTER_DEFINE_CLASS_EXT(name, desc, options)
static FilterLink * ff_filter_link(AVFilterLink *link)
#define AVFILTER_DEFINE_CLASS(fname)
#define FILTER_QUERY_FUNC2(func)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
@ EXT_STOP
Completely stop all streams with this one.
int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen, void *log_ctx)
Put the RGBA values that correspond to color_string in rgba_color.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
Describe the class of an AVClass context structure.
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * src
source filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
int format
agreed upon media format
A filter pad used for either input or output.
enum AVMediaType type
AVFilterPad type.
const char * name
Pad name.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Rational number (pair of numerator and denominator).
enum FFFrameSyncExtMode after
Extrapolation mode for timestamps after the last frame.
enum FFFrameSyncExtMode before
Extrapolation mode for timestamps before the first frame.
AVRational time_base
Time base for the incoming frames.
unsigned sync
Synchronization level: frames on input at the highest sync level will generate output frame events.
Link properties exposed to filter code, but not external callers.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
const AVPixFmtDescriptor * desc
static AVFormatContext * ctx
static const AVOption stack_options[]
static int process_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int activate(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)
static int config_output(AVFilterLink *outlink)
static int process_frame(FFFrameSync *fs)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.