| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
#ifndef __MEDIA_FEATURE_MANAGER_H__ |
| 31 |
#define __MEDIA_FEATURE_MANAGER_H__ |
| 32 |
#include <vector> |
| 33 |
#include <stdint.h> |
| 34 |
#include <map> |
| 35 |
#include <memory> |
| 36 |
#include <utility> |
| 37 |
#include "media_user_setting.h" |
| 38 |
#include "media_utils.h" |
| 39 |
#include "mos_defs.h" |
| 40 |
#include "media_feature_const_settings.h" |
| 41 |
|
| 42 |
#define CONSTRUCTFEATUREID(_componentID, _subComponentID, _featureID) \ |
| 43 |
(_componentID << 24 | _subComponentID << 16 | _featureID) |
| 44 |
|
| 45 |
enum ComponentIDs |
| 46 |
{ |
| 47 |
FEATURE_COMPONENT_COMMON = 0, |
| 48 |
FEATURE_COMPONENT_ENCODE, |
| 49 |
FEATURE_COMPONENT_DECODE, |
| 50 |
FEATURE_COMPONENT_VP, |
| 51 |
FEATURE_COMPONENT_OTHER |
| 52 |
}; |
| 53 |
|
| 54 |
enum SubComponentIDs |
| 55 |
{ |
| 56 |
FEATURE_SUBCOMPONENT_COMMON = 0, |
| 57 |
FEATURE_SUBCOMPONENT_HEVC, |
| 58 |
FEATURE_SUBCOMPONENT_VP9, |
| 59 |
FEATURE_SUBCOMPONENT_AVC, |
| 60 |
FEATURE_SUBCOMPONENT_AV1, |
| 61 |
FEATURE_SUBCOMPONENT_JPEG |
| 62 |
}; |
| 63 |
|
| 64 |
struct FeatureIDs |
| 65 |
{ |
| 66 |
enum CommonFeatureIDs |
| 67 |
{ |
| 68 |
basicFeature = CONSTRUCTFEATUREID(FEATURE_COMPONENT_COMMON, FEATURE_SUBCOMPONENT_COMMON, 0), |
| 69 |
encodeTile, |
| 70 |
preEncFeature, |
| 71 |
saliencyFeature, |
| 72 |
}; |
| 73 |
}; |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
#define RUN_FEATURE_INTERFACE_RETURN(_featureClassName, _featureID, _featureInterface, ...) \ |
| 79 |
{ \ |
| 80 |
if(m_featureManager){ \ |
| 81 |
auto feature = static_cast<_featureClassName*>(m_featureManager->GetFeature(_featureID)); \ |
| 82 |
if (feature) \ |
| 83 |
{ \ |
| 84 |
MEDIA_CHK_STATUS_RETURN(feature->_featureInterface(__VA_ARGS__)); \ |
| 85 |
} \ |
| 86 |
} \ |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
#define RUN_FEATURE_INTERFACE_NO_RETURN(_featureClassName, _featureID, _featureInterface, ...) \ |
| 94 |
{ \ |
| 95 |
if(m_featureManager){ \ |
| 96 |
auto feature = static_cast<_featureClassName*>(m_featureManager->GetFeature(_featureID)); \ |
| 97 |
if (feature) \ |
| 98 |
{ \ |
| 99 |
feature->_featureInterface(__VA_ARGS__); \ |
| 100 |
} \ |
| 101 |
} \ |
| 102 |
} |
| 103 |
|
| 104 |
class MediaFeature; |
| 105 |
|
| 106 |
enum class LIST_TYPE |
| 107 |
{ |
| 108 |
BLOCK_LIST, |
| 109 |
ALLOW_LIST, |
| 110 |
}; |
| 111 |
|
| 112 |
class MediaFeatureManager |
| 113 |
{ |
| 114 |
protected: |
| 115 |
using container_t = std::map<int, MediaFeature *>; |
| 116 |
|
| 117 |
public: |
| 118 |
class ManagerLite final |
| 119 |
{ |
| 120 |
friend class MediaFeatureManager; |
| 121 |
|
| 122 |
public: |
| 123 |
class iterator : public container_t::iterator |
| 124 |
{ |
| 125 |
public: |
| 126 |
explicit iterator(container_t::iterator it) : container_t::iterator(it) {} |
| 127 |
|
| 128 |
container_t::mapped_type operator*() { return (*this)->second; } |
| 129 |
}; |
| 130 |
|
| 131 |
ManagerLite() = default; |
| 132 |
|
| 133 |
iterator begin() { return iterator(m_features.begin()); } |
| 134 |
|
| 135 |
iterator end() { return iterator(m_features.end()); } |
| 136 |
|
| 137 |
MediaFeature *GetFeature(int featureID) |
| 138 |
{ |
| 139 |
auto iter = m_features.find(featureID); |
| 140 |
if (iter == m_features.end()) |
| 141 |
{ |
| 142 |
return nullptr; |
| 143 |
} |
| 144 |
return iter->second; |
| 145 |
} |
| 146 |
|
| 147 |
private: |
| 148 |
container_t m_features; |
| 149 |
}; |
| 150 |
|
| 151 |
public: |
| 152 |
class iterator : public container_t::iterator |
| 153 |
{ |
| 154 |
public: |
| 155 |
explicit iterator(container_t::iterator it) : container_t::iterator(it) {} |
| 156 |
|
| 157 |
container_t::mapped_type operator*() { return (*this)->second; } |
| 158 |
}; |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
MediaFeatureManager(){}; |
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
virtual ~MediaFeatureManager() { Destroy(); } |
| 169 |
|
| 170 |
iterator begin() { return iterator(m_features.begin()); } |
| 171 |
|
| 172 |
iterator end() { return iterator(m_features.end()); } |
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
virtual MOS_STATUS Init(void *settings) { return MOS_STATUS_UNIMPLEMENTED; } |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
MOS_STATUS RegisterFeatures( |
| 203 |
int featureID, |
| 204 |
MediaFeature * feature, |
| 205 |
std::vector<int> &&packetIds = {}, |
| 206 |
LIST_TYPE packetIdListType = LIST_TYPE::BLOCK_LIST); |
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
std::shared_ptr<ManagerLite> GetPacketLevelFeatureManager(int packetId); |
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
MOS_STATUS Update(void *params); |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
MOS_STATUS Destroy(); |
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
virtual MediaFeature *GetFeature(int featureID) |
| 241 |
{ |
| 242 |
auto iter = m_features.find(featureID); |
| 243 |
if (iter == m_features.end()) |
| 244 |
{ |
| 245 |
return nullptr; |
| 246 |
} |
| 247 |
return iter->second; |
| 248 |
} |
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
uint8_t GetNumPass() { return m_passNum; }; |
| 255 |
MediaFeatureConstSettings *GetFeatureSettings() { return m_featureConstSettings; }; |
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
virtual MOS_STATUS CheckFeatures(void *params) { return MOS_STATUS_SUCCESS; }; |
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
uint8_t GetDDITargetUsage(){return m_ddiTargetUsage;} |
| 271 |
void SetUserSettingPtr(MediaUserSettingSharedPtr userSettingPtr); |
| 272 |
|
| 273 |
protected: |
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
virtual MOS_STATUS CreateConstSettings() { return MOS_STATUS_SUCCESS; }; |
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
virtual MOS_STATUS CreateFeatures(void *constSettings) { return MOS_STATUS_SUCCESS; }; |
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
uint8_t GetTargetUsage(){return m_targetUsage;} |
| 297 |
|
| 298 |
container_t m_features; |
| 299 |
std::map<int, std::vector<int>> m_packetIdList; |
| 300 |
std::map<int, LIST_TYPE> m_packetIdListTypes; |
| 301 |
MediaFeatureConstSettings *m_featureConstSettings = nullptr; |
| 302 |
uint8_t m_ddiTargetUsage = 0; |
| 303 |
uint8_t m_targetUsage = 0; |
| 304 |
uint8_t m_passNum = 1; |
| 305 |
uint8_t m_forceTargetUsage = 0; |
| 306 |
|
| 307 |
|
| 308 |
MediaUserSettingSharedPtr m_userSettingPtr = nullptr; |
| 309 |
MEDIA_CLASS_DEFINE_END(MediaFeatureManager) |
| 310 |
}; |
| 311 |
|
| 312 |
#endif |