From b80534b85b8cd065505145fdb913978b38da9548 Mon Sep 17 00:00:00 2001
From: xuxiuxi <xuxiuxi@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期四, 20 七月 2017 12:35:08 +0800
Subject: [PATCH]
---
RtspFace/PL_Scale.cpp | 125 +++++++++++++++++++++--------------------
1 files changed, 63 insertions(+), 62 deletions(-)
diff --git a/RtspFace/PL_Scale.cpp b/RtspFace/PL_Scale.cpp
index 69b0866..4877fd1 100644
--- a/RtspFace/PL_Scale.cpp
+++ b/RtspFace/PL_Scale.cpp
@@ -2,7 +2,7 @@
#include "MaterialBuffer.h"
#include "logger.h"
#include <libyuv.h>
-#include <android/native_window.h>
+
struct PL_Scale_Internal
{
uint8_t* buffer;
@@ -94,8 +94,8 @@
{
#define SUBSAMPLE(v, a) ((((v) + (a) - 1)) / (a))
- const int dst_width = in->config.toWidth;
- const int dst_height = in->config.toHeight;
+ const int dst_width = in->config.toWidth;
+ const int dst_height = in->config.toHeight;
size_t dstSizeMax = 0;
if (srcType == MB_Frame::MBFT_YUV420||srcType == MB_Frame::MBFT_NV12)
@@ -139,42 +139,43 @@
in->buffSize = dstSizeMax;
}
- else if (srcType == MB_Frame::MBFT_NV12)
- {
- const uint8_t* src_y = (const uint8_t*)(srcBuffer);
- const uint8_t* src_uv = (const uint8_t*)(src_y + (srcHeight * srcWidth));
- if (srcWidth != dst_width || srcHeight != dst_height)
- {
- // RK3288, 1920->640: 2.8~12ms, avg=4ms
+ else if (srcType == MB_Frame::MBFT_NV12)
+ {
+ const uint8_t* src_y = (const uint8_t*)(srcBuffer);
+ const uint8_t* src_uv = (const uint8_t*)(src_y + (srcHeight * srcWidth));
+ if (srcWidth != dst_width || srcHeight != dst_height)
+ {
+ // RK3288, 1920->640: 2.8~12ms, avg=4ms
- uint8_t* dst_y = (uint8_t*)(in->buffer);
- uint8_t* dst_uv = (uint8_t*)(dst_y + (dst_height * dst_width));
+ uint8_t* dst_y = (uint8_t*)(in->buffer);
+ uint8_t* dst_uv = (uint8_t*)(dst_y + (dst_height * dst_width));
- libyuv::ScalePlane(src_y, srcWidth,
- srcWidth, srcHeight,
- dst_y, dst_width,
- dst_width, dst_height,
- libyuv::kFilterNone);
+ libyuv::ScalePlane(src_y, srcWidth,
+ srcWidth, srcHeight,
+ dst_y, dst_width,
+ dst_width, dst_height,
+ libyuv::kFilterNone);
- libyuv::ScalePlane_16((uint16*)src_uv, SUBSAMPLE(srcWidth, 2),
- SUBSAMPLE(srcWidth, 2), SUBSAMPLE(srcHeight, 2),
- (uint16*)dst_uv, SUBSAMPLE(dst_width, 2),
- SUBSAMPLE(dst_width, 2), SUBSAMPLE(dst_height, 2),
- libyuv::kFilterNone);
- in->buffSize = dstSizeMax;
- }
- else if (srcType == MB_Frame::MBFT_BGRA)
- {
- //#todo
- LOG_ERROR << "srcType only support MBFT_YUV420 and MBFT_NV12" << std::endl;
- return false;
- } else
- {
- LOG_ERROR << "srcType only support MBFT_YUV420 and MBFT_NV12" << std::endl;
- return false;
- }
- return true;
- }
+ libyuv::ScalePlane_16((uint16*)src_uv, SUBSAMPLE(srcWidth, 2),
+ SUBSAMPLE(srcWidth, 2), SUBSAMPLE(srcHeight, 2),
+ (uint16*)dst_uv, SUBSAMPLE(dst_width, 2),
+ SUBSAMPLE(dst_width, 2), SUBSAMPLE(dst_height, 2),
+ libyuv::kFilterNone);
+ in->buffSize = dstSizeMax;
+ }
+ else if (srcType == MB_Frame::MBFT_BGRA)
+ {
+ //#todo
+ LOG_ERROR << "srcType only support MBFT_YUV420 and MBFT_NV12" << std::endl;
+ return false;
+ }
+ else
+ {
+ LOG_ERROR << "srcType only support MBFT_YUV420 and MBFT_NV12" << std::endl;
+ return false;
+ }
+ return true;
+ }
}
bool PL_Scale::pay(const PipeMaterial& pm)
@@ -222,32 +223,32 @@
}
}
break;
- case PipeMaterial::PMT_PM_LIST:
- {
- // break pm list into single pm(s)
+ case PipeMaterial::PMT_PM_LIST:
+ {
+ // break pm list into single pm(s)
- MB_Frame* ppm = (MB_Frame*)pm.buffer;
- for (size_t i = 0; i < pm.buffSize; i++, ppm++)
- {
- if (ppm->type== PipeMaterial::PMT_FRAME)
- {
- MB_Frame* frame = (MB_Frame*)ppm->buffer;
- switch(frame->type)
- {
- case MB_Frame::MBFT_YUV420:
- case MB_Frame::MBFT_BGRA:
- case MB_Frame::MBFT_NV12:
- in->lastFrame = *frame;
- ret = image_scale(in, (uint8_t*)frame->buffer,frame->type,
- frame->width, frame->height);
- break;
- default:
- LOG_ERROR << "Only support MBFT_YUV420 / MBFT_BGRA" << std::endl;
- return false;
- }
- }
- }
- }break;
+ MB_Frame* ppm = (MB_Frame*)pm.buffer;
+ for (size_t i = 0; i < pm.buffSize; i++, ppm++)
+ {
+ if (ppm->type== PipeMaterial::PMT_FRAME)
+ {
+ MB_Frame* frame = (MB_Frame*)ppm->buffer;
+ switch(frame->type)
+ {
+ case MB_Frame::MBFT_YUV420:
+ case MB_Frame::MBFT_BGRA:
+ case MB_Frame::MBFT_NV12:
+ in->lastFrame = *frame;
+ ret = image_scale(in, (uint8_t*)frame->buffer,frame->type,
+ frame->width, frame->height);
+ break;
+ default:
+ LOG_ERROR << "Only support MBFT_YUV420 / MBFT_BGRA" << std::endl;
+ return false;
+ }
+ }
+ }
+ }break;
default:
LOG_ERROR << "Only support PMT_BYTES / PMT_FRAME" << std::endl;
return false;
@@ -275,7 +276,7 @@
}
break;
case PipeMaterial::PMT_FRAME:
- case PipeMaterial::PMT_PM_LIST:
+ case PipeMaterial::PMT_PM_LIST:
{
newPm.type = PipeMaterial::PMT_FRAME;
newPm.buffer = &(in->lastFrame);
--
Gitblit v1.8.0