From c2f45037c0e442ee8fe3a61d6b9e187c3a4f3668 Mon Sep 17 00:00:00 2001 From: pengxin99 Date: Tue, 22 Aug 2023 19:39:47 +0800 Subject: [PATCH] [Decode] Fix some psrit issue --- .../linux/common/ddi/media_libva_common.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/media_driver/linux/common/ddi/media_libva_common.cpp b/media_driver/linux/common/ddi/media_libva_common.cpp index 5998a72263..b558204dc4 100644 --- a/media_driver/linux/common/ddi/media_libva_common.cpp +++ b/media_driver/linux/common/ddi/media_libva_common.cpp @@ -195,6 +195,17 @@ PDDI_MEDIA_SURFACE DdiMedia_ReplaceSurfaceWithNewFormat(PDDI_MEDIA_SURFACE surfa dstSurface->uiLockedBufID = VA_INVALID_ID; dstSurface->uiLockedImageID = VA_INVALID_ID; dstSurface->pSurfDesc = nullptr; + + // copy for some pointer resource + if(dstSurface->pShadowBuffer) + { + dstSurface->pShadowBuffer = (PDDI_MEDIA_BUFFER)MOS_AllocAndZeroMemory(sizeof(DDI_MEDIA_BUFFER)); + MOS_SecureMemcpy(dstSurface->pShadowBuffer, sizeof(DDI_MEDIA_BUFFER), surface->pShadowBuffer, sizeof(DDI_MEDIA_BUFFER)); + mos_bo_reference(dstSurface->pShadowBuffer->bo); + dstSurface->pShadowBuffer->pGmmResourceInfo = (GMM_RESOURCE_INFO *)MOS_AllocAndZeroMemory(sizeof(GMM_RESOURCE_INFO)); + MOS_SecureMemcpy(dstSurface->pShadowBuffer->pGmmResourceInfo, sizeof(GMM_RESOURCE_INFO), surface->pShadowBuffer->pGmmResourceInfo, sizeof(GMM_RESOURCE_INFO)); + } + //lock surface heap DdiMediaUtil_LockMutex(&mediaCtx->SurfaceMutex); uint32_t i; @@ -214,12 +225,12 @@ PDDI_MEDIA_SURFACE DdiMedia_ReplaceSurfaceWithNewFormat(PDDI_MEDIA_SURFACE surfa MOS_FreeMemory(dstSurface); return nullptr; } - //FreeSurface - DdiMediaUtil_FreeSurface(surface); - MOS_FreeMemory(surface); //CreateNewSurface DdiMediaUtil_CreateSurface(dstSurface,mediaCtx); surfaceElement->pSurface = dstSurface; + //FreeSurface + DdiMediaUtil_FreeSurface(surface); + MOS_FreeMemory(surface); DdiMediaUtil_UnLockMutex(&mediaCtx->SurfaceMutex);