FFmpeg: fftools/thread_queue.c Source File
Go to the documentation of this file. 1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include <stdint.h>
20 #include <string.h>
21
28
31
32 enum {
35 };
36
41
45
47
50
53 };
54
56 {
58
59 if (!tq)
60 return;
61
66 }
68
70
72
75
77 }
78
80 ObjPool *obj_pool,
void (*obj_move)(
void *dst,
void *
src))
81 {
84
86 if (!tq)
88
93 }
94
100 }
101
106
110
113
114 return tq;
118 }
119
121 {
122 int *finished;
124
126 finished = &tq->
finished[stream_idx];
127
129
133 }
134
137
141 } else {
143
147
149
153 }
154
157
159 }
160
163 {
165 unsigned int nb_finished = 0;
166
171 return 0;
172 }
173
176 continue;
177
178 /* return EOF to the consumer at most once for each stream */
183 }
184
185 nb_finished++;
186 }
187
189 }
190
192 {
194
195 *stream_idx = -1;
196
198
199 while (1) {
203 continue;
204 }
205
206 break;
207 }
208
211
213
215 }
216
218 {
220
222
223 /* mark the stream as send-finished;
224 * next time the consumer thread tries to read this stream it will get
225 * an EOF and recv-finished flag will be set */
228
230 }
231
233 {
235
237
238 /* mark the stream as recv-finished;
239 * next time the producer thread tries to send for this stream, it will
240 * get an EOF and send-finished flag will be set */
243
245 }
size_t av_fifo_can_write(const AVFifo *f)
Filter the word "frame" indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
#define AVERROR_EOF
End of file.
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
void(* obj_move)(void *dst, void *src)
void objpool_free(ObjPool **pop)
int av_fifo_write(AVFifo *f, const void *buf, size_t nb_elems)
Write data into a FIFO.
void objpool_release(ObjPool *op, void **obj)
int av_fifo_read(AVFifo *f, void *buf, size_t nb_elems)
Read data from a FIFO.
static int receive_locked(ThreadQueue *tq, int *stream_idx, void *data)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static av_always_inline int pthread_cond_broadcast(pthread_cond_t *cond)
void tq_free(ThreadQueue **ptq)
void tq_receive_finish(ThreadQueue *tq, unsigned int stream_idx)
Mark the given stream finished from the receiving side.
int objpool_get(ObjPool *op, void **obj)
#define pthread_mutex_unlock(a)
int tq_send(ThreadQueue *tq, unsigned int stream_idx, void *data)
Send an item for the given stream to the queue.
ThreadQueue * tq_alloc(unsigned int nb_streams, size_t queue_size, ObjPool *obj_pool, void(*obj_move)(void *dst, void *src))
Allocate a queue for sending data between threads.
static av_always_inline int pthread_cond_destroy(pthread_cond_t *cond)
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
#define i(width, name, range_min, range_max)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int tq_receive(ThreadQueue *tq, int *stream_idx, void *data)
Read the next item from the queue.
void * av_calloc(size_t nmemb, size_t size)
AVFifo * av_fifo_alloc2(size_t nb_elems, size_t elem_size, unsigned int flags)
Allocate and initialize an AVFifo with a given element size.
static av_always_inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
void av_fifo_freep2(AVFifo **f)
Free an AVFifo and reset pointer to NULL.
static av_always_inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
#define pthread_mutex_lock(a)
void tq_send_finish(ThreadQueue *tq, unsigned int stream_idx)
Mark the given stream finished from the sending side.
Generated on Tue Feb 28 2023 21:33:05 for FFmpeg by
doxygen
1.8.17