Skip to content

Commit

Permalink
avformat: remove avio_flush() calls from the end of write_header func…
Browse files Browse the repository at this point in the history
…tions

To make it consistent with other muxers.

The user can still control the generic flushing behaviour after write_header
(same way as after packets) using the -flush_packets option, the default
typically means to flush unless a non-streamed file output is used.

Therefore this change should have no adverse effect on streaming, even if it is
assumed that the first packet has a clean buffer, so small seekbacks within the
output buffer work even when the IO context is not seekable.

Signed-off-by: Marton Balint <[email protected]>
  • Loading branch information
cus committed Jan 7, 2020
1 parent 4d7f825 commit 4bf90e0
Show file tree
Hide file tree
Showing 28 changed files with 0 additions and 40 deletions.
3 changes: 0 additions & 3 deletions libavformat/aiffenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,6 @@ static int aiff_write_header(AVFormatContext *s)
avpriv_set_pts_info(s->streams[aiff->audio_stream_idx], 64, 1,
s->streams[aiff->audio_stream_idx]->codecpar->sample_rate);

/* Data is starting here */
avio_flush(pb);

return 0;
}

Expand Down
1 change: 0 additions & 1 deletion libavformat/amr.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ static int amr_write_header(AVFormatContext *s)
} else {
return -1;
}
avio_flush(pb);
return 0;
}

Expand Down
2 changes: 0 additions & 2 deletions libavformat/asfenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,8 +801,6 @@ static int asf_write_header(AVFormatContext *s)
return -1;
}

avio_flush(s->pb);

asf->packet_nb_payloads = 0;
asf->packet_timestamp_start = -1;
asf->packet_timestamp_end = -1;
Expand Down
1 change: 0 additions & 1 deletion libavformat/assenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ static int write_header(AVFormatContext *s)
avio_printf(s->pb, "[Events]\r\nFormat: %s, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\r\n",
ass->ssa_mode ? "Marked" : "Layer");
}
avio_flush(s->pb);

return 0;
}
Expand Down
2 changes: 0 additions & 2 deletions libavformat/astenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ static int ast_write_header(AVFormatContext *s)
avio_wb64(pb, 0);
avio_wb32(pb, 0);

avio_flush(pb);

return 0;
}

Expand Down
1 change: 0 additions & 1 deletion libavformat/au.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ static int au_write_header(AVFormatContext *s)
} else {
avio_wb64(pb, 0); /* annotation field */
}
avio_flush(pb);

return 0;
}
Expand Down
2 changes: 0 additions & 2 deletions libavformat/avienc.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,6 @@ static int avi_write_header(AVFormatContext *s)
avi->movi_list = ff_start_tag(pb, "LIST");
ffio_wfourcc(pb, "movi");

avio_flush(pb);

return 0;
}

Expand Down
1 change: 0 additions & 1 deletion libavformat/cafenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ static int caf_write_header(AVFormatContext *s)
avio_wb64(pb, -1); //< mChunkSize
avio_wb32(pb, 0); //< mEditCount

avio_flush(pb);
return 0;
}

Expand Down
1 change: 0 additions & 1 deletion libavformat/ffmetaenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ static int write_header(AVFormatContext *s)
avio_write(s->pb, ID_STRING, sizeof(ID_STRING) - 1);
avio_w8(s->pb, '1'); // version
avio_w8(s->pb, '\n');
avio_flush(s->pb);
return 0;
}

Expand Down
1 change: 0 additions & 1 deletion libavformat/framehash.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ int ff_framehash_write_header(AVFormatContext *s)
avio_printf(s->pb, "#sar %d: %d/%d\n", i, st->sample_aspect_ratio.num, st->sample_aspect_ratio.den);
break;
}
avio_flush(s->pb);
}
return 0;
}
1 change: 0 additions & 1 deletion libavformat/gxfenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,6 @@ static int gxf_write_header(AVFormatContext *s)

gxf->packet_count = 3;

avio_flush(pb);
return 0;
}

Expand Down
2 changes: 0 additions & 2 deletions libavformat/icoenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ static int ico_write_header(AVFormatContext *s)
if (!ico->images)
return AVERROR(ENOMEM);

avio_flush(pb);

return 0;
}

Expand Down
1 change: 0 additions & 1 deletion libavformat/idroqenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ static int roq_write_header(struct AVFormatContext *s)
}

avio_write(s->pb, header, 8);
avio_flush(s->pb);

return 0;
}
Expand Down
1 change: 0 additions & 1 deletion libavformat/ilbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ static int ilbc_write_header(AVFormatContext *s)
av_log(s, AV_LOG_ERROR, "Unsupported mode\n");
return AVERROR(EINVAL);
}
avio_flush(pb);
return 0;
}

Expand Down
1 change: 0 additions & 1 deletion libavformat/jacosubenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ static int jacosub_write_header(AVFormatContext *s)

if (par->extradata_size) {
avio_write(s->pb, par->extradata, par->extradata_size - 1);
avio_flush(s->pb);
}
return 0;
}
Expand Down
2 changes: 0 additions & 2 deletions libavformat/matroskaenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2000,8 +2000,6 @@ static int mkv_write_header(AVFormatContext *s)
mkv->cur_audio_pkt.size = 0;
mkv->cluster_pos = -1;

avio_flush(pb);

// start a new cluster every 5 MB or 5 sec, or 32k / 1 sec for streaming or
// after 4k and on a keyframe
if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
Expand Down
1 change: 0 additions & 1 deletion libavformat/microdvdenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ static int microdvd_write_header(struct AVFormatContext *s)
avio_write(s->pb, "{DEFAULT}{}", 11);
avio_write(s->pb, par->extradata, par->extradata_size);
avio_w8(s->pb, '\n');
avio_flush(s->pb);
}

avpriv_set_pts_info(s->streams[0], 64, framerate.num, framerate.den);
Expand Down
2 changes: 0 additions & 2 deletions libavformat/mmf.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ static int mmf_write_header(AVFormatContext *s)

avpriv_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codecpar->sample_rate);

avio_flush(pb);

return 0;
}

Expand Down
1 change: 0 additions & 1 deletion libavformat/movenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6579,7 +6579,6 @@ static int mov_write_header(AVFormatContext *s)
!(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) {
if ((ret = mov_write_moov_tag(pb, mov, s)) < 0)
return ret;
avio_flush(pb);
mov->moov_written = 1;
if (mov->flags & FF_MOV_FLAG_GLOBAL_SIDX)
mov->reserved_header_pos = avio_tell(pb);
Expand Down
1 change: 0 additions & 1 deletion libavformat/mpjpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ static int mpjpeg_write_header(AVFormatContext *s)
{
MPJPEGContext *mpj = s->priv_data;
avio_printf(s->pb, "--%s\r\n", mpj->boundary_tag);
avio_flush(s->pb);
return 0;
}

Expand Down
2 changes: 0 additions & 2 deletions libavformat/nutenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,8 +768,6 @@ static int nut_write_header(AVFormatContext *s)
if (s->avoid_negative_ts < 0)
s->avoid_negative_ts = 1;

avio_flush(bc);

return 0;
}

Expand Down
1 change: 0 additions & 1 deletion libavformat/rmenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@ static int rm_write_header(AVFormatContext *s)

if (rv10_write_header(s, 0, 0))
return AVERROR_INVALIDDATA;
avio_flush(s->pb);
return 0;
}

Expand Down
2 changes: 0 additions & 2 deletions libavformat/rsoenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ static int rso_write_header(AVFormatContext *s)
avio_wb16(pb, par->sample_rate);
avio_wb16(pb, 0x0000); /* play mode ? (0x0000 = don't loop) */

avio_flush(pb);

return 0;
}

Expand Down
1 change: 0 additions & 1 deletion libavformat/smjpegenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ static int smjpeg_write_header(AVFormatContext *s)
}

avio_wl32(pb, SMJPEG_HEND);
avio_flush(pb);

return 0;
}
Expand Down
2 changes: 0 additions & 2 deletions libavformat/soxenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ static int sox_write_header(AVFormatContext *s)

ffio_fill(pb, 0, comment_size - comment_len);

avio_flush(pb);

return 0;
}

Expand Down
1 change: 0 additions & 1 deletion libavformat/swfenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ static int swf_write_header(AVFormatContext *s)
put_swf_end_tag(s);
}

avio_flush(s->pb);
return 0;
}

Expand Down
2 changes: 0 additions & 2 deletions libavformat/wavenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,6 @@ static int wav_write_header(AVFormatContext *s)
wav->data = ff_start_tag(pb, "data");
}

avio_flush(pb);

return 0;
}

Expand Down
1 change: 0 additions & 1 deletion libavformat/webvttenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ static int webvtt_write_header(AVFormatContext *ctx)
avpriv_set_pts_info(s, 64, 1, 1000);

avio_printf(pb, "WEBVTT\n");
avio_flush(pb);

return 0;
}
Expand Down

0 comments on commit 4bf90e0

Please sign in to comment.