FFmpeg
framequeue.h
1 /*
2  * Generic frame queue
3  * Copyright (c) 2016 Nicolas George
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with FFmpeg; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef AVFILTER_FRAMEQUEUE_H
23 #define AVFILTER_FRAMEQUEUE_H
24 
32 #include "libavutil/frame.h"
33 
34 typedef struct FFFrameBucket {
35  AVFrame *frame;
37 
46 typedef struct FFFrameQueueGlobal {
47  char dummy; /* C does not allow empty structs */
49 
53 typedef struct FFFrameQueue {
54 
59 
63  size_t allocated;
64 
69  size_t tail;
70 
74  size_t queued;
75 
80 
85 
91 
96 
102 
107 
108 } FFFrameQueue;
109 
113 void ff_framequeue_global_init(FFFrameQueueGlobal *fqg);
114 
118 void ff_framequeue_init(FFFrameQueue *fq, FFFrameQueueGlobal *fqg);
119 
123 void ff_framequeue_free(FFFrameQueue *fq);
124 
129 int ff_framequeue_add(FFFrameQueue *fq, AVFrame *frame);
130 
135 AVFrame *ff_framequeue_take(FFFrameQueue *fq);
136 
141 AVFrame *ff_framequeue_peek(FFFrameQueue *fq, size_t idx);
142 
146 static inline size_t ff_framequeue_queued_frames(const FFFrameQueue *fq)
147 {
148  return fq->queued;
149 }
150 
154 static inline uint64_t ff_framequeue_queued_samples(const FFFrameQueue *fq)
155 {
156  return fq->total_samples_head - fq->total_samples_tail;
157 }
158 
164 static inline void ff_framequeue_update_peeked(FFFrameQueue *fq, size_t idx)
165 {
166 }
167 
176 void ff_framequeue_skip_samples(FFFrameQueue *fq, size_t samples, AVRational time_base);
177 
178 #endif /* AVFILTER_FRAMEQUEUE_H */
This structure describes decoded (raw) audio or video data.
Definition: frame.h:218
uint64_t total_frames_head
Total number of frames entered in the queue.
Definition: framequeue.h:84
Queue of AVFrame pointers.
Definition: framequeue.h:53
size_t allocated
Size of the array of buckets.
Definition: framequeue.h:63
uint64_t total_samples_head
Total number of samples entered in the queue.
Definition: framequeue.h:95
uint64_t total_frames_tail
Total number of frames dequeued from the queue.
Definition: framequeue.h:90
reference-counted frame API
size_t tail
Tail of the queue.
Definition: framequeue.h:69
uint64_t total_samples_tail
Total number of samples dequeued from the queue.
Definition: framequeue.h:101
size_t queued
Number of currently queued frames.
Definition: framequeue.h:74
Rational number (pair of numerator and denominator).
Definition: rational.h:58
int samples_skipped
Indicate that samples are skipped.
Definition: framequeue.h:106
FFFrameBucket * queue
Array of allocated buckets, used as a circular buffer.
Definition: framequeue.h:58
FFFrameBucket first_bucket
Pre-allocated bucket for queues of size 1.
Definition: framequeue.h:79
Structure to hold global options and statistics for frame queues.
Definition: framequeue.h:46
FFFrameQueue: simple AVFrame queue API.
Definition: framequeue.h:34