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

Function write_header

libavformat/wtvenc.c:378–441  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

376}
377
378static int write_header(AVFormatContext *s)
379{
380 AVIOContext *pb = s->pb;
381 WtvContext *wctx = s->priv_data;
382 int i, pad, ret;
383 AVStream *st;
384
385 wctx->last_chunk_pos = -1;
386 wctx->last_timestamp_pos = -1;
387
388 ff_put_guid(pb, &ff_wtv_guid);
389 ff_put_guid(pb, &sub_wtv_guid);
390
391 avio_wl32(pb, 0x01);
392 avio_wl32(pb, 0x02);
393 avio_wl32(pb, 1 << WTV_SECTOR_BITS);
394 avio_wl32(pb, 1 << WTV_BIGSECTOR_BITS);
395
396 //write initial root fields
397 avio_wl32(pb, 0); // root_size, update later
398 write_pad(pb, 4);
399 avio_wl32(pb, 0); // root_sector, update it later.
400
401 write_pad(pb, 32);
402 avio_wl32(pb, 0); // file ends pointer, update it later.
403
404 pad = (1 << WTV_SECTOR_BITS) - avio_tell(pb);
405 write_pad(pb, pad);
406
407 wctx->timeline_start_pos = avio_tell(pb);
408
409 wctx->serial = 1;
410 wctx->last_chunk_pos = -1;
411 wctx->first_video_flag = 1;
412
413 for (i = 0; i < s->nb_streams; i++) {
414 st = s->streams[i];
415 if (st->codecpar->codec_id == AV_CODEC_ID_MJPEG)
416 continue;
417 ret = write_stream_codec(s, st);
418 if (ret < 0) {
419 av_log(s, AV_LOG_ERROR, "write stream codec failed codec_type(0x%x)\n", st->codecpar->codec_type);
420 return -1;
421 }
422 if (!i)
423 write_sync(s);
424 }
425
426 for (i = 0; i < s->nb_streams; i++) {
427 st = s->streams[i];
428 if (st->codecpar->codec_id == AV_CODEC_ID_MJPEG)
429 continue;
430 ret = write_stream_data(s, st);
431 if (ret < 0) {
432 av_log(s, AV_LOG_ERROR, "write stream data failed codec_type(0x%x)\n", st->codecpar->codec_type);
433 return -1;
434 }
435 }

Callers

nothing calls this directly

Calls 8

ff_put_guidFunction · 0.85
avio_wl32Function · 0.85
avio_tellFunction · 0.85
write_stream_codecFunction · 0.85
av_logFunction · 0.85
write_syncFunction · 0.85
write_stream_dataFunction · 0.85
write_indexFunction · 0.70

Tested by

no test coverage detected