MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / avformat_open_input

Function avformat_open_input

libavformat/demux.c:231–375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229}
230
231int avformat_open_input(AVFormatContext **ps, const char *filename,
232 const AVInputFormat *fmt, AVDictionary **options)
233{
234 FormatContextInternal *fci;
235 AVFormatContext *s = *ps;
236 FFFormatContext *si;
237 AVDictionary *tmp = NULL;
238 ID3v2ExtraMeta *id3v2_extra_meta = NULL;
239 int ret = 0;
240
241 if (!s && !(s = avformat_alloc_context()))
242 return AVERROR(ENOMEM);
243 fci = ff_fc_internal(s);
244 si = &fci->fc;
245 if (!s->av_class) {
246 av_log(NULL, AV_LOG_ERROR, "Input context has not been properly allocated by avformat_alloc_context() and is not NULL either\n");
247 return AVERROR(EINVAL);
248 }
249 if (fmt)
250 s->iformat = fmt;
251
252 if (options)
253 av_dict_copy(&tmp, *options, 0);
254
255 if (s->pb) // must be before any goto fail
256 s->flags |= AVFMT_FLAG_CUSTOM_IO;
257
258 if ((ret = av_opt_set_dict(s, &tmp)) < 0)
259 goto fail;
260
261 if (!(s->url = av_strdup(filename ? filename : ""))) {
262 ret = AVERROR(ENOMEM);
263 goto fail;
264 }
265
266 if ((ret = init_input(s, filename, &tmp)) < 0)
267 goto fail;
268 s->probe_score = ret;
269
270 if (!s->protocol_whitelist && s->pb && s->pb->protocol_whitelist) {
271 s->protocol_whitelist = av_strdup(s->pb->protocol_whitelist);
272 if (!s->protocol_whitelist) {
273 ret = AVERROR(ENOMEM);
274 goto fail;
275 }
276 }
277
278 if (!s->protocol_blacklist && s->pb && s->pb->protocol_blacklist) {
279 s->protocol_blacklist = av_strdup(s->pb->protocol_blacklist);
280 if (!s->protocol_blacklist) {
281 ret = AVERROR(ENOMEM);
282 goto fail;
283 }
284 }
285
286 if (s->format_whitelist && av_match_list(s->iformat->name, s->format_whitelist, ',') <= 0) {
287 av_log(s, AV_LOG_ERROR, "Format not on whitelist \'%s\'\n", s->format_whitelist);
288 ret = AVERROR(EINVAL);

Callers 15

handle_fileFunction · 0.85
mainFunction · 0.85
LLVMFuzzerTestOneInputFunction · 0.85
mainFunction · 0.85
handle_fileFunction · 0.85
ds_openFunction · 0.85
dvdvideo_subdemux_openFunction · 0.85
read_gab2_subFunction · 0.85
ff_wms_parse_sdp_a_lineFunction · 0.85
vobsub_read_headerFunction · 0.85
init_subtitle_contextFunction · 0.85

Calls 15

avformat_alloc_contextFunction · 0.85
av_logFunction · 0.85
av_dict_copyFunction · 0.85
av_opt_set_dictFunction · 0.85
av_strdupFunction · 0.85
init_inputFunction · 0.85
av_match_listFunction · 0.85
avio_skipFunction · 0.85
av_filename_number_testFunction · 0.85
ffifmtFunction · 0.85
av_opt_set_defaultsFunction · 0.85
is_id3v2_formatFunction · 0.85

Tested by 5

mainFunction · 0.68
video_decodeFunction · 0.68
seek_testFunction · 0.68
dump_stream_metaFunction · 0.68
video_decode_exampleFunction · 0.68