mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avformat/aviobuf: Add function to reset dynamic buffer
Resetting a dynamic buffer means to keep the AVIOContext and the internal buffer used by the dynamic buffer. This is done in order to save (re)allocations when one has a workflow where one opens and closes dynamic buffers in sequence. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
parent
5cdd2ebb55
commit
639728f51a
@ -171,6 +171,13 @@ int ffio_open_whitelist(AVIOContext **s, const char *url, int flags,
|
||||
*/
|
||||
int ffio_close_null_buf(AVIOContext *s);
|
||||
|
||||
/**
|
||||
* Reset a dynamic buffer.
|
||||
*
|
||||
* Resets everything, but keeps the allocated buffer for later use.
|
||||
*/
|
||||
void ffio_reset_dyn_buf(AVIOContext *s);
|
||||
|
||||
/**
|
||||
* Free a dynamic buffer.
|
||||
*
|
||||
|
@ -1407,6 +1407,17 @@ int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
|
||||
return d->size;
|
||||
}
|
||||
|
||||
void ffio_reset_dyn_buf(AVIOContext *s)
|
||||
{
|
||||
DynBuffer *d = s->opaque;
|
||||
int max_packet_size = s->max_packet_size;
|
||||
|
||||
ffio_init_context(s, d->io_buffer, d->io_buffer_size, 1, d, NULL,
|
||||
s->write_packet, s->seek);
|
||||
s->max_packet_size = max_packet_size;
|
||||
d->pos = d->size = 0;
|
||||
}
|
||||
|
||||
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
|
||||
{
|
||||
DynBuffer *d;
|
||||
|
Loading…
Reference in New Issue
Block a user