avformat/aiffenc: Avoid seek when writing id3v2 tags at the end
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
a4869bf029
commit
9f834a1ac1
@ -233,25 +233,12 @@ static int aiff_write_trailer(AVFormatContext *s)
|
|||||||
AVCodecParameters *par = s->streams[aiff->audio_stream_idx]->codecpar;
|
AVCodecParameters *par = s->streams[aiff->audio_stream_idx]->codecpar;
|
||||||
|
|
||||||
/* Chunks sizes must be even */
|
/* Chunks sizes must be even */
|
||||||
int64_t file_size, end_size;
|
int64_t file_size, data_size;
|
||||||
end_size = file_size = avio_tell(pb);
|
data_size = avio_tell(pb);
|
||||||
if (file_size & 1) {
|
if (data_size & 1)
|
||||||
avio_w8(pb, 0);
|
avio_w8(pb, 0);
|
||||||
end_size++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) {
|
if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) {
|
||||||
/* Number of sample frames */
|
|
||||||
avio_seek(pb, aiff->frames, SEEK_SET);
|
|
||||||
avio_wb32(pb, (file_size - aiff->ssnd - 12) / par->block_align);
|
|
||||||
|
|
||||||
/* Sound Data chunk size */
|
|
||||||
avio_seek(pb, aiff->ssnd, SEEK_SET);
|
|
||||||
avio_wb32(pb, file_size - aiff->ssnd - 4);
|
|
||||||
|
|
||||||
/* return to the end */
|
|
||||||
avio_seek(pb, end_size, SEEK_SET);
|
|
||||||
|
|
||||||
/* Write ID3 tags */
|
/* Write ID3 tags */
|
||||||
if (aiff->write_id3v2)
|
if (aiff->write_id3v2)
|
||||||
if ((ret = put_id3v2_tags(s, aiff)) < 0)
|
if ((ret = put_id3v2_tags(s, aiff)) < 0)
|
||||||
@ -261,6 +248,14 @@ static int aiff_write_trailer(AVFormatContext *s)
|
|||||||
file_size = avio_tell(pb);
|
file_size = avio_tell(pb);
|
||||||
avio_seek(pb, aiff->form, SEEK_SET);
|
avio_seek(pb, aiff->form, SEEK_SET);
|
||||||
avio_wb32(pb, file_size - aiff->form - 4);
|
avio_wb32(pb, file_size - aiff->form - 4);
|
||||||
|
|
||||||
|
/* Number of sample frames */
|
||||||
|
avio_seek(pb, aiff->frames, SEEK_SET);
|
||||||
|
avio_wb32(pb, (data_size - aiff->ssnd - 12) / par->block_align);
|
||||||
|
|
||||||
|
/* Sound Data chunk size */
|
||||||
|
avio_seek(pb, aiff->ssnd, SEEK_SET);
|
||||||
|
avio_wb32(pb, data_size - aiff->ssnd - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user