From e74a3ce334b52577081e14a1656f74ccb3f1ef69 Mon Sep 17 00:00:00 2001 From: gfxVPLsdm Date: Mon, 26 Dec 2022 14:15:15 +0800 Subject: [PATCH] Revert "[Decode] Enable delayed allocation of APP frames " (#4251) This reverts commit 607cf812f7c0b480aa202fc0706a062b6e13e5dc Co-authored-by: kaiyixix --- _studio/shared/include/libmfx_allocator.h | 7 +++-- _studio/shared/src/mfx_umc_alloc_wrapper.cpp | 29 +++----------------- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/_studio/shared/include/libmfx_allocator.h b/_studio/shared/include/libmfx_allocator.h index 4b7de5dbfe..2f986150ad 100644 --- a/_studio/shared/include/libmfx_allocator.h +++ b/_studio/shared/include/libmfx_allocator.h @@ -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; diff --git a/_studio/shared/src/mfx_umc_alloc_wrapper.cpp b/_studio/shared/src/mfx_umc_alloc_wrapper.cpp index db29a2d003..d494f99435 100644 --- a/_studio/shared/src/mfx_umc_alloc_wrapper.cpp +++ b/_studio/shared/src/mfx_umc_alloc_wrapper.cpp @@ -373,7 +373,7 @@ void mfx_UMC_FrameAllocator::SetExternalFramesResponse(mfxFrameAllocResponse *re { m_externalFramesResponse = 0; - if (!response) + if (!response || !response->NumFrameActual) return; m_externalFramesResponse = response; @@ -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; @@ -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);