From 4ef6d7ce69e2f195ba18c8db0aa42d6865990f75 Mon Sep 17 00:00:00 2001 From: Jay Yang Date: Tue, 22 Oct 2024 02:07:55 +0000 Subject: [PATCH] [vpp] [vfi] duplicate last frame so that number of output frame is multiple of that of input --- .../include/mfx_vpp_ai_frame_interpolation.h | 1 + _studio/mfx_lib/vpp/include/mfx_vpp_hw.h | 3 +++ .../src/mfx_vpp_ai_frame_interpolation.cpp | 12 +++++++++- _studio/mfx_lib/vpp/src/mfx_vpp_hw.cpp | 23 +++++++++++++++---- 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/_studio/mfx_lib/vpp/include/mfx_vpp_ai_frame_interpolation.h b/_studio/mfx_lib/vpp/include/mfx_vpp_ai_frame_interpolation.h index 28b63e9a48..74bfb5de35 100644 --- a/_studio/mfx_lib/vpp/include/mfx_vpp_ai_frame_interpolation.h +++ b/_studio/mfx_lib/vpp/include/mfx_vpp_ai_frame_interpolation.h @@ -92,6 +92,7 @@ class MFXVideoFrameInterpolation Ratio m_ratio; mfxU16 m_outStamp; mfxU16 m_outTick; + bool m_sequenceEnd; mfxU16 m_IOPattern; diff --git a/_studio/mfx_lib/vpp/include/mfx_vpp_hw.h b/_studio/mfx_lib/vpp/include/mfx_vpp_hw.h index c7480c26e0..03bab9fb02 100644 --- a/_studio/mfx_lib/vpp/include/mfx_vpp_hw.h +++ b/_studio/mfx_lib/vpp/include/mfx_vpp_hw.h @@ -281,6 +281,7 @@ namespace MfxHwVideoProcessing , skipQueryStatus(false) , pAuxData(NULL) , pSubResource(NULL) + , m_aiVfiSequenceEnd(false) { #ifdef MFX_ENABLE_MCTF memset(&MctfData, 0, sizeof(IntMctfParams)); @@ -318,6 +319,8 @@ namespace MfxHwVideoProcessing ReleaseResource* pSubResource; std::vector m_refList; //m_refList.size() == bkwdRefCount +fwdRefCount + + bool m_aiVfiSequenceEnd; }; struct ExtendedConfig diff --git a/_studio/mfx_lib/vpp/src/mfx_vpp_ai_frame_interpolation.cpp b/_studio/mfx_lib/vpp/src/mfx_vpp_ai_frame_interpolation.cpp index 335a191881..35b0f58526 100644 --- a/_studio/mfx_lib/vpp/src/mfx_vpp_ai_frame_interpolation.cpp +++ b/_studio/mfx_lib/vpp/src/mfx_vpp_ai_frame_interpolation.cpp @@ -31,6 +31,7 @@ #define HEIGHT2 (mfxU16)1440 MFXVideoFrameInterpolation::MFXVideoFrameInterpolation() : + m_sequenceEnd(false), m_inputFwd(), m_inputBkwd(), m_enableScd(false), @@ -368,7 +369,16 @@ mfxStatus MFXVideoFrameInterpolation::UpdateTsAndGetStatus( mfxFrameSurface1* output, mfxStatus* intSts) { - if (nullptr == input) return MFX_ERR_MORE_DATA; + if (nullptr == input) + { + // nullptr == input means input sequence reaches its end + if (m_sequenceEnd) + { + return MFX_ERR_MORE_DATA; + } + if (m_outStamp == (m_ratio - 1)) m_sequenceEnd = true; + return MFX_ERR_NONE; + } mfxStatus sts = MFX_ERR_NONE; if (m_outStamp == 0) diff --git a/_studio/mfx_lib/vpp/src/mfx_vpp_hw.cpp b/_studio/mfx_lib/vpp/src/mfx_vpp_hw.cpp index 0c0517dc55..dada3be424 100644 --- a/_studio/mfx_lib/vpp/src/mfx_vpp_hw.cpp +++ b/_studio/mfx_lib/vpp/src/mfx_vpp_hw.cpp @@ -1664,11 +1664,20 @@ mfxStatus TaskManager::FillTask( m_resMngr.m_surf[VPP_IN][pTask->input.resIdx].SetFree(false); } } - + mfxStatus sts = MFX_ERR_NONE; m_actualNumber += 1; // make sense for simple mode only - MFX_CHECK_NULL_PTR1(pTask->input.pSurf); - mfxStatus sts = m_core->IncreaseReference(*pTask->input.pSurf); - MFX_CHECK_STS(sts); + + if ((FRC_AI_INTERPOLATION & m_extMode) && !pTask->input.pSurf) + { + // input sequence reaches its end + pTask->m_aiVfiSequenceEnd = true; + } + else + { + MFX_CHECK_NULL_PTR1(pTask->input.pSurf); + sts = m_core->IncreaseReference(*pTask->input.pSurf); + MFX_CHECK_STS(sts); + } sts = m_core->IncreaseReference(*pTask->output.pSurf); MFX_CHECK_STS(sts); @@ -4222,6 +4231,12 @@ mfxStatus VideoVPPHW::MergeRuntimeParams(const DdiTask *pTask, MfxHwVideoProcess mfxStatus VideoVPPHW::SyncTaskSubmission(DdiTask* pTask) { mfxStatus sts = MFX_ERR_NONE; + + if (pTask->m_aiVfiSequenceEnd) + { + pTask->skipQueryStatus = true; + return sts; + } #ifdef MFX_ENABLE_MCTF if (pTask->outputForApp.pSurf) {