Commit 4bf90e09 authored by Marton Balint's avatar Marton Balint

avformat: remove avio_flush() calls from the end of write_header functions

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: 's avatarMarton Balint <cus@passwd.hu>
parent 4d7f8254
...@@ -199,9 +199,6 @@ static int aiff_write_header(AVFormatContext *s) ...@@ -199,9 +199,6 @@ static int aiff_write_header(AVFormatContext *s)
avpriv_set_pts_info(s->streams[aiff->audio_stream_idx], 64, 1, avpriv_set_pts_info(s->streams[aiff->audio_stream_idx], 64, 1,
s->streams[aiff->audio_stream_idx]->codecpar->sample_rate); s->streams[aiff->audio_stream_idx]->codecpar->sample_rate);
/* Data is starting here */
avio_flush(pb);
return 0; return 0;
} }
......
...@@ -60,7 +60,6 @@ static int amr_write_header(AVFormatContext *s) ...@@ -60,7 +60,6 @@ static int amr_write_header(AVFormatContext *s)
} else { } else {
return -1; return -1;
} }
avio_flush(pb);
return 0; return 0;
} }
......
...@@ -801,8 +801,6 @@ static int asf_write_header(AVFormatContext *s) ...@@ -801,8 +801,6 @@ static int asf_write_header(AVFormatContext *s)
return -1; return -1;
} }
avio_flush(s->pb);
asf->packet_nb_payloads = 0; asf->packet_nb_payloads = 0;
asf->packet_timestamp_start = -1; asf->packet_timestamp_start = -1;
asf->packet_timestamp_end = -1; asf->packet_timestamp_end = -1;
......
...@@ -77,7 +77,6 @@ static int write_header(AVFormatContext *s) ...@@ -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", avio_printf(s->pb, "[Events]\r\nFormat: %s, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\r\n",
ass->ssa_mode ? "Marked" : "Layer"); ass->ssa_mode ? "Marked" : "Layer");
} }
avio_flush(s->pb);
return 0; return 0;
} }
......
...@@ -101,8 +101,6 @@ static int ast_write_header(AVFormatContext *s) ...@@ -101,8 +101,6 @@ static int ast_write_header(AVFormatContext *s)
avio_wb64(pb, 0); avio_wb64(pb, 0);
avio_wb32(pb, 0); avio_wb32(pb, 0);
avio_flush(pb);
return 0; return 0;
} }
......
...@@ -311,7 +311,6 @@ static int au_write_header(AVFormatContext *s) ...@@ -311,7 +311,6 @@ static int au_write_header(AVFormatContext *s)
} else { } else {
avio_wb64(pb, 0); /* annotation field */ avio_wb64(pb, 0); /* annotation field */
} }
avio_flush(pb);
return 0; return 0;
} }
......
...@@ -580,8 +580,6 @@ static int avi_write_header(AVFormatContext *s) ...@@ -580,8 +580,6 @@ static int avi_write_header(AVFormatContext *s)
avi->movi_list = ff_start_tag(pb, "LIST"); avi->movi_list = ff_start_tag(pb, "LIST");
ffio_wfourcc(pb, "movi"); ffio_wfourcc(pb, "movi");
avio_flush(pb);
return 0; return 0;
} }
......
...@@ -203,7 +203,6 @@ static int caf_write_header(AVFormatContext *s) ...@@ -203,7 +203,6 @@ static int caf_write_header(AVFormatContext *s)
avio_wb64(pb, -1); //< mChunkSize avio_wb64(pb, -1); //< mChunkSize
avio_wb32(pb, 0); //< mEditCount avio_wb32(pb, 0); //< mEditCount
avio_flush(pb);
return 0; return 0;
} }
......
...@@ -54,7 +54,6 @@ static int write_header(AVFormatContext *s) ...@@ -54,7 +54,6 @@ static int write_header(AVFormatContext *s)
avio_write(s->pb, ID_STRING, sizeof(ID_STRING) - 1); avio_write(s->pb, ID_STRING, sizeof(ID_STRING) - 1);
avio_w8(s->pb, '1'); // version avio_w8(s->pb, '1'); // version
avio_w8(s->pb, '\n'); avio_w8(s->pb, '\n');
avio_flush(s->pb);
return 0; return 0;
} }
......
...@@ -45,7 +45,6 @@ int ff_framehash_write_header(AVFormatContext *s) ...@@ -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); avio_printf(s->pb, "#sar %d: %d/%d\n", i, st->sample_aspect_ratio.num, st->sample_aspect_ratio.den);
break; break;
} }
avio_flush(s->pb);
} }
return 0; return 0;
} }
...@@ -834,7 +834,6 @@ static int gxf_write_header(AVFormatContext *s) ...@@ -834,7 +834,6 @@ static int gxf_write_header(AVFormatContext *s)
gxf->packet_count = 3; gxf->packet_count = 3;
avio_flush(pb);
return 0; return 0;
} }
......
...@@ -106,8 +106,6 @@ static int ico_write_header(AVFormatContext *s) ...@@ -106,8 +106,6 @@ static int ico_write_header(AVFormatContext *s)
if (!ico->images) if (!ico->images)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
avio_flush(pb);
return 0; return 0;
} }
......
...@@ -55,7 +55,6 @@ static int roq_write_header(struct AVFormatContext *s) ...@@ -55,7 +55,6 @@ static int roq_write_header(struct AVFormatContext *s)
} }
avio_write(s->pb, header, 8); avio_write(s->pb, header, 8);
avio_flush(s->pb);
return 0; return 0;
} }
......
...@@ -49,7 +49,6 @@ static int ilbc_write_header(AVFormatContext *s) ...@@ -49,7 +49,6 @@ static int ilbc_write_header(AVFormatContext *s)
av_log(s, AV_LOG_ERROR, "Unsupported mode\n"); av_log(s, AV_LOG_ERROR, "Unsupported mode\n");
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
avio_flush(pb);
return 0; return 0;
} }
......
...@@ -25,7 +25,6 @@ static int jacosub_write_header(AVFormatContext *s) ...@@ -25,7 +25,6 @@ static int jacosub_write_header(AVFormatContext *s)
if (par->extradata_size) { if (par->extradata_size) {
avio_write(s->pb, par->extradata, par->extradata_size - 1); avio_write(s->pb, par->extradata, par->extradata_size - 1);
avio_flush(s->pb);
} }
return 0; return 0;
} }
......
...@@ -2000,8 +2000,6 @@ static int mkv_write_header(AVFormatContext *s) ...@@ -2000,8 +2000,6 @@ static int mkv_write_header(AVFormatContext *s)
mkv->cur_audio_pkt.size = 0; mkv->cur_audio_pkt.size = 0;
mkv->cluster_pos = -1; mkv->cluster_pos = -1;
avio_flush(pb);
// start a new cluster every 5 MB or 5 sec, or 32k / 1 sec for streaming or // start a new cluster every 5 MB or 5 sec, or 32k / 1 sec for streaming or
// after 4k and on a keyframe // after 4k and on a keyframe
if (pb->seekable & AVIO_SEEKABLE_NORMAL) { if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
......
...@@ -37,7 +37,6 @@ static int microdvd_write_header(struct AVFormatContext *s) ...@@ -37,7 +37,6 @@ static int microdvd_write_header(struct AVFormatContext *s)
avio_write(s->pb, "{DEFAULT}{}", 11); avio_write(s->pb, "{DEFAULT}{}", 11);
avio_write(s->pb, par->extradata, par->extradata_size); avio_write(s->pb, par->extradata, par->extradata_size);
avio_w8(s->pb, '\n'); avio_w8(s->pb, '\n');
avio_flush(s->pb);
} }
avpriv_set_pts_info(s->streams[0], 64, framerate.num, framerate.den); avpriv_set_pts_info(s->streams[0], 64, framerate.num, framerate.den);
......
...@@ -123,8 +123,6 @@ static int mmf_write_header(AVFormatContext *s) ...@@ -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); avpriv_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codecpar->sample_rate);
avio_flush(pb);
return 0; return 0;
} }
......
...@@ -6579,7 +6579,6 @@ static int mov_write_header(AVFormatContext *s) ...@@ -6579,7 +6579,6 @@ static int mov_write_header(AVFormatContext *s)
!(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) { !(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) {
if ((ret = mov_write_moov_tag(pb, mov, s)) < 0) if ((ret = mov_write_moov_tag(pb, mov, s)) < 0)
return ret; return ret;
avio_flush(pb);
mov->moov_written = 1; mov->moov_written = 1;
if (mov->flags & FF_MOV_FLAG_GLOBAL_SIDX) if (mov->flags & FF_MOV_FLAG_GLOBAL_SIDX)
mov->reserved_header_pos = avio_tell(pb); mov->reserved_header_pos = avio_tell(pb);
......
...@@ -34,7 +34,6 @@ static int mpjpeg_write_header(AVFormatContext *s) ...@@ -34,7 +34,6 @@ static int mpjpeg_write_header(AVFormatContext *s)
{ {
MPJPEGContext *mpj = s->priv_data; MPJPEGContext *mpj = s->priv_data;
avio_printf(s->pb, "--%s\r\n", mpj->boundary_tag); avio_printf(s->pb, "--%s\r\n", mpj->boundary_tag);
avio_flush(s->pb);
return 0; return 0;
} }
......
...@@ -768,8 +768,6 @@ static int nut_write_header(AVFormatContext *s) ...@@ -768,8 +768,6 @@ static int nut_write_header(AVFormatContext *s)
if (s->avoid_negative_ts < 0) if (s->avoid_negative_ts < 0)
s->avoid_negative_ts = 1; s->avoid_negative_ts = 1;
avio_flush(bc);
return 0; return 0;
} }
......
...@@ -360,7 +360,6 @@ static int rm_write_header(AVFormatContext *s) ...@@ -360,7 +360,6 @@ static int rm_write_header(AVFormatContext *s)
if (rv10_write_header(s, 0, 0)) if (rv10_write_header(s, 0, 0))
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
avio_flush(s->pb);
return 0; return 0;
} }
......
...@@ -60,8 +60,6 @@ static int rso_write_header(AVFormatContext *s) ...@@ -60,8 +60,6 @@ static int rso_write_header(AVFormatContext *s)
avio_wb16(pb, par->sample_rate); avio_wb16(pb, par->sample_rate);
avio_wb16(pb, 0x0000); /* play mode ? (0x0000 = don't loop) */ avio_wb16(pb, 0x0000); /* play mode ? (0x0000 = don't loop) */
avio_flush(pb);
return 0; return 0;
} }
......
...@@ -88,7 +88,6 @@ static int smjpeg_write_header(AVFormatContext *s) ...@@ -88,7 +88,6 @@ static int smjpeg_write_header(AVFormatContext *s)
} }
avio_wl32(pb, SMJPEG_HEND); avio_wl32(pb, SMJPEG_HEND);
avio_flush(pb);
return 0; return 0;
} }
......
...@@ -80,8 +80,6 @@ static int sox_write_header(AVFormatContext *s) ...@@ -80,8 +80,6 @@ static int sox_write_header(AVFormatContext *s)
ffio_fill(pb, 0, comment_size - comment_len); ffio_fill(pb, 0, comment_size - comment_len);
avio_flush(pb);
return 0; return 0;
} }
......
...@@ -337,7 +337,6 @@ static int swf_write_header(AVFormatContext *s) ...@@ -337,7 +337,6 @@ static int swf_write_header(AVFormatContext *s)
put_swf_end_tag(s); put_swf_end_tag(s);
} }
avio_flush(s->pb);
return 0; return 0;
} }
......
...@@ -361,8 +361,6 @@ static int wav_write_header(AVFormatContext *s) ...@@ -361,8 +361,6 @@ static int wav_write_header(AVFormatContext *s)
wav->data = ff_start_tag(pb, "data"); wav->data = ff_start_tag(pb, "data");
} }
avio_flush(pb);
return 0; return 0;
} }
......
...@@ -57,7 +57,6 @@ static int webvtt_write_header(AVFormatContext *ctx) ...@@ -57,7 +57,6 @@ static int webvtt_write_header(AVFormatContext *ctx)
avpriv_set_pts_info(s, 64, 1, 1000); avpriv_set_pts_info(s, 64, 1, 1000);
avio_printf(pb, "WEBVTT\n"); avio_printf(pb, "WEBVTT\n");
avio_flush(pb);
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment