diff --git a/media_driver/linux/common/vp/ddi/media_libva_vp.c b/media_driver/linux/common/vp/ddi/media_libva_vp.c index 3c740724974..dcff2555a76 100644 --- a/media_driver/linux/common/vp/ddi/media_libva_vp.c +++ b/media_driver/linux/common/vp/ddi/media_libva_vp.c @@ -1148,7 +1148,7 @@ DdiVp_SetProcPipelineParams( // Background Colorfill // According to libva definition, if alpha in output background color is zero, then colorfill is not needed - if ((pPipelineParam->output_background_color >> 24) != 0) + if ((pPipelineParam->output_background_color >> 24) != 0 || pVpHalTgtSurf->ColorSpace == CSpace_sRGB) { if (pVpHalRenderParams->pColorFillParams == nullptr) { @@ -1157,10 +1157,18 @@ DdiVp_SetProcPipelineParams( DDI_CHK_NULL(pVpHalRenderParams->pColorFillParams, "Null pColorFillParams.", VA_STATUS_ERROR_UNKNOWN); - // set background colorfill option - pVpHalRenderParams->pColorFillParams->Color = pPipelineParam->output_background_color; - pVpHalRenderParams->pColorFillParams->bYCbCr = false; - pVpHalRenderParams->pColorFillParams->CSpace = CSpace_sRGB; + if (pVpHalTgtSurf->ColorSpace == CSpace_sRGB && (pPipelineParam->output_background_color >> 24) == 0) + { + // set color space for sRGB output + pVpHalRenderParams->pColorFillParams->CSpace = CSpace_sRGB; + } + else + { + // set background colorfill option + pVpHalRenderParams->pColorFillParams->Color = pPipelineParam->output_background_color; + pVpHalRenderParams->pColorFillParams->bYCbCr = false; + pVpHalRenderParams->pColorFillParams->CSpace = CSpace_sRGB; + } }else { MOS_FreeMemAndSetNull(pVpHalRenderParams->pColorFillParams); 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 01f86335902..741228cea12 100644 --- a/media_softlet/linux/common/vp/ddi/ddi_vp_functions.cpp +++ b/media_softlet/linux/common/vp/ddi/ddi_vp_functions.cpp @@ -2112,8 +2112,9 @@ 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) + if ((outBackGroundcolor >> 24) != 0 || vpHalRenderParams->pTarget[0]->ColorSpace == CSpace_sRGB) { if (vpHalRenderParams->pColorFillParams == nullptr) { @@ -2122,10 +2123,18 @@ VAStatus DdiVpFunctions::SetBackgroundColorfill( DDI_VP_CHK_NULL(vpHalRenderParams->pColorFillParams, "nullptr pColorFillParams.", VA_STATUS_ERROR_UNKNOWN); - // set background colorfill option - vpHalRenderParams->pColorFillParams->Color = outBackGroundcolor; - vpHalRenderParams->pColorFillParams->bYCbCr = false; - vpHalRenderParams->pColorFillParams->CSpace = CSpace_sRGB; + 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; + } } else {