| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
#ifndef __ENCODE_VP9_PAK_H__ |
| 27 |
#define __ENCODE_VP9_PAK_H__ |
| 28 |
|
| 29 |
#include "media_cmd_packet.h" |
| 30 |
#include "encode_pipeline.h" |
| 31 |
#include "encode_vp9_basic_feature.h" |
| 32 |
#include "encode_vp9_pipeline.h" |
| 33 |
|
| 34 |
#include "media_pipeline.h" |
| 35 |
#include "encode_utils.h" |
| 36 |
|
| 37 |
namespace encode |
| 38 |
{ |
| 39 |
#define CODECHAL_ENCODE_VP9_MAX_NUM_HCP_PIPE 4 |
| 40 |
#define CODECHAL_VP9_ENCODE_RECYCLED_BUFFER_NUM (CODECHAL_ENCODE_RECYCLED_BUFFER_NUM * CODECHAL_ENCODE_VP9_MAX_NUM_HCP_PIPE) // for salability, need 1 buffer per pipe, |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
struct CU_DATA |
| 46 |
{ |
| 47 |
|
| 48 |
uint32_t cu_size : 2; |
| 49 |
uint32_t Res_DW0_2_3 : 2; |
| 50 |
uint32_t cu_part_mode : 2; |
| 51 |
uint32_t Res_DW0_6_7 : 2; |
| 52 |
uint32_t intra_chroma_mode0 : 4; |
| 53 |
uint32_t Res_DW0_12_15 : 4; |
| 54 |
uint32_t intra_chroma_mode1 : 4; |
| 55 |
uint32_t cu_pred_mode0 : 1; |
| 56 |
uint32_t cu_pred_mode1 : 1; |
| 57 |
uint32_t Res_DW0_23_22 : 2; |
| 58 |
uint32_t interpred_comp0 : 1; |
| 59 |
uint32_t interpred_comp1 : 1; |
| 60 |
uint32_t Res_DW0_31_26 : 6; |
| 61 |
|
| 62 |
|
| 63 |
uint32_t intra_mode0 : 4; |
| 64 |
uint32_t Res_DW1_4_7 : 4; |
| 65 |
uint32_t intra_mode1 : 4; |
| 66 |
uint32_t Res_DW1_12_15 : 4; |
| 67 |
uint32_t intra_mode2 : 4; |
| 68 |
uint32_t Res_DW1_20_23 : 4; |
| 69 |
uint32_t intra_mode3 : 4; |
| 70 |
uint32_t Res_DW1_28_31 : 4; |
| 71 |
|
| 72 |
|
| 73 |
int16_t mvx_l0_part0 : 16; |
| 74 |
int16_t mvy_l0_part0 : 16; |
| 75 |
|
| 76 |
|
| 77 |
int16_t mvx_l0_part1 : 16; |
| 78 |
int16_t mvy_l0_part1 : 16; |
| 79 |
|
| 80 |
|
| 81 |
int16_t mvx_l0_part2 : 16; |
| 82 |
int16_t mvy_l0_part2 : 16; |
| 83 |
|
| 84 |
|
| 85 |
int16_t mvx_l0_part3 : 16; |
| 86 |
int16_t mvy_l0_part3 : 16; |
| 87 |
|
| 88 |
|
| 89 |
int16_t mvx_l1_part0 : 16; |
| 90 |
int16_t mvy_l1_part0 : 16; |
| 91 |
|
| 92 |
|
| 93 |
int16_t mvx_l1_part1 : 16; |
| 94 |
int16_t mvy_l1_part1 : 16; |
| 95 |
|
| 96 |
|
| 97 |
int16_t mvx_l1_part2 : 16; |
| 98 |
int16_t mvy_l1_part2 : 16; |
| 99 |
|
| 100 |
|
| 101 |
int16_t mvx_l1_part3 : 16; |
| 102 |
int16_t mvy_l1_part3 : 16; |
| 103 |
|
| 104 |
|
| 105 |
uint32_t refframe_part0_l0 : 2; |
| 106 |
uint32_t Res_DW10_2_3 : 2; |
| 107 |
uint32_t refframe_part1_l0 : 2; |
| 108 |
uint32_t Res_DW10_6_7 : 2; |
| 109 |
uint32_t refframe_part0_l1 : 2; |
| 110 |
uint32_t Res_DW10_10_11 : 2; |
| 111 |
uint32_t refframe_part1_l1 : 2; |
| 112 |
uint32_t Res_DW10_14_15 : 2; |
| 113 |
uint32_t round_part0 : 3; |
| 114 |
uint32_t Res_DW10_19 : 1; |
| 115 |
uint32_t round_part1 : 3; |
| 116 |
uint32_t Res_DW10_23_31 : 9; |
| 117 |
|
| 118 |
|
| 119 |
uint32_t tu_size0 : 2; |
| 120 |
uint32_t tu_size1 : 2; |
| 121 |
uint32_t Res_DW11_4_13 : 10; |
| 122 |
uint32_t segidx_pred0 : 1; |
| 123 |
uint32_t segidx_pred1 : 1; |
| 124 |
uint32_t segidx_part0 : 3; |
| 125 |
uint32_t segidx_part1 : 3; |
| 126 |
uint32_t mc_filtertype_part0 : 2; |
| 127 |
uint32_t mc_filtertype_part1 : 2; |
| 128 |
uint32_t Res_DW11_26_31 : 6; |
| 129 |
|
| 130 |
uint32_t Res_DW12 : 32; |
| 131 |
|
| 132 |
uint32_t Res_DW13 : 32; |
| 133 |
|
| 134 |
uint32_t Res_DW14 : 32; |
| 135 |
|
| 136 |
uint32_t Res_DW15 : 32; |
| 137 |
|
| 138 |
}; |
| 139 |
C_ASSERT(MOS_BYTES_TO_DWORDS(sizeof(CU_DATA)) == 16); |
| 140 |
|
| 141 |
class Vp9EncodePak : public MediaFeature, |
| 142 |
public mhw::vdbox::huc::Itf::ParSetting, |
| 143 |
public mhw::vdbox::hcp::Itf::ParSetting, |
| 144 |
public mhw::vdbox::vdenc::Itf::ParSetting |
| 145 |
{ |
| 146 |
public: |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
Vp9EncodePak( |
| 160 |
MediaFeatureManager *featureManager, |
| 161 |
EncodeAllocator *allocator, |
| 162 |
CodechalHwInterfaceNext *hwInterface, |
| 163 |
void *constSettings); |
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
virtual ~Vp9EncodePak() {} |
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
MOS_STATUS Init(void *settings) override; |
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
MOS_STATUS Update(void *params) override; |
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
MOS_STATUS SetRegionsForBrcUpdate( |
| 198 |
mhw::vdbox::huc::HUC_VIRTUAL_ADDR_STATE_PAR ¶ms, |
| 199 |
uint32_t currPass) const; |
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
MOS_STATUS SetRegionsForHucProb( |
| 211 |
mhw::vdbox::huc::HUC_VIRTUAL_ADDR_STATE_PAR ¶ms, |
| 212 |
uint32_t currPass) const; |
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
MOS_STATUS ConstructPicStateBatchBuffer( |
| 222 |
EncodePipeline *pipeline); |
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
MOS_STATUS ConstructPakInsertObjBatchBuffer(); |
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
MOS_STATUS SetHucPakInsertObjBatchBuffer( |
| 239 |
MHW_BATCH_BUFFER &secondLevelBatchBuffer); |
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
virtual MOS_STATUS SetVdencSecondLevelBatchBuffer( |
| 251 |
uint32_t currPass, |
| 252 |
MHW_BATCH_BUFFER &secondLevelBatchBuffer); |
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
virtual MOS_STATUS GetVdencPictureState2ndLevelBatchBufferSize( |
| 262 |
uint32_t &size); |
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
virtual MOS_STATUS UpdateParameters(); |
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
MOS_STATUS PakConstructPicStateBatchBuffer( |
| 281 |
PMOS_RESOURCE picStateBuffer); |
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
PMOS_RESOURCE GetCompressedHeaderBuffer(); |
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
MHW_SETPAR_DECL_HDR(HCP_PAK_INSERT_OBJECT); |
| 293 |
MHW_SETPAR_DECL_HDR(HCP_IND_OBJ_BASE_ADDR_STATE); |
| 294 |
MHW_SETPAR_DECL_HDR(HCP_PIPE_BUF_ADDR_STATE); |
| 295 |
|
| 296 |
protected: |
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
MOS_STATUS AllocateResources() override; |
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
MOS_STATUS PreparePakObjAndCuRecord(); |
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
virtual MOS_STATUS AddVdencCmd1Command( |
| 319 |
MOS_COMMAND_BUFFER &cmdBuffer); |
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
MOS_STATUS AddVdencCmd2Command( |
| 329 |
MOS_COMMAND_BUFFER &cmdBuffer); |
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
void CalculateQpLambdaValues(double &sadQpLambda, double &rdQpLambda); |
| 341 |
|
| 342 |
CodechalHwInterfaceNext * m_hwInterface = nullptr; |
| 343 |
EncodeAllocator * m_allocator = nullptr; |
| 344 |
Vp9BasicFeature * m_basicFeature = nullptr; |
| 345 |
|
| 346 |
std::shared_ptr<mhw::vdbox::hcp::Itf> m_hcpInterfaceNew = nullptr; |
| 347 |
std::shared_ptr<mhw::vdbox::vdenc::Itf> m_vdencInterfaceNew = nullptr; |
| 348 |
std::shared_ptr<mhw::mi::Itf> m_miItf = nullptr; |
| 349 |
|
| 350 |
|
| 351 |
bool m_picState2ndLevelBBConstructed[3]; |
| 352 |
uint32_t m_vdencPicStateSecondLevelBatchBufferSize = 0; |
| 353 |
uint16_t m_vdencPictureState2ndLevelBBIndex = 0; |
| 354 |
uint16_t m_lastVdencPictureState2ndLevelBBIndex = 0; |
| 355 |
|
| 356 |
MOS_RESOURCE m_resVdencPictureState2ndLevelBatchBufferRead[3][CODECHAL_VP9_ENCODE_RECYCLED_BUFFER_NUM] = {0}; |
| 357 |
MOS_RESOURCE m_resVdencPictureState2ndLevelBatchBufferWrite[CODECHAL_VP9_ENCODE_RECYCLED_BUFFER_NUM] = {0}; |
| 358 |
|
| 359 |
|
| 360 |
MOS_RESOURCE m_resHucPakInsertUncompressedHeaderReadBuffer[CODECHAL_ENCODE_RECYCLED_BUFFER_NUM] = {0}; |
| 361 |
MOS_RESOURCE m_resHucPakInsertUncompressedHeaderWriteBuffer = {0}; |
| 362 |
|
| 363 |
MOS_RESOURCE m_resCompressedHeaderBuffer = {0}; |
| 364 |
MOS_RESOURCE m_resVdencDataExtensionBuffer = {0}; |
| 365 |
|
| 366 |
|
| 367 |
PMOS_RESOURCE m_resMetadataLineBuffer = nullptr; |
| 368 |
PMOS_RESOURCE m_resMetadataTileLineBuffer = nullptr; |
| 369 |
PMOS_RESOURCE m_resMetadataTileColumnBuffer = nullptr; |
| 370 |
|
| 371 |
|
| 372 |
MOS_RESOURCE m_resVdencDysPictureState2ndLevelBatchBuffer = {0}; |
| 373 |
|
| 374 |
MEDIA_CLASS_DEFINE_END(encode__Vp9EncodePak) |
| 375 |
}; |
| 376 |
|
| 377 |
} |
| 378 |
|
| 379 |
#endif |