63e6f7bc
Hu Chunming
完成dvpp。但是nv和gb281...
|
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
#include<string>
#include "depend_headers.h"
#include "CircularQueue.hpp"
#include "FFReceiver.h"
#include "DvppDec.h"
using namespace std;
class DvppDecoder2{
public:
DvppDecoder2();
~DvppDecoder2();
bool init(FFDecConfig cfg);
void close();
bool start();
void pause();
void resume();
void setDecKeyframe(bool bKeyframe);
bool isRunning();
bool isFinished();
bool isPausing();
bool getResolution( int &width, int &height );
bool isSurport(FFDecConfig& cfg);
float fps();
void setName(string nm){
m_dec_name = nm;
}
string getName(){
return m_dec_name;
}
FFImgInfo* snapshot();
void setPostDecArg(const void* postDecArg);
void setFinishedDecArg(const void* finishedDecArg);
int getCachedQueueLength();
public:
void taskFinishing();
private:
FFDecConfig m_cfg;
string m_dec_name;
CircularQueue<AVPacket *> *m_pktQueueptr;
FFReceiver m_receiver;
DvppDec m_decoder;
const void * m_finishedDecArg;
DECODE_FINISHED_CALLBACK decode_finished_cbk;
};
void receiver_finish_cbk(const void* userPtr){
if(userPtr != nullptr){
DvppDecoder2* self = (DvppDecoder2*)userPtr;
self->taskFinishing();
}
}
DvppDecoder2::DvppDecoder2(){
m_pktQueueptr = new CircularQueue<AVPacket *>();
}
DvppDecoder2::~DvppDecoder2(){
delete m_pktQueueptr;
m_pktQueueptr = nullptr;
}
bool DvppDecoder2::init(FFDecConfig cfg){
ReceiverConfig receiver_config;
receiver_config.uri = cfg.uri.c_str();
receiver_config.dec_name = cfg.dec_name;
receiver_config.force_tcp = cfg.force_tcp;
receiver_config.pktQueueptr = m_pktQueueptr;
receiver_config.receiver_finished_cbk = receiver_finish_cbk;
AVCodecContext* avctx = m_receiver.init_FFmpeg(receiver_config);
if(avctx == nullptr){
return false;
}
m_receiver.setFinishCbkArg(this);
DvppDecConfig dec_cfg;
if(avctx->codec_id == AV_CODEC_ID_H264){
dec_cfg.codec_id = 0;
}else if(avctx->codec_id == AV_CODEC_ID_HEVC){
dec_cfg.codec_id = 1;
}else {
return false;
}
dec_cfg.dec_name = cfg.dec_name;
dec_cfg.post_decoded_cbk = cfg.post_decoded_cbk;
dec_cfg.dev_id = cfg.gpuid;
dec_cfg.force_tcp = cfg.force_tcp;
dec_cfg.skip_frame = cfg.skip_frame;
dec_cfg.profile = avctx->profile;
dec_cfg.pktQueueptr = m_pktQueueptr;
dec_cfg.width = avctx->width;
dec_cfg.height = avctx->height;
bool bRet = m_decoder.init_vdpp(dec_cfg);
if(!bRet){
return false;
}
m_cfg = cfg;
decode_finished_cbk = cfg.decode_finished_cbk;
return true;
}
bool DvppDecoder2::isSurport(FFDecConfig& cfg){
return true;
}
bool DvppDecoder2::start(){
m_receiver.start();
m_decoder.start();
return true;
}
void DvppDecoder2::close(){
m_receiver.close();
}
void DvppDecoder2::setPostDecArg(const void* postDecArg){
m_decoder.setPostDecArg(postDecArg);
}
void DvppDecoder2::setFinishedDecArg(const void* finishedDecArg){
m_finishedDecArg = finishedDecArg;
}
void DvppDecoder2::pause(){
m_receiver.pause();
}
void DvppDecoder2::resume(){
m_receiver.resume();
}
void DvppDecoder2::setDecKeyframe(bool bKeyframe){
m_receiver.setDecKeyframe(bKeyframe);
}
bool DvppDecoder2::isRunning(){
return m_receiver.isRunning();
}
bool DvppDecoder2::isFinished(){
return m_receiver.isFinished();
}
bool DvppDecoder2::isPausing(){
return m_receiver.isPausing();
}
bool DvppDecoder2::getResolution(int &width, int &height){
return m_receiver.getResolution(width, height);
}
float DvppDecoder2::fps(){
return m_receiver.fps();
}
FFImgInfo* DvppDecoder2::snapshot(){
// TODO
return nullptr;
}
int DvppDecoder2::getCachedQueueLength(){
return 0;
}
void DvppDecoder2::taskFinishing(){
// receiver 中读取线程结束时执行
m_decoder.close();
decode_finished_cbk(m_finishedDecArg);
LOG_INFO("[{}]- task finished.", m_dec_name);
}
|