diff options
author | Ben Avison <bavison@riscosopen.org> | 2013-07-31 23:46:08 +0100 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2013-08-05 15:14:25 +0300 |
commit | daf1e0d3de03bd424016e2a7520e4e94ece5c0ac (patch) | |
tree | 3dd514f8ccace141868de817c2cb48ca985a95cc /libavformat/aviobuf.c | |
parent | 22a154e4363b351dd9f321003de01dffebd2fa18 (diff) | |
download | ffmpeg-daf1e0d3de03bd424016e2a7520e4e94ece5c0ac.tar.gz |
avio: Add an internal function for reading without copying
As long as there is enough contiguous data in the avio buffer,
just return a pointer to it instead of copying it to the caller
provided buffer.
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/aviobuf.c')
-rw-r--r-- | libavformat/aviobuf.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index bc89768ef6..07aa88068f 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -490,6 +490,18 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size) return size1 - size; } +int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, unsigned char **data) +{ + if (s->buf_end - s->buf_ptr >= size && !s->write_flag) { + *data = s->buf_ptr; + s->buf_ptr += size; + return size; + } else { + *data = buf; + return avio_read(s, buf, size); + } +} + int ffio_read_partial(AVIOContext *s, unsigned char *buf, int size) { int len; |