FFmpeg
queue.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include <stddef.h>
22 
23 #ifndef AVFILTER_DNN_QUEUE_H
24 #define AVFILTER_DNN_QUEUE_H
25 
26 /**
27  * Linear double-ended data structure
28  */
29 typedef struct Queue Queue;
30 
31 /**
32  * @brief Create a Queue instance.
33  * It initializes the length of the Queue as 0.
34  *
35  * @return Pointer to the Queue
36  * @retval NULL if allocation fails
37  */
38 Queue *ff_queue_create(void);
39 
40 /**
41  * @brief Destroy the Queue instance.
42  * It also frees all elements of the Queue.
43  */
44 void ff_queue_destroy(Queue *q);
45 
46 /**
47  * @brief Return the length of the Queue
48  */
49 size_t ff_queue_size(Queue *q);
50 
51 /**
52  * @brief Return a pointer to the data
53  * at the head of the queue.
54  *
55  * @retval NULL if null pointer was passed
56  * or queue is empty
57  */
58 void *ff_queue_peek_front(Queue *q);
59 
60 /**
61  * @brief Return a pointer to the data at
62  * the tail of the queue.
63  *
64  * @retval NULL if null pointer was passed
65  * or queue is empty
66  */
67 void *ff_queue_peek_back(Queue *q);
68 
69 /**
70  * @brief Add data to the head of the queue.
71  * It increases the length of Queue by one.
72  *
73  * @param q pointer to the Queue.
74  * @param v data to be added
75  * @return The length of the Queue
76  * @retval 0 if the pointer to queue is NULL
77  * @retval -1 if new entry cannot be created
78  */
79 int ff_queue_push_front(Queue *q, void *v);
80 
81 /**
82  * @brief Add data to the tail of the queue.
83  * It increases the length of Queue by one.
84  *
85  * @param q pointer to the Queue
86  * @param v data to be added
87  * @return The length of the Queue
88  * @retval 0 if the pointer to queue is NULL
89  * @retval -1 if new entry cannot be created
90  */
91 int ff_queue_push_back(Queue *q, void *v);
92 
93 /**
94  * @brief Remove and free first element from
95  * the Queue. It shrinks the length of Queue
96  * by one.
97  *
98  * @param q pointer to the Queue.
99  * @return The value of first element as void.
100  * If a null pointer or empty queue is passed,
101  * it returns NULL
102  */
103 void *ff_queue_pop_front(Queue *q);
104 
105 /**
106  * @brief Remove and free last element from
107  * the Queue. It shrinks the length of Queue
108  * by one.
109  *
110  * @param q pointer to the Queue.
111  * @return The value of last element as void.
112  * If a null pointer or empty queue is passed,
113  * it returns NULL
114  */
115 void *ff_queue_pop_back(Queue *q);
116 
117 #endif
Queue
Linear double-ended data structure.
Definition: queue.c:33
ff_queue_size
size_t ff_queue_size(Queue *q)
Return the length of the Queue.
Definition: queue.c:88
ff_queue_peek_front
void * ff_queue_peek_front(Queue *q)
Return a pointer to the data at the head of the queue.
Definition: queue.c:93
ff_queue_push_front
int ff_queue_push_front(Queue *q, void *v)
Add data to the head of the queue.
Definition: queue.c:109
ff_queue_push_back
int ff_queue_push_back(Queue *q, void *v)
Add data to the tail of the queue.
Definition: queue.c:130
ff_queue_pop_back
void * ff_queue_pop_back(Queue *q)
Remove and free last element from the Queue.
Definition: queue.c:172
ff_queue_destroy
void ff_queue_destroy(Queue *q)
Destroy the Queue instance.
Definition: queue.c:72
ff_queue_create
Queue * ff_queue_create(void)
Create a Queue instance.
Definition: queue.c:47
ff_queue_pop_front
void * ff_queue_pop_front(Queue *q)
Remove and free first element from the Queue.
Definition: queue.c:151
ff_queue_peek_back
void * ff_queue_peek_back(Queue *q)
Return a pointer to the data at the tail of the queue.
Definition: queue.c:101