FFmpeg: libavfilter/f_streamselect.c Source File
Go to the documentation of this file. 1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
29
41
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
49 };
50
52
54 {
58 int i, j,
ret = 0, have_out = 0;
59
60 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
63 }
64
65 for (j = 0; j <
ctx->nb_inputs; j++) {
66 for (
i = 0;
i <
s->nb_map;
i++) {
69
70 if (
s->is_audio &&
s->last_pts[j] == in[j]->
pts &&
71 ctx->outputs[
i]->frame_count_in > 0)
72 continue;
76
78 s->last_pts[j] = in[j]->
pts;
80 have_out = 1;
83 }
84 }
85 }
86
87 if (!have_out)
90 }
91
93 {
96 }
97
99 {
103 const int inlink_idx =
s->map[outlink_idx];
107
109 "with settings from input link %d\n",
110 outlink_idx, inlink_idx);
111
112 switch (outlink->
type) {
118 break;
122 #if FF_API_OLD_CHANNEL_LAYOUT
124 outlink->channel_layout =
inlink->channel_layout;
126 #endif
127 break;
128 }
129
132
133 if (
s->fs.opaque ==
s)
134 return 0;
135
138
142
143 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
148 }
149
153
155 }
156
158 {
159 const char *padtype = is_input ? "in" : "out";
161
162 for (
i = 0;
i < nb_pads;
i++) {
164
166
170
172
173 if (is_input) {
175 } else {
178 }
181 }
182
183 return 0;
184 }
185
187 {
189 int *new_map;
190 int new_nb_map = 0;
191
195 }
196
197 new_map =
av_calloc(
s->nb_inputs,
sizeof(*new_map));
198 if (!new_map)
200
201 while (1) {
202 char *p;
203 const int n = strtol(
map, &p, 0);
204
206
208 break;
210
211 if (new_nb_map >=
s->nb_inputs) {
213 "input pads available\n",
s->nb_inputs);
216 }
217
218 if (n < 0 || n >=
ctx->nb_inputs) {
220 "(there is only %d input streams defined)\n",
224 }
225
227 new_map[new_nb_map++] = n;
228 }
229
230 if (!new_nb_map) {
234 }
235
238 s->nb_map = new_nb_map;
239
241
242 return 0;
243 }
244
246 char *res,
int res_len,
int flags)
247 {
248 if (!strcmp(cmd, "map")) {
250
254 }
256 }
257
259 {
261 int ret, nb_outputs = 0;
262 char *
map =
s->map_str;
263
264 if (!strcmp(
ctx->filter->name,
"astreamselect"))
266
268 char *p;
269
272 break;
273 nb_outputs++;
275 }
276
277 s->last_pts =
av_calloc(
s->nb_inputs,
sizeof(*
s->last_pts));
280
284
286 ctx->nb_inputs,
ctx->nb_outputs);
287
289 }
290
292 {
294
299 }
300
302 {
305
306 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
310
315 }
316 }
317
318 return 0;
319 }
320
322 .
name =
"streamselect",
330 .priv_class = &streamselect_class,
332 };
333
335 .
name =
"astreamselect",
337 .priv_class = &streamselect_class,
345 };
#define FF_ENABLE_DEPRECATION_WARNINGS
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[]
int avfilter_config_links(AVFilterContext *filter)
Negotiate the media format, dimensions, etc of all inputs to a filter.
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.
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.
#define FF_DISABLE_DEPRECATION_WARNINGS
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.
Generated on Tue Feb 28 2023 21:33:51 for FFmpeg by
doxygen
1.8.17