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) {
187 for (
int i = 0;
i <
ctx->nb_inputs;
i++)
199 outlink->
w = inlink0->
w;
200 outlink->
h = inlink0->
h;
204 for (
i = 1;
i <
ctx->nb_inputs;
i++) {
207 if (outlink->
w != inlink->
w ||
208 outlink->
h != inlink->
h ||
212 "(size %dx%d, SAR %d:%d) do not match the corresponding "
213 "output link parameters (%dx%d, SAR %d:%d)\n",
214 ctx->input_pads[
i].name, inlink->
w, inlink->
h,
217 outlink->
w, outlink->
h,
227 #if CONFIG_INTERLEAVE_FILTER
242 .
name =
"interleave",
249 .priv_class = &interleave_class,
255 #if CONFIG_AINTERLEAVE_FILTER
270 .
name =
"ainterleave",
276 .
outputs = ainterleave_outputs,
277 .priv_class = &ainterleave_class,
static const AVFilterPad outputs[]
AVFilter ff_vf_interleave
AVFilter 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.
AVFrame * ff_inlink_peek_frame(AVFilterLink *link, size_t idx)
Access a frame in the link fifo without consuming it.
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.
size_t ff_inlink_queued_frames(AVFilterLink *link)
Get the number of frames available on the link.
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 flags(name, subs,...)
static av_always_inline void RENAME() interleave(TYPE *dst, TYPE *src0, TYPE *src1, int w2, int add, int shift)
#define DEFINE_OPTIONS(filt_name, flags_)
#define DURATION_SHORTEST
static int activate(AVFilterContext *ctx)
static av_cold int init(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)
static int config_output(AVFilterLink *outlink)
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.
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
static int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
#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 ff_insert_inpad(AVFilterContext *f, unsigned index, AVFilterPad *p)
Insert a new input pad for the filter.
#define AVFILTER_DEFINE_CLASS(fname)
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#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
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
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0,...
int format
agreed upon media format
A filter pad used for either input or output.
AVFrame *(* get_audio_buffer)(AVFilterLink *link, int nb_samples)
Callback function to get an audio buffer.
enum AVMediaType type
AVFilterPad type.
AVFrame *(* get_video_buffer)(AVFilterLink *link, int w, int h)
Callback function to get a video buffer.
const char * name
Pad name.
const char * name
Filter name.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Rational number (pair of numerator and denominator).
AVFrame * ff_null_get_video_buffer(AVFilterLink *link, int w, int h)