File indexing completed on 2024-11-10 04:28:19
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 DECODER_H 0009 #define DECODER_H 0010 0011 #include <QThread> 0012 0013 extern "C" { 0014 #include "libavcodec/avcodec.h" 0015 #include "libavformat/avformat.h" 0016 } 0017 0018 QT_FORWARD_DECLARE_CLASS(QWaitCondition) 0019 0020 namespace SubtitleComposer { 0021 class PacketQueue; 0022 class FrameQueue; 0023 class FFPlayer; 0024 0025 class Decoder : public QThread 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 Decoder(QObject *parent = nullptr); 0031 0032 void init(AVCodecContext *avctx, PacketQueue *pq, FrameQueue *fq, QWaitCondition *emptyQueueCond); 0033 void start(); 0034 int decodeFrame(AVFrame *frame, AVSubtitle *sub); 0035 virtual void destroy(); 0036 virtual void abort(); 0037 0038 inline int pktSerial() const { return m_pktSerial; } 0039 inline int width() const { return m_avCtx->width; } 0040 inline int height() const { return m_avCtx->height; } 0041 inline int finished() const { return m_finished; } 0042 0043 inline void startPts(int64_t pts, const AVRational &tb) { m_startPts = pts; m_startPtsTb = tb; } 0044 0045 protected: 0046 int m_reorderPts; 0047 AVPacket *m_pkt; 0048 PacketQueue *m_queue; 0049 FrameQueue *m_frameQueue; 0050 AVCodecContext *m_avCtx; 0051 int m_pktSerial; 0052 int m_finished; 0053 QWaitCondition *m_emptyQueueCond; 0054 int64_t m_startPts; 0055 AVRational m_startPtsTb; 0056 int64_t m_nextPts; 0057 AVRational m_nextPtsTb; 0058 }; 0059 } 0060 0061 #endif // DECODER_H