[FFmpeg-cvslog] avio: simplify url_open_dyn_buf_internal by using avio_alloc_context()
Anton Khirnov
git at videolan.org
Mon Apr 4 03:01:16 CEST 2011
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sun Apr 3 22:55:31 2011 +0200| [8bea72f7ebcb57ab929657ff5e2dcd1f6f28f222] | committer: Anton Khirnov
avio: simplify url_open_dyn_buf_internal by using avio_alloc_context()
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8bea72f7ebcb57ab929657ff5e2dcd1f6f28f222
---
libavformat/aviobuf.c | 20 ++++++--------------
1 files changed, 6 insertions(+), 14 deletions(-)
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index ad969ae..d126fa8 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -1136,7 +1136,6 @@ static int64_t dyn_buf_seek(void *opaque, int64_t offset, int whence)
static int url_open_dyn_buf_internal(AVIOContext **s, int max_packet_size)
{
DynBuffer *d;
- int ret;
unsigned io_buffer_size = max_packet_size ? max_packet_size : 1024;
if(sizeof(DynBuffer) + io_buffer_size < io_buffer_size)
@@ -1144,23 +1143,16 @@ static int url_open_dyn_buf_internal(AVIOContext **s, int max_packet_size)
d = av_mallocz(sizeof(DynBuffer) + io_buffer_size);
if (!d)
return AVERROR(ENOMEM);
- *s = av_mallocz(sizeof(AVIOContext));
+ d->io_buffer_size = io_buffer_size;
+ *s = avio_alloc_context(d->io_buffer, d->io_buffer_size, 1, d, NULL,
+ max_packet_size ? dyn_packet_buf_write : dyn_buf_write,
+ max_packet_size ? NULL : dyn_buf_seek);
if(!*s) {
av_free(d);
return AVERROR(ENOMEM);
}
- d->io_buffer_size = io_buffer_size;
- ret = ffio_init_context(*s, d->io_buffer, io_buffer_size,
- 1, d, NULL,
- max_packet_size ? dyn_packet_buf_write : dyn_buf_write,
- max_packet_size ? NULL : dyn_buf_seek);
- if (ret == 0) {
- (*s)->max_packet_size = max_packet_size;
- } else {
- av_free(d);
- av_freep(s);
- }
- return ret;
+ (*s)->max_packet_size = max_packet_size;
+ return 0;
}
int avio_open_dyn_buf(AVIOContext **s)
More information about the ffmpeg-cvslog
mailing list