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

Function avformat_new_stream

libavformat/options.c:245–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243}
244
245AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
246{
247 FFStream *sti;
248 AVStream *st;
249 AVStream **streams;
250
251 if (s->nb_streams >= s->max_streams) {
252 av_log(s, AV_LOG_ERROR, "Number of streams exceeds max_streams parameter"
253 " (%d), see the documentation if you wish to increase it\n",
254 s->max_streams);
255 return NULL;
256 }
257 streams = av_realloc_array(s->streams, s->nb_streams + 1, sizeof(*streams));
258 if (!streams)
259 return NULL;
260 s->streams = streams;
261
262 sti = av_mallocz(sizeof(*sti));
263 if (!sti)
264 return NULL;
265 st = &sti->pub;
266
267 st->av_class = &stream_class;
268 st->codecpar = avcodec_parameters_alloc();
269 if (!st->codecpar)
270 goto fail;
271
272 sti->fmtctx = s;
273
274 sti->parse_pkt = av_packet_alloc();
275 if (!sti->parse_pkt)
276 goto fail;
277
278 if (s->iformat) {
279 sti->avctx = avcodec_alloc_context3(NULL);
280 if (!sti->avctx)
281 goto fail;
282
283 sti->info = av_mallocz(sizeof(*sti->info));
284 if (!sti->info)
285 goto fail;
286
287#if FF_API_R_FRAME_RATE
288 sti->info->last_dts = AV_NOPTS_VALUE;
289#endif
290 sti->info->fps_first_dts = AV_NOPTS_VALUE;
291 sti->info->fps_last_dts = AV_NOPTS_VALUE;
292
293 /* default pts setting is MPEG-like */
294 avpriv_set_pts_info(st, 33, 1, 90000);
295 /* we set the current DTS to 0 so that formats without any timestamps
296 * but durations get some timestamps, formats with some unknown
297 * timestamps have their first few packets buffered and the
298 * timestamps corrected before they are returned to the user */
299 sti->cur_dts = RELATIVE_TS_BASE;
300 } else {
301 sti->cur_dts = AV_NOPTS_VALUE;
302 }

Callers 15

audio_read_headerFunction · 0.85
create_streamFunction · 0.85
pulse_read_headerFunction · 0.85
audio_read_headerFunction · 0.85
iec61883_read_headerFunction · 0.85
vfw_read_headerFunction · 0.85
ff_decklink_read_headerFunction · 0.85
v4l2_read_headerFunction · 0.85
read_headerFunction · 0.85
fbdev_read_headerFunction · 0.85
dshow_add_deviceFunction · 0.85
create_subcc_streamsFunction · 0.85

Calls 8

av_logFunction · 0.85
av_realloc_arrayFunction · 0.85
avcodec_parameters_allocFunction · 0.85
av_packet_allocFunction · 0.85
avcodec_alloc_context3Function · 0.85
avpriv_set_pts_infoFunction · 0.85
ff_free_streamFunction · 0.85
av_malloczFunction · 0.50

Tested by 3

vc1t_read_headerFunction · 0.68
init_fpsFunction · 0.68