]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
Add av_fifo_reset function to completely reset fifo state, which makes
authorreimar <reimar@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Mon, 9 Mar 2009 09:26:32 +0000 (09:26 +0000)
committerreimar <reimar@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Mon, 9 Mar 2009 09:26:32 +0000 (09:26 +0000)
it easier to reuse the fifo.

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@17901 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavutil/fifo.c
libavutil/fifo.h

index f36dfeea6e5d719fdf9b0957f1c662bcbd3a068a..9a9a139f3b1185e7b2687712d530a82214592864 100644 (file)
@@ -27,9 +27,9 @@ AVFifoBuffer *av_fifo_alloc(unsigned int size)
     AVFifoBuffer *f= av_mallocz(sizeof(AVFifoBuffer));
     if(!f)
         return NULL;
-    f->wptr = f->rptr =
     f->buffer = av_malloc(size);
     f->end = f->buffer + size;
+    av_fifo_reset(f);
     if (!f->buffer)
         av_freep(&f);
     return f;
@@ -43,6 +43,12 @@ void av_fifo_free(AVFifoBuffer *f)
     }
 }
 
+void av_fifo_reset(AVFifoBuffer *f)
+{
+    f->wptr = f->rptr = f->buffer;
+    f->wndx = f->rndx = 0;
+}
+
 int av_fifo_size(AVFifoBuffer *f)
 {
     return (uint32_t)(f->wndx - f->rndx);
index 9ba7e700fc0a7486724a67cade65faf9bf35b7d4..f64914f7c62517dd90784d526fe962b77c9b2656 100644 (file)
@@ -47,6 +47,12 @@ AVFifoBuffer *av_fifo_alloc(unsigned int size);
  */
 void av_fifo_free(AVFifoBuffer *f);
 
+/**
+ * Resets the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied.
+ * @param *f AVFifoBuffer to reset
+ */
+void av_fifo_reset(AVFifoBuffer *f);
+
 /**
  * Returns the amount of data in bytes in the AVFifoBuffer, that is the
  * amount of data you can read from it.