派生自 development/c++

pansen
2019-03-06 c73d6fde347cfb6e0386ab1c651e8f38f939e89e
QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp
@@ -128,6 +128,10 @@
    return bufsize;
}
/***
 * 解码线程
 * @param p_this
 */
void BASICGB28181::FFmpegDecoderJPG::BareFlowDecoderThd(FFmpegDecoderJPG *p_this) {
    DBG(p_this->m_camIdx << "  BareFlowDecoderThd ok ... gpuIdx is " << p_this->m_gpuIdx);
    p_this->m_running = true;
@@ -188,11 +192,6 @@
        //# todo save package
        p_this->frame_number++;
        //DBG("GotPicture "<<m_camId<<":"<<frame_number);
        //放在此处是因为之前放在前面,收到的帧不完成
        p_this->SaveToPacketVector(pkt);
        p_this->CheckSave();
        int err6 = avcodec_send_packet(ctx, &pkt);
        av_packet_unref(&pkt);
        int err7 = avcodec_receive_frame(ctx, frame);
@@ -201,12 +200,17 @@
            usleep(40000);
            continue;
        }
        //DBG("GotPicture "<<m_camId<<":"<<frame_number);
        //放在此处是因为之前放在前面,收到的帧不完成
        p_this->SaveToPacketVector(pkt);
        p_this->CheckSave();
//        BASICGB28181::avframe_to_cvmat(frame).copyTo(p_this->m_image);
        p_this->m_image = std::move(BASICGB28181::avframe_to_cvmat(frame));
#ifdef TestCode
        {
//            TestCode
//            TestCode 测试代码保存图片到本地
            ClockTimer cl("TestCode");
            std::string strNewTime2 = AppUtil::getTimeUSecString();
            cv::putText(p_this->m_image, strNewTime2, cv::Point(408, 540), cv::HersheyFonts::FONT_HERSHEY_PLAIN,
@@ -228,7 +232,7 @@
#ifdef TestCode
        DBG("emitSigal(\"DecoderImageOK\") begin");
#endif
        //触发信号
        gSignalLock.emitSigal(p_this->m_camIdx + "DecoderImageOK");
//#ifdef TestCode
//        DBG("emitSigal(\"DecoderImageOK\") after");
@@ -278,7 +282,7 @@
bool BASICGB28181::FFmpegDecoderJPG::stopThd() {
    TryCath(
        DBG(m_camIdx << "  FFmpegDecoderJPG stopThd ... ");
        DBG(m_camIdx << "  FFmpegDecoderJPG stopThd ... " << m_camIdx);
        m_running = false;
    );
    return true;
@@ -380,9 +384,11 @@
        int64_t firstKeyFrameDts = m_packetsVec[0].m_packet.dts;
        for (const auto &item:m_packetsVec) {
            if (item.m_frameId < lastFrameId) {
                DBG("item.m_frameId < lastFrameId   " << item.m_frameId << "  " << lastFrameId);
                conversion(const_cast<AVPacket *> (&item.m_packet), firstKeyFramePts, firstKeyFrameDts, video_st);
                av_write_frame(m_pOutFmtCtx, &item.m_packet);
            } else {
                DBG("item.m_frameId > lastFrameId   " << item.m_frameId << "  " << lastFrameId);
                break;
            }
        }