| 1 |
/* |
| 2 |
* Copyright (c) 2017, 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_encode_avc_g9_skl.h |
| 24 |
//! \brief AVC dual-pipe encoder for GEN9 SKL & BXT. |
| 25 |
//! |
| 26 |
|
| 27 |
#ifndef __CODECHAL_ENCODE_AVC_G9_SKL_H__ |
| 28 |
#define __CODECHAL_ENCODE_AVC_G9_SKL_H__ |
| 29 |
|
| 30 |
#include "codechal_encode_avc.h" |
| 31 |
#include "codechal_encode_avc_g9.h" |
| 32 |
|
| 33 |
#define MBENC_CURBE_SIZE_IN_DWORD_G9_SKL 104 |
| 34 |
|
| 35 |
class CodechalEncodeAvcEncG9Skl : public CodechalEncodeAvcEncG9 |
| 36 |
{ |
| 37 |
public: |
| 38 |
|
| 39 |
//! \brief Get encoder kernel header and kernel size |
| 40 |
//! |
| 41 |
//! \param [in] pvBinary |
| 42 |
//! Pointer to kernel binary |
| 43 |
//! \param [in] operation |
| 44 |
//! Enc kernel operation |
| 45 |
//! \param [in] dwKrnStateIdx |
| 46 |
//! Kernel state index |
| 47 |
//! \param [out] pvKrnHeader |
| 48 |
//! Pointer to kernel header |
| 49 |
//! \param [out] pdwKrnSize |
| 50 |
//! Pointer to kernel size |
| 51 |
//! |
| 52 |
//! \return MOS_STATUS |
| 53 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 54 |
//! |
| 55 |
static MOS_STATUS GetKernelHeaderAndSize( |
| 56 |
void *pvBinary, |
| 57 |
EncOperation operation, |
| 58 |
uint32_t dwKrnStateIdx, |
| 59 |
void *pvKrnHeader, |
| 60 |
uint32_t *pdwKrnSize); |
| 61 |
|
| 62 |
//! |
| 63 |
//! \brief Constructor |
| 64 |
//! |
| 65 |
CodechalEncodeAvcEncG9Skl( |
| 66 |
CodechalHwInterface * hwInterface, |
| 67 |
CodechalDebugInterface *debugInterface, |
| 68 |
PCODECHAL_STANDARD_INFO standardInfo); |
| 69 |
|
| 70 |
//! |
| 71 |
//! \brief Destructor |
| 72 |
//! |
| 73 |
~CodechalEncodeAvcEncG9Skl() {}; |
| 74 |
|
| 75 |
//! |
| 76 |
//! \brief Set MbEnc kernel curbe data |
| 77 |
//! |
| 78 |
//! \param [in] pParams |
| 79 |
//! Pointer to CODECHAL_ENCODE_AVC_MBENC_CURBE_PARAMS |
| 80 |
//! |
| 81 |
//! \return MOS_STATUS |
| 82 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 83 |
//! |
| 84 |
virtual MOS_STATUS SetCurbeAvcMbEnc( |
| 85 |
PCODECHAL_ENCODE_AVC_MBENC_CURBE_PARAMS pParams); |
| 86 |
|
| 87 |
//! |
| 88 |
//! \brief Get Trellis Quantization mode/value enable or not. |
| 89 |
//! |
| 90 |
//! \param [in] pParams |
| 91 |
//! Pointer to CODECHAL_ENCODE_AVC_TQ_INPUT_PARAMS. |
| 92 |
//! \param [out] pTrellisQuantParams |
| 93 |
//! Pointer to CODECHAL_ENCODE_AVC_TQ_PARAMS, mode & value setup. |
| 94 |
//! |
| 95 |
//! \return MOS_STATUS |
| 96 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 97 |
//! |
| 98 |
virtual MOS_STATUS GetTrellisQuantization( |
| 99 |
PCODECHAL_ENCODE_AVC_TQ_INPUT_PARAMS pParams, |
| 100 |
PCODECHAL_ENCODE_AVC_TQ_PARAMS pTrellisQuantParams); |
| 101 |
|
| 102 |
//! |
| 103 |
//! \brief Initialize brc constant buffer |
| 104 |
//! |
| 105 |
//! \param [in] pParams |
| 106 |
//! Pointer to CODECHAL_ENCODE_AVC_INIT_BRC_CONSTANT_BUFFER_PARAMS |
| 107 |
//! |
| 108 |
//! \return MOS_STATUS |
| 109 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 110 |
//! |
| 111 |
virtual MOS_STATUS InitBrcConstantBuffer( |
| 112 |
PCODECHAL_ENCODE_AVC_INIT_BRC_CONSTANT_BUFFER_PARAMS pParams); |
| 113 |
|
| 114 |
// state related funcs |
| 115 |
//! |
| 116 |
//! \brief Initialize encode state |
| 117 |
//! |
| 118 |
//! \return MOS_STATUS |
| 119 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 120 |
//! |
| 121 |
virtual MOS_STATUS InitializeState(); |
| 122 |
|
| 123 |
//! |
| 124 |
//! \brief Init MbEnc kernel state |
| 125 |
//! |
| 126 |
//! \return MOS_STATUS |
| 127 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 128 |
//! |
| 129 |
virtual MOS_STATUS InitKernelStateMbEnc(); |
| 130 |
|
| 131 |
//! |
| 132 |
//! \brief Init BRC kernel state |
| 133 |
//! |
| 134 |
//! \return MOS_STATUS |
| 135 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 136 |
//! |
| 137 |
virtual MOS_STATUS InitKernelStateBrc(); |
| 138 |
|
| 139 |
virtual MOS_STATUS InitKernelStateMfeMbEnc(); |
| 140 |
|
| 141 |
virtual MOS_STATUS InitMfe(); |
| 142 |
|
| 143 |
virtual MOS_STATUS SetCurbeAvcMfeMbEnc( |
| 144 |
PCODECHAL_ENCODE_AVC_MFE_MBENC_CURBE_PARAMS pParams); |
| 145 |
|
| 146 |
virtual MOS_STATUS UpdateMfeMbEncBindingTable( |
| 147 |
uint32_t submitIndex); |
| 148 |
|
| 149 |
//! |
| 150 |
//! \brief initial multi ref Qp BRC constant Buffer. |
| 151 |
//! |
| 152 |
//! \param [in] pParams |
| 153 |
//! BRC init constant buffer params. |
| 154 |
//! |
| 155 |
//! \return MOS_STATUS |
| 156 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 157 |
MOS_STATUS InitBrcConstantBufferMultiRefQP(PCODECHAL_ENCODE_AVC_INIT_BRC_CONSTANT_BUFFER_PARAMS pParams); |
| 158 |
|
| 159 |
void UpdateSSDSliceCount(); |
| 160 |
|
| 161 |
private: |
| 162 |
static const uint32_t TrellisQuantizationEnable[NUM_TARGET_USAGE_MODES]; |
| 163 |
static const uint32_t TrellisQuantizationRounding[NUM_TARGET_USAGE_MODES]; |
| 164 |
static const uint32_t EnableAdaptiveTrellisQuantization[NUM_TARGET_USAGE_MODES]; |
| 165 |
static const uint32_t MBEnc_CURBE_normal_I_frame[MBENC_CURBE_SIZE_IN_DWORD_G9_SKL]; |
| 166 |
static const uint32_t MBEnc_CURBE_normal_I_field[MBENC_CURBE_SIZE_IN_DWORD_G9_SKL]; |
| 167 |
static const uint32_t MBEnc_CURBE_normal_P_frame[MBENC_CURBE_SIZE_IN_DWORD_G9_SKL]; |
| 168 |
static const uint32_t MBEnc_CURBE_normal_P_field[MBENC_CURBE_SIZE_IN_DWORD_G9_SKL]; |
| 169 |
static const uint32_t MBEnc_CURBE_normal_B_frame[MBENC_CURBE_SIZE_IN_DWORD_G9_SKL]; |
| 170 |
static const uint32_t MBEnc_CURBE_normal_B_field[MBENC_CURBE_SIZE_IN_DWORD_G9_SKL]; |
| 171 |
static const uint32_t MBEnc_CURBE_I_frame_DIST[MBENC_CURBE_SIZE_IN_DWORD_G9_SKL]; |
| 172 |
static const int32_t BRC_BTCOUNTS[CODECHAL_ENCODE_BRC_IDX_NUM]; |
| 173 |
static const int32_t BRC_CURBE_SIZE[CODECHAL_ENCODE_BRC_IDX_NUM]; |
| 174 |
|
| 175 |
#if USE_CODECHAL_DEBUG_TOOL |
| 176 |
protected: |
| 177 |
virtual MOS_STATUS PopulatePakParam( |
| 178 |
PMOS_COMMAND_BUFFER cmdBuffer, |
| 179 |
PMHW_BATCH_BUFFER secondLevelBatchBuffer); |
| 180 |
#endif |
| 181 |
}; |
| 182 |
|
| 183 |
#endif // __CODECHAL_ENCODE_AVC_G9_SKL_H__ |