[vlc-devel] [PATCH 01/22] picture: add helpers for picture chaining

Steve Lhomme robux4 at ycbcr.xyz
Thu Sep 17 17:33:23 CEST 2020


Picture chains are used either to keep a list of picture (in FIFO order) or to
attach a picture to another (filters).
---
 include/vlc_picture.h | 68 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/include/vlc_picture.h b/include/vlc_picture.h
index 7bb9ee5083c..a16d82a94f6 100644
--- a/include/vlc_picture.h
+++ b/include/vlc_picture.h
@@ -167,6 +167,74 @@ static inline vlc_video_context* picture_GetVideoContext(picture_t *pic)
     return pic->context ? pic->context->vctx : NULL;
 }
 
+/**
+ * picture chaining helpers
+ */
+
+/**
+ * Check whether a picture chain is empty
+ */
+static inline bool picture_chain_empty(const picture_t *chain)
+{
+    return chain->p_next == NULL;
+}
+
+/**
+ * Pop the front of a picture chain.
+ *
+ * The next picture becomes the front of the picture chain.
+ *
+ * \return the front of the picture chain (the picture itself)
+ */
+static inline picture_t * picture_chain_pop_front(picture_t **chain)
+{
+    picture_t *front = *chain;
+    if (front)
+    {
+        *chain = front->p_next;
+        front->p_next = NULL;
+    }
+    return front;
+}
+
+/**
+ * Pop the picture chain contained in the given picture.
+ *
+ * The picture doesn't have a picture chain anymore after this call.
+ *
+ * \return the picture chain contained in the given picture
+ */
+static inline picture_t * picture_pop_chain(picture_t *pic)
+{
+    picture_t *chain = pic->p_next;
+    pic->p_next = NULL;
+    return chain;
+}
+
+/**
+ * Append a picture in a picture chain.
+ *
+ * \return the new tail of the picture chain
+ */
+static inline picture_t * picture_chain_append(picture_t *chain, picture_t *tail)
+{
+    chain->p_next = tail;
+    tail->p_next = NULL; // we're appending a picture, not a chain
+    return tail;
+}
+
+/**
+ * Add a picture at the front of a picture chain.
+ *
+ * The added picture becomes the front of the picture chain.
+ */
+static inline void picture_chain_prepend(picture_t **chain, picture_t *front)
+{
+    front->p_next = *chain;
+    *chain = front;
+}
+
+
 /**
  * This function will create a new picture.
  * The picture created will implement a default release management compatible
-- 
2.26.2



More information about the vlc-devel mailing list