From daf1e0d3de03bd424016e2a7520e4e94ece5c0ac Mon Sep 17 00:00:00 2001 From: Ben Avison Date: Wed, 31 Jul 2013 23:46:08 +0100 Subject: avio: Add an internal function for reading without copying MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ö --- libavformat/avio_internal.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'libavformat/avio_internal.h') diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h index 3da2fc8422..4fa3adb270 100644 --- a/libavformat/avio_internal.h +++ b/libavformat/avio_internal.h @@ -37,6 +37,23 @@ int ffio_init_context(AVIOContext *s, int64_t (*seek)(void *opaque, int64_t offset, int whence)); +/** + * Read size bytes from AVIOContext, returning a pointer. + * Note that the data pointed at by the returned pointer is only + * valid until the next call that references the same IO context. + * @param s IO context + * @param buf pointer to buffer into which to assemble the requested + * data if it is not available in contiguous addresses in the + * underlying buffer + * @param size number of bytes requested + * @param data address at which to store pointer: this will be a + * a direct pointer into the underlying buffer if the requested + * number of bytes are available at contiguous addresses, otherwise + * will be a copy of buf + * @return number of bytes read or AVERROR + */ +int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, unsigned char **data); + /** * Read size bytes from AVIOContext into buf. * This reads at most 1 packet. If that is not enough fewer bytes will be -- cgit v1.2.3