|
@@ -0,0 +1,1069 @@
|
|
|
|
+#include "DecodeVedio.h"
|
|
|
|
+#include "spdlog/spdlog.h"
|
|
|
|
+#include "FmtLog/fmtlog.h"
|
|
|
|
+
|
|
|
|
+#include <QThread>
|
|
|
|
+
|
|
|
|
+extern "C"
|
|
|
|
+{
|
|
|
|
+#include <libavcodec/avcodec.h>
|
|
|
|
+#include <libavformat/avformat.h>
|
|
|
|
+#include <libswscale/swscale.h>
|
|
|
|
+#include <libavutil/imgutils.h>
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+* @brief FFmpeg获取GPU硬件解码帧格式的回调函数
|
|
|
|
+===================================================================================================*/
|
|
|
|
+static enum AVPixelFormat g_hw_pix_fmt;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ * @brief 回调函数,获取GPU硬件解码帧的格式
|
|
|
|
+ *
|
|
|
|
+ * @param ctx
|
|
|
|
+ * @param pix_fmts
|
|
|
|
+ * @return AVPixelFormat
|
|
|
|
+ */
|
|
|
|
+AVPixelFormat get_hw_format(AVCodecContext *ctx, const AVPixelFormat *pix_fmts)
|
|
|
|
+{
|
|
|
|
+ Q_UNUSED(ctx)
|
|
|
|
+ const AVPixelFormat* p;
|
|
|
|
+ for(p = pix_fmts; *p != -1; p++)
|
|
|
|
+ {
|
|
|
|
+ if(*p == g_hw_pix_fmt)
|
|
|
|
+ {
|
|
|
|
+ return *p;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ SPDLOG_WARN("无法获取硬件解码器表面格式。");
|
|
|
|
+ return AV_PIX_FMT_NONE;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ * @brief Construct a new Decode Vedio:: Decode Vedio object
|
|
|
|
+ *
|
|
|
|
+ * @param thread
|
|
|
|
+ * @param parent
|
|
|
|
+ */
|
|
|
|
+DecodeVedio::DecodeVedio(QThread* thread, QObject* parent) : QObject(parent) , m_thread(thread)
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ this->moveToThread(thread);
|
|
|
|
+ connect(this, &DecodeVedio::signal_startDecode, this, &DecodeVedio::do_startDecodeVedio);
|
|
|
|
+ thread->start();
|
|
|
|
+ findHWDecoder();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+DecodeVedio::~DecodeVedio()
|
|
|
|
+{
|
|
|
|
+ stopDecodeVedio();
|
|
|
|
+ if(m_thread != nullptr)
|
|
|
|
+ {
|
|
|
|
+ if(m_thread->isRunning())
|
|
|
|
+ {
|
|
|
|
+ m_thread->quit();
|
|
|
|
+ m_thread->wait();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void DecodeVedio::startDecodeVedio()
|
|
|
|
+{
|
|
|
|
+ if(m_threadRuning)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if(!m_initFFmpeg)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_WARN("未初始化FFMPEG...");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ m_threadRuning = true;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ emit signal_startDecode();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void DecodeVedio::stopDecodeVedio()
|
|
|
|
+{
|
|
|
|
+ if(!m_threadRuning)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ exitThread();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ while(m_decodeState.load() != DecodeState::DecodeExit)
|
|
|
|
+ {
|
|
|
|
+ std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
|
|
|
+ }
|
|
|
|
+ freeAll();
|
|
|
|
+ m_threadRuning = false;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ * @brief 设置当前播放位置,单位是毫秒
|
|
|
|
+ * 这里需要去掉队列中已有的图片数目对应的时长
|
|
|
|
+ *
|
|
|
|
+ * @param pos 要跳转的位置,范围从0~duration
|
|
|
|
+ */
|
|
|
|
+void DecodeVedio::setCurrentPos(qint64 pos)
|
|
|
|
+{
|
|
|
|
+ if(!m_threadRuning)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ m_isSeek = true;
|
|
|
|
+
|
|
|
|
+ pauseDecode();
|
|
|
|
+
|
|
|
|
+ SPDLOG_DEBUG("跳转到:{}ms",pos);
|
|
|
|
+
|
|
|
|
+ pos = pos - m_queueImage.QueueSize() * (1000 / m_fps);
|
|
|
|
+ if(pos < 0) {
|
|
|
|
+ pos = 0;
|
|
|
|
+ }
|
|
|
|
+ if(pos > m_duration) {
|
|
|
|
+ pos = m_duration;
|
|
|
|
+ }
|
|
|
|
+ pos = pos + m_startPos;
|
|
|
|
+ qint64 targetPos = qRound64((double)pos / (1000 * rationalToDouble(&m_pFormatContext->streams[m_videoStream]->time_base)));
|
|
|
|
+
|
|
|
|
+ int ret = av_seek_frame(m_pFormatContext, m_videoStream, targetPos, AVSEEK_FLAG_BACKWARD);
|
|
|
|
+ if(ret < 0)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_ERROR("跳转失败!");
|
|
|
|
+ }
|
|
|
|
+ m_targetPos = pos;
|
|
|
|
+
|
|
|
|
+ m_flushDecoder.store(true);
|
|
|
|
+
|
|
|
|
+ SPDLOG_DEBUG("清空环形队列中的视频。");
|
|
|
|
+ QImage* image = 0;
|
|
|
|
+ while (m_queueImage.QueueSize() > 0)
|
|
|
|
+ {
|
|
|
|
+ image = nullptr;
|
|
|
|
+ m_queueImage.front_pop_NoBlock(image);
|
|
|
|
+ if(image != nullptr)
|
|
|
|
+ {
|
|
|
|
+ delete image;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ continueDecode();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+qint64 DecodeVedio::getCurrentPos()
|
|
|
|
+{
|
|
|
|
+ return m_pts.load() - m_startPos;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+qint64 DecodeVedio::getDuration()
|
|
|
|
+{
|
|
|
|
+ return m_duration;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ * @brief 获取一帧图像,队列为空就返回nullptr,这个函数应该是运行在UI线程中的
|
|
|
|
+ * @warning 传出这个指针后,队列就出队了,内存需要外面获取的实例释放
|
|
|
|
+ * @return QImage* 一帧图像的指针
|
|
|
|
+ */
|
|
|
|
+QImage* DecodeVedio::getOneImage()
|
|
|
|
+{
|
|
|
|
+ if(!m_threadRuning)
|
|
|
|
+ {
|
|
|
|
+ return nullptr;
|
|
|
|
+ }
|
|
|
|
+ QImage* image = nullptr;
|
|
|
|
+ if(!m_queueImage.front_pop_NoBlock(image))
|
|
|
|
+ {
|
|
|
|
+ return nullptr;
|
|
|
|
+ }
|
|
|
|
+ return image;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ * @brief 获取一帧图像,直到有图像为止
|
|
|
|
+ *
|
|
|
|
+ * @param timeOut 设为-1是一直等待,设置正整数是等待的时间,单位ms
|
|
|
|
+ * @return QImage*
|
|
|
|
+ */
|
|
|
|
+QImage* DecodeVedio::getOneImageUntilHave(int timeOut)
|
|
|
|
+{
|
|
|
|
+ if(!m_threadRuning)
|
|
|
|
+ {
|
|
|
|
+ return nullptr;
|
|
|
|
+ }
|
|
|
|
+ if(timeOut < 0)
|
|
|
|
+ {
|
|
|
|
+ QImage* image = m_queueImage.front_pop();
|
|
|
|
+ return image;
|
|
|
|
+ }
|
|
|
|
+ for(int i = 0; i < timeOut; i++)
|
|
|
|
+ {
|
|
|
|
+ QImage* image = nullptr;
|
|
|
|
+ if(m_queueImage.front_pop_NoBlock(image))
|
|
|
|
+ {
|
|
|
|
+ return image;
|
|
|
|
+ }
|
|
|
|
+ std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
|
|
|
+ }
|
|
|
|
+ return nullptr;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void DecodeVedio::findHWDecoder(QStringList& listDecoderName)
|
|
|
|
+{
|
|
|
|
+ AVHWDeviceType type = AV_HWDEVICE_TYPE_NONE;
|
|
|
|
+ listDecoderName.clear();
|
|
|
|
+ while( (type = av_hwdevice_iterate_types(type)) != AV_HWDEVICE_TYPE_NONE)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ const char* typeName = av_hwdevice_get_type_name(type);
|
|
|
|
+ if(typeName)
|
|
|
|
+ {
|
|
|
|
+ listDecoderName.append(QString(typeName));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void DecodeVedio::findHWDecoder()
|
|
|
|
+{
|
|
|
|
+ AVHWDeviceType type = AV_HWDEVICE_TYPE_NONE;
|
|
|
|
+
|
|
|
|
+ m_listDecoderName.clear();
|
|
|
|
+ while( (type = av_hwdevice_iterate_types(type)) != AV_HWDEVICE_TYPE_NONE)
|
|
|
|
+ {
|
|
|
|
+ m_listHWDeviceType.append(type);
|
|
|
|
+
|
|
|
|
+ const char* typeName = av_hwdevice_get_type_name(type);
|
|
|
|
+ if(typeName)
|
|
|
|
+ {
|
|
|
|
+ m_listDecoderName.append(QString(typeName));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(m_listHWDeviceType.isEmpty())
|
|
|
|
+ {
|
|
|
|
+ m_supportHWDecoder = false;
|
|
|
|
+ }else {
|
|
|
|
+ m_supportHWDecoder = true;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void DecodeVedio::initHWDecoder(const AVCodec* codec)
|
|
|
|
+{
|
|
|
|
+ if(codec == nullptr)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for(int i = 0;;i++)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ const AVCodecHWConfig* hwConfig = avcodec_get_hw_config(codec, 0);
|
|
|
|
+ if(hwConfig == nullptr)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_WARN("没有找到支持{}的硬件配置", codec->name);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(hwConfig->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ for(auto i : m_listHWDeviceType)
|
|
|
|
+ {
|
|
|
|
+ if(hwConfig->device_type == AVHWDeviceType(i))
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ g_hw_pix_fmt = hwConfig->pix_fmt;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ int ret = av_hwdevice_ctx_create(&m_hw_device_ctx, hwConfig->device_type, nullptr, nullptr, 0);
|
|
|
|
+ if(ret < 0)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_ERROR("打开硬件解码器失败!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ SPDLOG_INFO("打开硬件解码器:{}", av_hwdevice_get_type_name(hwConfig->device_type));
|
|
|
|
+ m_pCodecContext->hw_device_ctx = av_buffer_ref(m_hw_device_ctx);
|
|
|
|
+ m_pCodecContext->get_format = get_hw_format;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+bool DecodeVedio::copyDataFromGPU(AVFrame* pFrameHW, AVFrame* pFrameSRC)
|
|
|
|
+{
|
|
|
|
+ if(m_pFrameSRC->format != g_hw_pix_fmt)
|
|
|
|
+ {
|
|
|
|
+ av_frame_unref(m_pFrameSRC);
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int ret = av_hwframe_transfer_data(pFrameHW, pFrameSRC, 0);
|
|
|
|
+ if(ret < 0)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_ERROR("从GPU拷贝数据失败!");
|
|
|
|
+ av_frame_unref(pFrameSRC);
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ av_frame_copy_props(pFrameHW, pFrameSRC);
|
|
|
|
+ return true;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void DecodeVedio::openVedio(const QString& fileName)
|
|
|
|
+{
|
|
|
|
+ if(fileName.isEmpty())
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_WARN("文件名为空...");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ m_fileName = fileName;
|
|
|
|
+ if(m_initFFmpeg)
|
|
|
|
+ {
|
|
|
|
+ freeAll();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(m_queueImage.QueueSize() > 0)
|
|
|
|
+ {
|
|
|
|
+ for(int i = 0; i < m_queueImage.QueueSize(); i++)
|
|
|
|
+ {
|
|
|
|
+ QImage* image = nullptr;
|
|
|
|
+ if (m_queueImage.front_pop_NoBlock(image))
|
|
|
|
+ {
|
|
|
|
+ delete image;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ m_queueImage.clearQueue();
|
|
|
|
+ }
|
|
|
|
+ m_queueImage.setQueueCapacity(30);
|
|
|
|
+
|
|
|
|
+ SPDLOG_DEBUG("开始初始化FFMPEG");
|
|
|
|
+
|
|
|
|
+ AVDictionary *options = nullptr;
|
|
|
|
+
|
|
|
|
+ av_dict_set(&options, "buffer_size", "1024000", 0);
|
|
|
|
+
|
|
|
|
+ * (因为它们可能无序到达,或者数据包可能完全丢失)。这可以通过将最大解复用延迟设置为零
|
|
|
|
+ * (通过max_delayAVFormatContext 字段)来禁用。 */
|
|
|
|
+ av_dict_set(&options, "max_delay", "500000", 0);
|
|
|
|
+
|
|
|
|
+ av_dict_set(&options, "rtsp_transport", "tcp", 0);
|
|
|
|
+
|
|
|
|
+ av_dict_set(&options, "stimeout", "20000000", 0);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ int ret = avformat_open_input( &m_pFormatContext,
|
|
|
|
+ m_fileName.toStdString().data(),
|
|
|
|
+ nullptr,
|
|
|
|
+ &options);
|
|
|
|
+ if(ret != 0)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_WARN("打开视频文件错误,错误代码:{}",ret);
|
|
|
|
+ freeAll();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(options != nullptr)
|
|
|
|
+ {
|
|
|
|
+ av_dict_free(&options);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ * 查找到视频流,并获取视频时长相关的信息 */
|
|
|
|
+ ret = 0;
|
|
|
|
+ ret = avformat_find_stream_info(m_pFormatContext, nullptr);
|
|
|
|
+ if(ret < 0)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_WARN("获取视频流错误,错误代码:{}",ret);
|
|
|
|
+ freeAll();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ m_duration = m_pFormatContext->duration / (AV_TIME_BASE / 1000);
|
|
|
|
+ m_startPos = m_pFormatContext->start_time / (AV_TIME_BASE / 1000);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ av_dump_format(m_pFormatContext, 0, m_fileName.toStdString().c_str(), 0);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ m_videoStream = av_find_best_stream(m_pFormatContext, AVMEDIA_TYPE_VIDEO, -1, -1, nullptr, 0);
|
|
|
|
+ if(m_videoStream < 0)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_WARN("没有找到视频流");
|
|
|
|
+ freeAll();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ SPDLOG_DEBUG("找到视频流");
|
|
|
|
+
|
|
|
|
+ AVStream *pStream = m_pFormatContext->streams[m_videoStream];
|
|
|
|
+ AVCodecParameters* pCodecParams = pStream->codecpar;
|
|
|
|
+ SPDLOG_DEBUG("获取视频流参数成功!");
|
|
|
|
+
|
|
|
|
+ m_srcSize.setWidth(pCodecParams->width);
|
|
|
|
+ m_srcSize.setHeight(pCodecParams->height);
|
|
|
|
+ m_fps = rationalToDouble(&pStream->avg_frame_rate);
|
|
|
|
+ m_totalFrame = m_pFormatContext->streams[m_videoStream]->nb_frames;
|
|
|
|
+ m_pts.store(0);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ const AVCodec* pCodec = avcodec_find_decoder(pCodecParams->codec_id);
|
|
|
|
+ if(pCodec == nullptr)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_WARN("没有找到解码器");
|
|
|
|
+ freeAll();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ m_decoderName = pCodec->name;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ m_pCodecContext = avcodec_alloc_context3(pCodec);
|
|
|
|
+
|
|
|
|
+ if(avcodec_parameters_to_context(m_pCodecContext, pCodecParams) != 0)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_WARN("复制上下文错误");
|
|
|
|
+ freeAll();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ SPDLOG_DEBUG("设置解码器参数成功!");
|
|
|
|
+
|
|
|
|
+ m_pCodecContext->thread_count = 8;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(m_supportHWDecoder)
|
|
|
|
+ {
|
|
|
|
+ initHWDecoder(pCodec);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(avcodec_open2(m_pCodecContext, nullptr, nullptr) < 0)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_ERROR("打开解码器错误");
|
|
|
|
+ freeAll();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ SPDLOG_DEBUG("打开解码器成功!");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ m_packet = av_packet_alloc();
|
|
|
|
+ av_new_packet(m_packet, m_pCodecContext->width * m_pCodecContext->height);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ m_pFrameSRC = av_frame_alloc();
|
|
|
|
+ if(m_pFrameSRC == nullptr)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_ERROR("创建pFrame错误");
|
|
|
|
+ freeAll();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ m_pFrameHW = av_frame_alloc();
|
|
|
|
+ if(m_pFrameHW == nullptr)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_ERROR("创建pFrameHW错误");
|
|
|
|
+ freeAll();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(m_buffer != nullptr)
|
|
|
|
+ {
|
|
|
|
+ av_free(m_buffer);
|
|
|
|
+ m_buffer = nullptr;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ int numBytes = av_image_get_buffer_size(AV_PIX_FMT_RGBA, m_pCodecContext->width, m_pCodecContext->height, 1);
|
|
|
|
+
|
|
|
|
+ m_buffer = (uint8_t *)av_malloc(numBytes + 1000);
|
|
|
|
+
|
|
|
|
+ m_initFFmpeg = true;
|
|
|
|
+ SPDLOG_INFO("FFMPEG初始化完成!");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(m_fps == 0)
|
|
|
|
+ {
|
|
|
|
+ if((m_duration > 0) && (m_totalFrame > 0))
|
|
|
|
+ {
|
|
|
|
+ m_fps = m_totalFrame / (m_duration / 1000.0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(m_fps == 0)
|
|
|
|
+ {
|
|
|
|
+ m_fps = 25;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ * @brief 软解码线程,使用CPU解码,使用环境队列存储解码的数据
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+void DecodeVedio::threadDecodeUsingCPU()
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ bool isEnd = false;
|
|
|
|
+ int ret = 0;
|
|
|
|
+ int retFrame = 0;
|
|
|
|
+ int retPacket = 0;
|
|
|
|
+ m_pauseDecode = false;
|
|
|
|
+ m_decodeStatus = true;
|
|
|
|
+ m_decodeState.store(DecodeState::DecodeRun);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ SPDLOG_DEBUG("开始解码...");
|
|
|
|
+ while(m_threadRuning)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ while(m_pauseDecode)
|
|
|
|
+ {
|
|
|
|
+ m_decodeState.store(DecodeState::DecodePause);
|
|
|
|
+ std::this_thread::sleep_for(std::chrono::microseconds(100));
|
|
|
|
+ }
|
|
|
|
+ m_decodeState.store(DecodeState::DecodeRun);
|
|
|
|
+
|
|
|
|
+ if(m_flushDecoder.load())
|
|
|
|
+ {
|
|
|
|
+ avcodec_flush_buffers(m_pCodecContext);
|
|
|
|
+ m_flushDecoder.store(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int retRead = av_read_frame(m_pFormatContext, m_packet);
|
|
|
|
+ if(retRead == AVERROR_EOF)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ avcodec_send_packet(m_pCodecContext, m_packet);
|
|
|
|
+ }
|
|
|
|
+ else if(retRead < 0)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_ERROR("读取帧错误...");
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if(m_packet->stream_index == m_videoStream)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ dts 表示解码时间戳(Decoding Timestamp),它指示解码器应该在什么时候解码这个数据包。dts 用于确保解码器按照正确的顺序解码数据包。 */
|
|
|
|
+ #if 1
|
|
|
|
+
|
|
|
|
+ m_packet->pts = qRound64(m_packet->pts * (1000 * rationalToDouble(&m_pFormatContext->streams[m_videoStream]->time_base)));
|
|
|
|
+ m_packet->dts = qRound64(m_packet->dts * (1000 * rationalToDouble(&m_pFormatContext->streams[m_videoStream]->time_base)));
|
|
|
|
+ #else
|
|
|
|
+
|
|
|
|
+ m_currentFrame++;
|
|
|
|
+
|
|
|
|
+ #endif
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ int ret = avcodec_send_packet(m_pCodecContext, m_packet);
|
|
|
|
+ if(ret < 0)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_ERROR("发送数据包错误...");
|
|
|
|
+ av_packet_unref(m_packet);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+
|
|
|
|
+ av_packet_unref(m_packet);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ while(m_threadRuning)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ int ret = avcodec_receive_frame(m_pCodecContext, m_pFrameSRC);
|
|
|
|
+ if(ret == AVERROR_EOF)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_INFO("读取到视频流末尾。");
|
|
|
|
+ isEnd = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ else if (ret == AVERROR(EAGAIN))
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ * 这时候就需要往解码器送数据包了 */
|
|
|
|
+
|
|
|
|
+ av_frame_unref(m_pFrameSRC);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ else if(ret < 0)
|
|
|
|
+ {
|
|
|
|
+ av_frame_unref(m_pFrameSRC);
|
|
|
|
+ if(retRead < 0)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_ERROR("读取错误,错误值:{}",ret);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ * 如果在跳转状态,在这里判断是否到了目标位置 */
|
|
|
|
+ m_pts = m_pFrameSRC->pts;
|
|
|
|
+ if(m_isSeek.load())
|
|
|
|
+ {
|
|
|
|
+ if(m_pts < m_targetPos)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_DEBUG("目标位置:{} 当前位置:{}",m_targetPos, m_pts.load());
|
|
|
|
+ av_frame_unref(m_pFrameSRC);
|
|
|
|
+ continue;
|
|
|
|
+ }else {
|
|
|
|
+ m_isSeek = false;
|
|
|
|
+ m_targetPos = -1;
|
|
|
|
+ SPDLOG_INFO("跳转结束。");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(m_sws_ctx == nullptr)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ m_sws_ctx = sws_getCachedContext(m_sws_ctx,
|
|
|
|
+ m_pFrameSRC->width, m_pFrameSRC->height,
|
|
|
|
+ m_pCodecContext->pix_fmt,
|
|
|
|
+ m_srcSize.width(), m_srcSize.height(),
|
|
|
|
+ AV_PIX_FMT_RGBA,
|
|
|
|
+ SWS_BILINEAR,
|
|
|
|
+ nullptr,
|
|
|
|
+ nullptr,
|
|
|
|
+ nullptr);
|
|
|
|
+ if(m_sws_ctx == nullptr)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_ERROR("创建SwsContext错误...");
|
|
|
|
+ goto label_ThreadDecodeExit;
|
|
|
|
+ }
|
|
|
|
+ SPDLOG_INFO("创建SwsContext成功...");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ int lines[4];
|
|
|
|
+
|
|
|
|
+ av_image_fill_linesizes(lines, AV_PIX_FMT_RGBA, m_pFrameSRC->width);
|
|
|
|
+
|
|
|
|
+ sws_scale( m_sws_ctx,
|
|
|
|
+ m_pFrameSRC->data,
|
|
|
|
+ m_pFrameSRC->linesize,
|
|
|
|
+ 0,
|
|
|
|
+ m_pFrameSRC->height,
|
|
|
|
+ &m_buffer,
|
|
|
|
+ lines);
|
|
|
|
+ if(m_buffer != nullptr)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ auto image = new QImage(m_buffer, m_srcSize.width(), m_srcSize.height(), QImage::Format_RGBA8888);
|
|
|
|
+
|
|
|
|
+ m_queueImage.push(image);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ av_frame_unref(m_pFrameSRC);
|
|
|
|
+
|
|
|
|
+ if(m_isSeek)
|
|
|
|
+ {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ av_packet_unref(m_packet);
|
|
|
|
+ if(isEnd)
|
|
|
|
+ {
|
|
|
|
+ emit signal_playCompleted();
|
|
|
|
+ m_decodeState.store(DecodeState::DecodeStop);
|
|
|
|
+
|
|
|
|
+ while(m_decodeState.load() != DecodeState::DecodeRun)
|
|
|
|
+ {
|
|
|
|
+ std::this_thread::sleep_for(std::chrono::milliseconds(2));
|
|
|
|
+ }
|
|
|
|
+ isEnd = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+label_ThreadDecodeExit:
|
|
|
|
+
|
|
|
|
+ av_packet_free(&m_packet);
|
|
|
|
+ m_decodeState.store(DecodeState::DecodeExit);
|
|
|
|
+ m_threadRuning = false;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void DecodeVedio::exitThread()
|
|
|
|
+{
|
|
|
|
+ if(m_threadRuning)
|
|
|
|
+ {
|
|
|
|
+ m_threadRuning = false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ m_decodeState.store(DecodeState::DecodeRun);
|
|
|
|
+ m_pauseDecode = false;
|
|
|
|
+
|
|
|
|
+ m_queueImage.exit();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ * @brief 硬件解码线程,使用GPU解码,使用环境队列存储解码的数据
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+void DecodeVedio::threadDecodeUsingGPU()
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ bool isEnd = false;
|
|
|
|
+ int ret = 0;
|
|
|
|
+ int retFrame = 0;
|
|
|
|
+ int retPacket = 0;
|
|
|
|
+ m_pauseDecode = false;
|
|
|
|
+ m_decodeStatus = true;
|
|
|
|
+ m_decodeState.store(DecodeState::DecodeRun);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ SPDLOG_DEBUG("开始解码...");
|
|
|
|
+ while(m_threadRuning)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ while(m_pauseDecode)
|
|
|
|
+ {
|
|
|
|
+ m_decodeState.store(DecodeState::DecodePause);
|
|
|
|
+ std::this_thread::sleep_for(std::chrono::microseconds(100));
|
|
|
|
+ }
|
|
|
|
+ m_decodeState.store(DecodeState::DecodeRun);
|
|
|
|
+
|
|
|
|
+ if(m_flushDecoder.load())
|
|
|
|
+ {
|
|
|
|
+ avcodec_flush_buffers(m_pCodecContext);
|
|
|
|
+ m_flushDecoder.store(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int retRead = av_read_frame(m_pFormatContext, m_packet);
|
|
|
|
+ if(retRead == AVERROR_EOF)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ avcodec_send_packet(m_pCodecContext, m_packet);
|
|
|
|
+ }
|
|
|
|
+ else if(retRead < 0)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_ERROR("读取帧错误...");
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if(m_packet->stream_index == m_videoStream)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ dts 表示解码时间戳(Decoding Timestamp),它指示解码器应该在什么时候解码这个数据包。dts 用于确保解码器按照正确的顺序解码数据包。 */
|
|
|
|
+ #if 1
|
|
|
|
+
|
|
|
|
+ m_packet->pts = qRound64(m_packet->pts * (1000 * rationalToDouble(&m_pFormatContext->streams[m_videoStream]->time_base)));
|
|
|
|
+ m_packet->dts = qRound64(m_packet->dts * (1000 * rationalToDouble(&m_pFormatContext->streams[m_videoStream]->time_base)));
|
|
|
|
+ #else
|
|
|
|
+
|
|
|
|
+ m_currentFrame++;
|
|
|
|
+
|
|
|
|
+ #endif
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ int ret = avcodec_send_packet(m_pCodecContext, m_packet);
|
|
|
|
+ if(ret < 0)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_ERROR("发送数据包错误...");
|
|
|
|
+ av_packet_unref(m_packet);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+
|
|
|
|
+ av_packet_unref(m_packet);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ while(m_threadRuning)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ int ret = avcodec_receive_frame(m_pCodecContext, m_pFrameSRC);
|
|
|
|
+ if(ret == AVERROR_EOF)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_INFO("读取到视频流末尾。");
|
|
|
|
+ isEnd = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ else if (ret == AVERROR(EAGAIN))
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ * 这时候就需要往解码器送数据包了 */
|
|
|
|
+
|
|
|
|
+ av_frame_unref(m_pFrameSRC);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ else if(ret < 0)
|
|
|
|
+ {
|
|
|
|
+ av_frame_unref(m_pFrameSRC);
|
|
|
|
+ if(retRead < 0)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_ERROR("读取错误,错误值:{}",ret);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ * 数据要从GPU中拷贝出来 */
|
|
|
|
+ if(!copyDataFromGPU(m_pFrameHW, m_pFrameSRC))
|
|
|
|
+ {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ * 如果在跳转状态,在这里判断是否到了目标位置 */
|
|
|
|
+ m_pts = m_pFrameHW->pts;
|
|
|
|
+ if(m_isSeek.load())
|
|
|
|
+ {
|
|
|
|
+ if(m_pts < m_targetPos)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_DEBUG("目标位置:{} 当前位置:{}",m_targetPos, m_pts.load());
|
|
|
|
+ av_frame_unref(m_pFrameHW);
|
|
|
|
+ continue;
|
|
|
|
+ }else {
|
|
|
|
+ m_isSeek = false;
|
|
|
|
+ m_targetPos = -1;
|
|
|
|
+ SPDLOG_INFO("跳转结束。");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(m_sws_ctx == nullptr)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ m_sws_ctx = sws_getCachedContext(m_sws_ctx,
|
|
|
|
+ m_pFrameHW->width, m_pFrameHW->height,
|
|
|
|
+ m_pCodecContext->pix_fmt,
|
|
|
|
+ m_srcSize.width(), m_srcSize.height(),
|
|
|
|
+ AV_PIX_FMT_RGBA,
|
|
|
|
+ SWS_BILINEAR,
|
|
|
|
+ nullptr,
|
|
|
|
+ nullptr,
|
|
|
|
+ nullptr);
|
|
|
|
+ if(m_sws_ctx == nullptr)
|
|
|
|
+ {
|
|
|
|
+ SPDLOG_ERROR("创建SwsContext错误...");
|
|
|
|
+ goto label_ThreadDecodeExit;
|
|
|
|
+ }
|
|
|
|
+ SPDLOG_INFO("创建SwsContext成功...");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ int lines[4];
|
|
|
|
+
|
|
|
|
+ av_image_fill_linesizes(lines, AV_PIX_FMT_RGBA, m_pFrameHW->width);
|
|
|
|
+
|
|
|
|
+ sws_scale( m_sws_ctx,
|
|
|
|
+ m_pFrameHW->data,
|
|
|
|
+ m_pFrameHW->linesize,
|
|
|
|
+ 0,
|
|
|
|
+ m_pFrameHW->height,
|
|
|
|
+ &m_buffer,
|
|
|
|
+ lines);
|
|
|
|
+ if(m_buffer != nullptr)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ auto image = new QImage(m_buffer, m_srcSize.width(), m_srcSize.height(), QImage::Format_RGBA8888);
|
|
|
|
+
|
|
|
|
+ m_queueImage.push(image);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ av_frame_unref(m_pFrameSRC);
|
|
|
|
+
|
|
|
|
+ if(m_isSeek)
|
|
|
|
+ {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ av_packet_unref(m_packet);
|
|
|
|
+ if(isEnd)
|
|
|
|
+ {
|
|
|
|
+ emit signal_playCompleted();
|
|
|
|
+ m_decodeState.store(DecodeState::DecodeStop);
|
|
|
|
+
|
|
|
|
+ while(m_decodeState.load() != DecodeState::DecodeRun)
|
|
|
|
+ {
|
|
|
|
+ std::this_thread::sleep_for(std::chrono::milliseconds(2));
|
|
|
|
+ }
|
|
|
|
+ isEnd = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+label_ThreadDecodeExit:
|
|
|
|
+
|
|
|
|
+ av_packet_free(&m_packet);
|
|
|
|
+ m_decodeState.store(DecodeState::DecodeExit);
|
|
|
|
+ m_threadRuning = false;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void DecodeVedio::pauseDecode()
|
|
|
|
+{
|
|
|
|
+ if(!m_threadRuning)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if( (m_decodeState.load() == DecodeState::DecodeExit)
|
|
|
|
+ || (m_decodeState.load() == DecodeState::DecodePause) )
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ m_decodeState.store(DecodeState::DecodeRun);
|
|
|
|
+ m_pauseDecode = true;
|
|
|
|
+
|
|
|
|
+ QImage* image = nullptr;
|
|
|
|
+ m_queueImage.front_pop_NoBlock(image);
|
|
|
|
+ if(image != nullptr)
|
|
|
|
+ {
|
|
|
|
+ delete image;
|
|
|
|
+ image = nullptr;
|
|
|
|
+ }
|
|
|
|
+ m_queueImage.front_pop_NoBlock(image);
|
|
|
|
+ if(image != nullptr)
|
|
|
|
+ {
|
|
|
|
+ delete image;
|
|
|
|
+ image = nullptr;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ while (m_decodeState.load() != DecodeState::DecodePause)
|
|
|
|
+ {
|
|
|
|
+ std::this_thread::sleep_for(std::chrono::microseconds(100));
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void DecodeVedio::continueDecode()
|
|
|
|
+{
|
|
|
|
+ m_pauseDecode = false;
|
|
|
|
+ m_decodeState.store(DecodeState::DecodeRun);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ * @brief AVRational存储的是分子和分母,这里相除转换为double,用于计算帧率
|
|
|
|
+ * 这个函数就等同于av_q2d()
|
|
|
|
+ * @param rational
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+qreal DecodeVedio::rationalToDouble(AVRational* rational)
|
|
|
|
+{
|
|
|
|
+ return ( (rational->den == 0) ? 0 : (qreal(rational->num) / rational->den) );
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void DecodeVedio::do_startDecodeVedio()
|
|
|
|
+{
|
|
|
|
+ SPDLOG_DEBUG("解码线程ID:{}",QThread::currentThreadId());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ m_threadRuning = true;
|
|
|
|
+ m_pauseDecode = false;
|
|
|
|
+
|
|
|
|
+ threadDecodeUsingCPU();
|
|
|
|
+ SPDLOG_TRACE("Decode解码结束。");
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void DecodeVedio::freeAll()
|
|
|
|
+{
|
|
|
|
+ if(m_sws_ctx)
|
|
|
|
+ {
|
|
|
|
+ sws_freeContext(m_sws_ctx);
|
|
|
|
+ m_sws_ctx = nullptr;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(m_pFrameSRC)
|
|
|
|
+ {
|
|
|
|
+ av_frame_free(&m_pFrameSRC);
|
|
|
|
+ }
|
|
|
|
+ if(m_pFrameHW)
|
|
|
|
+ {
|
|
|
|
+ av_frame_free(&m_pFrameHW);
|
|
|
|
+ }
|
|
|
|
+ if(m_packet)
|
|
|
|
+ {
|
|
|
|
+ av_packet_free(&m_packet);
|
|
|
|
+ }
|
|
|
|
+ if(m_pCodecContext)
|
|
|
|
+ {
|
|
|
|
+ avcodec_free_context(&m_pCodecContext);
|
|
|
|
+ }
|
|
|
|
+ if(m_pFormatContext)
|
|
|
|
+ {
|
|
|
|
+ avformat_close_input(&m_pFormatContext);
|
|
|
|
+ }
|
|
|
|
+ if(m_buffer)
|
|
|
|
+ {
|
|
|
|
+ av_free(m_buffer);
|
|
|
|
+ m_buffer = nullptr;
|
|
|
|
+ }
|
|
|
|
+ if(m_hw_device_ctx)
|
|
|
|
+ {
|
|
|
|
+ av_buffer_unref(&m_hw_device_ctx);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for(int i = 0; i < m_queueImage.QueueSize(); i++)
|
|
|
|
+ {
|
|
|
|
+ QImage* image = nullptr;
|
|
|
|
+ if (m_queueImage.front_pop_NoBlock(image))
|
|
|
|
+ {
|
|
|
|
+ delete image;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ m_queueImage.clearQueue();
|
|
|
|
+}
|
|
|
|
+
|