Skip to content

Commit

Permalink
[VP, HAL] Replace to emplace C++11 for code refactor and optimize ins…
Browse files Browse the repository at this point in the history
…erts
  • Loading branch information
GermanAizek committed Nov 4, 2024
1 parent b6b411f commit c95e85f
Show file tree
Hide file tree
Showing 36 changed files with 177 additions and 181 deletions.
10 changes: 4 additions & 6 deletions media_common/agnostic/common/shared/media_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,17 @@ class MediaFactory
Iterator creator = creators.find(key);
if (creator == creators.end())
{
std::pair<Iterator, bool> result =
creators.insert(std::make_pair(key, Create<C>));
sizes.insert(std::make_pair(key, (uint32_t)sizeof(C)));
placecreators.insert(std::make_pair(key, PlaceCreate<C>));
std::pair<Iterator, bool> result = creators.emplace(key, Create<C>);
sizes.emplace(key, (uint32_t)sizeof(C));
placecreators.emplace(key, PlaceCreate<C>);
return result.second;
}
else
{
if (forceReplace)
{
creators.erase(creator);
std::pair<Iterator, bool> result =
creators.insert(std::make_pair(key, Create<C>));
std::pair<Iterator, bool> result = creators.emplace(key, Create<C>);
return result.second;
}
return true; //If it is registered, do nothing then return true.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ MOS_STATUS CodechalKernelBase::CreateKernelState(
CODECHAL_ENCODE_CHK_NULL_RETURN(m_kernelBinary);

CODECHAL_ENCODE_CHK_NULL_RETURN((*kernelState) = MOS_New(MHW_KERNEL_STATE));
m_kernelStatePool.insert(std::make_pair(kernelIndex, *kernelState));
m_kernelStatePool.emplace(kernelIndex, *kernelState);

CODECHAL_KERNEL_HEADER kernelHeader = {};
uint32_t kernelSize = 0;
Expand Down Expand Up @@ -319,7 +319,7 @@ MOS_STATUS CodechalKernelBase::AllocateSurface(PMOS_ALLOC_GFXRES_PARAMS param, P
{
CODECHAL_ENCODE_CHK_NULL_RETURN(param);
CODECHAL_ENCODE_CHK_NULL_RETURN(surface);
m_surfacePool.insert(std::make_pair(surfaceId, surface));
m_surfacePool.emplace(surfaceId, surface);

CODECHAL_ENCODE_CHK_STATUS_RETURN(
m_osInterface->pfnAllocateResource(
Expand Down
4 changes: 2 additions & 2 deletions media_driver/agnostic/common/os/mos_util_user_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ MOS_STATUS MosUtilUserInterface::AddEntry(const uint32_t keyId, PMOS_USER_FEATUR

if (result == m_userFeatureKeyMap.end())
{
m_userFeatureKeyMap.insert(std::make_pair(keyId, userFeatureKey));
m_userFeatureKeyMap.emplace(keyId, userFeatureKey);
}
else
{
MOS_OS_NORMALMESSAGE("User feature key already exist, replacing the old one.");
m_userFeatureKeyMap.erase(keyId);
m_userFeatureKeyMap.insert(std::make_pair(keyId, userFeatureKey));
m_userFeatureKeyMap.emplace(keyId, userFeatureKey);
m_mosMutex.Unlock();
return MOS_STATUS_SUCCESS;
}
Expand Down
3 changes: 1 addition & 2 deletions media_driver/linux/common/ddi/media_ddi_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ class MediaDdiFactoryNoArg
template <class C>
static bool RegisterCodec(const KeyType &key)
{
std::pair<iterator, bool> result =
GetCreators().insert(std::make_pair(key, create<C>));
std::pair<iterator, bool> result = GetCreators().emplace(key, create<C>);

return result.second;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ MOS_STATUS DecodeSubPacketManager::Register(uint32_t packetId, DecodeSubPacket&
auto iter = m_subPacketList.find(packetId);
DECODE_CHK_COND(iter != m_subPacketList.end(), "Failed to register sub packet %d", packetId);

m_subPacketList.insert(std::make_pair(packetId, &subPacket));
m_subPacketList.emplace(packetId, &subPacket);
return MOS_STATUS_SUCCESS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ MOS_STATUS DecodeSubPipeline::RegisterPacket(uint32_t packetId, MediaPacket& pac
auto iter = m_packetList.find(packetId);
if (iter == m_packetList.end())
{
m_packetList.insert(std::make_pair(packetId, &packet));
m_packetList.emplace(packetId, &packet);
}

return MOS_STATUS_SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ MOS_STATUS RecycleResource::RegisterResource(
return MOS_STATUS_CLIENT_AR_NO_SPACE;
}

m_resourceQueues.insert(std::make_pair(id, que));
m_resourceQueues.emplace(id, que);

return MOS_STATUS_SUCCESS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ MOS_STATUS TrackedBuffer::RegisterParam(BufferType type, MOS_ALLOC_GFXRES_PARAMS
auto iter = m_allocParams.find(type);
if (iter == m_allocParams.end())
{
m_allocParams.insert(std::make_pair(type, param));
m_allocParams.emplace(type, param);
}
else
{
Expand Down Expand Up @@ -279,7 +279,7 @@ std::shared_ptr<BufferQueue> TrackedBuffer::GetBufferQueue(BufferType type)

auto alloc = std::make_shared<BufferQueue>(m_allocator, param->second, m_maxSlotCnt);
alloc->SetResourceType(resType);
m_bufferQueue.insert(std::make_pair(type, alloc));
m_bufferQueue.emplace(type, alloc);
return alloc;
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ class DeviceInfoFactory
//!
static bool RegisterDevice(KeyType key, Type value)
{
std::pair<iterator, bool> result =
GetCreators().insert(std::make_pair(key, value));
std::pair<iterator, bool> result = GetCreators().emplace(key, value);

return result.second;
}
Expand Down
2 changes: 1 addition & 1 deletion media_softlet/agnostic/common/os/mos_oca_rtlog_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ MOS_STATUS MosOcaRTLogMgr::RegisterRes(OsContextNext *osDriverContext, MOS_OCA_R
MOS_OS_CHK_STATUS_RETURN(status);
}
s_ocaMutex.Lock();
m_resMap.insert(std::make_pair(osDriverContext, *resInterface));
m_resMap.emplace(osDriverContext, *resInterface);
s_ocaMutex.Unlock();
osDriverContext->SetRtLogRes(resInterface->ocaRTLogResource);
return MOS_STATUS_SUCCESS;
Expand Down
2 changes: 1 addition & 1 deletion media_softlet/agnostic/common/renderhal/renderhal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6791,7 +6791,7 @@ MOS_STATUS RenderHal_SetAndGetSamplerStates(
break;
}

samplerMap.insert(std::make_pair(i, stateOffsets));
samplerMap.emplace(i, stateOffsets);

if (MOS_FAILED(eStatus))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ MOS_STATUS MediaPipeline::RegisterPacket(uint32_t packetId, MediaPacket *packet)
{
m_packetList.erase(iter);
}
m_packetList.insert(std::make_pair(packetId, packet));
m_packetList.emplace(packetId, packet);

return MOS_STATUS_SUCCESS;
}
Expand Down Expand Up @@ -257,7 +257,7 @@ MediaTask *MediaPipeline::CreateTask(MediaTask::TaskType type)
}
if (nullptr != task)
{
m_taskList.insert(std::make_pair(type, task));
m_taskList.emplace(type, task);
}
return task;
}
Expand Down
4 changes: 2 additions & 2 deletions media_softlet/agnostic/common/vp/cm_fc_ld/PatchInfoReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,9 @@ bool PatchInfoReader::readSymbolTableSection(cm::patch::Collection &C,
S->setExtra(Sym[i].SymExtra);
}
// Assume there's just one symbol table section per patch info.
SymbolTable.insert(std::make_pair(i, S));
SymbolTable.emplace(i, S);
}
SymbolTableSectionMap.insert(std::make_pair(n, true));
SymbolTableSectionMap.emplace(n, true);

return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ class Collection {
return I->second;
Symbols.push_back(Symbol(Name, 0, nullptr, 0));
Symbol *S = &Symbols.back();
SymbolMap.insert(std::make_pair(Name, S));
SymbolMap.emplace(Name, S);
return S;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ MOS_STATUS VphdrResourceManager::AssignRenderResource(VP_EXECUTE_CAPS &caps, std
MOS_HW_RESOURCE_USAGE_VP_INTERNAL_READ_RENDER));

surfSetting.coeffAllocated = allocated;
surfSetting.surfGroup.insert(std::make_pair(SurfaceTypeHdrCoeff, m_hdrCoeff));
surfSetting.surfGroup.emplace(SurfaceTypeHdrCoeff, m_hdrCoeff);

// Allocate auto mode CSC CCM Coeff Surface
VP_PUBLIC_CHK_STATUS_RETURN(m_allocator.ReAllocateSurface(
Expand All @@ -106,7 +106,7 @@ MOS_STATUS VphdrResourceManager::AssignRenderResource(VP_EXECUTE_CAPS &caps, std
deferredDestroyed,
MOS_HW_RESOURCE_USAGE_VP_INTERNAL_READ_RENDER));

surfSetting.surfGroup.insert(std::make_pair(SurfaceTypeHdrAutoModeCoeff, m_hdrAutoModeCoeffSurface));
surfSetting.surfGroup.emplace(SurfaceTypeHdrAutoModeCoeff, m_hdrAutoModeCoeffSurface);

// Allocate auto mode iir temp Surface
dwWidth = VPHAL_HDR_AUTO_MODE_IIR_TEMP_SIZE;
Expand All @@ -127,7 +127,7 @@ MOS_STATUS VphdrResourceManager::AssignRenderResource(VP_EXECUTE_CAPS &caps, std
deferredDestroyed,
MOS_HW_RESOURCE_USAGE_VP_INTERNAL_READ_RENDER));

surfSetting.surfGroup.insert(std::make_pair(SurfaceTypeHdrAutoModeIirTempSurface, m_hdrAutoModeIirTempSurface));
surfSetting.surfGroup.emplace(SurfaceTypeHdrAutoModeIirTempSurface, m_hdrAutoModeIirTempSurface);

// Allocate OETF 1D LUT Surface
dwWidth = VPHAL_HDR_OETF_1DLUT_WIDTH;
Expand All @@ -136,7 +136,7 @@ MOS_STATUS VphdrResourceManager::AssignRenderResource(VP_EXECUTE_CAPS &caps, std
size_t cnt = MOS_MIN(inputSurfaces.size(), VPHAL_MAX_HDR_INPUT_LAYER);
for (size_t i = 0; i < cnt; ++i)
{
surfSetting.surfGroup.insert(std::make_pair((SurfaceType)(SurfaceTypeHdrInputLayer0 + i), inputSurfaces[i]));
surfSetting.surfGroup.emplace((SurfaceType)(SurfaceTypeHdrInputLayer0 + i), inputSurfaces[i]);

SwFilterHdr *hdr = dynamic_cast<SwFilterHdr *>(executedFilters.GetSwFilter(true, i, FeatureType::FeatureTypeHdrOnRender));
FeatureParamHdr params = {};
Expand Down Expand Up @@ -170,7 +170,7 @@ MOS_STATUS VphdrResourceManager::AssignRenderResource(VP_EXECUTE_CAPS &caps, std
MOS_HW_RESOURCE_USAGE_VP_INTERNAL_READ_RENDER));

surfSetting.OETF1DLUTAllocated = allocated;
surfSetting.surfGroup.insert(std::make_pair((SurfaceType)(SurfaceTypeHdrOETF1DLUTSurface0 + i), m_hdrOETF1DLUTSurface[i]));
surfSetting.surfGroup.emplace((SurfaceType)(SurfaceTypeHdrOETF1DLUTSurface0 + i), m_hdrOETF1DLUTSurface[i]);
}

dwWidth = dwHeight = dwDepth = VPHAL_HDR_CRI_3DLUT_SIZE;
Expand Down Expand Up @@ -208,10 +208,10 @@ MOS_STATUS VphdrResourceManager::AssignRenderResource(VP_EXECUTE_CAPS &caps, std
dwDepth));

surfSetting.Cri3DLUTAllocated = allocated;
surfSetting.surfGroup.insert(std::make_pair((SurfaceType)(SurfaceTypeHdrCRI3DLUTSurface0 + i), m_hdrCri3DLUTSurface[i]));
surfSetting.surfGroup.emplace((SurfaceType)(SurfaceTypeHdrCRI3DLUTSurface0 + i), m_hdrCri3DLUTSurface[i]);
}

surfSetting.surfGroup.insert(std::make_pair(SurfaceTypeHdrTarget0, outputSurface));
surfSetting.surfGroup.emplace(SurfaceTypeHdrTarget0, outputSurface);
surfSetting.dumpPostSurface = false;
reporting.GetFeatures().hdrMode = params.hdrMode;

Expand Down
Loading

0 comments on commit c95e85f

Please sign in to comment.