[FFmpeg-devel] [PATCH] fifo: add av_fifo_peek2()

Stefano Sabatini stefano.sabatini-lala at poste.it
Thu Jun 30 10:11:04 CEST 2011


The new functions provides a more generic interface than
av_fifo_peek2() for peeking data out of a fifo buffer.
---
 libavutil/fifo.h |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/libavutil/fifo.h b/libavutil/fifo.h
index 999d0bf..dfc4a47 100644
--- a/libavutil/fifo.h
+++ b/libavutil/fifo.h
@@ -113,4 +113,17 @@ static inline uint8_t av_fifo_peek(AVFifoBuffer *f, int offs)
         ptr -= f->end - f->buffer;
     return *ptr;
 }
+
+/**
+ * Return a pointer to the data offset by offs stored in the fifo,
+ * without modifying the fifo itself.
+ */
+static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs)
+{
+    uint8_t *ptr = f->rptr + offs;
+    if (ptr >= f->end)
+        ptr -= f->end - f->buffer;
+    return ptr;
+}
+
 #endif /* AVUTIL_FIFO_H */
-- 
1.7.2.5



More information about the ffmpeg-devel mailing list