aaa
houxiao
2017-07-24 5e9814a090f20c2b9c39d6efdc9a732b6097ee7d
RtspFace/PL_AndroidSurfaceViewRender.cpp
@@ -130,6 +130,9 @@
bool convert_yuv420_origin_to_render(PL_ASVR_Internal* in)
{
   if (in->config.directlyDisplay)
      return true;
    int src_width = in->lastMbfBuffOrigin.width;
    int src_height = in->lastMbfBuffOrigin.height;
    const uint8_t* src_y = (const uint8_t*)(in->lastMbfBuffOrigin.buffer);
@@ -249,35 +252,11 @@
   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 (in->config.directlyDisplay)
      return true;
    if (false)
    {//#test test nv12 on yuv420 frame
        const int src_width = in->lastMbfBuffOrigin.width;
@@ -409,6 +388,42 @@
    return true;
}
bool convert_rgb565_origin_to_render(PL_ASVR_Internal *in)
{
   if (in->config.directlyDisplay)
      return true;
   ANativeWindow* window = (ANativeWindow*)(in->config.windowSurface);
   int src_width = in->lastMbfBuffOrigin.width;
   int src_height = in->lastMbfBuffOrigin.height;
   const int dst_width = (in->config.scaleToWidth <= 0 ? in->nativeWindowStride : in->config.scaleToWidth);
   const int dst_height = (in->config.scaleToHeight <= 0 ? in->nativeWindowHeight : in->config.scaleToHeight);
   if (src_width != dst_width || src_height != dst_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, dst_width,
                       dst_width, dst_height,
                       libyuv::kFilterNone);
      in->buff1Size = dst_width * dst_height * 2;
      memcpy(in->buffer, in->buffer1, in->buff1Size);
      in->buffSize = in->buff1Size;
   }
   else
   {
      if (!in->config.directlyDisplay)
      {
         memcpy(in->buffer, in->lastMbfBuffOrigin.buffer, in->lastMbfBuffOrigin.buffSize);
         in->buffSize = in->lastMbfBuffOrigin.buffSize;
      }
   }
   return true;
}
bool render_surface(PL_ASVR_Internal* in)
{
   ANativeWindow* window = (ANativeWindow*)(in->config.windowSurface);
@@ -423,6 +438,10 @@
      else
         bitsSize = buffer.stride * buffer.height;
      
      if (in->config.directlyDisplay)
         memcpy(buffer.bits, in->lastMbfBuffOrigin.buffer,  bitsSize);
      else
      {
      if (bitsSize > in->buffSize)
      {
         LOG_WARN << "surface buffer truncated" << LOG_ENDL;
@@ -432,8 +451,9 @@
      {
         LOG_WARN << "in buffer truncated" << LOG_ENDL;
      }
      memcpy(buffer.bits, in->buffer,  bitsSize);
      }
      ANativeWindow_unlockAndPost(window);
   }
    else