From 109ffe9a777658936a38d0c146579a67c60a0d17 Mon Sep 17 00:00:00 2001
From: xuxiuxi <xuxiuxi@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期四, 11 五月 2017 17:48:48 +0800
Subject: [PATCH] 

---
 RtspFace/PL_AVFrameYUV420.cpp |   29 ++++++++++++++++-------------
 1 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/RtspFace/PL_AVFrameYUV420.cpp b/RtspFace/PL_AVFrameYUV420.cpp
index 5462ba9..3c61b7c 100644
--- a/RtspFace/PL_AVFrameYUV420.cpp
+++ b/RtspFace/PL_AVFrameYUV420.cpp
@@ -1,5 +1,6 @@
 #include "PL_AVFrameYUV420.h"
 #include "MaterialBuffer.h"
+#include "logger.h"
 
 extern "C"
 {
@@ -10,7 +11,7 @@
 
 struct AVFrameYUV420_Internal
 {
-	uint8_t buffer[1920*1080*3];
+	uint8_t buffer[1920*1080*3];//#todo from config
 	size_t buffSize;
 	size_t buffSizeMax;
 	MB_Frame lastFrame;
@@ -68,7 +69,7 @@
 	
 	if (pm.type != PipeMaterial::PMT_FRAME)
 	{
-		printf("PL_H264Encoder::pay only support PMT_FRAME\n");
+		LOG_ERROR << "Only support PMT_FRAME" << std::endl;
 		return false;
 	}
 	
@@ -78,7 +79,7 @@
 	MB_Frame* frame = (MB_Frame*)pm.buffer;
 	if (frame->type != MB_Frame::MBFT_PTR_AVFRAME)
 	{
-		printf("PL_H264Encoder::pay only support MBFT_PTR_AVFRAME\n");
+		LOG_ERROR << "Only support MBFT_PTR_AVFRAME" << std::endl;
 		return false;
 	}
 
@@ -89,8 +90,8 @@
 	int picSize = pAVFrame->height * pAVFrame->width;
 	in->buffSize = picSize * 1.5;
 
-	int height = pAVFrame->height;
-	int width = pAVFrame->width;
+	const int height = pAVFrame->height;
+	const int width = pAVFrame->width;
 
 	uint8_t* pBuff = in->buffer;
 	
@@ -110,15 +111,17 @@
 	in->lastFrame.type = MB_Frame::MBFT_YUV420;
 	in->lastFrame.buffer = in->buffer;
 	in->lastFrame.buffSize = in->buffSize;
+	in->lastFrame.width = width;
+	in->lastFrame.height = height;
 	in->lastFrame.pts = frame->pts;
 
 	//#test
-	static size_t f=0;
-	char fname[50];
-	sprintf(fname, "%u.yuv420", ++f);
-	FILE * pFile = fopen (fname,"wb");
-	fwrite (in->buffer , sizeof(char), in->buffSize, pFile);
-	fclose(pFile);
+	//static size_t f=0;
+	//char fname[50];
+	//sprintf(fname, "%u.yuv420", ++f);
+	//FILE * pFile = fopen (fname,"wb");
+	//fwrite (in->buffer , sizeof(char), in->buffSize, pFile);
+	//fclose(pFile);
 
 	return true;
 }
@@ -128,8 +131,8 @@
 	AVFrameYUV420_Internal* in = (AVFrameYUV420_Internal*)internal;
 
 	pm.type = PipeMaterial::PMT_FRAME;
-	pm.buffer = (uint8_t*)(&(in->lastFrame));
-	pm.buffSize = sizeof(in->lastFrame);
+	pm.buffer = &(in->lastFrame);
+	pm.buffSize = 0;
 	pm.former = this;
 	return true;
 }

--
Gitblit v1.8.0