| 1 |
/* |
| 2 |
* Copyright (c) 2017-2020, 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 |
//! |
| 24 |
//! \file codechal_debug_config_manager.cpp |
| 25 |
//! \brief Defines the dump configuration manager. |
| 26 |
//! \details The debug interface dumps configuration manager file which parse attributes. |
| 27 |
//! |
| 28 |
#include "codechal_debug_config_manager.h" |
| 29 |
#if USE_CODECHAL_DEBUG_TOOL |
| 30 |
|
| 31 |
CodecDebugConfigMgr::CodecDebugConfigMgr( |
| 32 |
CodechalDebugInterface *debugInterface, |
| 33 |
CODECHAL_FUNCTION codecFunction, |
| 34 |
std::string outputFolderPath) |
| 35 |
: MediaDebugConfigMgr(outputFolderPath), |
| 36 |
m_debugInterface(debugInterface), |
| 37 |
m_codecFunction(codecFunction) |
| 38 |
{ |
| 39 |
GetFunctionType(); |
| 40 |
} |
| 41 |
|
| 42 |
void CodecDebugConfigMgr::GetFunctionType() |
| 43 |
{ |
| 44 |
switch (m_codecFunction) |
| 45 |
{ |
| 46 |
case CODECHAL_FUNCTION_CENC_DECODE: |
| 47 |
m_mediaFunction = MEDIA_FUNCTION_CENC_DECODE; |
| 48 |
break; |
| 49 |
case CODECHAL_FUNCTION_DECODE: |
| 50 |
m_mediaFunction = MEDIA_FUNCTION_DECODE; |
| 51 |
break; |
| 52 |
case CODECHAL_FUNCTION_ENC: |
| 53 |
case CODECHAL_FUNCTION_PAK: |
| 54 |
case CODECHAL_FUNCTION_ENC_PAK: |
| 55 |
case CODECHAL_FUNCTION_HYBRIDPAK: |
| 56 |
case CODECHAL_FUNCTION_ENC_VDENC_PAK: |
| 57 |
case CODECHAL_FUNCTION_DEMO_COPY: |
| 58 |
case CODECHAL_FUNCTION_FEI_PRE_ENC: |
| 59 |
case CODECHAL_FUNCTION_FEI_ENC: |
| 60 |
case CODECHAL_FUNCTION_FEI_PAK: |
| 61 |
case CODECHAL_FUNCTION_FEI_ENC_PAK: |
| 62 |
m_mediaFunction = MEDIA_FUNCTION_ENCODE; |
| 63 |
break; |
| 64 |
default: |
| 65 |
m_mediaFunction = MEDIA_FUNCTION_DEFAULT; |
| 66 |
break; |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
std::string CodecDebugConfigMgr::InitFileName(MediaDbgFunction mediaFunction) |
| 71 |
{ |
| 72 |
return "CodecDbgSetting.cfg"; |
| 73 |
} |
| 74 |
|
| 75 |
MediaUserSettingSharedPtr CodecDebugConfigMgr::GetUserSettingInstance() |
| 76 |
{ |
| 77 |
return m_debugInterface->m_userSettingPtr; |
| 78 |
} |
| 79 |
|
| 80 |
CodecDebugConfigMgr::~CodecDebugConfigMgr() |
| 81 |
{ |
| 82 |
} |
| 83 |
|
| 84 |
uint32_t CodecDebugConfigMgr::GetDumpFrameNum() |
| 85 |
{ |
| 86 |
return (uint32_t)m_debugInterface->m_bufferDumpFrameNum; |
| 87 |
} |
| 88 |
|
| 89 |
std::string CodecDebugConfigMgr::GetMediaStateStr(CODECHAL_MEDIA_STATE_TYPE mediaState) |
| 90 |
{ |
| 91 |
CodechalDbgKernel::KernelStateMap::kernelMapType &kernelMap = CodechalDbgKernel::KernelStateMap::GetKernelStateMap(); |
| 92 |
auto it = kernelMap.find(mediaState); |
| 93 |
if (it != kernelMap.end()) |
| 94 |
{ |
| 95 |
return it->second; |
| 96 |
} |
| 97 |
|
| 98 |
return ""; |
| 99 |
} |
| 100 |
|
| 101 |
bool CodecDebugConfigMgr::AttrIsEnabled( |
| 102 |
CODECHAL_MEDIA_STATE_TYPE mediaState, |
| 103 |
std::string attrName) |
| 104 |
{ |
| 105 |
std::string kernelName = GetMediaStateStr(mediaState); |
| 106 |
if (kernelName.empty()) |
| 107 |
{ |
| 108 |
return false; |
| 109 |
} |
| 110 |
|
| 111 |
if (nullptr != m_debugAllConfigs) |
| 112 |
{ |
| 113 |
MediaKernelDumpConfig attrs = m_debugAllConfigs->kernelAttribs[kernelName]; |
| 114 |
bool enabled = KernelAttrEnabled(attrs, attrName); |
| 115 |
if (enabled) |
| 116 |
{ |
| 117 |
return enabled; |
| 118 |
} |
| 119 |
} |
| 120 |
|
| 121 |
for (auto it : m_debugFrameConfigs) |
| 122 |
{ |
| 123 |
if (it.frameIndex == GetDumpFrameNum()) |
| 124 |
{ |
| 125 |
MediaKernelDumpConfig attrs = it.kernelAttribs[kernelName]; |
| 126 |
return KernelAttrEnabled(attrs, attrName); |
| 127 |
} |
| 128 |
} |
| 129 |
return false; |
| 130 |
} |
| 131 |
|
| 132 |
bool CodecDebugConfigMgr::AttrIsEnabled(std::string attrName) |
| 133 |
{ |
| 134 |
if (nullptr != m_debugAllConfigs) |
| 135 |
{ |
| 136 |
int attrValue = m_debugAllConfigs->cmdAttribs[attrName]; |
| 137 |
if (attrValue > 0) |
| 138 |
{ |
| 139 |
return true; |
| 140 |
} |
| 141 |
} |
| 142 |
|
| 143 |
for (auto it : m_debugFrameConfigs) |
| 144 |
{ |
| 145 |
if (it.frameIndex == GetDumpFrameNum()) |
| 146 |
{ |
| 147 |
int attrValue = it.cmdAttribs[attrName]; |
| 148 |
return attrValue > 0; |
| 149 |
} |
| 150 |
} |
| 151 |
|
| 152 |
return false; |
| 153 |
} |
| 154 |
|
| 155 |
#endif // USE_CODECHAL_DEBUG_TOOL |
| 156 |
|