Debian Codegraph @

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

raw
1 /*
2 * Copyright (c) 2018-2025, 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_parameter.h
24 //! \brief Defines the common interface for encode parameter
25 //!
26 #ifndef __ENCODE_BASIC_FEATURE_H__
27 #define __ENCODE_BASIC_FEATURE_H__
28
29 #include "codec_hw_next.h"
30 #include "codec_def_encode.h"
31 #include "codechal_setting.h"
32 #include "encode_tracked_buffer.h"
33 #include "encode_recycle_resource.h"
34 #include "media_feature.h"
35 #include "mhw_vdbox.h"
36
37 namespace encode
38 {
39 class EncodeBasicFeature:public MediaFeature
40 {
41 public:
42 EncodeBasicFeature(EncodeAllocator *allocator,
43 CodechalHwInterfaceNext *hwInterface,
44 TrackedBuffer *trackedBuf,
45 RecycleResource *recycleBuf);
46 virtual ~EncodeBasicFeature() { }
47
48 //!
49 //! \brief Init encode parameter
50 //! \param [in] setting
51 //! Pointer to CodechalSetting
52 //! \return MOS_STATUS
53 //! MOS_STATUS_SUCCESS if success, else fail reason
54 //!
55 virtual MOS_STATUS Init(void *setting);
56
57 //!
58 //! \brief Update encode basic feature
59 //! \param [in] params
60 //! Pointer to EncoderParams
61 //! \return MOS_STATUS
62 //! MOS_STATUS_SUCCESS if success, else fail reason
63 //!
64 virtual MOS_STATUS Update(void *params);
65
66 //!
67 //! \brief Update encode basic format
68 //! \param [in] params
69 //! Pointer to EncoderParams
70 //! \return MOS_STATUS
71 //! MOS_STATUS_SUCCESS if success, else fail reason
72 //!
73 virtual MOS_STATUS UpdateFormat(void *params);
74
75 //!
76 //! \brief Reset encode basic feature.
77 //! \return MOS_STATUS
78 //! MOS_STATUS_SUCCESS if success, else fail reason
79 //!
80 virtual MOS_STATUS Reset(CODEC_REF_LIST *refList);
81
82 //!
83 //! \brief Get the waTable
84 //! \return The active WA table
85 //!
86 MEDIA_WA_TABLE *GetWaTable() { return m_osInterface? m_osInterface->pfnGetWaTable(m_osInterface):nullptr; }
87
88 virtual uint32_t GetProfileLevelMaxFrameSize() = 0;
89
90 static constexpr uint32_t m_vdencBrcPassNum = 3; //!< Vdenc Brc Number of passes
91 static constexpr uint32_t m_uncompressedSurfaceNum = 127; //!< Hevc/Av1 uncompressed surface number, 7 bits, 0x7f is invalid one
92 static constexpr uint32_t m_sizeOfHcpPakFrameStats = 9 * CODECHAL_CACHELINE_SIZE; //!> Size of HEVC PAK frame statistics
93 static constexpr uint32_t m_hevcPakStatsSSEOffset = 32;
94 static constexpr uint32_t m_codecHalHevcNumPakSliceBatchBuffers = 3;
95
96 uint32_t m_frameWidth = 0; //!< Frame width in luma samples
97 uint32_t m_frameHeight = 0; //!< Frame height in luma samples
98 uint32_t m_frameFieldHeight = 0; //!< Frame height in luma samples
99 uint32_t m_oriFrameHeight = 0; //!< Original frame height
100 uint32_t m_oriFrameWidth = 0; //!< Original frame width
101 uint16_t m_frame_crop_bottom_offset = 0; //!< frame_crop_bottom_offset
102 uint16_t m_frame_mbs_only_flag = 0; //!< frame_mbs_only_flag
103 uint16_t m_frame_cropping_flag = 0; //!< frame_cropping_flag
104 uint16_t m_picWidthInMb = 0; //!< Picture Width in MB width count
105 uint16_t m_picHeightInMb = 0; //!< Picture Height in MB height count
106 uint16_t m_frameFieldHeightInMb = 0; //!< Frame/field Height in MB
107 uint32_t m_downscaledWidthInMb4x = 0; //!< Downscale width in Mb 4x
108 uint32_t m_downscaledHeightInMb4x = 0; //!< Downscale height in Mb 4x
109
110 CODEC_PICTURE m_currOriginalPic = {}; //!< Raw.
111 CODEC_PICTURE m_currReconstructedPic = {}; //!< RECON.
112 uint16_t m_pictureCodingType = 0; //!< I, P, or B frame
113 uint32_t m_frameNum = 0; //!< Frame number
114 bool m_firstField = true; //!< Flag to indicate if it is first field
115 bool m_resolutionChanged = false; //!< Flag to indicate if resolution is changed
116
117 uint32_t m_standard = 0; //!< The encode state's standard
118 uint32_t m_mode = 0; //!< The encode mode
119 CODECHAL_FUNCTION m_codecFunction = CODECHAL_FUNCTION_INVALID; //!< The encode state's codec function used
120
121 PCODECHAL_NAL_UNIT_PARAMS *m_nalUnitParams = nullptr; //!< The encode nal unit
122 uint32_t m_NumNalUnits = 0; //!< Number of NAL units in ppNALUnitParams.
123
124 bool m_panicEnable = false; //!< Indicate if panic is enabled
125
126 bool m_newSeqHeader = false; //!< New sequence header flag
127 bool m_newPpsHeader = false; //!< New PPS header flag
128 bool m_newVuiData = false; //!< New VUI data flag
129 bool m_newSeq = false; //!< New sequence flag
130 bool m_lastPicInSeq = false; //!< Flag to indicate if it is last picture in sequence
131 bool m_lastPicInStream = false; //!< Flag to indicate if it is last picture in stream
132
133 bool m_picQuant = false; //!< picture quant
134 bool m_newQmatrixData = false; //!< New Qmatrix data
135 PCODEC_ENCODER_SLCDATA m_slcData = nullptr; //!< record slice header size & position
136 uint32_t m_numSlices = 0; //!< Number of slices
137
138 uint32_t m_mbDataBufferSize = 0;
139
140 TrackedBuffer *m_trackedBuf = nullptr; //!< Encode tracked buffer
141 RecycleResource *m_recycleBuf = nullptr; //!< Recycle resources
142
143 uint32_t m_mbCodeSize = 0; //!< MB code buffer size
144 uint32_t m_mvDataSize = 0; //!< MV data size
145 PMOS_RESOURCE m_resMbCodeBuffer = nullptr; //!< Pointer to MOS_RESOURCE of MbCode buffer
146 PMOS_RESOURCE m_resMvDataBuffer = nullptr; //!< Pointer to MOS_RESOURCE of MvData buffer
147 bool m_isMbCodeRegistered = false;
148
149 uint32_t m_downscaledWidth4x = 0;
150 uint32_t m_downscaledHeight4x = 0;
151 PMOS_SURFACE m_4xDSSurface = nullptr;
152 PMOS_SURFACE m_8xDSSurface = nullptr;
153
154 PMOS_SURFACE m_rawSurfaceToPak = nullptr;
155 PMOS_SURFACE m_rawSurfaceToEnc = nullptr; //!< raw surf to enc
156 MOS_SURFACE m_rawSurface = {}; //!< Pointer to MOS_SURFACE of raw surface
157 MOS_SURFACE m_reconSurface = {}; //!< Pointer to MOS_SURFACE of reconstructed surface
158 MOS_RESOURCE m_resBitstreamBuffer = {}; //!< Pointer to MOS_SURFACE of bitstream surface
159 PMOS_RESOURCE m_resMetadataBuffer = nullptr;
160 PMOS_RESOURCE m_LaDataBuffer = nullptr;
161 MetaDataOffset m_metaDataOffset = {};
162
163 BSBuffer m_bsBuffer = {}; //!< Bit-stream buffer
164
165 uint32_t m_bitstreamSize = 0; //!< Maximum amount of data to be output to presBitstreamBuffer.
166 bool m_mbQpDataEnabled = false; //!< [AVC & MPEG2] Indicates that psMbQpDataSurface is present.
167 bool m_laDataBufferEnabled = false;
168 bool m_mbDisableSkipMapEnabled = false; //!< [AVC] Indicates that psMbDisableSkipMapSurface is present.
169 MOS_SURFACE m_mbDisableSkipMapSurface = {}; //!< [AVC] MB disable skip map provided by framework
170 MOS_SURFACE m_mbQpDataSurface = {}; //!< pointer to surface of Mb QP Data
171 bool m_rgbEncodingEnable = false; //!< Enable RGB encoding
172 bool m_captureModeEnable = false; //!< Enable Capture mode with display
173 bool m_predicationNotEqualZero = false; //!< [Predication] Predication mode
174 bool m_predicationEnabled = false; //!< [Predication] Indicates whether or not Predication is enabled
175 bool m_setMarkerEnabled = false; //!< [SetMarker] Indicates whether or not SetMarker is enabled
176 uint64_t m_predicationResOffset = 0; //!< [Predication] Offset for Predication resource
177 PMOS_RESOURCE m_presPredication = nullptr; //!< [Predication] Resource for predication
178 PMOS_RESOURCE *m_tempPredicationBuffer = nullptr; //!< [Predication] Temp buffer for Predication
179 PMOS_RESOURCE m_predicationBuffer = nullptr; //!< [Predication] Internal buffer for predication
180
181 uint8_t m_targetUsage =0;
182
183 uint8_t m_chromaFormat = HCP_CHROMA_FORMAT_YUV420; //!< Chroma format(420, 422 etc)
184 uint8_t m_bitDepth = 8; //!< Bit depth
185 bool m_is10Bit = false;
186 uint8_t m_outputChromaFormat = (uint8_t)HCP_CHROMA_FORMAT_YUV420; //!< 1: 420 2: 422 3: 444
187
188 uint32_t m_currPakSliceIdx = 0; //!< Current pak slice index
189
190 bool m_enableTileStitchByHW = false; //!< Enable HW to stitch commands in scalable mode
191
192 bool m_lockableResource = false; //!< disable / enable lockable surface
193
194 uint8_t m_par65Inter = 0;
195 uint8_t m_par65Intra = 0;
196
197 /*! \brief Specifies motion search modes that will be used.
198 *
199 * SubPelMode is only valid when bEnableSubPelMode is true. Following are valid values of SubPelMode:
200 * 0:Integer mode searching
201 * 1:Half-pel mode searching
202 * 2:Reserved
203 * 3:Quarter-pel mode searching
204 */
205 bool m_bEnableSubPelMode = false;
206 uint8_t m_SubPelMode = 3;
207 bool m_dualEncEnable = false;
208
209 bool m_chromaPrefetchDisable = true;
210
211 protected:
212 //!
213 //! \brief Update the parameters of tracked buffers
214 //! \return MOS_STATUS
215 //! MOS_STATUS_SUCCESS if success, else fail reason
216 //!
217 virtual MOS_STATUS UpdateTrackedBufferParameters();
218
219 //!
220 //! \brief Get the buffers from tracked buffer manager
221 //! \return MOS_STATUS
222 //! MOS_STATUS_SUCCESS if success, else fail reason
223 //!
224 virtual MOS_STATUS GetTrackedBuffers() { return MOS_STATUS_SUCCESS; }
225
226 EncodeAllocator *m_allocator = nullptr;
227 MOS_INTERFACE *m_osInterface = nullptr;
228
229 MEDIA_CLASS_DEFINE_END(encode__EncodeBasicFeature)
230 };
231
232 } // namespace encode
233
234 #endif // !__ENCODE_BASIC_FEATURE_H__