| 1 |
/* |
| 2 |
* Copyright (c) 2020-2022, 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 decode_vp8_pipeline.cpp |
| 24 |
//! \brief Defines the interface for vp8 decode pipeline |
| 25 |
//! |
| 26 |
#include "decode_vp8_pipeline.h" |
| 27 |
#include "decode_utils.h" |
| 28 |
#include "codechal_setting.h" |
| 29 |
#include "decode_vp8_feature_manager.h" |
| 30 |
#include "media_debug_fast_dump.h" |
| 31 |
|
| 32 |
namespace decode |
| 33 |
{ |
| 34 |
Vp8Pipeline::Vp8Pipeline( |
| 35 |
CodechalHwInterfaceNext * hwInterface, |
| 36 |
CodechalDebugInterface *debugInterface) |
| 37 |
: DecodePipeline(hwInterface, debugInterface) |
| 38 |
{ |
| 39 |
MOS_STATUS m_status = InitUserSetting(m_userSettingPtr); |
| 40 |
} |
| 41 |
|
| 42 |
MOS_STATUS Vp8Pipeline::Initialize(void *settings) |
| 43 |
{ |
| 44 |
DECODE_FUNC_CALL(); |
| 45 |
DECODE_CHK_STATUS(DecodePipeline::Initialize(settings)); |
| 46 |
|
| 47 |
// Create basic GPU context |
| 48 |
DecodeScalabilityPars scalPars; |
| 49 |
MOS_ZeroMemory(&scalPars, sizeof(scalPars)); |
| 50 |
DECODE_CHK_STATUS(m_mediaContext->SwitchContext(VdboxDecodeFunc, &scalPars, &m_scalability)); |
| 51 |
m_decodeContext = m_osInterface->pfnGetGpuContext(m_osInterface); |
| 52 |
m_decodeContextHandle = m_osInterface->CurrentGpuContextHandle; |
| 53 |
|
| 54 |
m_basicFeature = dynamic_cast<Vp8BasicFeature *>(m_featureManager->GetFeature(FeatureIDs::basicFeature)); |
| 55 |
DECODE_CHK_NULL(m_basicFeature); |
| 56 |
|
| 57 |
auto *codecSettings = (CodechalSetting *)settings; |
| 58 |
DECODE_CHK_NULL(codecSettings); |
| 59 |
|
| 60 |
return MOS_STATUS_SUCCESS; |
| 61 |
} |
| 62 |
|
| 63 |
MOS_STATUS Vp8Pipeline::Prepare(void *params) |
| 64 |
{ |
| 65 |
DECODE_FUNC_CALL(); |
| 66 |
DECODE_CHK_NULL(params); |
| 67 |
|
| 68 |
DECODE_CHK_STATUS(DecodePipeline::Prepare(params)); |
| 69 |
|
| 70 |
return MOS_STATUS_SUCCESS; |
| 71 |
} |
| 72 |
|
| 73 |
MOS_STATUS Vp8Pipeline::Uninitialize() |
| 74 |
{ |
| 75 |
DECODE_FUNC_CALL(); |
| 76 |
|
| 77 |
return DecodePipeline::Uninitialize(); |
| 78 |
} |
| 79 |
|
| 80 |
MOS_STATUS Vp8Pipeline::UserFeatureReport() |
| 81 |
{ |
| 82 |
DECODE_FUNC_CALL(); |
| 83 |
DECODE_CHK_STATUS(DecodePipeline::UserFeatureReport()); |
| 84 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 85 |
WriteUserFeature(__MEDIA_USER_FEATURE_VALUE_APOGEIOS_VP8D_ENABLE_ID, 1, m_osInterface->pOsContext); |
| 86 |
#endif |
| 87 |
|
| 88 |
CODECHAL_DEBUG_TOOL( |
| 89 |
if (m_mmcState != nullptr) { |
| 90 |
m_mmcState->UpdateUserFeatureKey(&(m_basicFeature->m_destSurface)); |
| 91 |
}) |
| 92 |
|
| 93 |
return MOS_STATUS_SUCCESS; |
| 94 |
} |
| 95 |
|
| 96 |
MOS_STATUS Vp8Pipeline::Execute() |
| 97 |
{ |
| 98 |
DECODE_FUNC_CALL(); |
| 99 |
|
| 100 |
bool immediateSubmit = false; |
| 101 |
DECODE_CHK_STATUS(ActivatePacket(DecodePacketId(this, vp8DecodePacketId), immediateSubmit, 0, 0)); |
| 102 |
DECODE_CHK_STATUS(ExecuteActivePackets()); |
| 103 |
return MOS_STATUS_SUCCESS; |
| 104 |
} |
| 105 |
|
| 106 |
MOS_STATUS Vp8Pipeline::CreateFeatureManager() |
| 107 |
{ |
| 108 |
DECODE_FUNC_CALL(); |
| 109 |
m_featureManager = MOS_New(DecodeVp8FeatureManager, m_allocator, m_hwInterface, m_osInterface); |
| 110 |
DECODE_CHK_NULL(m_featureManager); |
| 111 |
return MOS_STATUS_SUCCESS; |
| 112 |
} |
| 113 |
|
| 114 |
MOS_STATUS Vp8Pipeline::CreateSubPackets(DecodeSubPacketManager &subPacketManager, CodechalSetting &codecSettings) |
| 115 |
{ |
| 116 |
DECODE_FUNC_CALL(); |
| 117 |
|
| 118 |
DECODE_CHK_STATUS(DecodePipeline::CreateSubPackets(subPacketManager, codecSettings)); |
| 119 |
|
| 120 |
return MOS_STATUS_SUCCESS; |
| 121 |
} |
| 122 |
|
| 123 |
Vp8Pipeline::Vp8DecodeMode Vp8Pipeline::GetDecodeMode() |
| 124 |
{ |
| 125 |
return m_decodeMode; |
| 126 |
} |
| 127 |
|
| 128 |
#if USE_CODECHAL_DEBUG_TOOL |
| 129 |
MOS_STATUS Vp8Pipeline::DumpPicParams(PCODEC_VP8_PIC_PARAMS picParams) |
| 130 |
{ |
| 131 |
DECODE_FUNC_CALL(); |
| 132 |
|
| 133 |
if (picParams == nullptr) |
| 134 |
{ |
| 135 |
return MOS_STATUS_SUCCESS; |
| 136 |
} |
| 137 |
|
| 138 |
if (m_debugInterface->DumpIsEnabled(CodechalDbgAttr::attrPicParams)) |
| 139 |
{ |
| 140 |
const char *fileName = m_debugInterface->CreateFileName( |
| 141 |
"_DEC", |
| 142 |
CodechalDbgBufferType::bufPicParams, |
| 143 |
CodechalDbgExtType::txt); |
| 144 |
|
| 145 |
if (m_debugInterface->DumpIsEnabled(CodechalDbgAttr::attrEnableFastDump)) |
| 146 |
{ |
| 147 |
MediaDebugFastDump::Dump( |
| 148 |
(uint8_t *)picParams, |
| 149 |
fileName, |
| 150 |
sizeof(CODEC_VP8_PIC_PARAMS), |
| 151 |
0, |
| 152 |
MediaDebugSerializer<CODEC_VP8_PIC_PARAMS>()); |
| 153 |
} |
| 154 |
else |
| 155 |
{ |
| 156 |
DumpDecodeVp8PicParams(picParams, fileName); |
| 157 |
} |
| 158 |
} |
| 159 |
|
| 160 |
return MOS_STATUS_SUCCESS; |
| 161 |
} |
| 162 |
|
| 163 |
MOS_STATUS Vp8Pipeline::DumpSliceParams(PCODEC_VP8_SLICE_PARAMS sliceParams) |
| 164 |
{ |
| 165 |
DECODE_FUNC_CALL(); |
| 166 |
|
| 167 |
if (sliceParams == nullptr) |
| 168 |
{ |
| 169 |
return MOS_STATUS_SUCCESS; |
| 170 |
} |
| 171 |
|
| 172 |
if (m_debugInterface->DumpIsEnabled(CodechalDbgAttr::attrSlcParams)) |
| 173 |
{ |
| 174 |
const char *fileName = m_debugInterface->CreateFileName( |
| 175 |
"_DEC", |
| 176 |
CodechalDbgBufferType::bufSlcParams, |
| 177 |
CodechalDbgExtType::txt); |
| 178 |
|
| 179 |
if (m_debugInterface->DumpIsEnabled(CodechalDbgAttr::attrEnableFastDump)) |
| 180 |
{ |
| 181 |
MediaDebugFastDump::Dump( |
| 182 |
(uint8_t *)sliceParams, |
| 183 |
fileName, |
| 184 |
sizeof(CODEC_VP8_SLICE_PARAMS), |
| 185 |
0, |
| 186 |
MediaDebugSerializer<CODEC_VP8_SLICE_PARAMS>()); |
| 187 |
} |
| 188 |
else |
| 189 |
{ |
| 190 |
DumpDecodeVp8SliceParams(sliceParams, fileName); |
| 191 |
} |
| 192 |
} |
| 193 |
|
| 194 |
return MOS_STATUS_SUCCESS; |
| 195 |
} |
| 196 |
|
| 197 |
MOS_STATUS Vp8Pipeline::DumpIQParams(PCODEC_VP8_IQ_MATRIX_PARAMS iqParams) |
| 198 |
{ |
| 199 |
DECODE_FUNC_CALL(); |
| 200 |
|
| 201 |
if (iqParams == nullptr) |
| 202 |
{ |
| 203 |
return MOS_STATUS_SUCCESS; |
| 204 |
} |
| 205 |
|
| 206 |
if (m_debugInterface->DumpIsEnabled(CodechalDbgAttr::attrIqParams)) |
| 207 |
{ |
| 208 |
const char *fileName = m_debugInterface->CreateFileName( |
| 209 |
"_DEC", |
| 210 |
CodechalDbgBufferType::bufIqParams, |
| 211 |
CodechalDbgExtType::txt); |
| 212 |
|
| 213 |
if (m_debugInterface->DumpIsEnabled(CodechalDbgAttr::attrEnableFastDump)) |
| 214 |
{ |
| 215 |
MediaDebugFastDump::Dump( |
| 216 |
(uint8_t *)iqParams, |
| 217 |
fileName, |
| 218 |
sizeof(CODEC_VP8_IQ_MATRIX_PARAMS), |
| 219 |
0, |
| 220 |
MediaDebugSerializer<CODEC_VP8_IQ_MATRIX_PARAMS>()); |
| 221 |
} |
| 222 |
else |
| 223 |
{ |
| 224 |
DumpDecodeVp8IqParams(iqParams, fileName); |
| 225 |
} |
| 226 |
} |
| 227 |
|
| 228 |
return MOS_STATUS_SUCCESS; |
| 229 |
} |
| 230 |
|
| 231 |
MOS_STATUS Vp8Pipeline::DumpCoefProbBuffer(PMOS_RESOURCE m_resCoefProbBuffer) |
| 232 |
{ |
| 233 |
DECODE_FUNC_CALL(); |
| 234 |
|
| 235 |
if (m_resCoefProbBuffer == nullptr) |
| 236 |
{ |
| 237 |
return MOS_STATUS_SUCCESS; |
| 238 |
} |
| 239 |
|
| 240 |
if (m_debugInterface->DumpIsEnabled(CodechalDbgAttr::attrCoefProb)) |
| 241 |
{ |
| 242 |
DECODE_CHK_STATUS(m_debugInterface->DumpBuffer( |
| 243 |
m_resCoefProbBuffer, |
| 244 |
CodechalDbgAttr::attrCoefProb, |
| 245 |
"_DEC_CoefProb", |
| 246 |
m_basicFeature->m_coefProbSize)); |
| 247 |
} |
| 248 |
|
| 249 |
return MOS_STATUS_SUCCESS; |
| 250 |
} |
| 251 |
#endif |
| 252 |
|
| 253 |
} // namespace decode |