diff --git a/c2_components/src/mfx_c2_decoder_component.cpp b/c2_components/src/mfx_c2_decoder_component.cpp index 0ad2f3a1..55c79f1f 100755 --- a/c2_components/src/mfx_c2_decoder_component.cpp +++ b/c2_components/src/mfx_c2_decoder_component.cpp @@ -1814,27 +1814,9 @@ c2_status_t MfxC2DecoderComponent::AllocateC2Block(uint32_t width, uint32_t heig C2MemoryUsage mem_usage = {m_consumerUsage, C2AndroidMemoryUsage::HW_CODEC_WRITE}; res = m_c2Allocator->fetchGraphicBlock(width, height, MfxFourCCToGralloc(fourcc), mem_usage, out_block); - if (res == C2_OK) { - auto hndl_deleter = [](native_handle_t *hndl) { - native_handle_delete(hndl); - hndl = nullptr; - }; - - std::unique_ptr hndl( - android::UnwrapNativeCodec2GrallocHandle((*out_block)->handle()), hndl_deleter); - - uint64_t id; - if (C2_OK != MfxGrallocInstance::getInstance()->GetBackingStore(hndl.get(), &id)) - return C2_CORRUPTED; - if(!m_vppConversion) { - if (m_allocator && !m_allocator->InCache(id)) { - res = C2_BLOCKING; - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - // If always fetch a nocached block, check if width or height have changed - // compare to when it was initialized. - MFX_DEBUG_TRACE_STREAM("fetchGraphicBlock a nocached block, please retune output blocks. id = " << id); - } - } + if (res == C2_BLOCKING) { + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + MFX_DEBUG_TRACE_MSG("fetchGraphicBlock blocking, wait and try again"); } } else if (m_mfxVideoParams.IOPattern == MFX_IOPATTERN_OUT_SYSTEM_MEMORY) { C2MemoryUsage mem_usage = {m_consumerUsage, C2MemoryUsage::CPU_WRITE}; diff --git a/c2_utils/include/mfx_frame_pool_allocator.h b/c2_utils/include/mfx_frame_pool_allocator.h index 9785e2f5..ab579aac 100755 --- a/c2_utils/include/mfx_frame_pool_allocator.h +++ b/c2_utils/include/mfx_frame_pool_allocator.h @@ -29,7 +29,6 @@ class MfxFramePoolAllocator virtual void SetC2Allocator(std::shared_ptr c2_allocator) = 0; virtual std::shared_ptr Alloc() = 0; virtual void Reset() = 0; - virtual bool InCache(uint64_t id) = 0; virtual void SetBufferCount(unsigned int cnt) = 0; virtual void SetConsumerUsage(uint64_t usage) = 0; diff --git a/c2_utils/include/mfx_va_frame_pool_allocator.h b/c2_utils/include/mfx_va_frame_pool_allocator.h index 2ed43833..459728fd 100755 --- a/c2_utils/include/mfx_va_frame_pool_allocator.h +++ b/c2_utils/include/mfx_va_frame_pool_allocator.h @@ -62,8 +62,8 @@ class MfxVaFramePoolAllocator : public MfxVaFrameAllocator, public MfxFramePoolA { MFX_DEBUG_TRACE_FUNC; m_pool = std::make_unique>(); - m_cachedBufferId.clear(); } + virtual void SetBufferCount(unsigned int cnt) override { MFX_DEBUG_TRACE_FUNC; @@ -76,14 +76,6 @@ class MfxVaFramePoolAllocator : public MfxVaFrameAllocator, public MfxFramePoolA m_consumerUsage = usage; } - bool InCache(uint64_t id) { - auto it = m_cachedBufferId.find(id); - if (it == m_cachedBufferId.end()){ - return false; - } - - return true; - } private: virtual mfxStatus AllocFrames(mfxFrameAllocRequest *request, mfxFrameAllocResponse *response) override; @@ -96,8 +88,6 @@ class MfxVaFramePoolAllocator : public MfxVaFrameAllocator, public MfxFramePoolA std::unique_ptr> m_pool; - std::map m_cachedBufferId; - unsigned int m_uSuggestBufferCnt = 0; uint64_t m_consumerUsage = 0; diff --git a/c2_utils/src/mfx_va_frame_pool_allocator.cpp b/c2_utils/src/mfx_va_frame_pool_allocator.cpp index d8aae064..40eee4cb 100755 --- a/c2_utils/src/mfx_va_frame_pool_allocator.cpp +++ b/c2_utils/src/mfx_va_frame_pool_allocator.cpp @@ -50,6 +50,7 @@ mfxStatus MfxVaFramePoolAllocator::AllocFrames(mfxFrameAllocRequest *request, // buffers_count = output_delay_ + kSmoothnessFactor(4) + kRenderingDepth(3) int max_buffers = m_uSuggestBufferCnt + kSmoothnessFactor + kRenderingDepth; int min_buffers = MFX_MAX(request->NumFrameSuggested, MFX_MAX(request->NumFrameMin, 1)); + // int opt_buffers = min_buffers; int opt_buffers = max_buffers; // optimal buffer count for better performance if (max_buffers < request->NumFrameMin) return MFX_ERR_MEMORY_ALLOC; @@ -113,19 +114,7 @@ mfxStatus MfxVaFramePoolAllocator::AllocFrames(mfxFrameAllocRequest *request, } while(res == C2_BLOCKING); if (res != C2_OK || !new_block) break; - uint64_t id; native_handle_t *hndl = android::UnwrapNativeCodec2GrallocHandle(new_block->handle()); - if (C2_OK != MfxGrallocInstance::getInstance()->GetBackingStore(hndl, &id)) { - mfx_res = MFX_ERR_INVALID_HANDLE; - break; - } - - m_cachedBufferId.emplace(id, i); - // if (C2_OK != res) { //TODO dead code not need. - // native_handle_delete(hndl); - // mfx_res = MFX_ERR_MEMORY_ALLOC; - // break; - // } // deep copy to have unique_ptr as m_pool required unique_ptr std::unique_ptr unique_block = std::make_unique(*new_block);