dupengyue
2017-07-20 3a5f09c61a87adb8dba2cc4a5366893886ba1c1d
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 、MBFT_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;
}