1 /*
2 * Copyright (c) 2017, Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22 //!
23 //! \file     vphal_render_vebox_procamp.cpp
24 //! \brief    VPHAL VEBOX IECP ProcAmp interfaces
25 //! \details  VPHAL VEBOX IECP ProcAmp interfaces
26 //!
27 
28 #include "vphal_render_vebox_procamp.h"
29 
30 #if VPHAL_RENDER_VEBOX_PROCAMP_ENABLE
31 
32 //!
33 //! \brief    Vebox set IECP parameter
34 //! \details  Set Vebox IECP state parameter
35 //! \param    [in] pSrcSurface
36 //!           Pointer to input surface of Vebox
37 //! \param    [in,out] pRenderData
38 //!           Pointer to Vebox Render Data
39 //! \return   void
40 //!
SetParams(PVPHAL_SURFACE pSrcSurface,PVPHAL_VEBOX_RENDER_DATA pRenderData)41 void VPHAL_VEBOX_IECP_ProcAmp::SetParams(
42     PVPHAL_SURFACE              pSrcSurface,
43     PVPHAL_VEBOX_RENDER_DATA    pRenderData)
44 {
45     PVPHAL_VEBOX_IECP_PARAMS    pVphalVeboxIecpParams;
46 
47     pVphalVeboxIecpParams = pRenderData->GetVeboxIECPParams();
48 
49     // Check whether ProcAmp is enabled in Vebox
50     if (pRenderData->bProcamp)
51     {
52         pVphalVeboxIecpParams->pProcAmpParams = pSrcSurface->pProcampParams;
53 
54         pRenderData->GetVeboxStateParams()->pVphalVeboxIecpParams = pVphalVeboxIecpParams;
55     }
56 }
57 
58 //!
59 //! \brief    Init Vebox IECP parameter
60 //! \param    [in] pVphalVeboxIecpParams
61 //!           Pointer to input Vphal Iecp parameters
62 //! \param    [in,out] pMhwVeboxIecpParams
63 //!           Pointer to Mhw Iecp parameters
64 //! \return   void
65 //!
InitParams(PVPHAL_VEBOX_IECP_PARAMS pVphalVeboxIecpParams,PMHW_VEBOX_IECP_PARAMS pMhwVeboxIecpParams)66 void VPHAL_VEBOX_IECP_ProcAmp::InitParams(
67     PVPHAL_VEBOX_IECP_PARAMS        pVphalVeboxIecpParams,
68     PMHW_VEBOX_IECP_PARAMS          pMhwVeboxIecpParams)
69 {
70     PVPHAL_PROCAMP_PARAMS           pVpHalProcAmpParams;
71     PMHW_PROCAMP_PARAMS             pMhwProcAmpParams;
72 
73     pVpHalProcAmpParams = pVphalVeboxIecpParams->pProcAmpParams;
74     pMhwProcAmpParams = &pMhwVeboxIecpParams->ProcAmpParams;
75     if (pVpHalProcAmpParams)
76     {
77         pMhwProcAmpParams->bActive    = true;
78         pMhwProcAmpParams->bEnabled   = pVpHalProcAmpParams->bEnabled;
79         pMhwProcAmpParams->brightness = (uint32_t)MOS_F_ROUND(pVpHalProcAmpParams->fBrightness * 16.0F);  // S7.4
80         pMhwProcAmpParams->contrast   = (uint32_t)MOS_UF_ROUND(pVpHalProcAmpParams->fContrast * 128.0F);  // U4.7
81         pMhwProcAmpParams->sinCS      = (uint32_t)MOS_F_ROUND(sin(MHW_DEGREE_TO_RADIAN(pVpHalProcAmpParams->fHue)) *
82                                                          pVpHalProcAmpParams->fContrast *
83                                                          pVpHalProcAmpParams->fSaturation * 256.0F);  // S7.8
84         pMhwProcAmpParams->cosCS      = (uint32_t)MOS_F_ROUND(cos(MHW_DEGREE_TO_RADIAN(pVpHalProcAmpParams->fHue)) *
85                                                          pVpHalProcAmpParams->fContrast *
86                                                          pVpHalProcAmpParams->fSaturation * 256.0F);  // S7.8
87     }
88 }
89 
90 #endif // VPHAL_RENDER_VEBOX_PROCAMP_ENABLE