Debian Codegraph @

media_softlet/agnostic/common/codec/hal/enc/shared/features/encode_aqm_feature.h

raw
1 /*
2 * Copyright (c) 2021-2024, 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_aqm_feature.h
24 //! \brief Defines the common interface for encode aqm feature
25 //!
26 #ifndef __ENCODE_AQM_FEATURE_H__
27 #define __ENCODE_AQM_FEATURE_H__
28
29 #include <queue>
30
31 #include "media_feature.h"
32 #include "encode_allocator.h"
33 #include "codec_hw_next.h"
34 #include "codechal_debug.h"
35 #include "encode_basic_feature.h"
36 #include "mhw_vdbox_aqm_itf.h"
37 #include "encode_mem_compression.h"
38 #if _MEDIA_RESERVED
39 #include "encode_aqm_feature_ext.h"
40 #endif
41
42 #define ENCODE_VDENC_MAX_TILE_NUM 4096
43
44 namespace encode
45 {
46 class EncodeAqmFeature : public MediaFeature, public mhw::vdbox::aqm::Itf::ParSetting
47 {
48 public:
49 EncodeAqmFeature(MediaFeatureManager *featureManager,
50 EncodeAllocator * allocator,
51 CodechalHwInterfaceNext * hwInterface,
52 void * constSettings);
53
54 virtual ~EncodeAqmFeature();
55
56 virtual MOS_STATUS Update(void *params) override;
57
58 MHW_SETPAR_DECL_HDR(AQM_PIPE_BUF_ADDR_STATE);
59 MHW_SETPAR_DECL_HDR(AQM_PIC_STATE);
60 MHW_SETPAR_DECL_HDR(AQM_FRAME_START);
61
62 virtual void SetAQMMode(const uint8_t aqmMode)
63 {
64 m_aqmMode = aqmMode;
65 }
66
67 virtual uint8_t GetAQMMode()
68 {
69 return m_aqmMode;
70 }
71
72 void SetCurrentPipe(const uint8_t currPipeNum)
73 {
74 m_currPipeNum = currPipeNum;
75 }
76 #if USE_CODECHAL_DEBUG_TOOL
77 virtual MOS_STATUS UpdateFrameDisplayOrder(const uint16_t pictureCodingType, const uint32_t framePOC, const uint32_t gopPicSize);
78 #endif
79 virtual MOS_STATUS ReportQualityInfoFrame(uint32_t statBufIdx, EncodeStatusReportData& statusReportData);
80
81 #if _MEDIA_RESERVED
82 #define AQM_FEATURE_HEADER_EXT
83 #include "encode_aqm_feature_ext.h"
84 #undef AQM_FEATURE_HEADER_EXT
85 #else
86 struct AQM_Ouput_Format
87 {
88 union
89 {
90 uint32_t DWord0;
91 struct
92 {
93 uint32_t SSEY; // [31:0]
94 };
95 };
96
97 //DW1
98 union
99 {
100 uint32_t DWord1;
101 struct
102 {
103 uint32_t SSEU; // [31:0]
104 };
105 };
106
107 //DW2
108 union
109 {
110 uint32_t DWord2;
111 struct
112 {
113 uint32_t SSEV; // [31:0]
114 };
115 };
116 uint32_t DWord[47];
117 };
118 #endif
119
120 protected:
121 //!
122 //! \enum AqmSurfaceId
123 //! Aqm surface ID
124 //!
125 enum AqmSurfaceId
126 {
127 reconPic = 0, //!< reconstructed picture
128 srcInputPic = 1, //!< input source picture
129 };
130
131 enum LCU_SIZE
132 {
133 LCU_SIZE_16X16 = 0,
134 LCU_SIZE_32X32 = 1,
135 LCU_SIZE_64X64 = 2,
136 };
137
138 enum CODECTYPE
139 {
140 CODECTYPE_AVC = 0,
141 CODECTYPE_HEVC = 1,
142 CODECTYPE_AV1 = 2,
143 CODECTYPE_VP9 = 3,
144 CODECTYPE_MP2 = 4,
145 };
146
147 static const uint32_t AQMBlockSizeLog2 = 2;
148 static const uint32_t CL_SIZE_BYTES = 64;
149 static const uint32_t AQM_INDEX = 5;
150
151 virtual MOS_STATUS AllocateResources() override;
152 virtual MOS_STATUS FreeResources();
153
154 uint32_t EncodeAqmFeatureFunction0(uint32_t frameWidth, uint32_t frameHeight, uint8_t index);
155
156 MOS_STATUS GetFrameMSE(AQM_Ouput_Format* pDataFrame, uint32_t(&MSE)[3]);
157
158 CodechalHwInterfaceNext *m_hwInterface = nullptr;
159 EncodeAllocator * m_allocator = nullptr;
160 EncodeBasicFeature * m_basicFeature = nullptr; //!< EncodeBasicFeature
161 bool m_AllocatedResources = false;
162 MOS_CONTEXT_HANDLE m_mosCtx = nullptr;
163
164 PMOS_RESOURCE EncodeAqmFeatureMember0[5] = {};
165 uint32_t EncodeAqmFeatureMember1[5] = {};
166
167 uint32_t EncodeAqmFeatureMember2 = 0;
168 uint32_t EncodeAqmFeatureMember3[5] = {};
169
170 uint32_t m_numTiles = 1; //!< Total tile numbers
171 uint16_t m_tile_width[ENCODE_VDENC_MAX_TILE_NUM] = {};
172 uint16_t m_tile_height[ENCODE_VDENC_MAX_TILE_NUM] = {};
173 bool m_tileBasedEngine = false;
174 uint8_t m_aqmMode = 0;
175 uint8_t m_metricsDumpMode = 0;
176
177 uint8_t m_numRowStore = 1;
178 uint8_t m_currPipeNum = 0;
179
180 MOS_SURFACE m_rawSurface = {}; //!< Pointer to MOS_SURFACE of raw surface
181 MOS_SURFACE m_reconSurface = {}; //!< Pointer to MOS_SURFACE of reconstructed surface
182
183 #if USE_CODECHAL_DEBUG_TOOL
184 std::queue<uint32_t> m_frameIdxQueue;
185 uint32_t m_gopSizePrevious = 0;
186 uint32_t m_frameNumPrevious = 0;
187 #endif
188
189 uint32_t m_dsWidth = 0;
190 uint32_t m_dsHeight = 0;
191 bool m_useFastPass = false;
192
193 MEDIA_CLASS_DEFINE_END(encode__EncodeAqmFeature)
194 };
195
196 } // namespace encode
197
198 #endif // !__ENCODE_AQM_FEATURE_H__