| | |
| | |
|
| | | 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);
|
| | |
| | |
|
| | | 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;
|
| | |
| | | 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;
|
| | |
| | | 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);
|
| | |
| | | bitsSize = buffer.stride * buffer.height * 2;
|
| | | else
|
| | | bitsSize = buffer.stride * buffer.height;
|
| | | |
| | | if (bitsSize > in->buffSize)
|
| | |
|
| | | if (in->config.directlyDisplay)
|
| | | memcpy(buffer.bits, in->lastMbfBuffOrigin.buffer, bitsSize);
|
| | | else
|
| | | {
|
| | | LOG_WARN << "surface buffer truncated" << LOG_ENDL;
|
| | | bitsSize = in->buffSize;
|
| | | }
|
| | | else if (bitsSize < in->buffSize)
|
| | | {
|
| | | LOG_WARN << "in buffer truncated" << LOG_ENDL;
|
| | | if (bitsSize > in->buffSize)
|
| | | {
|
| | | LOG_WARN << "surface buffer truncated" << LOG_ENDL;
|
| | | bitsSize = in->buffSize;
|
| | | }
|
| | | else if (bitsSize < in->buffSize)
|
| | | {
|
| | | LOG_WARN << "in buffer truncated" << LOG_ENDL;
|
| | | }
|
| | | memcpy(buffer.bits, in->buffer, bitsSize);
|
| | | }
|
| | |
|
| | | memcpy(buffer.bits, in->buffer, bitsSize);
|
| | | ANativeWindow_unlockAndPost(window);
|
| | | }
|
| | | else
|
| | |
| | | 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;
|
| | | }
|
| | |
| | | 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;
|
| | |
| | | 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);
|
| | | }
|
| | |
|
| | |
| | |
|
| | | return true;
|
| | | }
|
| | |
|