| 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_kernel_intra_dist.h |
| 24 |
//! \brief Defines the intra distortion kernel base |
| 25 |
//! \details Intra distortion base includes all common functions and definitions for intra distortion |
| 26 |
//! |
| 27 |
#ifndef __CODECHAL_KERNEL_INTRA_DIST_H__ |
| 28 |
#define __CODECHAL_KERNEL_INTRA_DIST_H__ |
| 29 |
#include "codechal_kernel_base.h" |
| 30 |
|
| 31 |
//! |
| 32 |
//! \class CodechalKernelIntraDist |
| 33 |
//! \brief Codechal kernel intra dist |
| 34 |
//! |
| 35 |
class CodechalKernelIntraDist : public CodechalKernelBase |
| 36 |
{ |
| 37 |
public: |
| 38 |
//! |
| 39 |
//! \enum KernelIndex |
| 40 |
//! \brief Kernel index |
| 41 |
//! |
| 42 |
enum KernelIndex |
| 43 |
{ |
| 44 |
intraDistortion = 0 |
| 45 |
}; |
| 46 |
|
| 47 |
//! |
| 48 |
//! \enum BindingTableOffset |
| 49 |
//! \brief Binding table offset |
| 50 |
//! |
| 51 |
enum BindingTableOffset |
| 52 |
{ |
| 53 |
intraDistCurrent4xY = 0, |
| 54 |
intraDistOutputSurf = 1, |
| 55 |
intraDistVmeIntraPred = 2, |
| 56 |
intraDistSurfaceNum = 3 |
| 57 |
}; |
| 58 |
|
| 59 |
//! |
| 60 |
//! \class CurbeParam |
| 61 |
//! \brief Curbe parameter |
| 62 |
//! |
| 63 |
struct CurbeParam |
| 64 |
{ |
| 65 |
uint32_t downScaledWidthInMb4x = 0; |
| 66 |
uint32_t downScaledHeightInMb4x = 0; |
| 67 |
}; |
| 68 |
|
| 69 |
//! |
| 70 |
//! \class SurfaceParams |
| 71 |
//! \brief Surface parameters |
| 72 |
//! |
| 73 |
struct SurfaceParams |
| 74 |
{ |
| 75 |
uint32_t intraDistBottomFieldOffset = 0; |
| 76 |
PMOS_SURFACE input4xDsSurface = nullptr; |
| 77 |
PMOS_SURFACE intraDistSurface = nullptr; |
| 78 |
PMOS_SURFACE input4xDsVmeSurface = nullptr; |
| 79 |
}; |
| 80 |
|
| 81 |
// clang-format off |
| 82 |
//! |
| 83 |
//! \class Curbe |
| 84 |
//! \brief Curbe |
| 85 |
//! |
| 86 |
class Curbe |
| 87 |
{ |
| 88 |
public: |
| 89 |
Curbe() |
| 90 |
{ |
| 91 |
memset(&m_data, 0, sizeof(CurbeData)); |
| 92 |
m_data.DW1.interSAD = 2; |
| 93 |
m_data.DW1.intraSAD = 2; |
| 94 |
m_data.DW8.value = 0xFFFFFFFF; |
| 95 |
m_data.DW9.value = 0xFFFFFFFF; |
| 96 |
m_data.DW10.value = 0xFFFFFFFF; |
| 97 |
} |
| 98 |
//! |
| 99 |
//! \struct CurbeData |
| 100 |
//! \brief Curbe data |
| 101 |
//! |
| 102 |
struct CurbeData |
| 103 |
{ |
| 104 |
//DW0 |
| 105 |
union |
| 106 |
{ |
| 107 |
struct |
| 108 |
{ |
| 109 |
uint32_t picWidthInLumaSamples : MOS_BITFIELD_RANGE(0, 15); |
| 110 |
uint32_t picHeightInLumaSamples : MOS_BITFIELD_RANGE(16, 31); |
| 111 |
}; |
| 112 |
uint32_t value; |
| 113 |
} DW0; |
| 114 |
|
| 115 |
//DW1 |
| 116 |
union |
| 117 |
{ |
| 118 |
struct |
| 119 |
{ |
| 120 |
uint32_t srcSize : MOS_BITFIELD_RANGE(0, 1); |
| 121 |
uint32_t reserved2 : MOS_BITFIELD_RANGE(2, 13); |
| 122 |
uint32_t skipType : MOS_BITFIELD_BIT(14); |
| 123 |
uint32_t reserved15 : MOS_BITFIELD_BIT(15); |
| 124 |
uint32_t intraChromaMode : MOS_BITFIELD_BIT(16); |
| 125 |
uint32_t ftSkipCheckEnable : MOS_BITFIELD_BIT(17); |
| 126 |
uint32_t reserved18 : MOS_BITFIELD_BIT(18); |
| 127 |
uint32_t blockBasedSkipEnable : MOS_BITFIELD_BIT(19); |
| 128 |
uint32_t interSAD : MOS_BITFIELD_RANGE(20, 21); |
| 129 |
uint32_t intraSAD : MOS_BITFIELD_RANGE(22, 23); |
| 130 |
uint32_t reserved24 : MOS_BITFIELD_RANGE(24, 31); |
| 131 |
}; |
| 132 |
uint32_t value; |
| 133 |
} DW1; |
| 134 |
|
| 135 |
//DW2 |
| 136 |
union |
| 137 |
{ |
| 138 |
struct |
| 139 |
{ |
| 140 |
uint32_t intraPartMask : MOS_BITFIELD_RANGE(0, 4); |
| 141 |
uint32_t nonSkipZmvAdded : MOS_BITFIELD_BIT(5); |
| 142 |
uint32_t nonSkipModeAdded : MOS_BITFIELD_BIT(6); |
| 143 |
uint32_t intraCornerSwap : MOS_BITFIELD_BIT(7); |
| 144 |
uint32_t reserved8 : MOS_BITFIELD_RANGE(8, 15); |
| 145 |
uint32_t mvCostScaleFactor : MOS_BITFIELD_RANGE(16, 17); |
| 146 |
uint32_t bilinearEnable : MOS_BITFIELD_BIT(18); |
| 147 |
uint32_t reserved19 : MOS_BITFIELD_BIT(19); |
| 148 |
uint32_t weightedSADHaar : MOS_BITFIELD_BIT(20); |
| 149 |
uint32_t acOnlyHaar : MOS_BITFIELD_BIT(21); |
| 150 |
uint32_t refIDCostMode : MOS_BITFIELD_BIT(22); |
| 151 |
uint32_t reserved23 : MOS_BITFIELD_BIT(23); |
| 152 |
uint32_t skipCenterMask : MOS_BITFIELD_RANGE(24, 31); |
| 153 |
}; |
| 154 |
uint32_t value; |
| 155 |
} DW2; |
| 156 |
|
| 157 |
//DW3 |
| 158 |
union |
| 159 |
{ |
| 160 |
struct |
| 161 |
{ |
| 162 |
uint32_t reserved; |
| 163 |
}; |
| 164 |
uint32_t value; |
| 165 |
} DW3; |
| 166 |
|
| 167 |
//DW4 |
| 168 |
union |
| 169 |
{ |
| 170 |
struct |
| 171 |
{ |
| 172 |
uint32_t reserved; |
| 173 |
}; |
| 174 |
uint32_t value; |
| 175 |
} DW4; |
| 176 |
|
| 177 |
//DW5 |
| 178 |
union |
| 179 |
{ |
| 180 |
struct |
| 181 |
{ |
| 182 |
uint32_t reserved; |
| 183 |
}; |
| 184 |
uint32_t value; |
| 185 |
} DW5; |
| 186 |
|
| 187 |
//DW6 |
| 188 |
union |
| 189 |
{ |
| 190 |
struct |
| 191 |
{ |
| 192 |
uint32_t reserved; |
| 193 |
}; |
| 194 |
uint32_t value; |
| 195 |
} DW6; |
| 196 |
|
| 197 |
//DW7 |
| 198 |
union |
| 199 |
{ |
| 200 |
struct |
| 201 |
{ |
| 202 |
uint32_t reserved; |
| 203 |
}; |
| 204 |
uint32_t value; |
| 205 |
} DW7; |
| 206 |
|
| 207 |
//DW8 |
| 208 |
union |
| 209 |
{ |
| 210 |
struct |
| 211 |
{ |
| 212 |
uint32_t currPic4xBTI; |
| 213 |
}; |
| 214 |
uint32_t value; |
| 215 |
} DW8; |
| 216 |
|
| 217 |
//DW9 |
| 218 |
union |
| 219 |
{ |
| 220 |
struct |
| 221 |
{ |
| 222 |
uint32_t intraDistSurfaceBTI; |
| 223 |
}; |
| 224 |
uint32_t value; |
| 225 |
} DW9; |
| 226 |
|
| 227 |
//DW10 |
| 228 |
union |
| 229 |
{ |
| 230 |
struct |
| 231 |
{ |
| 232 |
uint32_t vmeIntraPredSurfaceBTI; |
| 233 |
}; |
| 234 |
uint32_t value; |
| 235 |
} DW10; |
| 236 |
} m_data; |
| 237 |
static const uint32_t m_curbeSize = sizeof(CurbeData); |
| 238 |
}; |
| 239 |
// clang-format on |
| 240 |
|
| 241 |
CodechalKernelIntraDist(CodechalEncoderState *encoder); |
| 242 |
|
| 243 |
virtual ~CodechalKernelIntraDist(); |
| 244 |
|
| 245 |
//! |
| 246 |
//! \brief Execute Intra Distortion kernel |
| 247 |
//! |
| 248 |
//! \param [in] curbeParam |
| 249 |
//! Reference to CodechalKernelIntraDist::CurbeParam |
| 250 |
//! \param [in] surfaceParam |
| 251 |
//! Reference to CodechalKernelIntraDist::SurfaceParams |
| 252 |
//! |
| 253 |
//! \return MOS_STATUS |
| 254 |
//! MOS_STATUS_SUCCESS if success |
| 255 |
//! |
| 256 |
MOS_STATUS Execute(CurbeParam &curbeParam, SurfaceParams &surfaceParam); |
| 257 |
|
| 258 |
uint32_t GetBTCount() { return BindingTableOffset::intraDistSurfaceNum; } |
| 259 |
|
| 260 |
protected: |
| 261 |
MOS_STATUS AllocateResources(); |
| 262 |
MOS_STATUS ReleaseResources(); |
| 263 |
|
| 264 |
virtual uint32_t GetCurbeSize() { return Curbe::m_curbeSize; } |
| 265 |
virtual MOS_STATUS SetCurbe(MHW_KERNEL_STATE *kernelState); |
| 266 |
virtual MOS_STATUS SendSurfaces(PMOS_COMMAND_BUFFER cmd, MHW_KERNEL_STATE *kernelState); |
| 267 |
virtual MOS_STATUS AddPerfTag(); |
| 268 |
virtual MHW_KERNEL_STATE *GetActiveKernelState(); |
| 269 |
virtual MOS_STATUS InitWalkerCodecParams(CODECHAL_WALKER_CODEC_PARAMS &walkerParam); |
| 270 |
virtual CODECHAL_MEDIA_STATE_TYPE GetMediaStateType(); |
| 271 |
|
| 272 |
CurbeParam m_curbeParam; //!< curbe paramters |
| 273 |
SurfaceParams m_surfaceParam; //! surface parameters |
| 274 |
}; |
| 275 |
|
| 276 |
#endif /* __CODECHAL_KERNEL_INTRA_DIST_H__ */ |