26#include "config_components.h"
44#define DURATION_LONGEST 0
45#define DURATION_SHORTEST 1
46#define DURATION_FIRST 2
48#define OFFSET(x) offsetof(InterleaveContext, x)
50#define DEFINE_OPTIONS(filt_name, flags_) \
51static const AVOption filt_name##_options[] = { \
52 { "nb_inputs", "set number of inputs", OFFSET(nb_inputs), AV_OPT_TYPE_INT, {.i64 = 2}, 1, INT_MAX, .flags = flags_ }, \
53 { "n", "set number of inputs", OFFSET(nb_inputs), AV_OPT_TYPE_INT, {.i64 = 2}, 1, INT_MAX, .flags = flags_ }, \
54 { "duration", "how to determine the end-of-stream", \
55 OFFSET(duration_mode), AV_OPT_TYPE_INT, { .i64 = DURATION_LONGEST }, 0, 2, flags_, .unit = "duration" }, \
56 { "longest", "Duration of longest input", 0, AV_OPT_TYPE_CONST, { .i64 = DURATION_LONGEST }, 0, 0, flags_, .unit = "duration" }, \
57 { "shortest", "Duration of shortest input", 0, AV_OPT_TYPE_CONST, { .i64 = DURATION_SHORTEST }, 0, 0, flags_, .unit = "duration" }, \
58 { "first", "Duration of first input", 0, AV_OPT_TYPE_CONST, { .i64 = DURATION_FIRST }, 0, 0, flags_, .unit = "duration" }, \
67 int i, nb_eofs = 0, input_idx = -1;
71 int nb_inputs_with_frames = 0;
75 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
90 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
93 nb_inputs_with_frames++;
96 if (nb_inputs_with_frames >=
ctx->nb_inputs - nb_eofs) {
97 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
108 "NOPTS value for input frame cannot be accepted, frame discarded\n");
123 if (input_idx >= 0) {
136 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
160 for (
i = 0;
i <
s->nb_inputs;
i++) {
168 switch (outpad->
type) {
192 outlink->
w = inlink0->
w;
193 outlink->
h = inlink0->
h;
197 for (
i = 1;
i <
ctx->nb_inputs;
i++) {
200 if (outlink->
w != inlink->
w ||
201 outlink->
h != inlink->
h ||
205 "(size %dx%d, SAR %d:%d) do not match the corresponding "
206 "output link parameters (%dx%d, SAR %d:%d)\n",
207 ctx->input_pads[
i].name, inlink->
w, inlink->
h,
210 outlink->
w, outlink->
h,
220#if CONFIG_INTERLEAVE_FILTER
234 .p.name =
"interleave",
236 .p.priv_class = &interleave_class,
246#if CONFIG_AINTERLEAVE_FILTER
260 .p.name =
"ainterleave",
262 .p.priv_class = &ainterleave_class,
#define DURATION_SHORTEST
const FFFilter ff_vf_interleave
const FFFilter ff_af_ainterleave
AVFrame * ff_null_get_audio_buffer(AVFilterLink *link, int nb_samples)
get_audio_buffer() handler for filters which simply pass audio along
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_append_inpad_free_name(AVFilterContext *f, AVFilterPad *p)
int ff_outlink_get_status(AVFilterLink *link)
Get the status on an output link.
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
size_t ff_inlink_queued_frames(AVFilterLink *link)
Get the number of frames available on the link.
AVFrame * ff_inlink_peek_frame(AVFilterLink *link, size_t idx)
Access a frame in the link fifo without consuming it.
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Main libavfilter public API header.
char * av_asprintf(const char *fmt,...)
#define i(width, name, range_min, range_max)
int(* init)(AVBSFContext *ctx)
#define DEFINE_OPTIONS(filt_name, flags_)
static int activate(AVFilterContext *ctx)
static int config_output(AVFilterLink *outlink)
#define AV_OPT_FLAG_FILTERING_PARAM
A generic parameter which can be set by the user for filtering.
#define AV_OPT_FLAG_AUDIO_PARAM
#define AV_OPT_FLAG_VIDEO_PARAM
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
static int activate(AVBitStreamFilterContext *ctx)
static int config_output(AVBitStreamFilterLink *outlink)
#define FILTER_OUTPUTS(array)
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
#define FFERROR_NOT_READY
Filters implementation helper functions and internal structures.
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
static FilterLink * ff_filter_link(AVFilterLink *link)
#define AVFILTER_DEFINE_CLASS(fname)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
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
enum AVMediaType type
filter media type
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.
AVFrame *(* audio)(AVFilterLink *link, int nb_samples)
enum AVMediaType type
AVFilterPad type.
AVFrame *(* video)(AVFilterLink *link, int w, int h)
union AVFilterPad::@363170257351226013155122005037023043242205350137 get_buffer
Callback functions to get a video/audio buffers.
const char * name
Pad name.
This structure describes decoded (raw) audio or video data.
Rational number (pair of numerator and denominator).
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.
static AVFormatContext * ctx
static void interleave(uint8_t *dst, uint8_t *src, int w, int h, int dst_linesize, int src_linesize, enum FilterMode mode, int swap)
AVFrame * ff_null_get_video_buffer(AVFilterLink *link, int w, int h)