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.
This commit is contained in:
Anton Khirnov 2012-09-09 21:35:23 +02:00
parent 0c270239c2
commit 3b4bb19e63
19 changed files with 16 additions and 30 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -80,8 +80,6 @@ static int write_trailer(AVFormatContext *s)
write_tags(s->pb, ch->metadata);
}
avio_flush(s->pb);
return 0;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -3237,8 +3237,6 @@ static int mov_write_trailer(AVFormatContext *s)
}
avio_flush(pb);
av_freep(&mov->tracks);
return res;

View File

@ -1804,8 +1804,6 @@ static int mxf_write_footer(AVFormatContext *s)
}
}
avio_flush(pb);
ff_audio_interleave_close(s);
av_freep(&mxf->index_entries);

View File

@ -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);

View File

@ -455,7 +455,7 @@ static int rm_write_trailer(AVFormatContext *s)
avio_wb32(pb, 0);
avio_wb32(pb, 0);
}
avio_flush(pb);
return 0;
}

View File

@ -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;
}

View File

@ -130,7 +130,6 @@ static int smjpeg_write_trailer(AVFormatContext *s)
}
avio_wl32(pb, SMJPEG_DONE);
avio_flush(pb);
return 0;
}

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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