From 31e0d0c171b4d6a7dc9b9697e69e165651d3fe93 Mon Sep 17 00:00:00 2001 From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674> Date: 星期三, 28 十二月 2016 18:32:20 +0800 Subject: [PATCH] face detect ok --- RtspFace/PL_H264Decoder.cpp | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) diff --git a/RtspFace/PL_H264Decoder.cpp b/RtspFace/PL_H264Decoder.cpp index 7a3b705..11ae388 100644 --- a/RtspFace/PL_H264Decoder.cpp +++ b/RtspFace/PL_H264Decoder.cpp @@ -162,7 +162,7 @@ return true; } -bool decodeH264(H264Decoder_Internal* in, uint8_t* buffer, size_t buffSize) +bool decodeH264(H264Decoder_Internal* in, uint8_t* buffer, size_t buffSize, timeval pts) { AVPacket packet = {0}; int gotPicture = buffSize; // frameFinished @@ -171,7 +171,9 @@ { printf("av_packet_from_data error\n"); return false; - } + } + + packet.pts = packet.dts = (pts.tv_sec * 1000 * 1000 + pts.tv_usec) / 90000; // decode avcodec_decode_video2(in->pAVCodecContext, in->pAVFrame, &gotPicture, &packet); @@ -222,12 +224,15 @@ bool ret = false; if (pm.type == PipeMaterial::PMT_BYTES) - ret = decodeH264(in, pm.buffer, pm.buffSize); + { + timeval pts = {0}; + ret = decodeH264(in, pm.buffer, pm.buffSize, pts); + } else if (pm.type == PipeMaterial::PMT_FRAME) { MB_Frame* frame = (MB_Frame*)pm.buffer; - ret = decodeH264(in, frame->buffer, frame->buffSize); + ret = decodeH264(in, frame->buffer, frame->buffSize, frame->pts); if (ret) { in->lastFrame.type = MB_Frame::MBFT_PTR_AVFRAME; -- Gitblit v1.8.0