From 3a5f09c61a87adb8dba2cc4a5366893886ba1c1d Mon Sep 17 00:00:00 2001
From: dupengyue <dupengyue@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期四, 20 七月 2017 17:31:40 +0800
Subject: [PATCH] 接口初步完成

---
 RtspFace/PL_AndroidSurfaceViewRender.cpp |   52 +++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 41 insertions(+), 11 deletions(-)

diff --git a/RtspFace/PL_AndroidSurfaceViewRender.cpp b/RtspFace/PL_AndroidSurfaceViewRender.cpp
index 3336a15..9e7596e 100644
--- a/RtspFace/PL_AndroidSurfaceViewRender.cpp
+++ b/RtspFace/PL_AndroidSurfaceViewRender.cpp
@@ -249,6 +249,33 @@
 	return true;
 }
 
+bool convert_rgb565_origin_to_render(PL_ASVR_Internal *in) {
+
+    ANativeWindow* window = (ANativeWindow*)(in->config.windowSurface);
+    int widow_width = ANativeWindow_getWidth(window);
+    int window_height = ANativeWindow_getHeight(window);
+    int src_width = in->lastMbfBuffOrigin.width;
+    int src_height = in->lastMbfBuffOrigin.height;
+    if (src_width != widow_width || src_height != window_height)
+    {
+        uint8_t* src = (uint8_t*)in->lastMbfBuffOrigin.buffer;
+        uint8_t* dst = (uint8_t*)in->buffer1;
+        libyuv::ScalePlane_16((uint16*)src, src_width,
+                              src_width, src_height,
+                              (uint16*)dst, widow_width,
+                              widow_width, window_height,
+                              libyuv::kFilterNone);
+        in->buff1Size = widow_width * window_height * 2;
+        memcpy(in->buffer, in->buffer1, in->buff1Size);
+        in->buffSize = in->buff1Size;
+    }
+    else
+    {
+        memcpy(in->buffer, in->lastMbfBuffOrigin.buffer, in->lastMbfBuffOrigin.buffSize);
+        in->buffSize = in->lastMbfBuffOrigin.buffSize;
+    }
+	return true;
+}
 bool convert_nv12_origin_to_render(PL_ASVR_Internal* in)
 {
     if (false)
@@ -310,10 +337,10 @@
                           dst_width, dst_height,
                           libyuv::kFilterNone);
 
-        libyuv::ScalePlane_16((uint16*)src_uv, MH_SUBSAMPLE1(src_width ,2),
-                              MH_SUBSAMPLE1(src_width ,2), src_height,
-                              (uint16*)dst_uv, MH_SUBSAMPLE1(dst_width ,2),
-                              MH_SUBSAMPLE1(dst_width, 2), dst_height,
+        libyuv::ScalePlane_16((uint16*)src_uv, MH_SUBSAMPLE1(src_width, 2),
+                              MH_SUBSAMPLE1(src_width, 2), MH_SUBSAMPLE1(src_height, 2),
+                              (uint16*)dst_uv, MH_SUBSAMPLE1(dst_width, 2),
+                              MH_SUBSAMPLE1(dst_width, 2), MH_SUBSAMPLE1(dst_height, 2),
                               libyuv::kFilterNone);
 
         in->buff1Size = dst_width * dst_height * 1.5;
@@ -432,9 +459,9 @@
 		return false;
 	
 	MB_Frame* frame = (MB_Frame*)pm->buffer;
-	if (frame->type != MB_Frame::MBFT_YUV420 && frame->type != MB_Frame::MBFT_NV12)
+	if (frame->type != MB_Frame::MBFT_YUV420 && frame->type != MB_Frame::MBFT_NV12 && frame->type != MB_Frame::MBFT_RGB565)
 	{
-		LOG_ERROR << "Only support MBFT_YUV420 and MBFT_NV12" << LOG_ENDL;
+		LOG_ERROR << "Only support MBFT_YUV420 銆丮BFT_NV12 and MBFT_RGB565" << LOG_ENDL;
 		in->payError = true;
 		return false;
 	}
@@ -456,7 +483,8 @@
         ret = convert_yuv420_origin_to_render(in);
     else if (in->lastMbfBuffOrigin.type == MB_Frame::MBFT_NV12)
         ret = convert_nv12_origin_to_render(in);
-
+	else if (in->lastMbfBuffOrigin.type == MB_Frame::MBFT_RGB565)
+		ret = convert_rgb565_origin_to_render(in);
     if (!ret)
 	{
 		LOG_ERROR << "convert yuv origin to render error" << LOG_ENDL;
@@ -484,12 +512,13 @@
     if (in->payError)
         pm.breake(PipeMaterial::PMT_FRAME_LIST, MB_Frame::MBFT_YUV420, PL_AndroidSurfaceViewRender::pay_breaker_MBFT_YUV, in);
     if (in->payError)
-        pm.breake(PipeMaterial::PMT_FRAME_LIST, MB_Frame::MBFT_NV12, PL_AndroidSurfaceViewRender::pay_breaker_MBFT_YUV, in);
-    if (in->payError)
-        pm.breake(PipeMaterial::PMT_FRAME, MB_Frame::MBFT_YUV420, PL_AndroidSurfaceViewRender::pay_breaker_MBFT_YUV, in);
+	pm.breake(PipeMaterial::PMT_FRAME_LIST, MB_Frame::MBFT_NV12, PL_AndroidSurfaceViewRender::pay_breaker_MBFT_YUV, in);
+	if (in->payError)
+		pm.breake(PipeMaterial::PMT_FRAME, MB_Frame::MBFT_YUV420, PL_AndroidSurfaceViewRender::pay_breaker_MBFT_YUV, in);
 	if (in->payError)
 		pm.breake(PipeMaterial::PMT_FRAME, MB_Frame::MBFT_NV12, PL_AndroidSurfaceViewRender::pay_breaker_MBFT_YUV, in);
-
+	if (in->payError)
+		pm.breake(PipeMaterial::PMT_FRAME, MB_Frame::MBFT_RGB565, PL_AndroidSurfaceViewRender::pay_breaker_MBFT_YUV, in);
 	return !(in->payError);
 }
 
@@ -528,3 +557,4 @@
 
 	return true;
 }
+

--
Gitblit v1.8.0