Go to the documentation of this file.
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++) {
240 }
else if (
s->is_horizontal) {
241 for (
i = 0;
i <
s->nb_inputs;
i++) {
265 }
else if (
s->nb_grid_rows &&
s->nb_grid_columns) {
266 int inw = 0, inh = 0;
271 for (
i = 0;
i <
s->nb_grid_rows;
i++, inh += row_height) {
272 row_height =
ctx->inputs[
i *
s->nb_grid_columns]->h;
274 for (
int j = 0; j <
s->nb_grid_columns; j++, k++) {
278 if (
ctx->inputs[k]->h != row_height) {
280 k,
ctx->inputs[k]->h, row_height);
296 item->
y[0] = item->
y[3] = inh;
297 inw +=
ctx->inputs[k]->w;
308 char *
arg, *p =
s->layout, *saveptr =
NULL;
309 char *arg2, *p2, *saveptr2 =
NULL;
310 char *arg3, *p3, *saveptr3 =
NULL;
313 if (
s->fillcolor_enable) {
319 for (
i = 0;
i <
s->nb_inputs;
i++) {
338 for (
int j = 0; j < 2; j++) {
339 if (!(arg2 =
av_strtok(p2,
"_", &saveptr2)))
344 while ((arg3 =
av_strtok(p3,
"+", &saveptr3))) {
346 if (sscanf(arg3,
"w%d", &
size) == 1) {
347 if (
size ==
i || size < 0 || size >=
s->nb_inputs)
354 }
else if (sscanf(arg3,
"h%d", &
size) == 1) {
355 if (
size ==
i || size < 0 || size >=
s->nb_inputs)
362 }
else if (sscanf(arg3,
"%d", &
size) == 1) {
381 item->
y[0] = item->
y[3] = inh;
395 for (
i = 1;
i <
s->nb_inputs;
i++) {
400 "Video inputs have different frame rates, output will be VFR\n");
413 for (
i = 0;
i <
s->nb_inputs;
i++) {
443 #define OFFSET(x) offsetof(StackContext, x)
444 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
447 {
"shortest",
"force termination when the shortest input terminates",
OFFSET(shortest),
AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, .flags =
FLAGS },
461 #if CONFIG_HSTACK_FILTER
466 .priv_class = &stack_class,
478 #if CONFIG_VSTACK_FILTER
483 .priv_class = &stack_class,
495 #if CONFIG_XSTACK_FILTER
497 static const AVOption xstack_options[] = {
501 {
"shortest",
"force termination when the shortest input terminates",
OFFSET(shortest),
AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, .flags =
FLAGS },
512 .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.
#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.
Link properties exposed to filter code, but not external callers.
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
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)
#define FILTER_OUTPUTS(array)
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
Underlying C type is two consecutive integers.
const AVFilter ff_vf_hstack
#define AVFILTER_DEFINE_CLASS(fname)
const AVFilter ff_vf_vstack
static FilterLink * ff_filter_link(AVFilterLink *link)
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
#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
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.
#define FILTER_QUERY_FUNC2(func)
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
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
@ AV_OPT_TYPE_INT
Underlying C type is int.
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...
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
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.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
@ 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 AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
static const AVOption stack_options[]