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 
22 #ifndef AVFILTER_DNN_QUEUE_H
23 #define AVFILTER_DNN_QUEUE_H
24 
25 /**
26  * Linear double-ended data structure
27  */
28 typedef struct Queue Queue;
29 
30 /**
31  * @brief Create a Queue instance.
32  * It initializes the length of the Queue as 0.
33  *
34  * @return Pointer to the Queue
35  * @retval NULL if allocation fails
36  */
37 Queue *ff_queue_create(void);
38 
39 /**
40  * @brief Destroy the Queue instance.
41  * It also frees all elements of the Queue.
42  */
43 void ff_queue_destroy(Queue *q);
44 
45 /**
46  * @brief Return the length of the Queue
47  */
48 size_t ff_queue_size(Queue *q);
49 
50 /**
51  * @brief Return a pointer to the data
52  * at the head of the queue.
53  *
54  * @retval NULL if null pointer was passed
55  * or queue is empty
56  */
57 void *ff_queue_peek_front(Queue *q);
58 
59 /**
60  * @brief Return a pointer to the data at
61  * the tail of the queue.
62  *
63  * @retval NULL if null pointer was passed
64  * or queue is empty
65  */
66 void *ff_queue_peek_back(Queue *q);
67 
68 /**
69  * @brief Add data to the head of the queue.
70  * It increases the length of Queue by one.
71  *
72  * @param q pointer to the Queue.
73  * @param v data to be added
74  * @return The length of the Queue
75  * @retval 0 if the pointer to queue is NULL
76  * @retval -1 if new entry cannot be created
77  */
78 int ff_queue_push_front(Queue *q, void *v);
79 
80 /**
81  * @brief Add data to the tail of the queue.
82  * It increases the length of Queue by one.
83  *
84  * @param q pointer to the Queue
85  * @param v data to be added
86  * @return The length of the Queue
87  * @retval 0 if the pointer to queue is NULL
88  * @retval -1 if new entry cannot be created
89  */
90 int ff_queue_push_back(Queue *q, void *v);
91 
92 /**
93  * @brief Remove and free first element from
94  * the Queue. It shrinks the length of Queue
95  * by one.
96  *
97  * @param q pointer to the Queue.
98  * @return The value of first element as void.
99  * If a null pointer or empty queue is passed,
100  * it returns NULL
101  */
102 void *ff_queue_pop_front(Queue *q);
103 
104 /**
105  * @brief Remove and free last element from
106  * the Queue. It shrinks the length of Queue
107  * by one.
108  *
109  * @param q pointer to the Queue.
110  * @return The value of last element as void.
111  * If a null pointer or empty queue is passed,
112  * it returns NULL
113  */
114 void *ff_queue_pop_back(Queue *q);
115 
116 #endif
Queue
Linear double-ended data structure.
Definition: queue.c:34
ff_queue_size
size_t ff_queue_size(Queue *q)
Return the length of the Queue.
Definition: queue.c:89
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:94
ff_queue_push_front
int ff_queue_push_front(Queue *q, void *v)
Add data to the head of the queue.
Definition: queue.c:110
ff_queue_push_back
int ff_queue_push_back(Queue *q, void *v)
Add data to the tail of the queue.
Definition: queue.c:131
ff_queue_pop_back
void * ff_queue_pop_back(Queue *q)
Remove and free last element from the Queue.
Definition: queue.c:173
ff_queue_destroy
void ff_queue_destroy(Queue *q)
Destroy the Queue instance.
Definition: queue.c:73
ff_queue_create
Queue * ff_queue_create(void)
Create a Queue instance.
Definition: queue.c:48
ff_queue_pop_front
void * ff_queue_pop_front(Queue *q)
Remove and free first element from the Queue.
Definition: queue.c:152
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:102