History

avformat/ttaenc: Defer freeing dynamic buffer

The TTA muxer writes a seektable in a dynamic buffer as it receives packets and when writing the trailer, closes the dynamic buffer using avio_close_dyn_buf(), writes the seektable and frees the buffer. But the TTA muxer already has a deinit function which unconditionally calls ffio_free_dyn_buf() on the dynamic buffer, so switching to avio_get_dyn_buf() means that one can remove the code to free the buffer; furthermore, it also might save an allocation if the seektable is so small that it fits into the dynamic buffer's write buffer or if adding the padding that avio_close_dyn_buf() adds necessitated reallocating of the underlying buffer.

Andreas Rheinhardt committed 6 years ago

Commit dbacecd1 parent 9f6b7381 file · +1 −3Browse files

Unified · Split

libavformat/ttaenc.c+1−3
@@ -145,10 +145,8 @@ static int tta_write_trailer(AVFormatContext *s) · 144 unmodified lines
145145 /* Write Seek table */
146146 crc = ffio_get_checksum(tta->seek_table) ^ UINT32_MAX;
147147 avio_wl32(tta->seek_table, crc);
148− size = avio_close_dyn_buf(tta->seek_table, &ptr);
148+ size = avio_get_dyn_buf(tta->seek_table, &ptr);
149149 avio_write(s->pb, ptr, size);
150− tta->seek_table = NULL;
151− av_free(ptr);
152150
153151 /* Write audio data */
154152 tta_queue_flush(s);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t