diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 4167eb6..ac7afdd 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -38,6 +38,7 @@ ADD_MODULE( FilterComponentChromaV "FilterComponent" ) ADD_MODULE( FrameDifference "FrameDifference" ) ADD_MODULE( AbsoluteFrameDifference "AbsoluteFrameDifference" ) ADD_MODULE( FrameBinarization "FrameBinarization" ) +ADD_MODULE( SetChromaHalfScale "SetChromaHalfScale" ) ADD_MODULE( EightBitsSampling "EightBitsSampling" ) ADD_MODULE( FrameCrop "FrameCrop" ) ADD_MODULE( LumaAverage "LumaAverage" ) diff --git a/modules/FrameBinarization.h b/modules/FrameBinarization.h index 5efca95..aa6439c 100644 --- a/modules/FrameBinarization.h +++ b/modules/FrameBinarization.h @@ -50,5 +50,5 @@ public: } // NAMESPACE -#endif // __LUMAAVERAGE_H__ +#endif // __FRAMEBINARIZATION_H__ diff --git a/modules/PlaYUVerModuleFactory.cpp b/modules/PlaYUVerModuleFactory.cpp index 1a7e67c..db28eee 100644 --- a/modules/PlaYUVerModuleFactory.cpp +++ b/modules/PlaYUVerModuleFactory.cpp @@ -38,6 +38,7 @@ PlaYUVerModuleFactory::PlaYUVerModuleFactory() Register( "FilterComponentChromaV", &FilterComponentChromaV::Create ); Register( "FrameDifference", &FrameDifference::Create ); Register( "AbsoluteFrameDifference", &AbsoluteFrameDifference::Create ); + Register( "SetChromaHalfScale", &SetChromaHalfScale::Create ); Register( "FrameCrop", &FrameCrop::Create ); Register( "FrameBinarization", &FrameBinarization::Create ); Register( "EightBitsSampling", &EightBitsSampling::Create ); diff --git a/modules/SetChromaHalfScale.cpp b/modules/SetChromaHalfScale.cpp new file mode 100644 index 0000000..af22c60 --- /dev/null +++ b/modules/SetChromaHalfScale.cpp @@ -0,0 +1,75 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com) + * Joao Carreira (jfmcarreira@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file SetChromaHalfScale.cpp + * \brief Binarize frame module + */ + +#include "SetChromaHalfScale.h" + +namespace plaYUVer +{ + +SetChromaHalfScale::SetChromaHalfScale() +{ + /* Module Definition */ + m_iModuleType = FRAME_PROCESSING_MODULE; + m_pchModuleCategory = "Utilities"; + m_pchModuleName = "SetChromaHalfScale"; + m_pchModuleTooltip = "Copy frame only keeping luma component"; + m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; + m_uiModuleRequirements = MODULE_REQUIRES_NOTHING; + + m_pcProcessedFrame = NULL; + +} + +Void SetChromaHalfScale::create( PlaYUVerFrame* frame ) +{ + m_pcProcessedFrame = NULL; + m_pcProcessedFrame = new PlaYUVerFrame( frame->getWidth(), frame->getHeight(), frame->getPelFormat(), frame->getBitsPel() ); +} + +PlaYUVerFrame* SetChromaHalfScale::process( PlaYUVerFrame* frame ) +{ + Pel* pPelInput = frame->getPelBufferYUV()[LUMA][0]; + Pel* pPelOut = m_pcProcessedFrame->getPelBufferYUV()[0][0]; + Pel halfScaleValue = 1 << ( frame->getBitsPel() - 1 ); + for( UInt i = 0; i < frame->getHeight() * frame->getWidth(); i++ ) + { + *pPelOut++ = *pPelInput++; + } + pPelInput = frame->getPelBufferYUV()[CHROMA_U][0]; + for( UInt i = 0; i < m_pcProcessedFrame->getChromaLength() * 2; i++ ) + { + *pPelOut++ = halfScaleValue; + } + return m_pcProcessedFrame; +} + +Void SetChromaHalfScale::destroy() +{ + if( m_pcProcessedFrame ) + delete m_pcProcessedFrame; + m_pcProcessedFrame = NULL; +} + +} // NAMESPACE + diff --git a/modules/SetChromaHalfScale.h b/modules/SetChromaHalfScale.h new file mode 100644 index 0000000..4a36c17 --- /dev/null +++ b/modules/SetChromaHalfScale.h @@ -0,0 +1,53 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com) + * Joao Carreira (jfmcarreira@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file SetChromaHalfScale.h + * \brief Binarize frame module + */ + +#ifndef __CHROMA128_H__ +#define __CHROMA128_H__ + +#include "PlaYUVerModuleIf.h" + +namespace plaYUVer +{ + +class SetChromaHalfScale: public PlaYUVerModuleIf +{ +REGISTER_CLASS_FACTORY( SetChromaHalfScale ) + +private: + PlaYUVerFrame* m_pcProcessedFrame; +public: + SetChromaHalfScale(); + virtual ~SetChromaHalfScale() + { + } + Void create( PlaYUVerFrame* ); + PlaYUVerFrame* process( PlaYUVerFrame* ); + Void destroy(); + +}; + +} // NAMESPACE + +#endif // __CHROMA128_H__ +