Skip to content

Commit

Permalink
fix compressed surface width not align with 32 and seg fault
Browse files Browse the repository at this point in the history
 caused by wrong plane number
  • Loading branch information
Dylan-debug committed Jul 31, 2023
1 parent 55c4003 commit 69c15c7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,37 @@ MOS_STATUS MediaVeboxDecompState::GetResourceInfo(PMOS_SURFACE surface)
&resDetails));

surface->Format = resDetails.Format;
#ifdef LINUX
if ((surface->Format == Format_NV12 || surface->Format == Format_P010) && resDetails.dwWidth & 1 != 0)
{
uint32_t bitsPerPixel = surface->OsResource.pGmmResInfo->GetBitsPerPixel();
if (bitsPerPixel == 0)
{
VPHAL_MEMORY_DECOMP_ASSERTMESSAGE("Got zero BitsPerPixel.");
bitsPerPixel = 8;
}
if (surface->Format == Format_P010)
{
bitsPerPixel = 16;
}
uint32_t alignWidth = MOS_ALIGN_CEIL(resDetails.dwWidth, DECOMPRESSION_WIDTH_ALIGNMENT_IN_BYTE*8/bitsPerPixel);
if (alignWidth <= resDetails.dwPitch*8/bitsPerPixel)
{
surface->dwWidth = alignWidth;
}
else
{
VPHAL_MEMORY_DECOMP_ASSERTMESSAGE("May got green line corruption.");
surface->dwWidth = resDetails.dwWidth;
}
}
else
{
surface->dwWidth = resDetails.dwWidth;
}
#else
surface->dwWidth = resDetails.dwWidth;
#endif
surface->dwHeight = resDetails.dwHeight;
surface->dwPitch = resDetails.dwPitch;
surface->dwDepth = resDetails.dwDepth;
Expand Down
2 changes: 1 addition & 1 deletion media_driver/linux/common/ddi/media_libva.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5192,7 +5192,7 @@ VAStatus SwizzleSurface(PDDI_MEDIA_CONTEXT mediaCtx, PGMM_RESOURCE_INFO pGmmResI

memset(&gmmResCopyBlt, 0x0, sizeof(GMM_RES_COPY_BLT));
uiPicHeight = pGmmResInfo->GetBaseHeight();
uiSize = pGmmResInfo->GetSizeSurface();
uiSize = pGmmResInfo->GetSizeMainSurface();
uiPitch = pGmmResInfo->GetRenderPitch();
gmmResCopyBlt.Gpu.pData = pLockedAddr;
gmmResCopyBlt.Sys.pData = pResourceBase;
Expand Down
1 change: 1 addition & 0 deletions media_driver/linux/common/ddi/media_libva_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ VAStatus DdiMediaUtil_AllocateSurface(
uiPlanesOrAuxPlanes = mediaSurface->pSurfDesc->uiPlanes/2;
gmmCustomParams.AuxSurf.BaseAlignment = {0};
gmmCustomParams.Size = (uiPlanesOrAuxPlanes == 1) ? mediaSurface->pSurfDesc->uiOffsets[1]:mediaSurface->pSurfDesc->uiOffsets[2];
gmmCustomParams.NoOfPlanes = mediaSurface->pSurfDesc->uiPlanes/2;
}
switch(uiPlanesOrAuxPlanes)
{
Expand Down

0 comments on commit 69c15c7

Please sign in to comment.