Skip to content

Commit

Permalink
Revert "[Decode] Enable delayed allocation of APP frames " (#4251)
Browse files Browse the repository at this point in the history
This reverts commit 607cf81

Co-authored-by: kaiyixix <[email protected]>
  • Loading branch information
gfxVPLsdm and kaiyixix authored Dec 26, 2022
1 parent e210283 commit e74a3ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 27 deletions.
7 changes: 5 additions & 2 deletions _studio/shared/include/libmfx_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,11 @@ class FrameAllocatorWrapper

MFX_SAFE_CALL(allocator_ext->Alloc(request, response));

if (response.NumFrameActual == 0)
return MFX_ERR_NONE;
if (response.NumFrameActual < request.NumFrameMin)
{
std::ignore = MFX_STS_TRACE(allocator_ext->Free(response));
MFX_RETURN(MFX_ERR_MEMORY_ALLOC);
}

CacheMids(response, *allocator_ext);
return MFX_ERR_NONE;
Expand Down
29 changes: 4 additions & 25 deletions _studio/shared/src/mfx_umc_alloc_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ void mfx_UMC_FrameAllocator::SetExternalFramesResponse(mfxFrameAllocResponse *re
{
m_externalFramesResponse = 0;

if (!response)
if (!response || !response->NumFrameActual)
return;

m_externalFramesResponse = response;
Expand Down Expand Up @@ -775,31 +775,8 @@ mfxStatus mfx_UMC_FrameAllocator::SetCurrentMFXSurface(mfxFrameSurface1 *surf)
}
}

// in delay allocate mode, the m_externalFramesResponse->mids maybe not filled in the MFXInit
// surface will be added into m_frameDataInternal on the fly
if (!isFound)
{
for (mfxU32 i = 0; i < m_frameDataInternal.GetSize(); i++)
{
auto internal_surf = m_frameDataInternal.GetSurface(i);
if (internal_surf.Data.MemId == surf->Data.MemId)
{
isFound = true;
break;
}
}
}
// add the new APP surface on the fly
if (!isFound)
{
mfxFrameSurface1 * surface = new mfxFrameSurface1();
surface->Data.MemId = surf->Data.MemId;
surface->Data.MemType = surf->Data.MemType;
surface->Info = surf->Info;

m_frameDataInternal.AddNewFrame(this, surface, &m_info);
m_extSurfaces.push_back(surf_descr(surf, false));
}
return MFX_ERR_UNDEFINED_BEHAVIOR;
}

m_curIndex = -1;
Expand Down Expand Up @@ -1304,6 +1281,8 @@ SurfaceSource::SurfaceSource(VideoCORE* core, const mfxVideoParam& video_param,
// allocates internal surfaces:
if (useInternal)
{
m_response_alien = m_response;
m_umc_allocator_adapter->SetExternalFramesResponse(&m_response_alien);
request = request_internal;
bool useSystem = needVppJPEG ? video_param.IOPattern & MFX_IOPATTERN_OUT_SYSTEM_MEMORY : true;
mfxSts = m_core->AllocFrames(&request_internal, &m_response, useSystem);
Expand Down

0 comments on commit e74a3ce

Please sign in to comment.