diff --git a/CMakeLists.txt b/CMakeLists.txt index 5503446..5af4797 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,7 +83,6 @@ INCLUDE( cmake/LibPixfc.cmake ) ###################################################################################### SET( MODULES_DIR ${SRC_DIR}/modules ) INCLUDE_DIRECTORIES( ${MODULES_DIR} ) -FILE( GLOB ModuleCMakeFiles ModuleDefinition.cmake ) file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/ModulesListMacro.h "// This files defines the macro to \n" "// define a list of modules\n" @@ -91,8 +90,12 @@ file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/ModulesListMacro.h "// This files defin "#define REGISTER_ALL_MODULES ") file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/ModulesListHeader.h "// This files add the header files of each module\n" - "#ifndef __MODULESLISTHEADER_H__\n#define __MODULESLISTHEADER_H__\n" ) -INCLUDE( ${ModuleCMakeFiles} ) + + "#ifndef __MODULESLISTHEADER_H__\n#define __MODULESLISTHEADER_H__\n" ) + +# FILE( GLOB ModuleCMakeFiles ModuleDefinition.cmake ) +# INCLUDE( ${ModuleCMakeFiles} ) +INCLUDE( ModuleDefinition.cmake ) file( APPEND ${CMAKE_CURRENT_BINARY_DIR}/ModulesListMacro.h "\n#endif // __MODULESLISTMACRO_H__\n" ) file( APPEND ${CMAKE_CURRENT_BINARY_DIR}/ModulesListHeader.h "#endif // __MODULESLISTHEADER_H__\n" ) diff --git a/ModuleDefinition.cmake b/ModuleDefinition.cmake index d6c85dd..e6b14a5 100644 --- a/ModuleDefinition.cmake +++ b/ModuleDefinition.cmake @@ -2,8 +2,9 @@ # Default Modules ###################################################################################### -ADD_MODULE( FilterComponentLuma "FilterComponentLuma" ) -ADD_MODULE( FilterComponentChromaU "FilterComponentLuma" ) +ADD_MODULE( FilterComponentLuma "FilterComponent" ) +ADD_MODULE( FilterComponentChromaU "FilterComponent" ) +ADD_MODULE( FilterComponentChromaV "FilterComponent" ) ADD_MODULE( FrameDifference "FrameDifference" ) ADD_MODULE( MeasurePSNR "MeasurePSNR" ) diff --git a/source/lib/PlaYUVerFrame.cpp b/source/lib/PlaYUVerFrame.cpp index 79d9c7b..5088777 100644 --- a/source/lib/PlaYUVerFrame.cpp +++ b/source/lib/PlaYUVerFrame.cpp @@ -553,6 +553,49 @@ UInt64 PlaYUVerFrame::getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelF return 0; } +UInt PlaYUVerFrame::getChromaWidth() const +{ + switch( m_iPixelFormat ) + { + case YUV420p: + return m_uiWidth / 2; + break; + case YUV444p: + case YUV422p: + case YUYV422: + case RGB8: + return m_uiWidth; + break; + case GRAY: + return 0; + break; + default: + return 0; + } + return 0; +} + +UInt PlaYUVerFrame::getChromaHeight() const +{ + switch( m_iPixelFormat ) + { + case YUV420p: + case YUV422p: + case YUYV422: + return m_uiHeight / 2; + break; + case YUV444p: + case RGB8: + return m_uiHeight; + case GRAY: + return 0; + break; + default: + return 0; + } + return 0; +} + UInt PlaYUVerFrame::getChromaLength() const { switch( m_iPixelFormat ) diff --git a/source/lib/PlaYUVerFrame.h b/source/lib/PlaYUVerFrame.h index 1f3deb7..9e5ebe4 100644 --- a/source/lib/PlaYUVerFrame.h +++ b/source/lib/PlaYUVerFrame.h @@ -120,6 +120,8 @@ public: UInt64 getBytesPerFrame(); static UInt64 getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat ); + UInt getChromaWidth() const; + UInt getChromaHeight() const; UInt getChromaLength() const; Pel*** getPelBufferYUV() const diff --git a/source/modules/FilterComponentLuma.cpp b/source/modules/FilterComponent.cpp similarity index 72% rename from source/modules/FilterComponentLuma.cpp rename to source/modules/FilterComponent.cpp index a47bfe2..fecf005 100644 --- a/source/modules/FilterComponentLuma.cpp +++ b/source/modules/FilterComponent.cpp @@ -18,14 +18,13 @@ */ /** - * \file FilterComponentLuma.cpp - * \brief Filter frame module + * \file FilterComponent.cpp + * \brief Filter component frame module */ #include -#include "FilterComponentLuma.h" -#include "PlaYUVerFrame.h" +#include "FilterComponent.h" namespace plaYUVer { @@ -45,7 +44,7 @@ PlaYUVerFrame* FilterComponent::filterComponent( PlaYUVerFrame* InputFrame, Int { Pel*** pppOutputPelYUV = m_pcFilteredFrame->getPelBufferYUV(); Pel*** pppInputPelYUV = InputFrame->getPelBufferYUV(); - memcpy( pppOutputPelYUV[Component][0], pppInputPelYUV[Component][0], m_pcFilteredFrame->getWidth() * m_pcFilteredFrame->getHeight() * sizeof(Pel) ); + memcpy( pppOutputPelYUV[LUMA][0], pppInputPelYUV[Component][0], m_pcFilteredFrame->getWidth() * m_pcFilteredFrame->getHeight() * sizeof(Pel) ); return m_pcFilteredFrame; } @@ -60,7 +59,7 @@ Void FilterComponent::destroy() PlaYUVerModuleDefinition FilterComponentLumaDef = { FRAME_PROCESSING_MODULE, // Apply module to the frames or to the whole sequence. // Currently only support for frame - "Filter Component", // Category (sub-menu) + "Filter Component", // Category (sub-menu) "Luma", // Name "Filter Y matrix of YUV frame", // Description MODULE_REQUIRES_ONE_FRAME, // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES) @@ -84,7 +83,7 @@ PlaYUVerFrame* FilterComponentLuma::process( PlaYUVerFrame* InputFrame ) return filterComponent( InputFrame, LUMA ); } -PlaYUVerModuleDefinition FilterComponentCrDef = { +PlaYUVerModuleDefinition FilterComponentCbDef = { FRAME_PROCESSING_MODULE, // Apply module to the frames or to the whole sequence. // Currently only support for frame "Filter Component", // Category (sub-menu) @@ -98,12 +97,12 @@ PlaYUVerModuleDefinition FilterComponentCrDef = { FilterComponentChromaU::FilterComponentChromaU() { - setModuleDefinition( FilterComponentCrDef ); + setModuleDefinition( FilterComponentCbDef ); } Void FilterComponentChromaU::create( PlaYUVerFrame* InputFrame ) { - createFilter( InputFrame->getWidth(), InputFrame->getHeight() ); + createFilter( InputFrame->getChromaWidth(), InputFrame->getChromaHeight() ); } PlaYUVerFrame* FilterComponentChromaU::process( PlaYUVerFrame* InputFrame ) @@ -111,5 +110,32 @@ PlaYUVerFrame* FilterComponentChromaU::process( PlaYUVerFrame* InputFrame ) return filterComponent( InputFrame, CHROMA_U ); } +PlaYUVerModuleDefinition FilterComponentCrDef = { + FRAME_PROCESSING_MODULE, // Apply module to the frames or to the whole sequence. + // Currently only support for frame + "Filter Component", // Category (sub-menu) + "Chroma R", // Name + "Filter Y matrix of YUV frame", // Description + MODULE_REQUIRES_ONE_FRAME, // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES) + MODULE_REQUIRES_NOTHING, // Module requirements (check PlaYUVerModulesIf.h). + // Several requirements should be "or" between each others. + APPLY_WHILE_PLAYING, // Apply module while playing +}; + +FilterComponentChromaV::FilterComponentChromaV() +{ + setModuleDefinition( FilterComponentCrDef ); +} + +Void FilterComponentChromaV::create( PlaYUVerFrame* InputFrame ) +{ + createFilter( InputFrame->getChromaWidth(), InputFrame->getChromaHeight() ); +} + +PlaYUVerFrame* FilterComponentChromaV::process( PlaYUVerFrame* InputFrame ) +{ + return filterComponent( InputFrame, CHROMA_V ); +} + } // NAMESPACE diff --git a/source/modules/FilterComponentLuma.h b/source/modules/FilterComponent.h similarity index 85% rename from source/modules/FilterComponentLuma.h rename to source/modules/FilterComponent.h index 4a44ec3..d2698a5 100644 --- a/source/modules/FilterComponentLuma.h +++ b/source/modules/FilterComponent.h @@ -18,8 +18,8 @@ */ /** - * \file FilterComponentLuma.h - * \brief Filter frame module + * \file FilterComponent.h + * \brief Filter component frame module */ #ifndef __FILTERCOMPONENT_H__ @@ -73,6 +73,17 @@ public: PlaYUVerFrame* process( PlaYUVerFrame* InputFrame ); }; +class FilterComponentChromaV: public FilterComponent, public PlaYUVerModuleIf +{ +public: + FilterComponentChromaV(); + virtual ~FilterComponentChromaV() + { + } + Void create( PlaYUVerFrame* InputFrame ); + PlaYUVerFrame* process( PlaYUVerFrame* InputFrame ); +}; + } // NAMESPACE #endif // __FILTERFRAME_H__