From fe007cee79c88a084bef01333f86f5da5f3c143f Mon Sep 17 00:00:00 2001
From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期四, 22 十二月 2016 17:57:12 +0800
Subject: [PATCH] add padd pl emements
---
RtspFace/PL_StaticJpegSource.h | 24 ++++++
RtspFace/main.cpp | 8 +-
RtspFace/PL_StaticJpegSource.cpp | 86 +++++++++++++++++++++
RtspFace/PL_SensetimeFaceDetect.h | 24 ++++++
RtspFace/PL_AVFrameBGRA.cpp | 7 -
RtspFace/PL_SensetimeFaceDetect.cpp | 81 ++++++++++++++++++++
6 files changed, 221 insertions(+), 9 deletions(-)
diff --git a/RtspFace/PL_AVFrameBGRA.cpp b/RtspFace/PL_AVFrameBGRA.cpp
index e59a8a7..9329f14 100644
--- a/RtspFace/PL_AVFrameBGRA.cpp
+++ b/RtspFace/PL_AVFrameBGRA.cpp
@@ -14,13 +14,12 @@
uint8_t buffer[1920*1080*4];
size_t buffSize;
size_t buffSizeMax;
-
- AVFormatContext* pAVFormatContext;//#todo delete
+
bool payError;
PL_AVFrameBGRA_Internal() :
buffSize(0), buffSizeMax(sizeof(buffer)),
- pAVFormatContext(nullptr), payError(true)
+ payError(true)
{
}
@@ -55,8 +54,6 @@
PL_AVFrameBGRA_Internal* in = (PL_AVFrameBGRA_Internal*)internal;
in->reset();
- in->pAVFormatContext = avformat_alloc_context();
-
return true;
}
diff --git a/RtspFace/PL_SensetimeFaceDetect.cpp b/RtspFace/PL_SensetimeFaceDetect.cpp
new file mode 100644
index 0000000..a6fba62
--- /dev/null
+++ b/RtspFace/PL_SensetimeFaceDetect.cpp
@@ -0,0 +1,81 @@
+#include "PL_SensetimeFaceDetect.h"
+
+struct PL_SensetimeFaceDetect_Internal
+{
+ uint8_t buffer[1920*1080*4];
+ size_t buffSize;
+ size_t buffSizeMax;
+
+ bool payError;
+
+ PL_SensetimeFaceDetect_Internal() :
+ buffSize(0), buffSizeMax(sizeof(buffer)),
+ payError(true)
+ {
+ }
+
+ ~PL_SensetimeFaceDetect_Internal()
+ {
+ }
+
+ void reset()
+ {
+ buffSize = 0;
+ payError = true;
+ }
+};
+
+PipeLineElem* create_PL_SensetimeFaceDetect()
+{
+ return new PL_SensetimeFaceDetect;
+}
+
+PL_SensetimeFaceDetect::PL_SensetimeFaceDetect() : internal(new PL_SensetimeFaceDetect_Internal)
+{
+}
+
+PL_SensetimeFaceDetect::~PL_SensetimeFaceDetect()
+{
+ delete (PL_SensetimeFaceDetect_Internal*)internal;
+ internal= nullptr;
+}
+
+bool PL_SensetimeFaceDetect::init(void* args)
+{
+ PL_SensetimeFaceDetect_Internal* in = (PL_SensetimeFaceDetect_Internal*)internal;
+ in->reset();
+
+ return true;
+}
+
+void PL_SensetimeFaceDetect::finit()
+{
+ PL_SensetimeFaceDetect_Internal* in = (PL_SensetimeFaceDetect_Internal*)internal;
+
+}
+
+bool PL_SensetimeFaceDetect::pay(const PipeMaterial& pm)
+{
+ PL_SensetimeFaceDetect_Internal* in = (PL_SensetimeFaceDetect_Internal*)internal;
+
+ //in->buffer readly
+
+ //static size_t f=0;
+ //char fname[50];
+ //sprintf(fname, "%u.bgra", ++f);
+ //FILE * pFile = fopen (fname,"wb");
+ //fwrite (in->buffer , sizeof(char), in->buffSize, pFile);
+ //fclose(pFile);
+
+ return true;
+}
+
+bool PL_SensetimeFaceDetect::gain(PipeMaterial& pm)
+{
+ PL_SensetimeFaceDetect_Internal* in = (PL_SensetimeFaceDetect_Internal*)internal;
+
+ pm.buffer = in->buffer;
+ pm.buffSize = in->buffSize;
+ pm.former = this;
+ return true;
+}
diff --git a/RtspFace/PL_SensetimeFaceDetect.h b/RtspFace/PL_SensetimeFaceDetect.h
new file mode 100644
index 0000000..f1cdbb1
--- /dev/null
+++ b/RtspFace/PL_SensetimeFaceDetect.h
@@ -0,0 +1,24 @@
+#ifndef _PL_PL_SENSETIMEFACEDETECT_H_
+#define _PL_PL_SENSETIMEFACEDETECT_H_
+
+#include "PipeLine.h"
+
+class PL_SensetimeFaceDetect : public PipeLineElem
+{
+public:
+ PL_SensetimeFaceDetect();
+ virtual ~PL_SensetimeFaceDetect();
+
+ virtual bool init(void* args);
+ virtual void finit();
+
+ virtual bool pay(const PipeMaterial& pm);
+ virtual bool gain(PipeMaterial& pm);
+
+private:
+ void* internal;
+};
+
+PipeLineElem* create_PL_SensetimeFaceDetect();
+
+#endif
diff --git a/RtspFace/PL_StaticJpegSource.cpp b/RtspFace/PL_StaticJpegSource.cpp
new file mode 100644
index 0000000..6ad3382
--- /dev/null
+++ b/RtspFace/PL_StaticJpegSource.cpp
@@ -0,0 +1,86 @@
+#include "PL_StaticJpegSource.h"
+
+extern "C"
+{
+ #include <libyuv.h>
+}
+
+struct PL_StaticJpegSource_Internal
+{
+ uint8_t buffer[1920*1080*4];
+ size_t buffSize;
+ size_t buffSizeMax;
+
+ bool payError;
+
+ PL_StaticJpegSource_Internal() :
+ buffSize(0), buffSizeMax(sizeof(buffer)),
+ payError(true)
+ {
+ }
+
+ ~PL_StaticJpegSource_Internal()
+ {
+ }
+
+ void reset()
+ {
+ buffSize = 0;
+ payError = true;
+ }
+};
+
+PipeLineElem* create_PL_StaticJpegSource()
+{
+ return new PL_StaticJpegSource;
+}
+
+PL_StaticJpegSource::PL_StaticJpegSource() : internal(new PL_StaticJpegSource_Internal)
+{
+}
+
+PL_StaticJpegSource::~PL_StaticJpegSource()
+{
+ delete (PL_StaticJpegSource_Internal*)internal;
+ internal= nullptr;
+}
+
+bool PL_StaticJpegSource::init(void* args)
+{
+ PL_StaticJpegSource_Internal* in = (PL_StaticJpegSource_Internal*)internal;
+ in->reset();
+
+ return true;
+}
+
+void PL_StaticJpegSource::finit()
+{
+ PL_StaticJpegSource_Internal* in = (PL_StaticJpegSource_Internal*)internal;
+
+}
+
+bool PL_StaticJpegSource::pay(const PipeMaterial& pm)
+{
+ PL_StaticJpegSource_Internal* in = (PL_StaticJpegSource_Internal*)internal;
+
+ //in->buffer readly
+
+ //static size_t f=0;
+ //char fname[50];
+ //sprintf(fname, "%u.bgra", ++f);
+ //FILE * pFile = fopen (fname,"wb");
+ //fwrite (in->buffer , sizeof(char), in->buffSize, pFile);
+ //fclose(pFile);
+
+ return true;
+}
+
+bool PL_StaticJpegSource::gain(PipeMaterial& pm)
+{
+ PL_StaticJpegSource_Internal* in = (PL_StaticJpegSource_Internal*)internal;
+
+ pm.buffer = in->buffer;
+ pm.buffSize = in->buffSize;
+ pm.former = this;
+ return true;
+}
diff --git a/RtspFace/PL_StaticJpegSource.h b/RtspFace/PL_StaticJpegSource.h
new file mode 100644
index 0000000..08aa5b8
--- /dev/null
+++ b/RtspFace/PL_StaticJpegSource.h
@@ -0,0 +1,24 @@
+#ifndef _PL_PL_StaticJpegSource_H_
+#define _PL_PL_StaticJpegSource_H_
+
+#include "PipeLine.h"
+
+class PL_StaticJpegSource : public PipeLineElem
+{
+public:
+ PL_StaticJpegSource();
+ virtual ~PL_StaticJpegSource();
+
+ virtual bool init(void* args);
+ virtual void finit();
+
+ virtual bool pay(const PipeMaterial& pm);
+ virtual bool gain(PipeMaterial& pm);
+
+private:
+ void* internal;
+};
+
+PipeLineElem* create_PL_StaticJpegSource();
+
+#endif
diff --git a/RtspFace/main.cpp b/RtspFace/main.cpp
index f8e9875..d25eddb 100644
--- a/RtspFace/main.cpp
+++ b/RtspFace/main.cpp
@@ -1,7 +1,7 @@
#include "PipeLine.h"
#include "PL_RTSPClient.h"
#include "PL_H264Decoder.h"
-#include "PL_AVFrameBGRA.h"
+#include "PL_AVFrameYUV420.h"
#include <iostream>
using namespace std;
@@ -12,7 +12,7 @@
pipeLine.register_elem_creator("PL_RTSPClient", create_PL_RTSPClient);
pipeLine.register_elem_creator("PL_H264Decoder", create_PL_H264Decoder);
- pipeLine.register_elem_creator("PL_AVFrameBGRA", create_PL_AVFrameBGRA);
+ pipeLine.register_elem_creator("PL_AVFrameYUV420", create_PL_AVFrameYUV420);
PL_RTSPClient* rtspClient = (PL_RTSPClient*)pipeLine.push_elem("PL_RTSPClient");
RTSPConfig rtspConfig;
@@ -28,8 +28,8 @@
PL_H264Decoder* h264Decoder = (PL_H264Decoder*)pipeLine.push_elem("PL_H264Decoder");
h264Decoder->init(nullptr);
- PL_AVFrameBGRA* avFrameBGRA = (PL_AVFrameBGRA*)pipeLine.push_elem("PL_AVFrameBGRA");
- avFrameBGRA->init(nullptr);
+ PL_AVFrameYUV420* avFrameYUV420 = (PL_AVFrameYUV420*)pipeLine.push_elem("PL_AVFrameYUV420");
+ avFrameYUV420->init(nullptr);
while(true)
{
--
Gitblit v1.8.0