Debian Codegraph @

media_driver/agnostic/gen11/codec/hal/codechal_vdenc_avc_g11.h

raw
1 /*
2 * Copyright (c) 2017-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 codechal_vdenc_avc_g11.h
24 //! \brief This file defines the base C++ class/interface for G11 AVC VDENC
25 //! encoding to be used across CODECHAL components.
26 //!
27
28 #ifndef __CODECHAL_VDENC_AVC_G11_H__
29 #define __CODECHAL_VDENC_AVC_G11_H__
30
31 #include "codechal_vdenc_avc.h"
32 #include "codechal_encode_singlepipe_virtualengine.h"
33
34 class CodechalVdencAvcStateG11 : public CodechalVdencAvcState
35 {
36 protected:
37 struct KernelHeader;
38 struct BrcInitDmem;
39 struct BrcUpdateDmem;
40 class SfdCurbe;
41
42 public:
43 PCODECHAL_ENCODE_SINGLEPIPE_VIRTUALENGINE_STATE m_sinlgePipeVeState; //!< single pipe virtual engine state
44 //!
45 //! \brief Constructor
46 //!
47 CodechalVdencAvcStateG11(
48 CodechalHwInterface * hwInterface,
49 CodechalDebugInterface *debugInterface,
50 PCODECHAL_STANDARD_INFO standardInfo);
51
52 //!
53 //! \brief Destructor
54 //!
55 virtual ~CodechalVdencAvcStateG11();
56
57 //!
58 //! \brief Get encoder kernel header and kernel size
59 //!
60 //! \param [in] binary
61 //! Pointer to kernel binary
62 //! \param [in] operation
63 //! Enc kernel operation
64 //! \param [in] krnStateIdx
65 //! Kernel state index
66 //! \param [out] krnHeader
67 //! Pointer to kernel header
68 //! \param [out] krnSize
69 //! Pointer to kernel size
70 //!
71 //! \return MOS_STATUS
72 //! MOS_STATUS_SUCCESS if success, else fail reason
73 //!
74 static MOS_STATUS GetKernelHeaderAndSize(
75 void *binary,
76 EncOperation operation,
77 uint32_t krnStateIdx,
78 void *krnHeader,
79 uint32_t *krnSize);
80
81 //!
82 //! \brief Check if Specific Color Is Supported.
83 //!
84 //! \param [in] surface
85 //! Pointer to Surface.
86 //!
87 //! \return bool
88 //! Support or Not.
89 //!
90 bool CheckSupportedFormat(PMOS_SURFACE surface) override;
91
92 // Inherited virtual functions
93 MOS_STATUS InitializeState() override;
94
95 MOS_STATUS GetTrellisQuantization(
96 PCODECHAL_ENCODE_AVC_TQ_INPUT_PARAMS params,
97 PCODECHAL_ENCODE_AVC_TQ_PARAMS trellisQuantParams) override;
98
99 virtual MOS_STATUS AddHucOutputRegistersHandling(
100 MmioRegistersHuc* mmioRegisters,
101 PMOS_COMMAND_BUFFER cmdBuffer,
102 bool addToEncodeStatus) override;
103
104 MOS_STATUS HuCBrcDummyStreamObject(PMOS_COMMAND_BUFFER cmdBuffer) override { return MOS_STATUS_SUCCESS; }
105
106 MOS_STATUS SetDmemHuCBrcInitReset() override;
107
108 MOS_STATUS SetDmemHuCBrcUpdate() override;
109
110 MOS_STATUS LoadMvCost(uint8_t qp) override;
111
112 MOS_STATUS LoadHmeMvCost(uint8_t qp) override;
113
114 MOS_STATUS LoadHmeMvCostTable(
115 PCODEC_AVC_ENCODE_SEQUENCE_PARAMS seqParams,
116 uint8_t hmeMvCostTable[8][42]) override;
117
118 MOS_STATUS InitKernelStateSFD() override;
119
120 MOS_STATUS AddVdencWalkerStateCmd(
121 PMOS_COMMAND_BUFFER cmdBuffer) override;
122
123 MOS_STATUS SendPrologWithFrameTracking(
124 PMOS_COMMAND_BUFFER cmdBuffer,
125 bool frameTracking,
126 MHW_MI_MMIOREGISTERS *mmioRegister = nullptr) override;
127
128 //!
129 //! \brief Create MHW_VDBOX_STATE_CMDSIZE_PARAMS
130 //!
131 //! \return PMHW_VDBOX_STATE_CMDSIZE_PARAMS
132 //!
133 PMHW_VDBOX_STATE_CMDSIZE_PARAMS CreateMhwVdboxStateCmdsizeParams() override;
134
135 //!
136 //! \brief Create PMHW_VDBOX_VDENC_WALKER_STATE_PARAMS.
137 //!
138 //! \return PMHW_VDBOX_VDENC_WALKER_STATE_PARAMS
139 //!
140 PMHW_VDBOX_VDENC_WALKER_STATE_PARAMS CreateMhwVdboxVdencWalkerStateParams() override;
141
142 MOS_STATUS InitKernelStateMe() override;
143
144 MOS_STATUS ExecuteMeKernel() override;
145
146 MOS_STATUS UpdateCmdBufAttribute(
147 PMOS_COMMAND_BUFFER cmdBuffer,
148 bool renderEngineInUse) override;
149 //!
150 //! \brief Set up params for gpu context creation
151 //! \return MOS_STATUS
152 //! MOS_STATUS_SUCCESS if success, else fail reason
153 //!
154 MOS_STATUS SetGpuCtxCreatOption() override;
155 //!
156 //! \brief Set And Populate VE Hint parameters
157 //! \details Set Virtual Engine hint parameter and populate it to primary cmd buffer attributes
158 //! \param [in] cmdBuffer
159 //! Pointer to primary cmd buffer
160 //! \return MOS_STATUS
161 //! MOS_STATUS_SUCCESS if success, else fail reason
162 //!
163
164 //!
165 //! \brief Encode User Feature Key Report.
166 //! \details Report user feature values set by encode.
167 //!
168 //! \return MOS_STATUS
169 //! MOS_STATUS_SUCCESS if success
170 //!
171 virtual MOS_STATUS UserFeatureKeyReport() override;
172
173 MOS_STATUS SetAndPopulateVEHintParams(
174 PMOS_COMMAND_BUFFER cmdBuffer);
175
176 //!
177 //! \brief Encode frame in slice level.
178 //! \details Call related encode functions to encode
179 //! one frame in slice level.
180 //!
181 //! \return MOS_STATUS
182 //! MOS_STATUS_SUCCESS if success
183 //!
184 virtual MOS_STATUS ExecuteSliceLevel() override;
185
186 protected:
187
188 MOS_STATUS CalculateVdencCommandsSize() override;
189
190 private:
191 static const uint32_t m_mvCostSkipBiasQPel[3][8];
192 static const uint32_t m_hmeCostDisplayRemote[8][CODEC_AVC_NUM_QP];
193 static const uint32_t m_hmeCost[8][CODEC_AVC_NUM_QP];
194 static const int8_t m_brcInitDistQpDeltaI8[4];
195 static const int8_t m_brcInitDistQpDeltaI8LowDelay[4];
196 static const uint32_t m_singlePassMinFrameWidth = 3840;
197 static const uint32_t m_singlePassMinFrameHeight = 2160;
198 static const uint32_t m_singlePassMinFramePer100s = 6000;
199
200 #if USE_CODECHAL_DEBUG_TOOL
201 protected:
202 virtual MOS_STATUS PopulateBrcInitParam(
203 void *cmd) override;
204
205 virtual MOS_STATUS PopulateBrcUpdateParam(
206 void *cmd) override;
207
208 virtual MOS_STATUS PopulateEncParam(
209 uint8_t meMethod,
210 void *cmd) override;
211
212 virtual MOS_STATUS PopulatePakParam(
213 PMOS_COMMAND_BUFFER cmdBuffer,
214 PMHW_BATCH_BUFFER secondLevelBatchBuffer) override;
215 #endif
216 };
217
218 #endif // __CODECHAL_VDENC_AVC_G11_H__