From 4c5237b9ea388fde01fb702e72a8fa4cbc0898f6 Mon Sep 17 00:00:00 2001 From: Hu_Molly Date: Thu, 22 Oct 2020 17:36:20 +0800 Subject: [PATCH] [Media Common] aligned GetSurface info for all compoment [Media Common] aligned GetSurface info for all compoment GetSurfaceinfo is common function to get information from Gmm. Need aligned for all compoment and forbide to calucate it by themself Change-Id: Ifb46317693b96d0b6a408fe0b9814ce272c0bb64 --- .../linux/common/os/mos_interface.cpp | 29 ++++++++++++ .../linux/common/os/mos_os_specific.h | 2 + .../dec/shared/bufferMgr/decode_allocator.cpp | 46 ++++--------------- 3 files changed, 39 insertions(+), 38 deletions(-) diff --git a/media_driver/linux/common/os/mos_interface.cpp b/media_driver/linux/common/os/mos_interface.cpp index b411c752319..3800cb80439 100644 --- a/media_driver/linux/common/os/mos_interface.cpp +++ b/media_driver/linux/common/os/mos_interface.cpp @@ -1637,6 +1637,9 @@ MOS_STATUS MosInterface::GetResourceInfo( reqInfo[2].ArrayIndex = 0; gmmResourceInfo->GetOffset(reqInfo[2]); details.RenderOffset.YUV.Y.BaseOffset = reqInfo[2].Render.Offset; + details.RenderOffset.YUV.Y.XOffset = reqInfo[2].Render.XOffset; + details.RenderOffset.YUV.Y.YOffset = reqInfo[2].Render.YOffset; + details.LockOffset.YUV.Y = reqInfo[2].Lock.Offset; // Get U/UV plane information (plane offset, X/Y offset) reqInfo[0].ReqRender = true; @@ -1649,6 +1652,7 @@ MOS_STATUS MosInterface::GetResourceInfo( details.RenderOffset.YUV.U.BaseOffset = reqInfo[0].Render.Offset; details.RenderOffset.YUV.U.XOffset = reqInfo[0].Render.XOffset; details.RenderOffset.YUV.U.YOffset = reqInfo[0].Render.YOffset; + details.LockOffset.YUV.U = reqInfo[0].Lock.Offset; // Get V plane information (plane offset, X/Y offset) reqInfo[1].ReqRender = true; @@ -1661,6 +1665,31 @@ MOS_STATUS MosInterface::GetResourceInfo( details.RenderOffset.YUV.V.BaseOffset = reqInfo[1].Render.Offset; details.RenderOffset.YUV.V.XOffset = reqInfo[1].Render.XOffset; details.RenderOffset.YUV.V.YOffset = reqInfo[1].Render.YOffset; + details.LockOffset.YUV.V = reqInfo[1].Lock.Offset; + + // Get Y plane information (plane offset, X / Y offset) + details.dwOffset = details.RenderOffset.YUV.Y.BaseOffset; + details.YPlaneOffset.iSurfaceOffset = details.RenderOffset.YUV.Y.BaseOffset; + details.YPlaneOffset.iXOffset = details.RenderOffset.YUV.Y.XOffset; + details.YPlaneOffset.iYOffset = details.RenderOffset.YUV.Y.YOffset; + details.YPlaneOffset.iLockSurfaceOffset = details.LockOffset.YUV.Y; + + // Get U/UV plane information (plane offset, X/Y offset) + details.UPlaneOffset.iSurfaceOffset = details.RenderOffset.YUV.U.BaseOffset; + details.UPlaneOffset.iXOffset = details.RenderOffset.YUV.U.XOffset; + details.UPlaneOffset.iYOffset = details.RenderOffset.YUV.U.YOffset; + details.UPlaneOffset.iLockSurfaceOffset = details.LockOffset.YUV.U; + + // Get V plane information (plane offset, X/Y offset) + details.VPlaneOffset.iSurfaceOffset = details.RenderOffset.YUV.V.BaseOffset; + details.VPlaneOffset.iXOffset = details.RenderOffset.YUV.V.XOffset; + details.VPlaneOffset.iYOffset = details.RenderOffset.YUV.V.YOffset; + details.VPlaneOffset.iLockSurfaceOffset = details.LockOffset.YUV.V; + + details.YoffsetForUplane = (details.UPlaneOffset.iSurfaceOffset - details.dwOffset) / details.dwPitch + + details.UPlaneOffset.iYOffset; + details.YoffsetForVplane = (details.VPlaneOffset.iSurfaceOffset - details.dwOffset) / details.dwPitch + + details.VPlaneOffset.iYOffset; } return eStatus; diff --git a/media_driver/linux/common/os/mos_os_specific.h b/media_driver/linux/common/os/mos_os_specific.h index 7b0cc51a613..7c5c6d3d0b0 100644 --- a/media_driver/linux/common/os/mos_os_specific.h +++ b/media_driver/linux/common/os/mos_os_specific.h @@ -363,6 +363,8 @@ struct MOS_SURFACE // Tile Switch MOS_TILE_MODE_GMM TileModeGMM; //!< [out] Transparent GMM Tiletype specifying in hwcmd finally bool bGMMTileEnabled; //!< [out] GMM defined tile mode flag + uint32_t YoffsetForUplane; //!< [out] Y offset from U plane to Y plane. + uint32_t YoffsetForVplane; //!< [out] Y offset from V plane to Y plane. }; typedef MOS_SURFACE *PMOS_SURFACE; diff --git a/media_driver/media_driver_next/agnostic/common/codec/hal/dec/shared/bufferMgr/decode_allocator.cpp b/media_driver/media_driver_next/agnostic/common/codec/hal/dec/shared/bufferMgr/decode_allocator.cpp index df1afe42c8d..cf46445a0d8 100644 --- a/media_driver/media_driver_next/agnostic/common/codec/hal/dec/shared/bufferMgr/decode_allocator.cpp +++ b/media_driver/media_driver_next/agnostic/common/codec/hal/dec/shared/bufferMgr/decode_allocator.cpp @@ -490,45 +490,15 @@ MOS_STATUS DecodeAllocator::GetSurfaceInfo(PMOS_SURFACE surface) DECODE_CHK_NULL(m_allocator); DECODE_CHK_NULL(surface); - MOS_SURFACE details; - MOS_ZeroMemory(&details, sizeof(details)); - details.Format = Format_Invalid; - - DECODE_CHK_STATUS(m_allocator->GetSurfaceInfo(&surface->OsResource, &details)); - - surface->Format = details.Format; - surface->dwWidth = details.dwWidth; - surface->dwHeight = details.dwHeight; - surface->dwPitch = details.dwPitch; - surface->dwDepth = details.dwDepth; - surface->dwQPitch = details.dwQPitch; - surface->bArraySpacing = details.bArraySpacing; - surface->TileType = details.TileType; - surface->TileModeGMM = details.TileModeGMM; - surface->bGMMTileEnabled = details.bGMMTileEnabled; - surface->dwOffset = details.RenderOffset.YUV.Y.BaseOffset; - surface->YPlaneOffset.iSurfaceOffset = details.RenderOffset.YUV.Y.BaseOffset; - surface->YPlaneOffset.iXOffset = details.RenderOffset.YUV.Y.XOffset; - surface->YPlaneOffset.iYOffset = - (surface->YPlaneOffset.iSurfaceOffset - surface->dwOffset) / surface->dwPitch + - details.RenderOffset.YUV.Y.YOffset; - surface->UPlaneOffset.iSurfaceOffset = details.RenderOffset.YUV.U.BaseOffset; - surface->UPlaneOffset.iXOffset = details.RenderOffset.YUV.U.XOffset; - surface->UPlaneOffset.iYOffset = - (surface->UPlaneOffset.iSurfaceOffset - surface->dwOffset) / surface->dwPitch + - details.RenderOffset.YUV.U.YOffset; - surface->UPlaneOffset.iLockSurfaceOffset = details.LockOffset.YUV.U; - surface->VPlaneOffset.iSurfaceOffset = details.RenderOffset.YUV.V.BaseOffset; - surface->VPlaneOffset.iXOffset = details.RenderOffset.YUV.V.XOffset; - surface->VPlaneOffset.iYOffset = - (surface->VPlaneOffset.iSurfaceOffset - surface->dwOffset) / surface->dwPitch + - details.RenderOffset.YUV.V.YOffset; - surface->VPlaneOffset.iLockSurfaceOffset = details.LockOffset.YUV.V; - surface->bCompressible = details.bCompressible; - surface->CompressionMode = details.CompressionMode; - surface->bIsCompressed = details.bIsCompressed; - + surface->Format = Format_Invalid; + DECODE_CHK_STATUS(m_allocator->GetSurfaceInfo(&surface->OsResource, surface)); + // Refine the surface's Yoffset as offset from Y plane, refer YOffsetForUCbInPixel, YOffsetForVCbInPixel. + surface->UPlaneOffset.iYOffset = (surface->UPlaneOffset.iSurfaceOffset - surface->dwOffset) / surface->dwPitch + + surface->UPlaneOffset.iYOffset; + surface->VPlaneOffset.iYOffset = (surface->VPlaneOffset.iSurfaceOffset - surface->dwOffset) / surface->dwPitch + + surface->VPlaneOffset.iYOffset; return MOS_STATUS_SUCCESS; + } MOS_STATUS DecodeAllocator::UpdateResoreceUsageType(