Go to the documentation of this file.
42 #define OFFSET(x) offsetof(StreamSelectContext, x)
43 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
44 #define TFLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM
58 int i, j,
ret = 0, have_out = 0;
60 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
65 for (j = 0; j <
ctx->nb_inputs; j++) {
66 for (
i = 0;
i <
s->nb_map;
i++) {
70 if (
s->is_audio &&
s->last_pts[j] == in[j]->
pts &&
71 ctx->outputs[
i]->frame_count_in > 0)
78 s->last_pts[j] = in[j]->
pts;
103 const int inlink_idx =
s->map[outlink_idx];
109 "with settings from input link %d\n",
110 outlink_idx, inlink_idx);
112 switch (outlink->
type) {
128 if (
s->fs.opaque ==
s)
138 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
154 const char *padtype = is_input ?
"in" :
"out";
157 for (
i = 0;
i < nb_pads;
i++) {
192 new_map =
av_calloc(
s->nb_inputs,
sizeof(*new_map));
198 const int n = strtol(
map, &p, 0);
206 if (new_nb_map >=
s->nb_inputs) {
208 "input pads available\n",
s->nb_inputs);
213 if (n < 0 || n >=
ctx->nb_inputs) {
215 "(there is only %d input streams defined)\n",
222 new_map[new_nb_map++] = n;
233 s->nb_map = new_nb_map;
241 char *res,
int res_len,
int flags)
243 if (!strcmp(cmd,
"map")) {
256 int ret, nb_outputs = 0;
257 char *
map =
s->map_str;
259 if (!strcmp(
ctx->filter->name,
"astreamselect"))
272 s->last_pts =
av_calloc(
s->nb_inputs,
sizeof(*
s->last_pts));
281 ctx->nb_inputs,
ctx->nb_outputs);
301 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
317 .
name =
"streamselect",
325 .priv_class = &streamselect_class,
330 .
name =
"astreamselect",
332 .priv_class = &streamselect_class,
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.
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(streamselect, "(a)streamselect", streamselect_options)
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).
#define FILTER_QUERY_FUNC(func)
#define AV_LOG_VERBOSE
Detailed information.
static int parse_mapping(AVFilterContext *ctx, const char *map)
const char * name
Filter name.
int nb_channels
Number of channels in this layout.
A link between two filters.
static int process_frame(FFFrameSync *fs)
@ EXT_STOP
Completely stop all streams with this one.
static const AVOption streamselect_options[]
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.
int ff_filter_config_links(AVFilterContext *filter)
Negotiate the media format, dimensions, etc of all inputs to a filter.
enum AVMediaType type
filter media type
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const AVFilter ff_vf_streamselect
#define FF_OUTLINK_IDX(link)
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
static int query_formats(AVFilterContext *ctx)
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0,...
const AVFilter ff_af_astreamselect
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static int activate(AVFilterContext *ctx)
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Describe the class of an AVClass context structure.
static int config_output(AVFilterLink *outlink)
#define fs(width, name, subs,...)
int ff_append_inpad_free_name(AVFilterContext *f, AVFilterPad *p)
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
#define AVFILTER_FLAG_DYNAMIC_OUTPUTS
The number of the filter outputs is not determined just by AVFilter.outputs.
int(* config_props)(AVFilterLink *link)
Link configuration callback.
static av_cold int init(AVFilterContext *ctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int format
agreed upon media format
AVFilterContext * src
source filter
int sample_rate
samples per second
#define i(width, name, range_min, range_max)
int w
agreed upon image width
const char * name
Pad name.
void * av_calloc(size_t nmemb, size_t size)
enum AVMediaType type
AVFilterPad type.
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.
const VDPAUPixFmtMap * map
AVChannelLayout ch_layout
channel layout of current buffer (see libavutil/channel_layout.h)
int ff_append_outpad_free_name(AVFilterContext *f, AVFilterPad *p)
static av_cold void uninit(AVFilterContext *ctx)
#define flags(name, subs,...)
static int parse_definition(AVFilterContext *ctx, int nb_pads, int is_input, int is_audio)
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.
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.