| 1 |
/* |
| 2 |
* Copyright (c) 2018-2025, 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 media_feature_manager.cpp |
| 25 |
//! \brief Defines the common interface for media feature manager |
| 26 |
//! \details The encode feature manager is further sub-divided by codec type |
| 27 |
//! this file is for the base interface which is shared by all components. |
| 28 |
//! |
| 29 |
|
| 30 |
#include "media_feature_manager.h" |
| 31 |
#include "media_feature.h" |
| 32 |
#include "mos_utilities.h" |
| 33 |
|
| 34 |
MOS_STATUS MediaFeatureManager::RegisterFeatures( |
| 35 |
int featureID, |
| 36 |
MediaFeature * feature, |
| 37 |
std::vector<int> &&packetIds, |
| 38 |
LIST_TYPE packetIdListType) |
| 39 |
{ |
| 40 |
MEDIA_FUNC_CALL(); |
| 41 |
MEDIA_CHK_NULL_RETURN(feature); |
| 42 |
|
| 43 |
auto iter = m_features.find(featureID); |
| 44 |
if (iter == m_features.end()) |
| 45 |
{ |
| 46 |
m_features.insert(std::make_pair(featureID, feature)); |
| 47 |
} |
| 48 |
else |
| 49 |
{ |
| 50 |
MEDIA_NORMALMESSAGE("This feature already exist, will replay it with the new one!"); |
| 51 |
if (iter->second != nullptr) |
| 52 |
{ |
| 53 |
MOS_Delete(iter->second); |
| 54 |
}; |
| 55 |
iter->second = feature; |
| 56 |
} |
| 57 |
m_packetIdList[featureID] = std::move(packetIds); |
| 58 |
m_packetIdListTypes[featureID] = packetIdListType; |
| 59 |
|
| 60 |
return MOS_STATUS_SUCCESS; |
| 61 |
} |
| 62 |
|
| 63 |
std::shared_ptr<MediaFeatureManager::ManagerLite> MediaFeatureManager::GetPacketLevelFeatureManager(int packetId) |
| 64 |
{ |
| 65 |
MEDIA_FUNC_CALL(); |
| 66 |
|
| 67 |
auto manager = std::make_shared<ManagerLite>(); |
| 68 |
|
| 69 |
for (const auto &e : m_features) |
| 70 |
{ |
| 71 |
const auto &packetIds = m_packetIdList.at(e.first); |
| 72 |
bool blockList = m_packetIdListTypes.at(e.first) == LIST_TYPE::BLOCK_LIST; |
| 73 |
|
| 74 |
// Default value if packetId is not in feature's packet ID vector. |
| 75 |
// For block list, feature is by default allowed if it's not in the list. |
| 76 |
// For allow list, feature is by default blocked if it's not in the list. |
| 77 |
bool blocked = !blockList; |
| 78 |
|
| 79 |
for (auto id : packetIds) |
| 80 |
{ |
| 81 |
if (blockList && id == packetId) |
| 82 |
{ |
| 83 |
blocked = true; |
| 84 |
break; |
| 85 |
} |
| 86 |
else if (!blockList && id == packetId) |
| 87 |
{ |
| 88 |
blocked = false; |
| 89 |
break; |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
if (!blocked) |
| 94 |
{ |
| 95 |
manager->m_features[e.first] = e.second; |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
return manager; |
| 100 |
} |
| 101 |
|
| 102 |
MOS_STATUS MediaFeatureManager::Update(void *params) |
| 103 |
{ |
| 104 |
MEDIA_FUNC_CALL(); |
| 105 |
for (auto feature=m_features.begin(); feature!=m_features.end(); feature++) |
| 106 |
{ |
| 107 |
MEDIA_CHK_STATUS_RETURN(feature->second->Update(params)); |
| 108 |
} |
| 109 |
return MOS_STATUS_SUCCESS; |
| 110 |
} |
| 111 |
|
| 112 |
MOS_STATUS MediaFeatureManager::Destroy() |
| 113 |
{ |
| 114 |
MEDIA_FUNC_CALL(); |
| 115 |
for (auto feature=m_features.begin(); feature!=m_features.end(); feature++) |
| 116 |
{ |
| 117 |
if (feature->second != nullptr) |
| 118 |
{ |
| 119 |
MOS_Delete(feature->second); |
| 120 |
}; |
| 121 |
} |
| 122 |
m_features.clear(); |
| 123 |
|
| 124 |
if (m_featureConstSettings != nullptr) |
| 125 |
{ |
| 126 |
MOS_Delete(m_featureConstSettings); |
| 127 |
} |
| 128 |
return MOS_STATUS_SUCCESS; |
| 129 |
} |
| 130 |
|
| 131 |
void MediaFeatureManager::SetUserSettingPtr(MediaUserSettingSharedPtr userSettingPtr) |
| 132 |
{ |
| 133 |
m_userSettingPtr = userSettingPtr; //!< usersettingInstance |
| 134 |
} |