diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-09-20 12:25:58 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-09-20 12:26:09 +0200 |
commit | 2ad8056c5e4c30c1c090eacad3d545a1e568235d (patch) | |
tree | af1148e1612fcbcd500748ae25c04e09ac0ce5c8 /libavformat/aviobuf.c | |
parent | 04ee57ce0aba34722e47419fce5977f81ea09d07 (diff) | |
parent | 3627ce2f1dab1d33b7f99d78907a3e4d86b7d847 (diff) | |
download | ffmpeg-2ad8056c5e4c30c1c090eacad3d545a1e568235d.tar.gz |
Merge commit '3627ce2f1dab1d33b7f99d78907a3e4d86b7d847'
* commit '3627ce2f1dab1d33b7f99d78907a3e4d86b7d847':
aviobuf: Add functions for null buffers
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/aviobuf.c')
-rw-r--r-- | libavformat/aviobuf.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 652b7769fb..e0fdf445bf 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -1045,3 +1045,36 @@ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) av_free(s); return size - padding; } + +static int null_buf_write(void *opaque, uint8_t *buf, int buf_size) +{ + DynBuffer *d = opaque; + + d->pos += buf_size; + if (d->pos > d->size) + d->size = d->pos; + return buf_size; +} + +int ffio_open_null_buf(AVIOContext **s) +{ + int ret = url_open_dyn_buf_internal(s, 0); + if (ret >= 0) { + AVIOContext *pb = *s; + pb->write_packet = null_buf_write; + } + return ret; +} + +int ffio_close_null_buf(AVIOContext *s) +{ + DynBuffer *d = s->opaque; + int size; + + avio_flush(s); + + size = d->size; + av_free(d); + av_free(s); + return size; +} |