From 307706a63521650ca1cc7eebff0a931b432539c3 Mon Sep 17 00:00:00 2001
From: pans <pans@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期三, 11 一月 2017 19:09:50 +0800
Subject: [PATCH] faceAPI整合
---
RtspFace/PL_H264Encoder.cpp | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/RtspFace/PL_H264Encoder.cpp b/RtspFace/PL_H264Encoder.cpp
index 1b3123a..a4d3089 100644
--- a/RtspFace/PL_H264Encoder.cpp
+++ b/RtspFace/PL_H264Encoder.cpp
@@ -9,9 +9,9 @@
#include <libavutil/imgutils.h>
#include <libavutil/opt.h>
#include <libavformat/avformat.h>
-
- #include <libyuv.h>
}
+
+#include <libyuv.h>
PL_H264Encoder_Config::PL_H264Encoder_Config() :
inBufferSize(2*1024*1024), // 2MByte
@@ -47,6 +47,8 @@
~H264Encoder_Internal()
{
+ delete[] buffer;
+ buffer = nullptr;
}
void reset()
@@ -67,8 +69,10 @@
pAVFormatContext = nullptr;
if (buffer != nullptr)
+ {
delete[] buffer;
- buffer = new uint8_t[config.inBufferSize];
+ buffer = nullptr;
+ }
}
};
@@ -97,6 +101,8 @@
PL_H264Encoder_Config* config = (PL_H264Encoder_Config*)args;
in->config = *config;
}
+
+ in->buffer = new uint8_t[in->config.inBufferSize];
return true;
}
@@ -235,7 +241,7 @@
{
in->frameCount++;
LOGP(DEBUG, "Succeed to encode (1) frame=%d, size=%d", in->frameCount, pAVPacket.size);
- memcpy(in->buffer, pAVPacket.data, pAVPacket.size);
+ memcpy(in->buffer, pAVPacket.data, pAVPacket.size);//#todo check inBufferSize
in->buffSize = pAVPacket.size;
av_free_packet(&pAVPacket);
}
@@ -361,8 +367,11 @@
in->lastFrame.buffSize = in->buffSize;
in->lastFrame.width = frame->width;
in->lastFrame.height = frame->height;
- in->lastFrame.pts = frame->pts;
- //#todo resetPts
+
+ if (in->config.resetPTS)
+ gettimeofday(&(in->lastFrame.pts),NULL);
+ else
+ in->lastFrame.pts = frame->pts;
}
return ret;
--
Gitblit v1.8.0