[FFmpeg-cvslog] avformat/mux: do not call write_header multiple times if it fails the first time
Marton Balint
git at videolan.org
Mon Jun 20 00:30:53 CEST 2016
ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Sat Jun 11 20:18:40 2016 +0200| [517fe64406d4b0f5ae2b1428f17063ac7a1643aa] | committer: Marton Balint
avformat/mux: do not call write_header multiple times if it fails the first time
Signed-off-by: Marton Balint <cus at passwd.hu>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=517fe64406d4b0f5ae2b1428f17063ac7a1643aa
---
libavformat/internal.h | 1 +
libavformat/mux.c | 5 +++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 40ba089..b6c2020 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -124,6 +124,7 @@ struct AVFormatInternal {
* Whether or not a header has already been written
*/
int header_written;
+ int write_header_ret;
};
struct AVStreamInternal {
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 08ed940..b1b65a1 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -479,6 +479,7 @@ static int write_header_internal(AVFormatContext *s)
int ret = s->oformat->write_header(s);
if (ret >= 0 && s->pb && s->pb->error < 0)
ret = s->pb->error;
+ s->internal->write_header_ret = ret;
if (ret < 0)
return ret;
if (s->flush_packets && s->pb && s->pb->error >= 0 && s->flags & AVFMT_FLAG_FLUSH_PACKETS)
@@ -713,7 +714,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
did_split = av_packet_split_side_data(pkt);
if (!s->internal->header_written) {
- ret = write_header_internal(s);
+ ret = s->internal->write_header_ret ? s->internal->write_header_ret : write_header_internal(s);
if (ret < 0)
goto fail;
}
@@ -1152,7 +1153,7 @@ int av_write_trailer(AVFormatContext *s)
}
if (!s->internal->header_written) {
- ret = write_header_internal(s);
+ ret = s->internal->write_header_ret ? s->internal->write_header_ret : write_header_internal(s);
if (ret < 0)
goto fail;
}
More information about the ffmpeg-cvslog
mailing list