Debian Codegraph @

media_driver/agnostic/common/hw/vdbox/mhw_vdbox_avp_generic.h

raw
1 /*
2 * Copyright (c) 2020, 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 mhw_vdbox_avp_generic.h
24 //! \brief MHW interface for constructing AVP commands for the Vdbox engine
25 //! \details Impelements shared Vdbox AVP command construction functions across all platforms as templates
26 //!
27
28 #ifndef _MHW_VDBOX_AVP_GENERIC_H_
29 #define _MHW_VDBOX_AVP_GENERIC_H_
30
31 #include "mhw_vdbox_avp_interface.h"
32
33 //! MHW Vdbox Avp generic interface
34 /*!
35 This class defines the shared Avp command construction functions across all platforms as templates
36 */
37 template <class TAvpCmds>
38 class MhwVdboxAvpInterfaceGeneric : public MhwVdboxAvpInterface
39 {
40 protected:
41 static const uint32_t m_av1ScalingFactor = (1 << 14); //!< AV1 Scaling factor
42 static const uint32_t m_rawUVPlaneAlignment = 4; //!< starting Gen9 the alignment is relaxed to 4x instead of 16x
43 static const uint32_t m_reconUVPlaneAlignment = 8; //!< recon UV Plane alignment
44 static const uint32_t m_uvPlaneAlignmentLegacy = 8; //!< starting Gen9 the alignment is relaxed to 4x instead of 16x
45
46 //!
47 //! \brief Constructor
48 //!
49 MhwVdboxAvpInterfaceGeneric(
50 PMOS_INTERFACE osInterface,
51 MhwMiInterface *miInterface,
52 MhwCpInterface *cpInterface,
53 bool decodeInUse) :
54 MhwVdboxAvpInterface(osInterface, miInterface, cpInterface, decodeInUse)
55 {
56 MHW_FUNCTION_ENTER;
57 }
58
59 //!
60 //! \brief Destructor
61 //!
62 virtual ~MhwVdboxAvpInterfaceGeneric() {}
63
64 MOS_STATUS AddAvpDecodeSurfaceStateCmd(
65 PMOS_COMMAND_BUFFER cmdBuffer,
66 PMHW_VDBOX_SURFACE_PARAMS params)
67 {
68 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
69
70 MHW_FUNCTION_ENTER;
71
72 MHW_MI_CHK_NULL(m_osInterface);
73 MHW_MI_CHK_NULL(params);
74 MHW_ASSERT(params->Mode != CODECHAL_UNSUPPORTED_MODE);
75
76 typename TAvpCmds::AVP_SURFACE_STATE_CMD cmd;
77
78 uint32_t uvPlaneAlignment = m_uvPlaneAlignmentLegacy;
79
80 cmd.DW1.SurfaceId = params->ucSurfaceStateId;
81 cmd.DW1.SurfacePitchMinus1 = params->psSurface->dwPitch - 1;
82
83 if (params->ucSurfaceStateId == srcInputPic)
84 {
85 uvPlaneAlignment = params->dwUVPlaneAlignment ? params->dwUVPlaneAlignment : m_rawUVPlaneAlignment;
86 }
87 else
88 {
89 uvPlaneAlignment = params->dwUVPlaneAlignment ? params->dwUVPlaneAlignment : m_reconUVPlaneAlignment;
90 }
91
92 cmd.DW2.YOffsetForUCbInPixel =
93 MOS_ALIGN_CEIL((params->psSurface->UPlaneOffset.iSurfaceOffset - params->psSurface->dwOffset) / params->psSurface->dwPitch + params->psSurface->RenderOffset.YUV.U.YOffset, uvPlaneAlignment);
94 MHW_MI_CHK_STATUS(m_osInterface->pfnAddCommand(cmdBuffer, &cmd, cmd.byteSize));
95
96 return eStatus;
97 }
98 };
99 #endif