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
13 13
14API changes, most recent first:14API changes, most recent first:
15 15
162011-08-xx - xxxxxx - lavu 51.9.0
17 Add av_fifo_peek2(), deprecate av_fifo_peek().
18
162011-08-xx - xxxxxxx - lavf 53.4.0192011-08-xx - xxxxxxx - lavf 53.4.0
17 Add avformat_query_codec().20 Add avformat_query_codec().
18 21
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
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 admit195 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 PCM196 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 }
libavutil/avutil.h+4−1
@@ -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 5142#define LIBAVUTIL_VERSION_MAJOR 51
43#define LIBAVUTIL_VERSION_MINOR 843#define LIBAVUTIL_VERSION_MINOR 9
44#define LIBAVUTIL_VERSION_MICRO 044#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_OPT63#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#endif65#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.
libavutil/fifo.h+28−3
@@ -25,6 +25,7 @@ · 24 unmodified lines
25#define AVUTIL_FIFO_H25#define AVUTIL_FIFO_H
26 26
27#include <stdint.h>27#include <stdint.h>
28#include "avutil.h"
28 29
29typedef struct AVFifoBuffer {30typedef 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 */
107void av_fifo_drain(AVFifoBuffer *f, int size);108void av_fifo_drain(AVFifoBuffer *f, int size);
108 109
109static 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 */
120static 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 */
134attribute_deprecated
135static 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 */

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