On Wed, 31 Jul 2013, Luca Barbato wrote:

On 31/07/13 14:44, Ben Avison wrote:
This was being performed to ensure that a complete packet was held in
contiguous memory, prior to parsing the packet. However, the source buffer
is typically large enough that the packet was already contiguous, so it is
beneficial to return the packet by reference in most cases.

         Before          After
         Mean   StdDev   Mean   StdDev  Change
memcpy    720.7  32.7     649.8  25.1   +10.9%
Overall  2372.7  46.1    2291.7  21.8    +3.5%
---
 libavformat/avio.h    |   15 +++++++++++++++
 libavformat/aviobuf.c |   12 ++++++++++++
 libavformat/mpegts.c  |   41 ++++++++++++++++++++++++++++-------------
 3 files changed, 55 insertions(+), 13 deletions(-)

diff --git a/libavformat/avio.h b/libavformat/avio.h
index b6d3cb3..fb195ff 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -240,6 +240,21 @@ void avio_flush(AVIOContext *s);
 int avio_read(AVIOContext *s, unsigned char *buf, int size);

 /**
+ * Read size bytes from AVIOContext, returning a pointer.
+ * @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 avio_read_indirect(AVIOContext *s, unsigned char *buf, int size, unsigned 
char **data);

Looks quite dangerous / easy to misuse. Probably is better to keep it
local for now. (the usage here seems fine)

I assume what Luca means is to make it a library-internal function, with a ff prefix, in avio_internal.h instead.

// Martin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to