File indexing completed on 2024-06-16 04:38:29
0001 /* 0002 SPDX-FileCopyrightText: 2003 Fabrice Bellard 0003 SPDX-FileCopyrightText: 2020-2022 Mladen Milinkovic <max@smoothware.net> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef FRAMEQUEUE_H 0009 #define FRAMEQUEUE_H 0010 0011 extern "C" { 0012 #include "libavcodec/avcodec.h" 0013 #include "libavformat/avformat.h" 0014 } 0015 0016 #include <QObject> 0017 0018 QT_FORWARD_DECLARE_CLASS(QMutex) 0019 QT_FORWARD_DECLARE_CLASS(QWaitCondition) 0020 0021 #define VIDEO_PICTURE_QUEUE_SIZE 3 0022 #define SUBPICTURE_QUEUE_SIZE 16 0023 #define SAMPLE_QUEUE_SIZE 9 0024 #define FRAME_QUEUE_SIZE FFMAX(SAMPLE_QUEUE_SIZE, FFMAX(VIDEO_PICTURE_QUEUE_SIZE, SUBPICTURE_QUEUE_SIZE)) 0025 0026 namespace SubtitleComposer { 0027 class PacketQueue; 0028 0029 struct Frame { 0030 AVFrame *frame; 0031 AVSubtitle sub; 0032 int serial; 0033 double pts; /* presentation timestamp for the frame */ 0034 double duration; /* estimated duration of the frame */ 0035 int64_t pos; /* byte position of the frame in the input file */ 0036 int width; 0037 int height; 0038 int format; 0039 AVRational sar; 0040 bool uploaded; 0041 }; 0042 0043 class FrameQueue 0044 { 0045 friend class RenderThread; 0046 0047 public: 0048 FrameQueue(); 0049 0050 void unrefItem(Frame *vp); 0051 int init(PacketQueue *pktq, int maxSize, int keepLast); 0052 void destory(); 0053 void signal(); 0054 Frame * peek(); 0055 Frame * peekNext(); 0056 Frame * peekLast(); 0057 Frame * peekWritable(); 0058 Frame * peekReadable(); 0059 void push(); 0060 void next(); 0061 int nbRemaining(); 0062 int64_t lastPos(); 0063 0064 private: 0065 Frame m_queue[FRAME_QUEUE_SIZE]; 0066 int m_rIndex; 0067 int m_wIndex; 0068 int m_size; 0069 int m_maxSize; 0070 int m_keepLast; 0071 int m_rIndexShown; 0072 QMutex *m_mutex; 0073 QWaitCondition *m_cond; 0074 PacketQueue *m_pktQ; 0075 }; 0076 } 0077 0078 #endif // FRAMEQUEUE_H