From ad8ee0872802ba5d0194458bf215a6cc89f4d0d0 Mon Sep 17 00:00:00 2001
From: chenshijun <csj_sky@126.com>
Date: 星期一, 15 四月 2019 15:30:38 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/1.3nsq' into 1.3nsq
---
QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp | 50 +++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 39 insertions(+), 11 deletions(-)
diff --git a/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp b/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp
index 7fa85cd..f1386f5 100644
--- a/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp
+++ b/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp
@@ -5,6 +5,7 @@
#include <zconf.h>
#include <opencv2/opencv.hpp>
#include "FFmpegDecoderJPG.h"
+#include <cstring>
void BASICGB28181::initFFmpeg() {
av_register_all();
@@ -32,7 +33,7 @@
dst.data, dst.linesize);
sws_freeContext(convert_ctx);
- DBG("m.size is " << m.size());
+// DBG("m.size is " << m.size());
// LOG_IF();
return m;
@@ -45,7 +46,9 @@
}
BASICGB28181::FFmpegDecoderJPG::~FFmpegDecoderJPG() {
+ //娓呯┖闃熷垪
while (m_rtpQueue.count_queue()) {
+ //#todo delete frameBuffInfo*
m_rtpQueue.popNotWait();
}
@@ -75,10 +78,9 @@
}
#ifdef TestCode
- DBG(" m_rtpQueue.push before ");
+ DBG(" m_rtpQueue.push befores ");
#endif
- m_rtpQueue.
- push(info);
+ m_rtpQueue.push(info);
#ifdef TestCode
DBG(" m_rtpQueue.push after ");
#endif
@@ -96,10 +98,11 @@
do {
// DBG(" m_rtpQueue.pop before ");
+ //浠庣紦瀛樹腑鑾峰彇buffinfo
frameBuffInfo *buffinfo = fFmpegDecoderJPG->m_rtpQueue.pop();
// DBG(" m_rtpQueue.pop after ");
diff = len - buffinfo->buffLen;
-// printf("bufsize is :%ld,len is :%ld, datalen:%d \n", bufsize, len, buffinfo->buffLen);
+
//甯ч暱澶т簬bufsize
if (diff < 0) {
// DBG("/甯ч暱澶т簬bufsize" << diff);
@@ -130,7 +133,7 @@
delete[] buffinfo->buff;
delete buffinfo;
} while (diff > 0);
- //#todo 瑙﹀彂淇″彿
+
// DBG("emitSigal(\"read_dataOk\") begin");
// gSignalLock.emitSigal("read_dataOk");
fFmpegDecoderJPG->m_readData = true;
@@ -143,7 +146,8 @@
* @param p_this
*/
void BASICGB28181::FFmpegDecoderJPG::BareFlowDecoderThd(FFmpegDecoderJPG *p_this) {
- DBG(p_this->m_camIdx << " BareFlowDecoderThd ok ... gpuIdx is " << p_this->m_gpuIdx);
+ DBG(p_this->m_camIdx << " BareFlowDecoderThd ok ... gpuIdx is " << p_this->m_gpuIdx);
+ DBG("p_thisADDR:" << p_this << "p_this->m_running" << p_this->m_running);
while (!p_this->m_running) {
p_this->m_running = true;
@@ -151,12 +155,14 @@
// avformat_network_init();
p_this->ic = avformat_alloc_context();
+ //鍒涘缓ffmpeg浣跨敤鐨勫唴瀛樼┖闂�
p_this->iobuffer = (unsigned char *) av_malloc(p_this->m_buf_size);
if (!p_this->iobuffer) {
ERR("av_malloc: err======" << p_this->m_camIdx);
p_this->m_running = false;
continue;
}
+// 浣跨敤鍥炶皟鍑芥暟鍜屽唴瀛樺潡鍒涘缓 AVIOContext
p_this->avio = avio_alloc_context(p_this->iobuffer, p_this->m_buf_size, 0, p_this, p_this->read_data, NULL,
NULL);
if (!p_this->avio) {
@@ -193,6 +199,12 @@
vi = i;
break;
}
+ }
+ if(vi == -1)//鏃犺棰戝寘
+ {
+ ERR("no video packet!!");
+ p_this->m_running = false;
+ continue;
}
p_this->stream = p_this->ic->streams[vi];
p_this->video_st = p_this->stream;
@@ -267,7 +279,21 @@
// BASICGB28181::avframe_to_cvmat(frame).copyTo(p_this->m_image);
p_this->m_image = std::move(BASICGB28181::avframe_to_cvmat(p_this->frame));
-
+ if(p_this->m_image.empty()) {
+ ERR("camID:" << p_this->m_camIdx << " frameW:" << p_this->frame->width << "frame.data.len" << strlen(p_this->frame->data[0]));
+ continue;
+ }
+// else {
+// static int count =0;
+// count ++;
+// if(count > 100){
+// ERR("camID:" << p_this->m_camIdx << " cols:" << p_this->m_image.cols <<\
+// " rows:" << p_this->m_image.rows << " channels:" << p_this->m_image.channels());
+// count = 0;
+// }
+//
+// }
+// 灏唅甯т繚瀛樹负蹇収
if (p_this->m_SnapshotNotSaveRet && (p_this->pkt.flags & AV_PKT_FLAG_KEY)) {
try {
std::string strNewName = "./";
@@ -304,8 +330,9 @@
#ifdef TestCode
DBG("emitSigal(\"DecoderImageOK\") begin");
#endif
- //瑙﹀彂淇″彿
+ //瑙﹀彂涓婂眰淇″彿
gSignalLock.emitSigal(p_this->m_camIdx + "DecoderImageOK");
+// DBG("emitSigal: " << p_this->m_camIdx);
//#ifdef TestCode
// DBG("emitSigal(\"DecoderImageOK\") after");
//#endif
@@ -349,6 +376,7 @@
}
m_camIdx = camIdx;
DBG("BareFlowDecoderThd camIdx : " << camIdx);
+// 鍚姩瑙g爜绾跨▼
std::thread t_BareFlowDecoder(BareFlowDecoderThd, this);
t_BareFlowDecoder.detach();
);
@@ -441,7 +469,7 @@
delete iter->m_packet.data;
iter = m_packetsVec.erase(iter);
while (!(iter->m_packet.flags & AV_PKT_FLAG_KEY)) {
- INFO("DropFrame: " << iter->m_frameId);
+// INFO("DropFrame: " << iter->m_frameId);
delete iter->m_packet.data;
iter = m_packetsVec.erase(iter);
}
@@ -524,7 +552,7 @@
m_frameIndex++;
m_packetsVec.push_back({m_frameIndex, newPacket});
if (newPacket.flags & AV_PKT_FLAG_KEY) {
- DBG("newPacket.flags & AV_PKT_FLAG_KEY ");
+// DBG("newPacket.flags & AV_PKT_FLAG_KEY ");
m_last_I_FrameId = m_frameIndex;
}
}
--
Gitblit v1.8.0