目录
ChiMetadata
chiMetadata与metabuffer的调用关系
chiMetadata是通过pMetadataOps调用camx中metabuffer的函数。
pMetadataOps的赋值:
chxmetadata.cpp ExtensionModule::GetInstance()→GetMetadataOps(pMetadataOps);
Chxextensionmodule.cpp g_chiContextOps.pMetadataOps(pMetadataOps);
camxchi.cpp ChiEntry(ChiContextOps* pChiContextOps)中加载了这些接口 pChiContextOps->pMetadataOps = CamX::ChiGetMetadataOps;
ChiMetadata的成员变量
ChiMetadata是对Metabuffer的封装, chimetabuffer中有一个指向MetaBuffer的指针. 在chi模块使用的Chimetadata. camx中使用Metabuffer
ChiMetadata的成员函数解析
(1)创建ChiMetadata
static ChiMetadata* Create( const UINT32* pTagList = NULL, UINT32 tagCount = 0, bool useDefaultFrameworkKeys = false, ChiMetadataManager* pManager = NULL, UINT logicalCameraId = InvalidCameraId);
参数: pTagList 预分配内存的taglist
tagCount 预分配内存的tag总数
useDefaultFrameworkKeys 是否使用默认的Tag
pManager 该chimetadata所属的metadata manager
logicalCameraId 该chimetadata所属的logical camera id
作用:创建一个chimetadata对象,然后创建一个metabuffer对象存到m_metaHandle中
返回:chimetadata的指针
ChiMetadata* ChiMetadata::Create(const UINT32* pTagList, UINT32 tagCount, bool useDefaultKeys, ChiMetadataManager* pManager, UINT logicalCameraId)
{
ChiMetadata* pMetadata = CHX_NEW ChiMetadata;
pMetadata->m_pManager = pManager;
InitializeMetadataOps(&pMetadata->m_metadataOps); //初始化m_metadataOps操作
pMetadata->m_metadataManagerClientId = ChiMetadataManager::InvalidClientId;
pMetadata->m_logicalCameraId = logicalCameraId;
//使用默认的tag集合
if ((NULL == pTagList) && useDefaultKeys)
{
tagList.resize(ChxMaxRequestKeys); // ChxMaxRequestKeys = 100
ExtensionModule::GetInstance()->GetAvailableRequestKeys(0, tagList.data(), tagList.size(), &tagCount); //获取ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS tag中存的默认的 default keys(82个)
pTagList = tagList.data();
}
result = pMetadata->Initialize(pTagList, tagCount);
return pMetadata;
}
//useContextMeta默认为TRUE
CDKResult ChiMetadata::Initialize(const UINT32* pTagList, UINT32 tagCount, BOOL useContextMeta)
{
ChiCMBCreateParams createParams = {};
createParams.useExpContextMeta = (TRUE == useContextMeta) || (TRUE == ExtensionModule::GetInstance()->EnableMFHDR(m_logicalCameraId));
if ((NULL != pTagList) && (0 < tagCount))
{
result = m_metadataOps.pCreateWithTagArray(pTagList, tagCount, &m_metaHandle, this, &createParams);//创建一个新的metabuffer,并给pTagList中的tag分配内存,然后存到m_metaHandle中
}
else
{
result = m_metadataOps.pCreate(&m_metaHandle, this, &createParams);创建一个新的metabuffer,不分配额外的内存(memory region),然后存到m_metaHandle中
}
for (UINT32 index = 0; index < MaxChiMetaClients; ++index)
{
m_clientName[index] = NULL;
}
}
//m_metadataOps.pCreateWithTagArray
static CDKResult ChiMetabufferCreateWithTaglist(const UINT32* pTagList, UINT32 tagListCount, CHIMETAHANDLE* phMetaHandle, CHIMETAPRIVATEDATA pPrivateData, CHICMBCREATEPARAMS* pCMBParams)
{
if ((NULL != phMetaHandle) && (NULL != pTagList) && (0 < tagListCount))
{
MetaBuffer* pMetaBuffer = MetaBuffer::Create(pPrivateData, pCMBParams); //创建一个metabuffer
if (NULL != pMetaBuffer)
{
result = pMetaBuffer->AllocateBuffer(pTagList, tagListCount); //给tagList中的外置tag分配内存
if (CamxResultSuccess == result)
{
*phMetaHandle = pMetaBuffer;
result = CDKResultSuccess;
}
else
{
pMetaBuffer->Destroy();
}
}
}
}
//m_metadataOps.pCreate
static CDKResult ChiMetabufferCreate( CHIMETAHANDLE* phMetaHandle, CHIMETAPRIVATEDATA pPrivateData, CHICMBCREATEPARAMS* pCMBParams)
{
if (NULL != phMetaHandle)
{
MetaBuffer* pMetaBuffer = MetaBuffer::Create(pPrivateData, pCMBParams); //创建一个metabuffer,没有分配额外的空间
if (NULL != pMetaBuffer)
{
*phMetaHandle = pMetaBuffer;
}
}
}
(2)TranslateToCameraPartialMetadata & TranslateToCameraMetadata
CDKResult ChiMetadata::TranslateToCameraPartialMetadata(camera_metadata* pDstCameraMetadata, UINT32* pPartial, UINT32 partialCount)
参数: pDstCameraMetadata 是返回给framework的 Andriod camera
pPartial 要更新的tag数组
partialCount 要更新的tag总数
作用:将pPartial tag从chiMetadata中更新到pDstCameraMetadata
CDKResult TranslateToCameraMetadata(camera_metadata* pDstCameraMetadata, bool frameworkTagsOnly = true,bool filterProperties = true, UINT32 filterTagCount = 0, UINT32* pFilterTagArray = NULL);
参数: pDstCameraMetadata 是返回给framework的 Andriod camera
frameworkTagsOnly 是否只更新 visiblity为TagSectionVisibleToFramework的tag
filterProperties 是否更新property, filterProperties为true时,不更新
filterTagCount 不更新的tag总数
pFilterTagArray 不更新的tag数组
作用:将除了pFilterTagArray之外的其他tag, 从chiMetadata中更新到pDstCameraMetadata
例如:
Chxadvancedcamerausecase.cpp (vendor\qcom\proprietary\chi-cdk\core\chiusecase)
pChiOutputMetadata→TranslateToCameraMetadata(m_batchFrameworkOutput, TRUE, TRUE, partialTagCount, pPartialTagList);
Chxmulticamerabase.cpp (vendor\qcom\proprietary\chi-cdk\core\chiframework)
pChiMetadata->TranslateToCameraMetadata(pFrameworkOutput, TRUE, !m_pUseCase→IsReprocessUsecase());
pChiMetadata->TranslateToCameraPartialMetadata(pFrameworkOutput, pPartialTagList, partialTagCount);
//将pPartial tag从chiMetadata中更新到pDstCameraMetadata
CDKResult ChiMetadata::TranslateToCameraPartialMetadata(camera_metadata* pDstCameraMetadata, UINT32* pPartial, UINT32 partialCount)
{
std::unordered_set::iterator
标签:pTagList,pMetaBuffer,ChiMetadataManager,ChiMetadata,tag,&&,NULL,UINT32
From: https://blog.csdn.net/weixin_39732855/article/details/139446498