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

Function mov_write_header

libavformat/movenc.c:8385–8563  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8383}
8384
8385static int mov_write_header(AVFormatContext *s)
8386{
8387 AVIOContext *pb = s->pb;
8388 MOVMuxContext *mov = s->priv_data;
8389 int ret, hint_track = 0, tmcd_track = 0, nb_tracks = mov->nb_streams;
8390
8391 if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && s->nb_chapters)
8392 nb_tracks++;
8393
8394 if (mov->flags & FF_MOV_FLAG_RTP_HINT) {
8395 hint_track = nb_tracks;
8396 for (int i = 0; i < mov->nb_streams; i++) {
8397 if (rtp_hinting_needed(mov->tracks[i].st))
8398 nb_tracks++;
8399 }
8400 }
8401
8402 if (mov->nb_meta_tmcd)
8403 tmcd_track = nb_tracks;
8404
8405 for (int i = 0; i < mov->nb_streams; i++) {
8406 MOVTrack *track = &mov->tracks[i];
8407 AVStream *st = track->st;
8408
8409 /* copy extradata if it exists */
8410 if (st->codecpar->extradata_size) {
8411 if (st->codecpar->codec_id == AV_CODEC_ID_DVD_SUBTITLE)
8412 mov_create_dvd_sub_decoder_specific_info(track, st);
8413 else if (!TAG_IS_AVCI(track->tag) && st->codecpar->codec_id != AV_CODEC_ID_DNXHD) {
8414 track->extradata_size[track->last_stsd_index] = st->codecpar->extradata_size;
8415 track->extradata[track->last_stsd_index] =
8416 av_malloc(track->extradata_size[track->last_stsd_index] + AV_INPUT_BUFFER_PADDING_SIZE);
8417 if (!track->extradata[track->last_stsd_index]) {
8418 return AVERROR(ENOMEM);
8419 }
8420 memcpy(track->extradata[track->last_stsd_index],
8421 st->codecpar->extradata, track->extradata_size[track->last_stsd_index]);
8422 memset(track->extradata[track->last_stsd_index] + track->extradata_size[track->last_stsd_index],
8423 0, AV_INPUT_BUFFER_PADDING_SIZE);
8424 }
8425 }
8426
8427 if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO ||
8428 av_channel_layout_compare(&track->par->ch_layout,
8429 &(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO))
8430 continue;
8431
8432 for (int j = 0; j < mov->nb_streams; j++) {
8433 AVStream *stj= mov->tracks[j].st;
8434 MOVTrack *trackj= &mov->tracks[j];
8435 if (j == i)
8436 continue;
8437
8438 if (stj->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
8439 (trackj->par->ch_layout.nb_channels != 1 ||
8440 !av_channel_layout_compare(&trackj->par->ch_layout,
8441 &(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO))
8442 )

Callers

nothing calls this directly

Calls 15

rtp_hinting_neededFunction · 0.85
mov_write_identificationFunction · 0.85
avio_tellFunction · 0.85
avio_skipFunction · 0.85
avio_wb32Function · 0.85
ffio_wfourccFunction · 0.85
mov_write_mdat_tagFunction · 0.85
mov_create_chapter_trackFunction · 0.85
ff_mov_init_hintingFunction · 0.85

Tested by

no test coverage detected