From 6190520f469beca10fa20627266cbbfdeadb4057 Mon Sep 17 00:00:00 2001 From: Jay Yang Date: Tue, 11 Jun 2024 05:34:47 +0000 Subject: [PATCH] [VPP] scene change detection minor refactor This is preparation for vpp frc which leverages SCD. SCD support both sys/vid memory input surface. Sys implemented in base ASC class while vid implemented in derived ASC_Cm class. Move several sys mem related functions to base ASC class. --- _studio/mfx_lib/ext/asc/CMakeLists.txt | 1 + _studio/mfx_lib/ext/asc/include/asc_cm.h | 7 +++-- _studio/mfx_lib/ext/asc/src/asc_cm.cpp | 25 ------------------ _studio/shared/asc/CMakeLists.txt | 1 - _studio/shared/asc/include/asc.h | 5 ++++ _studio/shared/asc/include/asc_defs.h | 6 ++--- _studio/shared/asc/src/asc.cpp | 33 ++++++++++++++++++++++++ 7 files changed, 45 insertions(+), 33 deletions(-) diff --git a/_studio/mfx_lib/ext/asc/CMakeLists.txt b/_studio/mfx_lib/ext/asc/CMakeLists.txt index 0ee4537cfc..7c0338fcec 100644 --- a/_studio/mfx_lib/ext/asc/CMakeLists.txt +++ b/_studio/mfx_lib/ext/asc/CMakeLists.txt @@ -38,6 +38,7 @@ target_sources(asc_ext target_link_libraries(asc_ext PRIVATE cmrt_cross_platform_hw + asc ) include(sources_ext.cmake OPTIONAL) \ No newline at end of file diff --git a/_studio/mfx_lib/ext/asc/include/asc_cm.h b/_studio/mfx_lib/ext/asc/include/asc_cm.h index 4f44166a41..8264dd3c44 100644 --- a/_studio/mfx_lib/ext/asc/include/asc_cm.h +++ b/_studio/mfx_lib/ext/asc/include/asc_cm.h @@ -49,11 +49,11 @@ typedef struct ASCvideoBufferCm: public ASCVidSample class ASC_Cm: public ASC { -using ASC::Init; public: ASC_Cm(); virtual ~ASC_Cm(){} virtual void Close(); + using ASC::Init; virtual mfxStatus Init(mfxI32 Width, mfxI32 Height, mfxI32 Pitch, @@ -123,7 +123,6 @@ using ASC::Init; mfxStatus RunFrame(SurfaceIndex *idxFrom, mfxU32 parity); mfxStatus RunFrame(mfxHDLPair frameHDL, mfxU32 parity); - mfxStatus RunFrame(mfxU8 *frame, mfxU32 parity); mfxStatus CreateCmSurface2D(mfxHDLPair pSrcPair, CmSurface2D* & pCmSurface2D, SurfaceIndex* &pCmSrcIndex); mfxStatus CreateCmKernels(); @@ -154,13 +153,13 @@ using ASC::Init; mfxStatus PutFrameProgressive(mfxHDLPair surface); mfxStatus PutFrameProgressive(mfxHDL surface); mfxStatus PutFrameProgressive(SurfaceIndex* idxSurf); - mfxStatus PutFrameProgressive(mfxU8 *frame, mfxI32 Pitch); - mfxStatus PutFrameInterlaced(mfxHDLPair surface); mfxStatus PutFrameInterlaced(mfxHDL surface); mfxStatus PutFrameInterlaced(SurfaceIndex* idxSurf); mfxStatus PutFrameInterlaced(mfxU8 *frame, mfxI32 Pitch); + using ASC::RunFrame; + using ASC::PutFrameProgressive; virtual mfxStatus calc_RaCa_Surf(mfxHDLPair surface, mfxF64& rscs); //private: diff --git a/_studio/mfx_lib/ext/asc/src/asc_cm.cpp b/_studio/mfx_lib/ext/asc/src/asc_cm.cpp index 5a4380cb5c..b57c8f1a9f 100644 --- a/_studio/mfx_lib/ext/asc/src/asc_cm.cpp +++ b/_studio/mfx_lib/ext/asc/src/asc_cm.cpp @@ -411,18 +411,6 @@ mfxStatus ASC_Cm::RunFrame(mfxHDLPair frameHDL, mfxU32 parity) return MFX_ERR_NONE; } -mfxStatus ASC_Cm::RunFrame(mfxU8 *frame, mfxU32 parity) { - if (!m_ASCinitialized) - return MFX_ERR_NOT_INITIALIZED; - m_videoData[ASCCurrent_Frame]->frame_number = m_videoData[ASCReference_Frame]->frame_number + 1; - (this->*(resizeFunc))(frame, m_width, m_height, m_pitch, (ASCLayers)0, parity); - RsCsCalc(); - DetectShotChangeFrame(); - Put_LTR_Hint(); - GeneralBufferRotation(); - return MFX_ERR_NONE; -} - mfxStatus ASC_Cm::CreateCmSurface2D(mfxHDLPair pSrcPair, CmSurface2D* & pCmSurface2D, SurfaceIndex* &pCmSrcIndex) { INT cmSts = 0; @@ -696,19 +684,6 @@ mfxStatus ASC_Cm::PutFrameProgressive(mfxHDL surface) return sts; } -mfxStatus ASC_Cm::PutFrameProgressive(mfxU8 *frame, mfxI32 Pitch) { - mfxStatus sts; - if (Pitch > 0) { - sts = SetPitch(Pitch); - SCD_CHECK_MFX_ERR(sts); - } - - sts = RunFrame(frame, ASCTopField); - SCD_CHECK_MFX_ERR(sts); - m_dataReady = (sts == MFX_ERR_NONE); - return sts; -} - mfxStatus ASC_Cm::PutFrameInterlaced(mfxU8 *frame, mfxI32 Pitch) { mfxStatus sts; diff --git a/_studio/shared/asc/CMakeLists.txt b/_studio/shared/asc/CMakeLists.txt index 6129e3795f..9cbfb067df 100644 --- a/_studio/shared/asc/CMakeLists.txt +++ b/_studio/shared/asc/CMakeLists.txt @@ -64,5 +64,4 @@ target_link_libraries(asc PRIVATE mfx_sdl_properties umc - $<$:mfx_ext> ) diff --git a/_studio/shared/asc/include/asc.h b/_studio/shared/asc/include/asc.h index bc0e2b4815..cb64827d83 100644 --- a/_studio/shared/asc/include/asc.h +++ b/_studio/shared/asc/include/asc.h @@ -188,6 +188,7 @@ class ASC { void InitStruct(); mfxStatus VidRead_Init(); void VidSample_Init(); + virtual mfxStatus VidSample_Alloc(); void SubSampleASC_ImagePro(mfxU8 *frame, mfxI32 srcWidth, mfxI32 srcHeight, mfxI32 inputPitch, ASCLayers dstIdx, mfxU32 parity); void SubSampleASC_ImageInt(mfxU8 *frame, mfxI32 srcWidth, mfxI32 srcHeight, mfxI32 inputPitch, ASCLayers dstIdx, mfxU32 parity); bool CompareStats(mfxU8 current, mfxU8 reference); @@ -244,6 +245,10 @@ class ASC { static mfxI32 Get_CpuFeature_SSE41(); virtual mfxStatus calc_RaCa_Surf(mfxHDLPair surface, mfxF64& rscs); + + mfxStatus RunFrame(mfxU8* frame, mfxU32 parity); + mfxStatus PutFrameProgressive(mfxU8* frame, mfxI32 Pitch); + protected: ASCVidSample** m_videoData; }; diff --git a/_studio/shared/asc/include/asc_defs.h b/_studio/shared/asc/include/asc_defs.h index 543009bade..bee2303533 100644 --- a/_studio/shared/asc/include/asc_defs.h +++ b/_studio/shared/asc/include/asc_defs.h @@ -18,13 +18,13 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#ifndef __ASC_DEFS_H__ +#define __ASC_DEFS_H__ + #include #include "mfx_config.h" -#ifndef __ASC_DEFS_H__ -#define __ASC_DEFS_H__ - #define ASCTUNEDATA 0 #undef NULL diff --git a/_studio/shared/asc/src/asc.cpp b/_studio/shared/asc/src/asc.cpp index 97e8db29f9..25b2ca114d 100644 --- a/_studio/shared/asc/src/asc.cpp +++ b/_studio/shared/asc/src/asc.cpp @@ -332,6 +332,13 @@ void ASC::VidSample_Init() { } } +mfxStatus ASC::VidSample_Alloc() +{ + for (mfxI32 i = 0; i < ASCVIDEOSTATSBUF; i++) + SCD_CHECK_MFX_ERR(m_videoData[i]->layer.InitFrame(m_dataIn->layer)); + return MFX_ERR_NONE; +} + void ASC::SetUltraFastDetection() { m_support->size = ASCSmall_Size; resizeFunc = &ASC::SubSampleASC_ImagePro; @@ -454,6 +461,7 @@ mfxStatus ASC::Init(mfxI32 Width, VidSample_Init(); Setup_Environment(); + VidSample_Alloc(); sts = VidRead_Init(); SCD_CHECK_MFX_ERR(sts); @@ -1163,4 +1171,29 @@ void ASC::VidSample_dispose() free(m_frameBkp); } +mfxStatus ASC::RunFrame(mfxU8* frame, mfxU32 parity) { + if (!m_ASCinitialized) + return MFX_ERR_NOT_INITIALIZED; + m_videoData[ASCCurrent_Frame]->frame_number = m_videoData[ASCReference_Frame]->frame_number + 1; + (this->*(resizeFunc))(frame, m_width, m_height, m_pitch, (ASCLayers)0, parity); + RsCsCalc(); + DetectShotChangeFrame(); + Put_LTR_Hint(); + GeneralBufferRotation(); + return MFX_ERR_NONE; +} + +mfxStatus ASC::PutFrameProgressive(mfxU8* frame, mfxI32 Pitch) { + mfxStatus sts; + if (Pitch > 0) { + sts = SetPitch(Pitch); + SCD_CHECK_MFX_ERR(sts); + } + + sts = RunFrame(frame, ASCTopField); + SCD_CHECK_MFX_ERR(sts); + m_dataReady = (sts == MFX_ERR_NONE); + return sts; +} + }