[FFmpeg-cvslog] fifo: add av_fifo_peek2(), and deprecate av_fifo_peek()

Stefano Sabatini git at videolan.org
Fri Aug 26 23:26:55 CEST 2011


ffmpeg | branch: master | Stefano Sabatini <stefano.sabatini-lala at poste.it> | Wed Jun 29 17:30:23 2011 +0200| [f2011ed234f580de01768257f3da6e73fbf8ac7b] | committer: Anton Khirnov

fifo: add av_fifo_peek2(), and deprecate av_fifo_peek()

The new function provides a more generic interface than av_fifo_peek()
for peeking at a FIFO buffer data.

Signed-off-by: Anton Khirnov <anton at khirnov.net>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f2011ed234f580de01768257f3da6e73fbf8ac7b
---

 doc/APIchanges      |    3 +++
 libavformat/dvenc.c |    4 ++--
 libavutil/avutil.h  |    5 ++++-
 libavutil/fifo.h    |   31 ++++++++++++++++++++++++++++---
 4 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index cfce48b..a312681 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil:   2011-04-18
 
 API changes, most recent first:
 
+2011-08-xx - xxxxxx - lavu 51.9.0
+  Add av_fifo_peek2(), deprecate av_fifo_peek().
+
 2011-08-xx - xxxxxxx - lavf 53.4.0
   Add avformat_query_codec().
 
diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c
index 15b659b..5c55338 100644
--- a/libavformat/dvenc.c
+++ b/libavformat/dvenc.c
@@ -192,8 +192,8 @@ static void dv_inject_audio(DVMuxContext *c, int channel, uint8_t* frame_ptr)
                 if (of*2 >= size)
                     continue;
 
-                frame_ptr[d]   = av_fifo_peek(c->audio_data[channel], of*2+1); // FIXME: maybe we have to admit
-                frame_ptr[d+1] = av_fifo_peek(c->audio_data[channel], of*2);   //        that DV is a big-endian PCM
+                frame_ptr[d]   = *av_fifo_peek2(c->audio_data[channel], of*2+1); // FIXME: maybe we have to admit
+                frame_ptr[d+1] = *av_fifo_peek2(c->audio_data[channel], of*2);   //        that DV is a big-endian PCM
             }
             frame_ptr += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */
         }
diff --git a/libavutil/avutil.h b/libavutil/avutil.h
index 01e4e2f..484659a 100644
--- a/libavutil/avutil.h
+++ b/libavutil/avutil.h
@@ -40,7 +40,7 @@
 #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
 
 #define LIBAVUTIL_VERSION_MAJOR 51
-#define LIBAVUTIL_VERSION_MINOR  8
+#define LIBAVUTIL_VERSION_MINOR  9
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
@@ -63,6 +63,9 @@
 #ifndef FF_API_FIND_OPT
 #define FF_API_FIND_OPT                 (LIBAVUTIL_VERSION_MAJOR < 52)
 #endif
+#ifndef FF_API_AV_FIFO_PEEK
+#define FF_API_AV_FIFO_PEEK             (LIBAVUTIL_VERSION_MAJOR < 52)
+#endif
 
 /**
  * Return the LIBAVUTIL_VERSION_INT constant.
diff --git a/libavutil/fifo.h b/libavutil/fifo.h
index 9231961..961463a 100644
--- a/libavutil/fifo.h
+++ b/libavutil/fifo.h
@@ -25,6 +25,7 @@
 #define AVUTIL_FIFO_H
 
 #include <stdint.h>
+#include "avutil.h"
 
 typedef struct AVFifoBuffer {
     uint8_t *buffer;
@@ -106,11 +107,35 @@ int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size);
  */
 void av_fifo_drain(AVFifoBuffer *f, int size);
 
-static inline uint8_t av_fifo_peek(AVFifoBuffer *f, int offs)
+/**
+ * Return a pointer to the data stored in a FIFO buffer at a certain offset.
+ * The FIFO buffer is not modified.
+ *
+ * @param *f   AVFifoBuffer to peek at, f must be non-NULL
+ * @param offs an offset in bytes, its absolute value must be less
+ *             than the used buffer size or the returned pointer will
+ *             point outside to the buffer data.
+ *             The used buffer size can be checked with av_fifo_size().
+ */
+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;
+        ptr = f->buffer + (ptr - f->end);
+    else if (ptr < f->buffer)
+        ptr = f->end - (f->buffer - ptr);
+    return ptr;
 }
+
+#if FF_API_AV_FIFO_PEEK
+/**
+ * @deprecated Use av_fifo_peek2() instead.
+ */
+attribute_deprecated
+static inline uint8_t av_fifo_peek(AVFifoBuffer *f, int offs)
+{
+    return *av_fifo_peek2(f, offs);
+}
+#endif
+
 #endif /* AVUTIL_FIFO_H */



More information about the ffmpeg-cvslog mailing list