The new function provides a more generic interface than av_fifo_peek() for peeking at a FIFO buffer data.
Unified · Split
| @@ -13,6 +13,9 @@ libavutil: 2011-04-18 · 12 unmodified lines | |||
| 13 | 13 | ||
| 14 | API changes, most recent first: | 14 | API changes, most recent first: |
| 15 | 15 | ||
| 16 | 2011-08-xx - xxxxxx - lavu 51.9.0 | ||
| 17 | Add av_fifo_peek2(), deprecate av_fifo_peek(). | ||
| 18 | |||
| 16 | 2011-08-xx - xxxxxxx - lavf 53.4.0 | 19 | 2011-08-xx - xxxxxxx - lavf 53.4.0 |
| 17 | Add avformat_query_codec(). | 20 | Add avformat_query_codec(). |
| 18 | 21 | ||
| @@ -192,8 +192,8 @@ static void dv_inject_audio(DVMuxContext *c, int channel, uint8_t* frame_ptr) · 191 unmodified lines | |||
| 192 | if (of*2 >= size) | 192 | if (of*2 >= size) |
| 193 | continue; | 193 | continue; |
| 194 | 194 | ||
| 195 | frame_ptr[d] = av_fifo_peek(c->audio_data[channel], of*2+1); // FIXME: maybe we have to admit | 195 | frame_ptr[d] = *av_fifo_peek2(c->audio_data[channel], of*2+1); // FIXME: maybe we have to admit |
| 196 | frame_ptr[d+1] = av_fifo_peek(c->audio_data[channel], of*2); // that DV is a big-endian PCM | 196 | frame_ptr[d+1] = *av_fifo_peek2(c->audio_data[channel], of*2); // that DV is a big-endian PCM |
| 197 | } | 197 | } |
| 198 | frame_ptr += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */ | 198 | frame_ptr += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */ |
| 199 | } | 199 | } |
| @@ -40,7 +40,7 @@ · 39 unmodified lines | |||
| 40 | #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) | 40 | #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) |
| 41 | 41 | ||
| 42 | #define LIBAVUTIL_VERSION_MAJOR 51 | 42 | #define LIBAVUTIL_VERSION_MAJOR 51 |
| 43 | #define LIBAVUTIL_VERSION_MINOR 8 | 43 | #define LIBAVUTIL_VERSION_MINOR 9 |
| 44 | #define LIBAVUTIL_VERSION_MICRO 0 | 44 | #define LIBAVUTIL_VERSION_MICRO 0 |
| 45 | 45 | ||
| 46 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ | 46 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |
| @@ -63,6 +63,9 @@ · 16 unmodified lines | |||
| 63 | #ifndef FF_API_FIND_OPT | 63 | #ifndef FF_API_FIND_OPT |
| 64 | #define FF_API_FIND_OPT (LIBAVUTIL_VERSION_MAJOR < 52) | 64 | #define FF_API_FIND_OPT (LIBAVUTIL_VERSION_MAJOR < 52) |
| 65 | #endif | 65 | #endif |
| 66 | #ifndef FF_API_AV_FIFO_PEEK | ||
| 67 | #define FF_API_AV_FIFO_PEEK (LIBAVUTIL_VERSION_MAJOR < 52) | ||
| 68 | #endif | ||
| 66 | 69 | ||
| 67 | /** | 70 | /** |
| 68 | * Return the LIBAVUTIL_VERSION_INT constant. | 71 | * Return the LIBAVUTIL_VERSION_INT constant. |
| @@ -25,6 +25,7 @@ · 24 unmodified lines | |||
| 25 | #define AVUTIL_FIFO_H | 25 | #define AVUTIL_FIFO_H |
| 26 | 26 | ||
| 27 | #include <stdint.h> | 27 | #include <stdint.h> |
| 28 | #include "avutil.h" | ||
| 28 | 29 | ||
| 29 | typedef struct AVFifoBuffer { | 30 | typedef struct AVFifoBuffer { |
| 30 | uint8_t *buffer; | 31 | uint8_t *buffer; |
| @@ -106,11 +107,35 @@ int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size); · 75 unmodified lines | |||
| 106 | */ | 107 | */ |
| 107 | void av_fifo_drain(AVFifoBuffer *f, int size); | 108 | void av_fifo_drain(AVFifoBuffer *f, int size); |
| 108 | 109 | ||
| 109 | static inline uint8_t av_fifo_peek(AVFifoBuffer *f, int offs) | 110 | /** |
| 111 | * Return a pointer to the data stored in a FIFO buffer at a certain offset. | ||
| 112 | * The FIFO buffer is not modified. | ||
| 113 | * | ||
| 114 | * @param *f AVFifoBuffer to peek at, f must be non-NULL | ||
| 115 | * @param offs an offset in bytes, its absolute value must be less | ||
| 116 | * than the used buffer size or the returned pointer will | ||
| 117 | * point outside to the buffer data. | ||
| 118 | * The used buffer size can be checked with av_fifo_size(). | ||
| 119 | */ | ||
| 120 | static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs) | ||
| 110 | { | 121 | { |
| 111 | uint8_t *ptr = f->rptr + offs; | 122 | uint8_t *ptr = f->rptr + offs; |
| 112 | if (ptr >= f->end) | 123 | if (ptr >= f->end) |
| 113 | ptr -= f->end - f->buffer; | 124 | ptr = f->buffer + (ptr - f->end); |
| 114 | return *ptr; | 125 | else if (ptr < f->buffer) |
| 126 | ptr = f->end - (f->buffer - ptr); | ||
| 127 | return ptr; | ||
| 115 | } | 128 | } |
| 129 | |||
| 130 | #if FF_API_AV_FIFO_PEEK | ||
| 131 | /** | ||
| 132 | * @deprecated Use av_fifo_peek2() instead. | ||
| 133 | */ | ||
| 134 | attribute_deprecated | ||
| 135 | static inline uint8_t av_fifo_peek(AVFifoBuffer *f, int offs) | ||
| 136 | { | ||
| 137 | return *av_fifo_peek2(f, offs); | ||
| 138 | } | ||
| 139 | #endif | ||
| 140 | |||
| 116 | #endif /* AVUTIL_FIFO_H */ | 141 | #endif /* AVUTIL_FIFO_H */ |