1 /*
2 * Copyright (c) 2018, 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     encode_hevc_cqp.h
24 //! \brief    Defines the common interface for hevc encode cqp features
25 //!
26 #ifndef __ENCODE_HEVC_CQP_H__
27 #define __ENCODE_HEVC_CQP_H__
28 
29 #include "media_feature.h"
30 #include "encode_allocator.h"
31 #include "codec_hw_next.h"
32 #include "encode_basic_feature.h"
33 
34 namespace encode
35 {
36 class HevcEncodeCqp : public MediaFeature, public mhw::vdbox::hcp::Itf::ParSetting
37 {
38 public:
39     HevcEncodeCqp(MediaFeatureManager *featureManager, EncodeAllocator *allocator, CodechalHwInterfaceNext *hwInterface, void *constSettings);
40 
~HevcEncodeCqp()41     ~HevcEncodeCqp() {}
42 
43     //!
44     //! \brief  Init cqp basic features related parameter
45     //! \param  [in] settings
46     //!         Pointer to settings
47     //! \return MOS_STATUS
48     //!         MOS_STATUS_SUCCESS if success, else fail reason
49     //!
50     MOS_STATUS Init(void *settings) override;
51 
52     //!
53     //! \brief  Update cqp basic features related parameter
54     //! \param  [in] params
55     //!         Pointer to parameters
56     //! \return MOS_STATUS
57     //!         MOS_STATUS_SUCCESS if success, else fail reason
58     //!
59     MOS_STATUS Update(void *params) override;
60 
61     //!
62     //! \brief    Check if RDOQ enabled
63     //!
64     //! \return   bool
65     //!           true if rdoq enabled, else rdoq disabled.
66     //!
IsRDOQEnabled()67     bool IsRDOQEnabled() { return m_rdoqEnable; }
68 
69     MHW_SETPAR_DECL_HDR(HCP_PIC_STATE);
70 
71     MHW_SETPAR_DECL_HDR(HCP_PIPE_MODE_SELECT);
72 
73     MHW_SETPAR_DECL_HDR(HCP_PIPE_BUF_ADDR_STATE);
74 
75     MHW_SETPAR_DECL_HDR(HCP_SLICE_STATE);
76 
77 protected:
78 
79     //! \brief  Allocate feature related resources
80     //! \return MOS_STATUS
81     //!         MOS_STATUS_SUCCESS if success, else fail reason
82     //!
83     MOS_STATUS AllocateResources() override;
84 
85     //! \brief  set feature refer to const settings.
86     //! \return MOS_STATUS
87     //!         MOS_STATUS_SUCCESS if success, else fail reason
88     //!
89     MOS_STATUS SetConstSettings() override;
90 
91     //!
92     //! \brief    Verify slice SAO state
93     //!
94     //! \return   MOS_STATUS
95     //!           MOS_STATUS_SUCCESS if success, else fail reason
96     //!
97     MOS_STATUS VerifySliceSAOState();
98 
99     virtual void UpdateRDOQCfg();
100 
101     EncodeAllocator *m_allocator = nullptr;
102     EncodeBasicFeature   *m_basicFeature = nullptr;  //!< EncodeBasicFeature
103     MOS_CONTEXT_HANDLE  m_mosCtx = nullptr;
104 
105     std::shared_ptr<mhw::vdbox::hcp::Itf> m_hcpItf = nullptr;
106 
107     static const uint8_t m_hevcSAOStreamoutSizePerLCU = 16;
108 
109     int m_picQPY = 0;
110     int m_slcQP  = 0;
111 
112     //Deblocking
113     bool     m_SliceDeblockingFilterDisabled = false;
114     uint32_t m_SliceTcOffsetDiv2             = 0;
115     uint32_t m_SliceBettaOffsetDiv2          = 0;
116     PMOS_RESOURCE m_resDeblockingFilterTileRowStoreScratchBuffer = nullptr;    //!< De-blocking filter tile row store Scratch data buffer
117     PMOS_RESOURCE m_resDeblockingFilterColumnRowStoreScratchBuffer = nullptr;  //!< De-blocking filter column row Store scratch data buffer
118     PMOS_RESOURCE m_resDeblockingFilterRowStoreScratchBuffer = nullptr;        //!< Handle of De-block row store surface
119 
120     //SAO
121     bool m_saoEnable = false;
122     PMOS_RESOURCE   m_resSAOLineBuffer = nullptr;                    //!< SAO line data buffer
123     PMOS_RESOURCE   m_resSAOTileLineBuffer = nullptr;                //!< SAO tile line data buffer
124     PMOS_RESOURCE   m_resSAOTileColumnBuffer = nullptr;              //!< SAO tile column data buffer
125     PMOS_RESOURCE   m_resSAOStreamOutBuffer = nullptr;               //!< SAO stream-out buffer
126     MOS_RESOURCE    m_vdencSAORowStoreBuffer = { 0 };                //!< SAO RowStore buffer
127 
128     //TransformSkip
129     bool m_transformSkipEnable = false;
130 
131     //RDOQ
132     bool     m_rdoqEnable           = false;
133     uint32_t m_rdoqIntraTuThreshold = 0;
134 #if (_DEBUG || _RELEASE_INTERNAL)
135     bool     m_rdoqIntraTuOverride          = false;  //!< Override RDOQ intra TU or not
136     bool     m_rdoqIntraTuDisableOverride   = false;  //!< Override RDOQ intra TU disable
137     uint16_t m_rdoqIntraTuThresholdOverride = 0;      //!< Override RDOQ intra TU threshold
138 #endif
139 
140 MEDIA_CLASS_DEFINE_END(encode__HevcEncodeCqp)
141 };
142 
143 }  // namespace encode
144 
145 #endif  // !__ENCODE_HEVC_CQP_H__
146