Skip to content

Commit

Permalink
[VPP] scene change detection minor refactor
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MicroYY authored and gfxVPLsdm committed Jun 11, 2024
1 parent c4c88b0 commit 6190520
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 33 deletions.
1 change: 1 addition & 0 deletions _studio/mfx_lib/ext/asc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ target_sources(asc_ext
target_link_libraries(asc_ext
PRIVATE
cmrt_cross_platform_hw
asc
)

include(sources_ext.cmake OPTIONAL)
7 changes: 3 additions & 4 deletions _studio/mfx_lib/ext/asc/include/asc_cm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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:
Expand Down
25 changes: 0 additions & 25 deletions _studio/mfx_lib/ext/asc/src/asc_cm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion _studio/shared/asc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,4 @@ target_link_libraries(asc
PRIVATE
mfx_sdl_properties
umc
$<$<BOOL:${MFX_ENABLE_EXT}>:mfx_ext>
)
5 changes: 5 additions & 0 deletions _studio/shared/asc/include/asc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
};
Expand Down
6 changes: 3 additions & 3 deletions _studio/shared/asc/include/asc_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdint.h>

#include "mfx_config.h"

#ifndef __ASC_DEFS_H__
#define __ASC_DEFS_H__

#define ASCTUNEDATA 0

#undef NULL
Expand Down
33 changes: 33 additions & 0 deletions _studio/shared/asc/src/asc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -454,6 +461,7 @@ mfxStatus ASC::Init(mfxI32 Width,

VidSample_Init();
Setup_Environment();
VidSample_Alloc();

sts = VidRead_Init();
SCD_CHECK_MFX_ERR(sts);
Expand Down Expand Up @@ -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;
}

}

0 comments on commit 6190520

Please sign in to comment.