summaryrefslogtreecommitdiff
path: root/libavformat/aviobuf.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-11-26 07:53:52 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-03-30 05:50:49 +0200
commit639728f51a9fa5e321effad5909c1e37df0e80bb (patch)
tree70fb345421fd89a6e8cdd1a834a45875d491390c /libavformat/aviobuf.c
parent5cdd2ebb55f760d06d35b71a421b8433851b92e9 (diff)
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>
Diffstat (limited to 'libavformat/aviobuf.c')
-rw-r--r--libavformat/aviobuf.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index c4f168e49b..85c01c938a 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -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;