Go to the documentation of this file.
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_) \
51 static 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_, "duration" }, \
56 { "longest", "Duration of longest input", 0, AV_OPT_TYPE_CONST, { .i64 = DURATION_LONGEST }, 0, 0, flags_, "duration" }, \
57 { "shortest", "Duration of shortest input", 0, AV_OPT_TYPE_CONST, { .i64 = DURATION_SHORTEST }, 0, 0, flags_, "duration" }, \
58 { "first", "Duration of first input", 0, AV_OPT_TYPE_CONST, { .i64 = DURATION_FIRST }, 0, 0, flags_, "duration" }, \
66 int64_t q_pts,
pts = INT64_MAX;
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) {
191 outlink->
w = inlink0->
w;
192 outlink->
h = inlink0->
h;
196 for (
i = 1;
i <
ctx->nb_inputs;
i++) {
204 "(size %dx%d, SAR %d:%d) do not match the corresponding "
205 "output link parameters (%dx%d, SAR %d:%d)\n",
207 inlink->sample_aspect_ratio.num,
208 inlink->sample_aspect_ratio.den,
209 outlink->
w, outlink->
h,
219 #if CONFIG_INTERLEAVE_FILTER
233 .
name =
"interleave",
239 .priv_class = &interleave_class,
245 #if CONFIG_AINTERLEAVE_FILTER
259 .
name =
"ainterleave",
265 .priv_class = &ainterleave_class,
#define AV_LOG_WARNING
Something somehow does not look correct.
they must not be accessed directly The fifo field contains the frames that are queued in the input for processing by the filter The status_in and status_out fields contains the queued status(EOF or error) of the link
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
#define AV_OPT_FLAG_VIDEO_PARAM
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
#define AVERROR_EOF
End of file.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
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,...)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
const char * name
Filter name.
A link between two filters.
#define AV_OPT_FLAG_FILTERING_PARAM
a generic parameter which can be set by the user for filtering
static int config_output(AVFilterLink *outlink)
static int activate(AVFilterContext *ctx)
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
const AVFilter ff_af_ainterleave
#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.
const AVFilter ff_vf_interleave
#define DEFINE_OPTIONS(filt_name, flags_)
enum AVMediaType type
filter media type
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
#define av_assert0(cond)
assert() equivalent, that is always enabled.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0,...
AVFrame * ff_null_get_audio_buffer(AVFilterLink *link, int nb_samples)
get_audio_buffer() handler for filters which simply pass audio along
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static av_cold int init(AVFilterContext *ctx)
#define AV_OPT_FLAG_AUDIO_PARAM
AVFrame * ff_inlink_peek_frame(AVFilterLink *link, size_t idx)
Access a frame in the link fifo without consuming it.
Describe the class of an AVClass context structure.
Rational number (pair of numerator and denominator).
int ff_append_inpad_free_name(AVFilterContext *f, AVFilterPad *p)
union AVFilterPad::@209 get_buffer
Callback functions to get a video/audio buffers.
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
size_t ff_inlink_queued_frames(AVFilterLink *link)
Get the number of frames available on the link.
static void interleave(uint8_t *dst, uint8_t *src, int w, int h, int dst_linesize, int src_linesize, enum FilterMode mode, int swap)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int format
agreed upon media format
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define DURATION_SHORTEST
AVFilterContext * src
source filter
AVFrame * ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
#define AVFILTER_DEFINE_CLASS(fname)
#define i(width, name, range_min, range_max)
int w
agreed upon image width
const char * name
Pad name.
enum AVMediaType type
AVFilterPad type.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
AVFrame *(* video)(AVFilterLink *link, int w, int h)
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.
int ff_outlink_get_status(AVFilterLink *link)
Get the status on an output link.
AVFrame *(* audio)(AVFilterLink *link, int nb_samples)
#define FILTER_OUTPUTS(array)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.