Commit 73084391 authored by Clément Bœsch's avatar Clément Bœsch Committed by Martin Storsjö

lavf: Don't explicitly flush after each written packet in muxers

Since 596e5d47, this is not necessary anymore. It also allows to
actually disable the flushing, improving write performance (but
possibly giving worse latency in real-time streaming).
Signed-off-by: 's avatarMartin Storsjö <martin@martin.st>
parent 596e5d47
...@@ -158,7 +158,6 @@ static int adts_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -158,7 +158,6 @@ static int adts_write_packet(AVFormatContext *s, AVPacket *pkt)
} }
} }
avio_write(pb, pkt->data, pkt->size); avio_write(pb, pkt->data, pkt->size);
avio_flush(pb);
return 0; return 0;
} }
......
...@@ -55,7 +55,6 @@ static int amr_write_header(AVFormatContext *s) ...@@ -55,7 +55,6 @@ static int amr_write_header(AVFormatContext *s)
static int amr_write_packet(AVFormatContext *s, AVPacket *pkt) static int amr_write_packet(AVFormatContext *s, AVPacket *pkt)
{ {
avio_write(s->pb, pkt->data, pkt->size); avio_write(s->pb, pkt->data, pkt->size);
avio_flush(s->pb);
return 0; return 0;
} }
#endif /* CONFIG_AMR_MUXER */ #endif /* CONFIG_AMR_MUXER */
......
...@@ -58,9 +58,6 @@ static int write_header(AVFormatContext *s) ...@@ -58,9 +58,6 @@ static int write_header(AVFormatContext *s)
static int write_packet(AVFormatContext *s, AVPacket *pkt) static int write_packet(AVFormatContext *s, AVPacket *pkt)
{ {
avio_write(s->pb, pkt->data, pkt->size); avio_write(s->pb, pkt->data, pkt->size);
avio_flush(s->pb);
return 0; return 0;
} }
......
...@@ -558,7 +558,6 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -558,7 +558,6 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
if (size & 1) if (size & 1)
avio_w8(pb, 0); avio_w8(pb, 0);
avio_flush(pb);
return 0; return 0;
} }
......
...@@ -68,7 +68,6 @@ static int daud_write_packet(struct AVFormatContext *s, AVPacket *pkt) ...@@ -68,7 +68,6 @@ static int daud_write_packet(struct AVFormatContext *s, AVPacket *pkt)
avio_wb16(s->pb, pkt->size); avio_wb16(s->pb, pkt->size);
avio_wb16(s->pb, 0x8010); // unknown avio_wb16(s->pb, 0x8010); // unknown
avio_write(s->pb, pkt->data, pkt->size); avio_write(s->pb, pkt->data, pkt->size);
avio_flush(s->pb);
return 0; return 0;
} }
......
...@@ -388,7 +388,6 @@ static int dv_write_packet(struct AVFormatContext *s, AVPacket *pkt) ...@@ -388,7 +388,6 @@ static int dv_write_packet(struct AVFormatContext *s, AVPacket *pkt)
pkt->data, pkt->size, &frame); pkt->data, pkt->size, &frame);
if (fsize > 0) { if (fsize > 0) {
avio_write(s->pb, frame, fsize); avio_write(s->pb, frame, fsize);
avio_flush(s->pb);
} }
return 0; return 0;
} }
......
...@@ -113,7 +113,6 @@ static int flac_write_trailer(struct AVFormatContext *s) ...@@ -113,7 +113,6 @@ static int flac_write_trailer(struct AVFormatContext *s)
static int flac_write_packet(struct AVFormatContext *s, AVPacket *pkt) static int flac_write_packet(struct AVFormatContext *s, AVPacket *pkt)
{ {
avio_write(s->pb, pkt->data, pkt->size); avio_write(s->pb, pkt->data, pkt->size);
avio_flush(s->pb);
return 0; return 0;
} }
......
...@@ -545,7 +545,6 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -545,7 +545,6 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
pkt->pts + flv->delay + pkt->duration); pkt->pts + flv->delay + pkt->duration);
} }
avio_flush(pb);
av_free(data); av_free(data);
return pb->error; return pb->error;
......
...@@ -31,7 +31,6 @@ static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt) ...@@ -31,7 +31,6 @@ static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt)
snprintf(buf, sizeof(buf), "%d, %10"PRId64", %10"PRId64", %8d, %8d, 0x%08x\n", snprintf(buf, sizeof(buf), "%d, %10"PRId64", %10"PRId64", %8d, %8d, 0x%08x\n",
pkt->stream_index, pkt->dts, pkt->pts, pkt->duration, pkt->size, crc); pkt->stream_index, pkt->dts, pkt->pts, pkt->duration, pkt->size, crc);
avio_write(s->pb, buf, strlen(buf)); avio_write(s->pb, buf, strlen(buf));
avio_flush(s->pb);
return 0; return 0;
} }
......
...@@ -329,7 +329,6 @@ static int gif_write_video(AVFormatContext *s, AVCodecContext *enc, ...@@ -329,7 +329,6 @@ static int gif_write_video(AVFormatContext *s, AVCodecContext *enc,
gif_image_write_image(pb, 0, 0, enc->width, enc->height, gif_image_write_image(pb, 0, 0, enc->width, enc->height,
buf, enc->width * 3, AV_PIX_FMT_RGB24); buf, enc->width * 3, AV_PIX_FMT_RGB24);
avio_flush(s->pb);
return 0; return 0;
} }
......
...@@ -896,8 +896,6 @@ static int gxf_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -896,8 +896,6 @@ static int gxf_write_packet(AVFormatContext *s, AVPacket *pkt)
gxf->packet_count = 0; gxf->packet_count = 0;
} }
avio_flush(pb);
return 0; return 0;
} }
......
...@@ -56,7 +56,6 @@ static int ilbc_write_header(AVFormatContext *s) ...@@ -56,7 +56,6 @@ static int ilbc_write_header(AVFormatContext *s)
static int ilbc_write_packet(AVFormatContext *s, AVPacket *pkt) static int ilbc_write_packet(AVFormatContext *s, AVPacket *pkt)
{ {
avio_write(s->pb, pkt->data, pkt->size); avio_write(s->pb, pkt->data, pkt->size);
avio_flush(s->pb);
return 0; return 0;
} }
......
...@@ -53,7 +53,6 @@ static int ivf_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -53,7 +53,6 @@ static int ivf_write_packet(AVFormatContext *s, AVPacket *pkt)
avio_wl32(pb, pkt->size); avio_wl32(pb, pkt->size);
avio_wl64(pb, pkt->pts); avio_wl64(pb, pkt->pts);
avio_write(pb, pkt->data, pkt->size); avio_write(pb, pkt->data, pkt->size);
avio_flush(pb);
return 0; return 0;
} }
......
...@@ -44,7 +44,6 @@ static int mpjpeg_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -44,7 +44,6 @@ static int mpjpeg_write_packet(AVFormatContext *s, AVPacket *pkt)
snprintf(buf1, sizeof(buf1), "\n--%s\n", BOUNDARY_TAG); snprintf(buf1, sizeof(buf1), "\n--%s\n", BOUNDARY_TAG);
avio_write(s->pb, buf1, strlen(buf1)); avio_write(s->pb, buf1, strlen(buf1));
avio_flush(s->pb);
return 0; return 0;
} }
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
int ff_raw_write_packet(AVFormatContext *s, AVPacket *pkt) int ff_raw_write_packet(AVFormatContext *s, AVPacket *pkt)
{ {
avio_write(s->pb, pkt->data, pkt->size); avio_write(s->pb, pkt->data, pkt->size);
avio_flush(s->pb);
return 0; return 0;
} }
......
...@@ -369,7 +369,6 @@ static int rm_write_audio(AVFormatContext *s, const uint8_t *buf, int size, int ...@@ -369,7 +369,6 @@ static int rm_write_audio(AVFormatContext *s, const uint8_t *buf, int size, int
} else { } else {
avio_write(pb, buf, size); avio_write(pb, buf, size);
} }
avio_flush(pb);
stream->nb_frames++; stream->nb_frames++;
av_free(buf1); av_free(buf1);
return 0; return 0;
...@@ -414,7 +413,6 @@ static int rm_write_video(AVFormatContext *s, const uint8_t *buf, int size, int ...@@ -414,7 +413,6 @@ static int rm_write_video(AVFormatContext *s, const uint8_t *buf, int size, int
avio_w8(pb, stream->nb_frames & 0xff); avio_w8(pb, stream->nb_frames & 0xff);
avio_write(pb, buf, size); avio_write(pb, buf, size);
avio_flush(pb);
stream->nb_frames++; stream->nb_frames++;
return 0; return 0;
......
...@@ -109,7 +109,6 @@ static int smjpeg_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -109,7 +109,6 @@ static int smjpeg_write_packet(AVFormatContext *s, AVPacket *pkt)
avio_wb32(pb, pkt->pts); avio_wb32(pb, pkt->pts);
avio_wb32(pb, pkt->size); avio_wb32(pb, pkt->size);
avio_write(pb, pkt->data, pkt->size); avio_write(pb, pkt->data, pkt->size);
avio_flush(pb);
smc->duration = FFMAX(smc->duration, pkt->pts + pkt->duration); smc->duration = FFMAX(smc->duration, pkt->pts + pkt->duration);
return 0; return 0;
......
...@@ -538,7 +538,6 @@ static int spdif_write_packet(struct AVFormatContext *s, AVPacket *pkt) ...@@ -538,7 +538,6 @@ static int spdif_write_packet(struct AVFormatContext *s, AVPacket *pkt)
av_log(s, AV_LOG_DEBUG, "type=%x len=%i pkt_offset=%i\n", av_log(s, AV_LOG_DEBUG, "type=%x len=%i pkt_offset=%i\n",
ctx->data_type, ctx->out_bytes, ctx->pkt_offset); ctx->data_type, ctx->out_bytes, ctx->pkt_offset);
avio_flush(s->pb);
return 0; return 0;
} }
......
...@@ -436,8 +436,6 @@ static int swf_write_video(AVFormatContext *s, ...@@ -436,8 +436,6 @@ static int swf_write_video(AVFormatContext *s,
put_swf_tag(s, TAG_SHOWFRAME); put_swf_tag(s, TAG_SHOWFRAME);
put_swf_end_tag(s); put_swf_end_tag(s);
avio_flush(s->pb);
return 0; return 0;
} }
......
...@@ -63,7 +63,6 @@ static int vc1test_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -63,7 +63,6 @@ static int vc1test_write_packet(AVFormatContext *s, AVPacket *pkt)
avio_wl32(pb, pkt->size | ((pkt->flags & AV_PKT_FLAG_KEY) ? 0x80000000 : 0)); avio_wl32(pb, pkt->size | ((pkt->flags & AV_PKT_FLAG_KEY) ? 0x80000000 : 0));
avio_wl32(pb, pkt->pts); avio_wl32(pb, pkt->pts);
avio_write(pb, pkt->data, pkt->size); avio_write(pb, pkt->data, pkt->size);
avio_flush(pb);
ctx->frames++; ctx->frames++;
return 0; return 0;
......
...@@ -51,7 +51,6 @@ static int wv_write_packet(AVFormatContext *ctx, AVPacket *pkt) ...@@ -51,7 +51,6 @@ static int wv_write_packet(AVFormatContext *ctx, AVPacket *pkt)
s->samples += header.samples; s->samples += header.samples;
avio_write(ctx->pb, pkt->data, pkt->size); avio_write(ctx->pb, pkt->data, pkt->size);
avio_flush(ctx->pb);
return 0; return 0;
} }
......
...@@ -147,7 +147,6 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -147,7 +147,6 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt)
ptr2 += picture->linesize[2]; ptr2 += picture->linesize[2];
} }
} }
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