@@ -18,7 +18,7 @@ API changes, most recent first:
Add av_fifo_alloc2(), which allows setting a FIFO element size.
Operations on FIFOs created with this function on these elements
rather than bytes.
- Add av_fifo_elem_size().
+ Add av_fifo_elem_size(), av_fifo_can_read(), av_fifo_can_write().
2022-01-xx - xxxxxxxxxx - lavu fifo.h
Access to all AVFifoBuffer members is deprecated. The struct will
@@ -126,7 +126,7 @@ size_t av_fifo_elem_size(const AVFifoBuffer *f)
return fb->elem_size;
}
-int av_fifo_size(const AVFifoBuffer *f)
+size_t av_fifo_can_read(const AVFifoBuffer *f)
{
const FifoBuffer *fb = (const FifoBuffer*)f;
if (fb->offset_w <= fb->offset_r && !fb->is_empty)
@@ -134,10 +134,20 @@ int av_fifo_size(const AVFifoBuffer *f)
return fb->offset_w - fb->offset_r;
}
-int av_fifo_space(const AVFifoBuffer *f)
+size_t av_fifo_can_write(const AVFifoBuffer *f)
{
const FifoBuffer *fb = (const FifoBuffer*)f;
- return fb->nb_elems - av_fifo_size(f);
+ return fb->nb_elems - av_fifo_can_read(f);
+}
+
+int av_fifo_size(const AVFifoBuffer *f)
+{
+ return av_fifo_can_read(f);
+}
+
+int av_fifo_space(const AVFifoBuffer *f)
+{
+ return av_fifo_can_write(f);
}
int av_fifo_realloc2(AVFifoBuffer *f, unsigned int new_size)
@@ -119,6 +119,16 @@ int av_fifo_size(const AVFifoBuffer *f);
*/
int av_fifo_space(const AVFifoBuffer *f);
+/**
+ * @return number of elements available for reading from the given FIFO.
+ */
+size_t av_fifo_can_read(const AVFifoBuffer *f);
+
+/**
+ * @return number of elements that can be written into the given FIFO.
+ */
+size_t av_fifo_can_write(const AVFifoBuffer *f);
+
/**
* Feed data at specific position from an AVFifoBuffer to a user-supplied callback.
* Similar as av_fifo_gereric_read but without discarding data.