Go to the documentation of this file.
21 #include "config_components.h"
72 if (
s->fillcolor_enable) {
84 if (!strcmp(
ctx->filter->name,
"vstack"))
87 if (!strcmp(
ctx->filter->name,
"hstack"))
90 if (!strcmp(
ctx->filter->name,
"xstack")) {
92 if (strcmp(
s->fillcolor_str,
"none") &&
94 s->fillcolor_enable = 1;
96 s->fillcolor_enable = 0;
98 is_grid =
s->nb_grid_rows &&
s->nb_grid_columns;
99 if (
s->layout && is_grid) {
103 if (!
s->layout && !is_grid) {
104 if (
s->nb_inputs == 2) {
106 s->nb_grid_columns = 2;
115 s->nb_inputs =
s->nb_grid_rows *
s->nb_grid_columns;
118 s->frames =
av_calloc(
s->nb_inputs,
sizeof(*
s->frames));
126 for (
i = 0;
i <
s->nb_inputs;
i++) {
146 const int start = (
s->nb_inputs * job ) / nb_jobs;
147 const int end = (
s->nb_inputs * (job+1)) / nb_jobs;
149 for (
int i = start;
i < end;
i++) {
152 for (
int p = 0; p <
s->nb_planes; p++) {
173 for (
i = 0;
i <
s->nb_inputs;
i++) {
184 if (
s->fillcolor_enable)
186 0, 0, outlink->
w, outlink->
h);
209 if (
s->is_vertical) {
210 for (
i = 0;
i <
s->nb_inputs;
i++) {
233 }
else if (
s->is_horizontal) {
234 for (
i = 0;
i <
s->nb_inputs;
i++) {
258 }
else if (
s->nb_grid_rows &&
s->nb_grid_columns) {
259 int inw = 0, inh = 0;
264 for (
i = 0;
i <
s->nb_grid_rows;
i++, inh += row_height) {
265 row_height =
ctx->inputs[
i *
s->nb_grid_columns]->h;
267 for (
int j = 0; j <
s->nb_grid_columns; j++, k++) {
271 if (
ctx->inputs[k]->h != row_height) {
273 k,
ctx->inputs[k]->h, row_height);
289 item->
y[0] = item->
y[3] = inh;
290 inw +=
ctx->inputs[k]->w;
301 char *
arg, *p =
s->layout, *saveptr =
NULL;
302 char *arg2, *p2, *saveptr2 =
NULL;
303 char *arg3, *p3, *saveptr3 =
NULL;
306 if (
s->fillcolor_enable) {
312 for (
i = 0;
i <
s->nb_inputs;
i++) {
331 for (
int j = 0; j < 2; j++) {
332 if (!(arg2 =
av_strtok(p2,
"_", &saveptr2)))
337 while ((arg3 =
av_strtok(p3,
"+", &saveptr3))) {
339 if (sscanf(arg3,
"w%d", &
size) == 1) {
340 if (
size ==
i || size < 0 || size >=
s->nb_inputs)
347 }
else if (sscanf(arg3,
"h%d", &
size) == 1) {
348 if (
size ==
i || size < 0 || size >=
s->nb_inputs)
355 }
else if (sscanf(arg3,
"%d", &
size) == 1) {
374 item->
y[0] = item->
y[3] = inh;
388 for (
i = 1;
i <
s->nb_inputs;
i++) {
393 "Video inputs have different frame rates, output will be VFR\n");
406 for (
i = 0;
i <
s->nb_inputs;
i++) {
436 #define OFFSET(x) offsetof(StackContext, x)
437 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
440 {
"shortest",
"force termination when the shortest input terminates",
OFFSET(shortest),
AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, .flags =
FLAGS },
454 #if CONFIG_HSTACK_FILTER
459 .priv_class = &stack_class,
471 #if CONFIG_VSTACK_FILTER
476 .priv_class = &stack_class,
488 #if CONFIG_XSTACK_FILTER
490 static const AVOption xstack_options[] = {
494 {
"shortest",
"force termination when the shortest input terminates",
OFFSET(shortest),
AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, .flags =
FLAGS },
505 .priv_class = &xstack_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
AVRational time_base
Time base for the incoming frames.
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
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 ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, unsigned get)
Get the current frame in an input.
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
char * av_asprintf(const char *fmt,...)
AVFILTER_DEFINE_CLASS_EXT(stack, "(h|v)stack", stack_options)
This structure describes decoded (raw) audio or video data.
static int query_formats(AVFilterContext *ctx)
#define FILTER_QUERY_FUNC(func)
#define AV_LOG_VERBOSE
Detailed information.
const char * name
Filter name.
@ EXT_INFINITY
Extend the frame to infinity.
A link between two filters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
static av_cold void uninit(AVFilterContext *ctx)
@ EXT_STOP
Completely stop all streams with this one.
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
static const AVFilterPad outputs[]
static int activate(AVFilterContext *ctx)
unsigned sync
Synchronization level: frames on input at the highest sync level will generate output frame events.
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_cold int init(AVFilterContext *ctx)
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.
#define AV_CEIL_RSHIFT(a, b)
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().
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0,...
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static int process_frame(FFFrameSync *fs)
static int config_output(AVFilterLink *outlink)
Describe the class of an AVClass context structure.
#define fs(width, name, subs,...)
Rational number (pair of numerator and denominator).
int ff_append_inpad_free_name(AVFilterContext *f, AVFilterPad *p)
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
const AVFilter ff_vf_hstack
const AVFilter ff_vf_vstack
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int ff_draw_init2(FFDrawContext *draw, enum AVPixelFormat format, enum AVColorSpace csp, enum AVColorRange range, unsigned flags)
Init a draw context.
int format
agreed upon media format
static AVRational av_make_q(int num, int den)
Create an AVRational.
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.
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
AVFilterContext * src
source filter
#define AVFILTER_DEFINE_CLASS(fname)
const AVPixFmtDescriptor * desc
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel layout
#define i(width, name, range_min, range_max)
int w
agreed upon image width
AVFilterFormats * ff_draw_supported_pixel_formats(unsigned flags)
Return the list of pixel formats supported by the draw functions.
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
const char * name
Pad name.
void * av_calloc(size_t nmemb, size_t size)
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color.
enum AVMediaType type
AVFilterPad type.
const AVFilter ff_vf_xstack
int ff_framesync_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in)
Initialize a frame sync structure.
enum FFFrameSyncExtMode before
Extrapolation mode for timestamps before the first frame.
int h
agreed upon image height
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define FILTER_OUTPUTS(array)
static int process_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
enum FFFrameSyncExtMode after
Extrapolation mode for timestamps after the last frame.
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
static const AVOption stack_options[]