-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathTaoDecoder.h
87 lines (76 loc) · 1.66 KB
/
TaoDecoder.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#pragma once
extern "C"
{
#define __STDC_CONSTANT_MACROS
#include <libavformat/avformat.h>
#include <libavutil/imgutils.h>
#include <libavutil/samplefmt.h>
#include <libavutil/timestamp.h>
}
#include <QContiguousCache>
#include <QObject>
#include <QThread>
const static int cDataCount = 4;
const static int cBufferSize = 1024 * 768;
struct YUVData
{
YUVData()
{
Y.reserve(cBufferSize);
U.reserve(cBufferSize);
V.reserve(cBufferSize);
}
QByteArray Y;
QByteArray U;
QByteArray V;
int yLineSize;
int uLineSize;
int vLineSize;
int height;
};
Q_DECLARE_METATYPE(YUVData);
class TaoDecoder : public QObject
{
Q_OBJECT
public:
public slots:
void init();
void uninit();
void load(const QString& file);
signals:
void videoFrameDataReady(YUVData data);
void videoInfoReady(int width, int height, int format);
protected:
void demuxing();
void decodeFrame();
private:
AVFormatContext* m_fmtCtx = nullptr;
AVCodecContext* m_videoCodecCtx = nullptr;
AVStream* m_videoStream = nullptr;
AVFrame* m_frame = nullptr;
AVPacket m_packet;
int m_videoStreamIndex = 0;
AVPixelFormat m_pixFmt;
int m_width, m_height;
YUVData m_yuvData;
};
class TaoDecoderController : public QObject
{
Q_OBJECT
public:
TaoDecoderController(QObject* parent = nullptr);
~TaoDecoderController();
YUVData getFrame(bool& got);
signals:
void init();
void uninit();
void pause(bool);
void load(const QString& file);
void videoInfoReady(int width, int height, int format);
protected slots:
void onVideoFrameDataReady(YUVData data);
private:
TaoDecoder* m_decoder = nullptr;
QThread m_thread;
QContiguousCache<YUVData> m_videoDataCache;
};