1 /*
2 * Copyright (c) 2020-2021, 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     media_vdbox_sfc_render.h
24 //! \brief    Common interface and structure used in sfc interface
25 //! \details  Common interface and structure used in sfc interface which are platform independent
26 //!
27 #ifndef __MEDIA_VDBOX_SFC_RENDER_H__
28 #define __MEDIA_VDBOX_SFC_RENDER_H__
29 
30 #include "mos_os_specific.h"
31 #include "mhw_vebox.h"
32 #include "vp_common.h"
33 #include "vp_platform_interface.h"
34 #include "vp_pipeline.h"
35 
36 class VPMediaMemComp;
37 namespace vp
38 {
39     class VpAllocator;
40     class SfcRenderBase;
41     class VpCscFilter;
42     class VpScalingFilter;
43     class VpRotMirFilter;
44 };
45 
46 class MediaVdboxSfcRender
47 {
48 public:
49     //!
50     //! \brief    MediaVdboxSfcRender constructor
51     //!
52     MediaVdboxSfcRender();
53 
54     //!
55     //! \brief    MediaVdboxSfcRender deconstructor
56     //!
57     virtual ~MediaVdboxSfcRender();
58 
59     //!
60     //! \brief    Destroy MediaVdboxSfcRender variables
61     //!
62     virtual void Destroy();
63 
64     //!
65     //! \brief    MediaVdboxSfcRender constructor
66     //! \details  Initialize the MediaVdboxSfcRender members.
67     //! \return   MOS_STATUS
68     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
69     //!
70     virtual MOS_STATUS Initialize(VP_MHWINTERFACE &vpMhwinterface, MediaMemComp *mmc);
71 
72     //!
73     //! \brief    Add sfc states to command buffer
74     //! \details  Add sfc states to command buffer according to sfcParam.
75     //! \return   MOS_STATUS
76     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
77     //!
78     MOS_STATUS AddSfcStates(MOS_COMMAND_BUFFER *cmdBuffer, VDBOX_SFC_PARAMS &sfcParam);
79 
80     //!
81     //! \brief    Check whether VDBOX-SFC Format Supported
82     //! \details  Check whether VDBOX-SFC Format Supported.
83     //! \param    codecStandard
84     //!           [in] Codec Standard.
85     //! \param    inputFormat
86     //!           [in] Format of Input Frame
87     //! \param    outputFormat
88     //!           [in] Format of Output Frame
89     //! \return   bool
90     //!           Return true if supported, otherwise failed
91     //!
92     bool IsVdboxSfcFormatSupported(
93         CODECHAL_STANDARD           codecStandard,
94         MOS_FORMAT                  inputFormat,
95         MOS_FORMAT                  outputFormat,
96         MOS_TILE_TYPE               tileType);
97 
98 protected:
99     MOS_STATUS SetCSCParams(VDBOX_SFC_PARAMS &sfcParam, VP_EXECUTE_CAPS &vpExecuteCaps);
100     MOS_STATUS SetScalingParams(VDBOX_SFC_PARAMS &sfcParam, VP_EXECUTE_CAPS &vpExecuteCaps);
101     MOS_STATUS SetRotMirParams(VDBOX_SFC_PARAMS &sfcParam, VP_EXECUTE_CAPS &vpExecuteCaps);
102     MOS_STATUS SetHistogramParams(VDBOX_SFC_PARAMS &sfcParam);
103     MOS_STATUS SetSfcMmcParams(VDBOX_SFC_PARAMS &sfcParam);
104 
105     VPHAL_SCALING_MODE GetScalingMode(CODECHAL_SCALING_MODE scalingMode);
106 
107     VP_MHWINTERFACE         m_vpMhwInterface        = {};
108     PMOS_INTERFACE          m_osInterface           = nullptr;
109     vp::VpAllocator         *m_allocator            = nullptr;
110     MediaMemComp            *m_mmc                  = nullptr;
111     vp::SfcRenderBase       *m_sfcRender            = nullptr;
112     vp::VpCscFilter         *m_cscFilter            = nullptr;
113     vp::VpScalingFilter     *m_scalingFilter        = nullptr;
114     vp::VpRotMirFilter      *m_rotMirFilter         = nullptr;
115     bool                    m_isMmcAllocated        = false;
116 MEDIA_CLASS_DEFINE_END(MediaVdboxSfcRender)
117 };
118 
119 #endif // __MEDIA_VDBOX_SFC_RENDER_H__
120