diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2011-08-13 18:26:01 +0200 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2011-08-14 01:56:28 +0200 |
commit | 323b930699179cb17b39fddaa9aba3379c0c9e26 (patch) | |
tree | 4f5be7de15f1dadc4c838ae4434ea77dbe5eb233 /libavutil | |
parent | a9d1878abe81ae8085d12590c5d089a49a0714e7 (diff) | |
download | ffmpeg-323b930699179cb17b39fddaa9aba3379c0c9e26.tar.gz |
fifo: add av_fifo_peek2(), and deprecate av_fifo_peek()
The new function provides a more flexible interface for peeking at a
FIFO buffer data.
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/avutil.h | 7 | ||||
-rw-r--r-- | libavutil/fifo.h | 31 |
2 files changed, 33 insertions, 5 deletions
diff --git a/libavutil/avutil.h b/libavutil/avutil.h index ffcac1c152..fc437dd21f 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -40,8 +40,8 @@ #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) #define LIBAVUTIL_VERSION_MAJOR 51 -#define LIBAVUTIL_VERSION_MINOR 11 -#define LIBAVUTIL_VERSION_MICRO 1 +#define LIBAVUTIL_VERSION_MINOR 12 +#define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ @@ -66,6 +66,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 999d0bf89b..e03d4ba73f 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 */ |