From 7291ab5206c5e172c6c94dcfbe4f1bc258f3b7a5 Mon Sep 17 00:00:00 2001 From: WenshengZhang Date: Wed, 10 Jan 2024 14:08:37 +0800 Subject: [PATCH 10/12] Fix failed 4k video wall test case and color corruption of video composition Fix failed 4k video wall test case from 16CH video only show 1CH output and corruption observed on certain number of video composition when doing sample_multi_transcode. Upstream-Status: Backport [https://github.com/intel/media-driver/commit/38e14b1b97170b51586d00d1fa607e496b0c5825] Signed-off-by: Lim, Siew Hoon --- .../common/vp/kdll/hal_kerneldll_next.h | 1 + .../vp/hal/packet/vp_render_fc_kernel.cpp | 7 ++ .../common/vp/kdll/hal_kerneldll_next.c | 70 +++++++++++-------- .../linux/common/vp/ddi/ddi_vp_functions.cpp | 20 ++---- 4 files changed, 55 insertions(+), 43 deletions(-) diff --git a/media_common/agnostic/common/vp/kdll/hal_kerneldll_next.h b/media_common/agnostic/common/vp/kdll/hal_kerneldll_next.h index 6447999b7..8e2ab371e 100644 --- a/media_common/agnostic/common/vp/kdll/hal_kerneldll_next.h +++ b/media_common/agnostic/common/vp/kdll/hal_kerneldll_next.h @@ -588,6 +588,7 @@ typedef struct tagKdll_FilterEntry Kdll_Scalingratio ScalingRatio; Kdll_RenderMethod RenderMethod; Kdll_SetCSCCoeffMethod SetCSCCoeffMode; + bool forceToTargetColorSpace; } Kdll_FilterEntry, *PKdll_FilterEntry; // Structure that defines a compositing filter diff --git a/media_softlet/agnostic/common/vp/hal/packet/vp_render_fc_kernel.cpp b/media_softlet/agnostic/common/vp/hal/packet/vp_render_fc_kernel.cpp index 8e982f67e..f8308fed1 100644 --- a/media_softlet/agnostic/common/vp/hal/packet/vp_render_fc_kernel.cpp +++ b/media_softlet/agnostic/common/vp/hal/packet/vp_render_fc_kernel.cpp @@ -775,6 +775,13 @@ MOS_STATUS VpRenderFcKernel::BuildFilter( for (i = 0; (i < (int)compParams->sourceCount) && (iMaxFilterSize > 0); i++) { + if (i > 0) + { + if (!RECT1_CONTAINS_RECT2(compParams->source[0].surf->rcDst, compParams->source[i].surf->rcDst)) + { + pFilter->forceToTargetColorSpace = true; + } + } src = &compParams->source[i]; //-------------------------------- diff --git a/media_softlet/agnostic/common/vp/kdll/hal_kerneldll_next.c b/media_softlet/agnostic/common/vp/kdll/hal_kerneldll_next.c index d8f7d429a..151f3b039 100644 --- a/media_softlet/agnostic/common/vp/kdll/hal_kerneldll_next.c +++ b/media_softlet/agnostic/common/vp/kdll/hal_kerneldll_next.c @@ -2378,6 +2378,7 @@ bool KernelDll_SetupCSC( Kdll_CSC_Matrix curr_matrix; Kdll_CSC_Matrix *matrix = pCSC->Matrix; // Color Space conversion matrix uint8_t * matrixID = pCSC->MatrixID; // CSC coefficient allocation table + bool forceToTargetColorSpace = false; // Clear all CSC matrices MOS_ZeroMemory(matrix, sizeof(pCSC->Matrix)); @@ -2395,6 +2396,10 @@ bool KernelDll_SetupCSC( //---------------------------------------------------------------// for (i = iFilterSize, pFilter = pSearchState->Filter; i > 0; i--, pFilter++) { + if (pFilter->forceToTargetColorSpace) + { + forceToTargetColorSpace = true; + } // Disable Procamp for all layers except Main Video // Disable Procamp if source is RGB if (pFilter->layer != Layer_MainVideo || @@ -2456,44 +2461,51 @@ bool KernelDll_SetupCSC( //---------------------------------------------------------------// if (sel_cspace == CSpace_Any) { - int cs; - for (cs = (CSpace_Any + 1); cs < CSpace_Count; cs++) + if (forceToTargetColorSpace) { - // Skip color spaces not in use - cspace = (VPHAL_CSPACE)cs; - if (!cspace_in_use[cspace]) - { - continue; - } - - // xvYCC and BT are treated as same for CSC considerations (BT.x to xvYCC.x matrix is I) - cspace = KernelDll_TranslateCspace(cspace); - - // Count # of CS conversions and matrices - csc_count = 0; - for (i = iFilterSize, pFilter = pSearchState->Filter; i > 0; i--, pFilter++) + sel_cspace = out_cspace; + } + else + { + int cs; + for (cs = (CSpace_Any + 1); cs < CSpace_Count; cs++) { - // Ignore layers where the Color Space may be set in software (colorfill, palletized) - if (pFilter->cspace == CSpace_Any) + // Skip color spaces not in use + cspace = (VPHAL_CSPACE)cs; + if (!cspace_in_use[cspace]) { continue; } - // Check if CSC/PA is required - if (KernelDll_TranslateCspace(pFilter->cspace) != cspace || - pFilter->procamp != DL_PROCAMP_DISABLED) + // xvYCC and BT are treated as same for CSC considerations (BT.x to xvYCC.x matrix is I) + cspace = KernelDll_TranslateCspace(cspace); + + // Count # of CS conversions and matrices + csc_count = 0; + for (i = iFilterSize, pFilter = pSearchState->Filter; i > 0; i--, pFilter++) { - csc_count++; + // Ignore layers where the Color Space may be set in software (colorfill, palletized) + if (pFilter->cspace == CSpace_Any) + { + continue; + } + + // Check if CSC/PA is required + if (KernelDll_TranslateCspace(pFilter->cspace) != cspace || + pFilter->procamp != DL_PROCAMP_DISABLED) + { + csc_count++; + } } - } - // Save best choice as requiring minimum number of CSC operations - if ((sel_csc_count < 0) || // Initial value - (csc_count < sel_csc_count) || // Minimum number of CSC operations - (csc_count == sel_csc_count && cs == main_cspace)) // Use main cspace as default if same CSC count - { - sel_cspace = cspace; - sel_csc_count = csc_count; + // Save best choice as requiring minimum number of CSC operations + if ((sel_csc_count < 0) || // Initial value + (csc_count < sel_csc_count) || // Minimum number of CSC operations + (csc_count == sel_csc_count && cs == main_cspace)) // Use main cspace as default if same CSC count + { + sel_cspace = cspace; + sel_csc_count = csc_count; + } } } } diff --git a/media_softlet/linux/common/vp/ddi/ddi_vp_functions.cpp b/media_softlet/linux/common/vp/ddi/ddi_vp_functions.cpp index 40d0b3fad..e60a6c69c 100644 --- a/media_softlet/linux/common/vp/ddi/ddi_vp_functions.cpp +++ b/media_softlet/linux/common/vp/ddi/ddi_vp_functions.cpp @@ -2115,9 +2115,8 @@ VAStatus DdiVpFunctions::SetBackgroundColorfill( { DDI_VP_FUNC_ENTER; DDI_VP_CHK_NULL(vpHalRenderParams, "nullptr vpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER); - DDI_VP_CHK_NULL(vpHalRenderParams->pTarget[0],"nullptr pTarget[0].", VA_STATUS_ERROR_INVALID_PARAMETER); - if ((outBackGroundcolor >> 24) != 0 || vpHalRenderParams->pTarget[0]->ColorSpace == CSpace_sRGB) + if ((outBackGroundcolor >> 24) != 0) { if (vpHalRenderParams->pColorFillParams == nullptr) { @@ -2126,18 +2125,11 @@ VAStatus DdiVpFunctions::SetBackgroundColorfill( DDI_VP_CHK_NULL(vpHalRenderParams->pColorFillParams, "nullptr pColorFillParams.", VA_STATUS_ERROR_UNKNOWN); - if (vpHalRenderParams->pTarget[0]->ColorSpace == CSpace_sRGB && (outBackGroundcolor >> 24) == 0) - { - // set color space for sRGB output - vpHalRenderParams->pColorFillParams->CSpace = CSpace_sRGB; - } - else - { - // set background colorfill option - vpHalRenderParams->pColorFillParams->Color = outBackGroundcolor; - vpHalRenderParams->pColorFillParams->bYCbCr = false; - vpHalRenderParams->pColorFillParams->CSpace = CSpace_sRGB; - } + // set background colorfill option + vpHalRenderParams->pColorFillParams->Color = outBackGroundcolor; + vpHalRenderParams->pColorFillParams->bYCbCr = false; + vpHalRenderParams->pColorFillParams->CSpace = CSpace_sRGB; + } else { -- 2.40.1