History

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.

Stefano Sabatini committed 15 years ago

Commit f2011ed1 parent f4f33004 files · +37 −6Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavformat/dvenc.c +2 −2
  3. libavutil/avutil.h +4 −1
  4. libavutil/fifo.h +28 −3
doc/APIchanges+3−0
@@ -13,6 +13,9 @@ libavutil: 2011-04-18 · 12 unmodified lines
1313
1414 API changes, most recent first:
1515
16+2011-08-xx - xxxxxx - lavu 51.9.0
17+ Add av_fifo_peek2(), deprecate av_fifo_peek().
18+
1619 2011-08-xx - xxxxxxx - lavf 53.4.0
1720 Add avformat_query_codec().
1821
libavformat/dvenc.c+2−2
@@ -192,8 +192,8 @@ static void dv_inject_audio(DVMuxContext *c, int channel, uint8_t* frame_ptr) · 191 unmodified lines
192192 if (of*2 >= size)
193193 continue;
194194
195− frame_ptr[d] = av_fifo_peek(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
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_peek2(c->audio_data[channel], of*2); // that DV is a big-endian PCM
197197 }
198198 frame_ptr += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */
199199 }
libavutil/avutil.h+4−1
@@ -40,7 +40,7 @@ · 39 unmodified lines
4040 #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
4141
4242 #define LIBAVUTIL_VERSION_MAJOR 51
43−#define LIBAVUTIL_VERSION_MINOR 8
43+#define LIBAVUTIL_VERSION_MINOR 9
4444 #define LIBAVUTIL_VERSION_MICRO 0
4545
4646 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
@@ -63,6 +63,9 @@ · 16 unmodified lines
6363 #ifndef FF_API_FIND_OPT
6464 #define FF_API_FIND_OPT (LIBAVUTIL_VERSION_MAJOR < 52)
6565 #endif
66+#ifndef FF_API_AV_FIFO_PEEK
67+#define FF_API_AV_FIFO_PEEK (LIBAVUTIL_VERSION_MAJOR < 52)
68+#endif
6669
6770 /**
6871 * Return the LIBAVUTIL_VERSION_INT constant.
libavutil/fifo.h+28−3
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #define AVUTIL_FIFO_H
2626
2727 #include <stdint.h>
28+#include "avutil.h"
2829
2930 typedef struct AVFifoBuffer {
3031 uint8_t *buffer;
@@ -106,11 +107,35 @@ int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size); · 75 unmodified lines
106107 */
107108 void av_fifo_drain(AVFifoBuffer *f, int size);
108109
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)
110121 {
111122 uint8_t *ptr = f->rptr + offs;
112123 if (ptr >= f->end)
113− ptr -= f->end - f->buffer;
114− return *ptr;
124+ ptr = f->buffer + (ptr - f->end);
125+ else if (ptr < f->buffer)
126+ ptr = f->end - (f->buffer - ptr);
127+ return ptr;
115128 }
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+
116141 #endif /* AVUTIL_FIFO_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t