[FFmpeg-cvslog] lavf: flush the output AVIOContext in av_write_trailer().

Anton Khirnov git at videolan.org
Sun Sep 16 14:29:19 CEST 2012


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sun Sep  9 21:35:23 2012 +0200| [3b4bb19e63b41a0a542ba3ef254443b2e76a6a3e] | committer: Anton Khirnov

lavf: flush the output AVIOContext in av_write_trailer().

This is consistent with stdio and is what we want to do in all cases.

Fixes a bug in the voc muxer which didn't flush in write_trailer()
previously. This is the cause of the change in the test results.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3b4bb19e63b41a0a542ba3ef254443b2e76a6a3e
---

 libavformat/asfenc.c       |    1 -
 libavformat/assenc.c       |    2 --
 libavformat/avienc.c       |    1 -
 libavformat/crcenc.c       |    2 +-
 libavformat/ffmenc.c       |    3 ---
 libavformat/ffmetaenc.c    |    2 --
 libavformat/filmstripenc.c |    2 +-
 libavformat/gif.c          |    2 +-
 libavformat/matroskaenc.c  |    2 +-
 libavformat/movenc.c       |    2 --
 libavformat/mxfenc.c       |    2 --
 libavformat/nutenc.c       |    2 +-
 libavformat/rmenc.c        |    2 +-
 libavformat/rsoenc.c       |    2 --
 libavformat/smjpegenc.c    |    1 -
 libavformat/swfenc.c       |    2 --
 libavformat/utils.c        |    4 ++++
 tests/ref/lavf/voc         |    6 +++---
 tests/ref/lavf/voc_s16     |    6 +++---
 19 files changed, 16 insertions(+), 30 deletions(-)

diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index bcb741e..5c820be 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -872,7 +872,6 @@ static int asf_write_trailer(AVFormatContext *s)
         asf_write_header1(s, file_size, data_size - asf->data_offset);
     }
 
-    avio_flush(s->pb);
     av_free(asf->index_ptr);
     return 0;
 }
diff --git a/libavformat/assenc.c b/libavformat/assenc.c
index 1ae8680..5bf2e20 100644
--- a/libavformat/assenc.c
+++ b/libavformat/assenc.c
@@ -72,8 +72,6 @@ static int write_trailer(AVFormatContext *s)
     avio_write(s->pb, avctx->extradata      + ass->extra_index,
                       avctx->extradata_size - ass->extra_index);
 
-    avio_flush(s->pb);
-
     return 0;
 }
 
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 40fd7ad..8669879 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -626,7 +626,6 @@ static int avi_write_trailer(AVFormatContext *s)
             avi_write_counters(s, avi->riff_id);
         }
     }
-    avio_flush(pb);
 
     for (i=0; i<s->nb_streams; i++) {
          AVIStream *avist= s->streams[i]->priv_data;
diff --git a/libavformat/crcenc.c b/libavformat/crcenc.c
index 4a13f1c..3b30cc9 100644
--- a/libavformat/crcenc.c
+++ b/libavformat/crcenc.c
@@ -50,7 +50,7 @@ static int crc_write_trailer(struct AVFormatContext *s)
 
     snprintf(buf, sizeof(buf), "CRC=0x%08x\n", crc->crcval);
     avio_write(s->pb, buf, strlen(buf));
-    avio_flush(s->pb);
+
     return 0;
 }
 
diff --git a/libavformat/ffmenc.c b/libavformat/ffmenc.c
index 8069309..c020672 100644
--- a/libavformat/ffmenc.c
+++ b/libavformat/ffmenc.c
@@ -226,15 +226,12 @@ static int ffm_write_packet(AVFormatContext *s, AVPacket *pkt)
 
 static int ffm_write_trailer(AVFormatContext *s)
 {
-    AVIOContext *pb = s->pb;
     FFMContext *ffm = s->priv_data;
 
     /* flush packets */
     if (ffm->packet_ptr > ffm->packet)
         flush_packet(s);
 
-    avio_flush(pb);
-
     return 0;
 }
 
diff --git a/libavformat/ffmetaenc.c b/libavformat/ffmetaenc.c
index f75efea..19fe6c9 100644
--- a/libavformat/ffmetaenc.c
+++ b/libavformat/ffmetaenc.c
@@ -80,8 +80,6 @@ static int write_trailer(AVFormatContext *s)
         write_tags(s->pb, ch->metadata);
     }
 
-    avio_flush(s->pb);
-
     return 0;
 }
 
diff --git a/libavformat/filmstripenc.c b/libavformat/filmstripenc.c
index 91706fb..d000c4f 100644
--- a/libavformat/filmstripenc.c
+++ b/libavformat/filmstripenc.c
@@ -67,7 +67,7 @@ static int write_trailer(AVFormatContext *s)
     avio_wb16(pb, 1/av_q2d(st->codec->time_base));
     for (i = 0; i < 16; i++)
         avio_w8(pb, 0x00);  // reserved
-    avio_flush(pb);
+
     return 0;
 }
 
diff --git a/libavformat/gif.c b/libavformat/gif.c
index bfe63f3..f11b267 100644
--- a/libavformat/gif.c
+++ b/libavformat/gif.c
@@ -347,7 +347,7 @@ static int gif_write_trailer(AVFormatContext *s)
     AVIOContext *pb = s->pb;
 
     avio_w8(pb, 0x3b);
-    avio_flush(s->pb);
+
     return 0;
 }
 
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 2400a6b..9d9c223 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1265,7 +1265,7 @@ static int mkv_write_trailer(AVFormatContext *s)
     av_freep(&mkv->cues->entries);
     av_freep(&mkv->cues);
     av_destruct_packet(&mkv->cur_audio_pkt);
-    avio_flush(pb);
+
     return 0;
 }
 
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 441da5c..90c5806 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -3237,8 +3237,6 @@ static int mov_write_trailer(AVFormatContext *s)
 
     }
 
-    avio_flush(pb);
-
     av_freep(&mov->tracks);
 
     return res;
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index f25e08b..3d32be3 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -1804,8 +1804,6 @@ static int mxf_write_footer(AVFormatContext *s)
         }
     }
 
-    avio_flush(pb);
-
     ff_audio_interleave_close(s);
 
     av_freep(&mxf->index_entries);
diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index 9675af1..df0301b 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -851,7 +851,7 @@ static int nut_write_trailer(AVFormatContext *s){
 
     while(nut->header_count<3)
         write_headers(s, bc);
-    avio_flush(bc);
+
     ff_nut_free_sp(nut);
     av_freep(&nut->stream);
     av_freep(&nut->chapter);
diff --git a/libavformat/rmenc.c b/libavformat/rmenc.c
index 63202b1..ed1ba7c 100644
--- a/libavformat/rmenc.c
+++ b/libavformat/rmenc.c
@@ -455,7 +455,7 @@ static int rm_write_trailer(AVFormatContext *s)
         avio_wb32(pb, 0);
         avio_wb32(pb, 0);
     }
-    avio_flush(pb);
+
     return 0;
 }
 
diff --git a/libavformat/rsoenc.c b/libavformat/rsoenc.c
index 4d560cb..cc76f9a 100644
--- a/libavformat/rsoenc.c
+++ b/libavformat/rsoenc.c
@@ -95,8 +95,6 @@ static int rso_write_trailer(AVFormatContext *s)
     avio_wb16(pb, coded_file_size);
     avio_seek(pb, file_size, SEEK_SET);
 
-    avio_flush(pb);
-
     return 0;
 }
 
diff --git a/libavformat/smjpegenc.c b/libavformat/smjpegenc.c
index 86b6afa..59ede7a 100644
--- a/libavformat/smjpegenc.c
+++ b/libavformat/smjpegenc.c
@@ -130,7 +130,6 @@ static int smjpeg_write_trailer(AVFormatContext *s)
     }
 
     avio_wl32(pb, SMJPEG_DONE);
-    avio_flush(pb);
 
     return 0;
 }
diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c
index 1916650..9de8b67 100644
--- a/libavformat/swfenc.c
+++ b/libavformat/swfenc.c
@@ -485,8 +485,6 @@ static int swf_write_trailer(AVFormatContext *s)
     put_swf_tag(s, TAG_END);
     put_swf_end_tag(s);
 
-    avio_flush(s->pb);
-
     /* patch file size and number of frames if not streamed */
     if (s->pb->seekable && video_enc) {
         file_size = avio_tell(pb);
diff --git a/libavformat/utils.c b/libavformat/utils.c
index b555ad0..b5b49c9 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3270,6 +3270,10 @@ int av_write_trailer(AVFormatContext *s)
 
     if (s->oformat->write_trailer)
         ret = s->oformat->write_trailer(s);
+
+    if (!(s->oformat->flags & AVFMT_NOFILE))
+        avio_flush(s->pb);
+
 fail:
     for (i = 0; i < s->nb_streams; i++) {
         av_freep(&s->streams[i]->priv_data);
diff --git a/tests/ref/lavf/voc b/tests/ref/lavf/voc
index 25e8b44..ea903b6 100644
--- a/tests/ref/lavf/voc
+++ b/tests/ref/lavf/voc
@@ -1,3 +1,3 @@
-b0bc287ce4e3eef7c1012610dd7ff6d0 *./tests/data/lavf/lavf.voc
-32768 ./tests/data/lavf/lavf.voc
-./tests/data/lavf/lavf.voc CRC=0xa2d77c12
+5c4ee01048e7a8a138a97e80cf7a1924 *./tests/data/lavf/lavf.voc
+45261 ./tests/data/lavf/lavf.voc
+./tests/data/lavf/lavf.voc CRC=0x74b2b546
diff --git a/tests/ref/lavf/voc_s16 b/tests/ref/lavf/voc_s16
index 425d965..d53c950 100644
--- a/tests/ref/lavf/voc_s16
+++ b/tests/ref/lavf/voc_s16
@@ -1,3 +1,3 @@
-b20728bf036d2e23508869acbad4e576 *./tests/data/lavf/lavf.s16.voc
-163840 ./tests/data/lavf/lavf.s16.voc
-./tests/data/lavf/lavf.s16.voc CRC=0xfa9b6c39
+8ed10b311e49b4d4b18679b126492159 *./tests/data/lavf/lavf.s16.voc
+180437 ./tests/data/lavf/lavf.s16.voc
+./tests/data/lavf/lavf.s16.voc CRC=0x7bd585ff



More information about the ffmpeg-cvslog mailing list