summaryrefslogtreecommitdiff
path: root/libavutil/fifo.c
diff options
context:
space:
mode:
authorStefano Sabatini <stefano.sabatini-lala@poste.it>2011-07-16 09:49:42 +0200
committerAnton Khirnov <anton@khirnov.net>2011-08-26 20:54:36 +0200
commit1717ba0cdd587fe3463c1d8560f2c7e13fb21ba3 (patch)
tree8756401368ee35322d7d5fc87c64c07e5dfdc532 /libavutil/fifo.c
parentf2011ed234f580de01768257f3da6e73fbf8ac7b (diff)
downloadffmpeg-1717ba0cdd587fe3463c1d8560f2c7e13fb21ba3.tar.gz
fifo: add FIFO API test program, and fate test
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavutil/fifo.c')
-rw-r--r--libavutil/fifo.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/libavutil/fifo.c b/libavutil/fifo.c
index f87a99dee5..5774d33d25 100644
--- a/libavutil/fifo.c
+++ b/libavutil/fifo.c
@@ -127,3 +127,39 @@ void av_fifo_drain(AVFifoBuffer *f, int size)
f->rptr -= f->end - f->buffer;
f->rndx += size;
}
+
+#ifdef TEST
+
+#undef printf
+
+int main(void)
+{
+ /* create a FIFO buffer */
+ AVFifoBuffer *fifo = av_fifo_alloc(13 * sizeof(int));
+ int i, j, n;
+
+ /* fill data */
+ for (i = 0; av_fifo_space(fifo) >= sizeof(int); i++)
+ av_fifo_generic_write(fifo, &i, sizeof(int), NULL);
+
+ /* peek at FIFO */
+ n = av_fifo_size(fifo)/sizeof(int);
+ for (i = -n+1; i < n; i++) {
+ int *v = (int *)av_fifo_peek2(fifo, i*sizeof(int));
+ printf("%d: %d\n", i, *v);
+ }
+ printf("\n");
+
+ /* read data */
+ for (i = 0; av_fifo_size(fifo) >= sizeof(int); i++) {
+ av_fifo_generic_read(fifo, &j, sizeof(int), NULL);
+ printf("%d ", j);
+ }
+ printf("\n");
+
+ av_fifo_free(fifo);
+
+ return 0;
+}
+
+#endif