Merge branch 'dev_modules_api'
Conflicts: source/PlaYUVerFrame.h
This commit is contained in:
commit
d83eca0120
16 files changed
+695
-67
No files matched your search
+12
-3
@@ -67,7 +67,15 @@ ENDIF()
|
||||
INCLUDE( cmake/LibFFmpeg.cmake )
|
||||
|
||||
######################################################################################
|
||||
# Create config.h
|
||||
# PlaYUVer modules build
|
||||
######################################################################################
|
||||
SET( MODULES_DIR ${SRC_DIR}/modules )
|
||||
INCLUDE_DIRECTORIES( ${MODULES_DIR} )
|
||||
FILE( GLOB ModuleCMakeFiles cmake/Module*.cmake )
|
||||
INCLUDE( ${ModuleCMakeFiles} )
|
||||
|
||||
######################################################################################
|
||||
# Main config.h
|
||||
######################################################################################
|
||||
CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h )
|
||||
|
||||
@@ -76,13 +84,14 @@ CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_D
|
||||
######################################################################################
|
||||
ADD_EXECUTABLE( ${PROJECT_NAME} ${SOURCES_FILES} ${HEADERS_MOC_FILES} ${FORMS_HEADERS_FILES} ${RESOURCES_RCC_FILES} )
|
||||
|
||||
TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${LINKER_LIBS} )
|
||||
TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${MODULES_LIBS} ${LINKER_LIBS} )
|
||||
|
||||
IF( NOT USE_QT4)
|
||||
QT5_USE_MODULES( ${PROJECT_NAME} ${CURR_QT_MODULES} )
|
||||
ENDIF()
|
||||
|
||||
|
||||
status("Configuration:")
|
||||
status(" Build type:" ${CMAKE_BUILD_TYPE} )
|
||||
status("Dependencies:")
|
||||
status(" QT:" USE_QT4 THEN "QT4" ELSE "QT5" )
|
||||
status(" Use OpenCV:" USE_OPENCV THEN YES ELSE NO)
|
||||
|
||||
+10
-1
@@ -94,4 +94,13 @@ function(status text)
|
||||
else()
|
||||
message(STATUS "${text}")
|
||||
endif()
|
||||
endfunction()
|
||||
endfunction()
|
||||
|
||||
|
||||
macro(ADD_MODULE name files )
|
||||
set(__modulename "Module${name}")
|
||||
add_library( ${__modulename} ${files} )
|
||||
set(MODULES_LIBS ${MODULES_LIBS} ${__modulename})
|
||||
ADD_DEFINITIONS( -DUSE_${name} )
|
||||
unset(__modulename)
|
||||
endmacro()
|
||||
@@ -0,0 +1,6 @@
|
||||
######################################################################################
|
||||
# Filter frame module
|
||||
######################################################################################
|
||||
|
||||
ADD_MODULE( FilterFrame "${MODULES_DIR}/FilterFrame.cpp" )
|
||||
|
||||
+12
-18
@@ -243,30 +243,24 @@ Void InputStream::readFrame()
|
||||
|
||||
Bool InputStream::writeFrame( const QString& filename )
|
||||
{
|
||||
QImage img( m_uiWidth, m_uiHeight, QImage::Format_RGB888 );
|
||||
getFrame( &img );
|
||||
img.save( filename );
|
||||
m_cCurrFrame->getQimage().save( filename );
|
||||
return true;
|
||||
}
|
||||
|
||||
Void InputStream::getFrame( QImage *qimage )
|
||||
PlaYUVerFrame* InputStream::getFrame( PlaYUVerFrame *pyuv_image )
|
||||
{
|
||||
Pel*** bufferRGB = m_cCurrFrame->getPelBufferRGB();
|
||||
|
||||
if( sizeof(Pel) == sizeof(unsigned char) )
|
||||
{
|
||||
for( Int y = 0; y < m_uiHeight; y++ )
|
||||
{
|
||||
for( Int x = 0; x < m_uiWidth; x++ )
|
||||
{
|
||||
qimage->setPixel( x, y, qRgb( bufferRGB[0][y][x], bufferRGB[1][y][x], bufferRGB[2][y][x] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_ASSERT( 0 );
|
||||
}
|
||||
if( pyuv_image == NULL )
|
||||
pyuv_image = new PlaYUVerFrame( m_cCurrFrame->getWidth(), m_cCurrFrame->getHeight(), m_cCurrFrame->getPelFormat() );
|
||||
|
||||
pyuv_image->CopyFrom(m_cCurrFrame);
|
||||
return pyuv_image;
|
||||
}
|
||||
|
||||
PlaYUVerFrame* InputStream::getFrame()
|
||||
{
|
||||
return m_cCurrFrame;
|
||||
}
|
||||
|
||||
#ifdef USE_OPENCV
|
||||
|
||||
@@ -103,7 +103,8 @@ public:
|
||||
|
||||
Bool writeFrame( const QString& filename );
|
||||
|
||||
Void getFrame( QImage *qimage );
|
||||
PlaYUVerFrame* getFrame();
|
||||
PlaYUVerFrame* getFrame( PlaYUVerFrame * );
|
||||
#ifdef USE_OPENCV
|
||||
cv::Mat getFrameCvMat();
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
/* This file is a part of plaYUVer project
|
||||
* Copyright (C) 2014 by plaYUVer developers
|
||||
*
|
||||
* 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 ModulesHandle.cpp
|
||||
* \brief PlaYUVer modules handle
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "ModulesHandle.h"
|
||||
#include "FilterFrame.h"
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
ModulesHandle::ModulesHandle( QWidget * parent )
|
||||
{
|
||||
// Register Modules
|
||||
REGISTER_MODULE( FilterFrame );
|
||||
|
||||
|
||||
// configure class
|
||||
setParent( parent );
|
||||
m_uiModulesCount = 0;
|
||||
m_uiModuleSelected= -1;
|
||||
}
|
||||
|
||||
ModulesHandle::~ModulesHandle()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Void ModulesHandle::appendModule( PlaYUVerModuleIf* pIfModule )
|
||||
{
|
||||
m_pcPlaYUVerModules.append( pIfModule );
|
||||
m_uiModulesCount++;
|
||||
}
|
||||
|
||||
void ModulesHandle::selectModule( int index )
|
||||
{
|
||||
m_uiModuleSelected = index;
|
||||
}
|
||||
|
||||
PlaYUVerModuleIf* ModulesHandle::getSelectedModuleIf()
|
||||
{
|
||||
PlaYUVerModuleIf* currModuleIf = NULL;
|
||||
|
||||
if( m_uiModuleSelected >= 0 )
|
||||
//if( m_arrayModulesActions.at(m_uiModuleSelected)->isChecked() )
|
||||
currModuleIf = m_pcPlaYUVerModules.at( m_uiModuleSelected );
|
||||
|
||||
m_uiModuleSelected = -1;
|
||||
return currModuleIf;
|
||||
}
|
||||
|
||||
QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar )
|
||||
{
|
||||
PlaYUVerModuleIf* currModuleIf;
|
||||
QAction* currAction;
|
||||
Bool bCategoryExists = false;
|
||||
Int iNumberCategories = 0;
|
||||
|
||||
m_pcActionMapper = new QSignalMapper( this );
|
||||
connect( m_pcActionMapper, SIGNAL( mapped(int) ), this, SLOT( selectModule(int) ) );
|
||||
|
||||
m_pcModulesMenu = MainAppMenuBar->addMenu( "&Modules" );
|
||||
|
||||
//m_arrayModulesActions.resize( m_uiModulesCount );
|
||||
|
||||
for( Int i = 0; i < m_pcPlaYUVerModules.size(); i++ )
|
||||
{
|
||||
currModuleIf = m_pcPlaYUVerModules.at( i );
|
||||
|
||||
currAction = new QAction( tr( currModuleIf->m_cModuleDef.m_pchModuleName ), parent() );
|
||||
currAction->setStatusTip( tr( currModuleIf->m_cModuleDef.m_pchModuleTooltip ) );
|
||||
currAction->setCheckable( true );
|
||||
connect( currAction, SIGNAL( triggered() ), m_pcActionMapper, SLOT( map() ) );
|
||||
m_pcActionMapper->setMapping( currAction, i );
|
||||
m_arrayModulesActions.append( currAction );
|
||||
|
||||
m_pcModulesMenu->addAction( currAction );
|
||||
|
||||
currModuleIf->m_pcAction = currAction;
|
||||
}
|
||||
return m_pcModulesMenu;
|
||||
}
|
||||
|
||||
Void ModulesHandle::updateMenus( Bool hasSubWindow )
|
||||
{
|
||||
QAction* currModuleAction;
|
||||
for( Int i = 0; i < m_pcPlaYUVerModules.size(); i++ )
|
||||
{
|
||||
currModuleAction = m_arrayModulesActions.at( i );
|
||||
currModuleAction->setEnabled( hasSubWindow );
|
||||
}
|
||||
}
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/* This file is a part of plaYUVer project
|
||||
* Copyright (C) 2014 by plaYUVer developers
|
||||
*
|
||||
* 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 ModulesHandle.h
|
||||
* \brief PlaYUVer modules handle
|
||||
*/
|
||||
|
||||
#ifndef __MODULESHANDLE_H__
|
||||
#define __MODULESHANDLE_H__
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
|
||||
#include <QtCore>
|
||||
#if( QT_VERSION_PLAYUVER == 5 )
|
||||
#include <QtWidgets>
|
||||
#elif( QT_VERSION_PLAYUVER == 4 )
|
||||
#include <QtGui>
|
||||
#endif
|
||||
|
||||
#include "TypeDef.h"
|
||||
#include "PlaYUVerModuleIf.h"
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
#define REGISTER_MODULE(X) \
|
||||
{ \
|
||||
if( USE_##X ) \
|
||||
{ \
|
||||
X *pMod = new X(); \
|
||||
appendModule( pMod ); \
|
||||
} \
|
||||
}
|
||||
|
||||
class ModulesHandle : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ModulesHandle( QWidget * parent = 0 );
|
||||
~ModulesHandle();
|
||||
|
||||
QMenu* createMenus( QMenuBar *MainAppMenuBar );
|
||||
Void updateMenus( Bool hasSubWindow );
|
||||
PlaYUVerModuleIf* getSelectedModuleIf();
|
||||
|
||||
private:
|
||||
UInt m_uiModulesCount;
|
||||
Int m_uiModuleSelected;
|
||||
QMenu* m_pcModulesMenu;
|
||||
QList<PlaYUVerModuleIf*> m_pcPlaYUVerModules;
|
||||
QSignalMapper* m_pcActionMapper;
|
||||
QVector<QAction*> m_arrayModulesActions;
|
||||
|
||||
Void appendModule( PlaYUVerModuleIf* );
|
||||
|
||||
private Q_SLOTS:
|
||||
void selectModule( int index );
|
||||
};
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
#endif // __MODULESHANDLE_H__
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "PlaYUVerFrame.h"
|
||||
#include "LibMemAlloc.h"
|
||||
|
||||
#include <QImage>
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
@@ -165,16 +167,14 @@ Void PlaYUVerFrame::FrameFromBuffer( Pel *input_buffer, Int pel_format )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UInt64 frame_bytes_input = m_uiWidth * m_uiHeight;
|
||||
|
||||
switch( m_iPixelFormat )
|
||||
{
|
||||
case YUV420:
|
||||
memcpy( &m_pppcInputPel[0][0][0], input_buffer, frame_bytes_input * sizeof(Pel) );
|
||||
memcpy( &m_pppcInputPel[1][0][0], input_buffer + frame_bytes_input, frame_bytes_input / 4 * sizeof(Pel) );
|
||||
memcpy( &m_pppcInputPel[2][0][0], input_buffer + frame_bytes_input * 5 / 4, frame_bytes_input / 4 * sizeof(Pel) );
|
||||
YUV420toRGB();
|
||||
//YUV420toRGB();
|
||||
break;
|
||||
case YUV422:
|
||||
break;
|
||||
@@ -185,6 +185,52 @@ Void PlaYUVerFrame::FrameFromBuffer( Pel *input_buffer, Int pel_format )
|
||||
}
|
||||
}
|
||||
|
||||
Void PlaYUVerFrame::CopyFrom( PlaYUVerFrame* input_frame )
|
||||
{
|
||||
if( m_iPixelFormat != input_frame->getPelFormat() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
UInt64 num_bytes = m_uiWidth * m_uiHeight;
|
||||
switch( m_iPixelFormat )
|
||||
{
|
||||
case YUV420:
|
||||
memcpy( &m_pppcInputPel[0][0][0], &( input_frame->getPelBufferYUV()[0][0][0] ), num_bytes * sizeof(Pel) );
|
||||
memcpy( &m_pppcInputPel[1][0][0], &( input_frame->getPelBufferYUV()[1][0][0] ), num_bytes / 4 * sizeof(Pel) );
|
||||
memcpy( &m_pppcInputPel[2][0][0], &( input_frame->getPelBufferYUV()[2][0][0] ), num_bytes / 4 * sizeof(Pel) );
|
||||
//YUV420toRGB();
|
||||
break;
|
||||
case YUV422:
|
||||
break;
|
||||
case YUV400:
|
||||
break;
|
||||
case RGB:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QImage PlaYUVerFrame::getQimage()
|
||||
{
|
||||
QImage img( m_uiWidth, m_uiHeight, QImage::Format_RGB888 );
|
||||
Pel*** bufferRGB = getPelBufferRGB();
|
||||
|
||||
if( sizeof(Pel) == sizeof(unsigned char) )
|
||||
{
|
||||
for( Int y = 0; y < m_uiHeight; y++ )
|
||||
{
|
||||
for( Int x = 0; x < m_uiWidth; x++ )
|
||||
{
|
||||
img.setPixel( x, y, qRgb( bufferRGB[0][y][x], bufferRGB[1][y][x], bufferRGB[2][y][x] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_ASSERT( 0 );
|
||||
}
|
||||
return img;
|
||||
}
|
||||
|
||||
UInt64 PlaYUVerFrame::getBytesPerFrame()
|
||||
{
|
||||
switch( m_iPixelFormat )
|
||||
|
||||
+20
-3
@@ -33,6 +33,8 @@
|
||||
|
||||
#include "TypeDef.h"
|
||||
|
||||
class QImage;
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
@@ -44,7 +46,10 @@ public:
|
||||
|
||||
static QStringList supportedPixelFormatList();
|
||||
|
||||
Void YUV420toRGB();
|
||||
|
||||
Void FrameFromBuffer( Pel *input_buffer, Int pel_format );
|
||||
Void CopyFrom( PlaYUVerFrame* );
|
||||
|
||||
UInt64 getBytesPerFrame();
|
||||
|
||||
@@ -59,10 +64,22 @@ public:
|
||||
|
||||
Pel getPixelValueFromYUV(const QPoint &pos, YUVcomponent color);
|
||||
|
||||
QImage getQimage();
|
||||
|
||||
UInt getWidth()
|
||||
{
|
||||
return m_uiWidth;
|
||||
}
|
||||
UInt getHeight()
|
||||
{
|
||||
return m_uiHeight;
|
||||
}
|
||||
Int getPelFormat()
|
||||
{
|
||||
return m_iPixelFormat;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Void YUV420toRGB();
|
||||
|
||||
UInt m_uiWidth;
|
||||
UInt m_uiHeight;
|
||||
Int m_iPixelFormat;
|
||||
|
||||
@@ -46,6 +46,8 @@ SubWindowHandle::SubWindowHandle( QWidget * parent ) :
|
||||
// Define the cViewArea as the widget inside the scroll area
|
||||
m_cScrollArea->setWidget( m_cViewArea );
|
||||
|
||||
m_pcCurrentModule = NULL;
|
||||
|
||||
m_cWindowName = QString( " " );
|
||||
m_bIsPlaying = true;
|
||||
m_dScaleFactor = 1;
|
||||
@@ -55,6 +57,11 @@ SubWindowHandle::SubWindowHandle( QWidget * parent ) :
|
||||
SubWindowHandle::~SubWindowHandle()
|
||||
{
|
||||
delete m_cViewArea;
|
||||
if( !m_pcCurrentModule )
|
||||
return;
|
||||
m_pcCurrentModule->m_pcAction->setChecked( false );
|
||||
m_pcCurrentModule->destroy();
|
||||
m_pcCurrentModule = NULL;
|
||||
}
|
||||
|
||||
bool SubWindowHandle::loadFile( const QString &fileName )
|
||||
@@ -107,9 +114,58 @@ bool SubWindowHandle::loadFile( const QString &fileName )
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Functions to enable a module in the
|
||||
* current SubWindow
|
||||
*/
|
||||
Void SubWindowHandle::enableModule( PlaYUVerModuleIf* select_module )
|
||||
{
|
||||
if( m_pcCurrentModule == select_module )
|
||||
{
|
||||
disableModule();
|
||||
return;
|
||||
}
|
||||
m_pcCurrentModule = select_module;
|
||||
m_pcCurrentModule->create( m_pCurrStream->getFrame() );
|
||||
refreshFrame();
|
||||
}
|
||||
|
||||
Void SubWindowHandle::disableModule()
|
||||
{
|
||||
if( !m_pcCurrentModule )
|
||||
return;
|
||||
|
||||
m_pcCurrentModule->destroy();
|
||||
m_pcCurrentModule = NULL;
|
||||
refreshFrame();
|
||||
}
|
||||
|
||||
QImage* SubWindowHandle::FrameToQImage( PlaYUVerFrame* curr_frame )
|
||||
{
|
||||
Pel*** bufferRGB = curr_frame->getPelBufferRGB();
|
||||
|
||||
curr_frame->YUV420toRGB();
|
||||
|
||||
for( Int y = 0; y < curr_frame->getHeight(); y++ )
|
||||
{
|
||||
for( Int x = 0; x < curr_frame->getWidth(); x++ )
|
||||
{
|
||||
m_pCurrFrameQImage->setPixel( x, y, qRgb( bufferRGB[0][y][x], bufferRGB[1][y][x], bufferRGB[2][y][x] ) );
|
||||
}
|
||||
}
|
||||
return m_pCurrFrameQImage;
|
||||
}
|
||||
|
||||
Void SubWindowHandle::refreshFrame()
|
||||
{
|
||||
m_pCurrStream->getFrame( m_pCurrFrameQImage );
|
||||
if( m_pcCurrentModule )
|
||||
{
|
||||
FrameToQImage( m_pcCurrentModule->process( m_pCurrStream->getFrame() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
FrameToQImage( m_pCurrStream->getFrame( (PlaYUVerFrame*) NULL ) );
|
||||
}
|
||||
m_cViewArea->setImage( QPixmap::fromImage( *m_pCurrFrameQImage ) );
|
||||
}
|
||||
|
||||
@@ -179,7 +235,6 @@ Void SubWindowHandle::stopEvent()
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Void SubWindowHandle::normalSize()
|
||||
{
|
||||
m_dScaleFactor = 1.0;
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "TypeDef.h"
|
||||
#include "InputStream.h"
|
||||
#include "viewarea.h"
|
||||
#include "PlaYUVerModuleIf.h"
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
@@ -50,6 +51,8 @@ private:
|
||||
QScrollArea* m_cScrollArea;
|
||||
ViewArea* m_cViewArea;
|
||||
|
||||
PlaYUVerModuleIf* m_pcCurrentModule;
|
||||
|
||||
InputStream* m_pCurrStream;
|
||||
QImage* m_pCurrFrameQImage;
|
||||
|
||||
@@ -70,6 +73,8 @@ public:
|
||||
Void stopEvent();
|
||||
Void seekEvent( UInt new_frame_num );
|
||||
|
||||
QImage* FrameToQImage( PlaYUVerFrame* curr_frame );
|
||||
|
||||
Void refreshFrame();
|
||||
|
||||
InputStream* getInputStream()
|
||||
@@ -82,6 +87,13 @@ public:
|
||||
return m_cViewArea;
|
||||
}
|
||||
|
||||
/**
|
||||
* Functions to enable a module in the
|
||||
* current SubWindow
|
||||
*/
|
||||
Void enableModule( PlaYUVerModuleIf* select_module );
|
||||
Void disableModule();
|
||||
|
||||
/**
|
||||
* Show the image at its original size
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/* This file is a part of plaYUVer project
|
||||
* Copyright (C) 2014 by plaYUVer developers
|
||||
*
|
||||
* 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 FilterFrame.cpp
|
||||
* \brief Filter frame module
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "FilterFrame.h"
|
||||
#include "PlaYUVerFrame.h"
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
PlaYUVerModuleDefinition FilterFrameDef = {
|
||||
FRAME_LEVEL_MODULE,
|
||||
"Filters"
|
||||
"Y_Filter",
|
||||
"Filter Y matrix of YUV frame",
|
||||
};
|
||||
|
||||
FilterFrame::FilterFrame()
|
||||
{
|
||||
m_cModuleDef = FilterFrameDef;
|
||||
|
||||
m_pcFilteredFrame = NULL;
|
||||
}
|
||||
|
||||
Void FilterFrame::create( PlaYUVerFrame* InputFrame )
|
||||
{
|
||||
if( m_pcFilteredFrame )
|
||||
delete m_pcFilteredFrame;
|
||||
m_pcFilteredFrame = new PlaYUVerFrame( InputFrame->getWidth(), InputFrame->getHeight(), InputFrame->getPelFormat() );
|
||||
}
|
||||
|
||||
PlaYUVerFrame* FilterFrame::process( PlaYUVerFrame* InputFrame )
|
||||
{
|
||||
Pel*** pppPelYUV = m_pcFilteredFrame->getPelBufferYUV();
|
||||
|
||||
m_pcFilteredFrame->CopyFrom( InputFrame );
|
||||
|
||||
for( Int y = 0; y < m_pcFilteredFrame->getHeight() / 2; y++ )
|
||||
{
|
||||
for( Int x = 0; x < m_pcFilteredFrame->getWidth() / 2; x++ )
|
||||
{
|
||||
pppPelYUV[1][y][x] = 128;
|
||||
pppPelYUV[2][y][x] = 128;
|
||||
}
|
||||
}
|
||||
//m_pcFilteredFrame->YUV420toRGB();
|
||||
return m_pcFilteredFrame;
|
||||
}
|
||||
|
||||
Void FilterFrame::destroy()
|
||||
{
|
||||
if( m_pcFilteredFrame )
|
||||
delete m_pcFilteredFrame;
|
||||
m_pcFilteredFrame = NULL;
|
||||
}
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/* This file is a part of plaYUVer project
|
||||
* Copyright (C) 2014 by plaYUVer developers
|
||||
*
|
||||
* 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 FilterFrame.h
|
||||
* \brief Filter frame module
|
||||
*/
|
||||
|
||||
#ifndef __FILTERFRAME_H__
|
||||
#define __FILTERFRAME_H__
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
#include "TypeDef.h"
|
||||
#include "PlaYUVerFrame.h"
|
||||
#include "PlaYUVerModuleIf.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
class FilterFrame: public PlaYUVerModuleIf
|
||||
{
|
||||
private:
|
||||
PlaYUVerFrame* m_pcFilteredFrame;
|
||||
|
||||
public:
|
||||
FilterFrame();
|
||||
virtual ~FilterFrame()
|
||||
{
|
||||
}
|
||||
|
||||
Void create( PlaYUVerFrame* InputFrame );
|
||||
|
||||
PlaYUVerFrame* process( PlaYUVerFrame* InputFrame );
|
||||
Void destroy();
|
||||
|
||||
PlaYUVerFrame* getModImage()
|
||||
{
|
||||
return m_pcFilteredFrame;
|
||||
}
|
||||
};
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
#endif // __FILTERFRAME_H__
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/* This file is a part of plaYUVer project
|
||||
* Copyright (C) 2014 by plaYUVer developers
|
||||
*
|
||||
* 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 PlaYUVerModuleIf.h
|
||||
* \brief PlaYUVer modules interface
|
||||
*/
|
||||
|
||||
#ifndef __PLAYUVERMODULESIF_H__
|
||||
#define __PLAYUVERMODULESIF_H__
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
|
||||
#include "TypeDef.h"
|
||||
#include "PlaYUVerFrame.h"
|
||||
|
||||
class QImage;
|
||||
class QAction;
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
enum __PlaYUVerModuleTypes
|
||||
{
|
||||
FRAME_LEVEL_MODULE,
|
||||
VIDEO_LEVEL_MODULE,
|
||||
};
|
||||
|
||||
typedef struct __PlaYUVerModuleDefinition
|
||||
{
|
||||
int m_pchModuleType;
|
||||
char* m_pchModuleCategory;
|
||||
char* m_pchModuleName;
|
||||
char* m_pchModuleTooltip;
|
||||
}PlaYUVerModuleDefinition;
|
||||
|
||||
|
||||
class PlaYUVerModuleIf
|
||||
{
|
||||
public:
|
||||
PlaYUVerModuleIf()
|
||||
{
|
||||
m_pcAction = NULL;
|
||||
}
|
||||
virtual ~PlaYUVerModuleIf()
|
||||
{
|
||||
}
|
||||
|
||||
QAction* m_pcAction;
|
||||
|
||||
PlaYUVerModuleDefinition m_cModuleDef;
|
||||
|
||||
virtual Void create() {};
|
||||
virtual Void process() {};
|
||||
|
||||
virtual Void create( PlaYUVerFrame* ) {};
|
||||
virtual PlaYUVerFrame* process( PlaYUVerFrame* ) {};
|
||||
|
||||
virtual Void destroy() {};
|
||||
|
||||
};
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
#endif // __PLAYUVERMODULESIF_H__
|
||||
|
||||
+62
-28
@@ -51,6 +51,8 @@ plaYUVerApp::plaYUVerApp()
|
||||
mapperWindow = new QSignalMapper( this );
|
||||
connect( mapperWindow, SIGNAL( mapped(QWidget*) ), this, SLOT( setActiveSubWindow(QWidget*) ) );
|
||||
|
||||
m_pcModulesHandle = new ModulesHandle( this );
|
||||
|
||||
createActions();
|
||||
createMenus();
|
||||
createToolBars();
|
||||
@@ -71,6 +73,8 @@ plaYUVerApp::plaYUVerApp()
|
||||
|
||||
setAcceptDrops( true );
|
||||
mdiArea->setAcceptDrops( true );
|
||||
|
||||
m_pcCurrentSubWindow = NULL;
|
||||
}
|
||||
|
||||
Void plaYUVerApp::closeEvent( QCloseEvent *event )
|
||||
@@ -135,6 +139,22 @@ void plaYUVerApp::save()
|
||||
activeSubWindow()->save();
|
||||
}
|
||||
|
||||
// ----------------------- Modules Selection --------------------
|
||||
|
||||
void plaYUVerApp::selectModule( QAction *curr_action )
|
||||
{
|
||||
//emit curr_action->triggered();
|
||||
if( activeSubWindow() )
|
||||
{
|
||||
PlaYUVerModuleIf* pcCurrMod = m_pcModulesHandle->getSelectedModuleIf();
|
||||
if( pcCurrMod )
|
||||
{
|
||||
activeSubWindow()->enableModule( pcCurrMod );
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// ----------------------- Playing Functions --------------------
|
||||
|
||||
void plaYUVerApp::play()
|
||||
@@ -217,8 +237,15 @@ void plaYUVerApp::chageSubWindowSelection()
|
||||
playingTimer->stop();
|
||||
if( activeSubWindow() )
|
||||
{
|
||||
if( m_pcCurrentSubWindow )
|
||||
m_pcCurrentSubWindow->disableModule();
|
||||
m_pcFrameSlider->setMaximum( activeSubWindow()->getInputStream()->getFrameNum() - 1 );
|
||||
m_pcFrameSlider->setValue( activeSubWindow()->getInputStream()->getCurrFrameNum() );
|
||||
m_pcCurrentSubWindow = activeSubWindow();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pcCurrentSubWindow = NULL;
|
||||
}
|
||||
updateMenus();
|
||||
//updateWindowMenu();
|
||||
@@ -245,20 +272,22 @@ Void plaYUVerApp::updateMenus()
|
||||
actionVideoBackward->setEnabled( hasSubWindow );
|
||||
actionVideoForward->setEnabled( hasSubWindow );
|
||||
m_pcFrameSlider->setEnabled( hasSubWindow );
|
||||
|
||||
m_pcModulesHandle->updateMenus( hasSubWindow );
|
||||
}
|
||||
|
||||
void plaYUVerApp::updateWindowMenu()
|
||||
{
|
||||
menuWindow->clear();
|
||||
menuWindow->addAction( actionClose );
|
||||
menuWindow->addAction( actionCloseAll );
|
||||
menuWindow->addSeparator();
|
||||
menuWindow->addAction( actionTile );
|
||||
menuWindow->addAction( actionCascade );
|
||||
menuWindow->addSeparator();
|
||||
menuWindow->addAction( actionNext );
|
||||
menuWindow->addAction( actionPrevious );
|
||||
menuWindow->addAction( actionSeparator );
|
||||
m_arrayMenu[WINDOW_MENU]->clear();
|
||||
m_arrayMenu[WINDOW_MENU]->addAction( actionClose );
|
||||
m_arrayMenu[WINDOW_MENU]->addAction( actionCloseAll );
|
||||
m_arrayMenu[WINDOW_MENU]->addSeparator();
|
||||
m_arrayMenu[WINDOW_MENU]->addAction( actionTile );
|
||||
m_arrayMenu[WINDOW_MENU]->addAction( actionCascade );
|
||||
m_arrayMenu[WINDOW_MENU]->addSeparator();
|
||||
m_arrayMenu[WINDOW_MENU]->addAction( actionNext );
|
||||
m_arrayMenu[WINDOW_MENU]->addAction( actionPrevious );
|
||||
m_arrayMenu[WINDOW_MENU]->addAction( actionSeparator );
|
||||
|
||||
updateMenus();
|
||||
|
||||
@@ -290,7 +319,7 @@ void plaYUVerApp::updateWindowMenu()
|
||||
{
|
||||
text = tr( "%1 %2" ).arg( i + 1 ).arg( child->userFriendlyCurrentFile() );
|
||||
}
|
||||
QAction *action = menuWindow->addAction( text );
|
||||
QAction *action = m_arrayMenu[WINDOW_MENU]->addAction( text );
|
||||
action->setCheckable( true );
|
||||
action->setChecked( child == activeSubWindow() );
|
||||
connect( action, SIGNAL( triggered() ), mapperWindow, SLOT( map() ) );
|
||||
@@ -449,29 +478,34 @@ Void plaYUVerApp::createActions()
|
||||
|
||||
Void plaYUVerApp::createMenus()
|
||||
{
|
||||
menuFile = menuBar()->addMenu( tr( "&File" ) );
|
||||
menuFile->addAction( actionOpen );
|
||||
menuFile->addSeparator();
|
||||
menuFile->addAction( actionSave );
|
||||
menuFile->addSeparator();
|
||||
menuFile->addAction( actionClose );
|
||||
menuFile->addAction( actionExit );
|
||||
m_arrayMenu.resize( TOTAL_MENUS );
|
||||
|
||||
menuView = new QMenu( tr( "&View" ), this );
|
||||
menuView->addAction( actionZoomIn );
|
||||
menuView->addAction( actionZoomOut );
|
||||
menuView->addAction( actionNormalSize );
|
||||
menuView->addAction( actionZoomToFit );
|
||||
m_arrayMenu[FILE_MENU] = menuBar()->addMenu( tr( "&File" ) );
|
||||
m_arrayMenu[FILE_MENU]->addAction( actionOpen );
|
||||
m_arrayMenu[FILE_MENU]->addSeparator();
|
||||
m_arrayMenu[FILE_MENU]->addAction( actionSave );
|
||||
m_arrayMenu[FILE_MENU]->addSeparator();
|
||||
m_arrayMenu[FILE_MENU]->addAction( actionClose );
|
||||
m_arrayMenu[FILE_MENU]->addAction( actionExit );
|
||||
|
||||
menuWindow = menuBar()->addMenu( tr( "&Window" ) );
|
||||
m_arrayMenu[VIEW_MENU] = menuBar()->addMenu( tr( "&View" ) );
|
||||
m_arrayMenu[VIEW_MENU]->addAction( actionZoomIn );
|
||||
m_arrayMenu[VIEW_MENU]->addAction( actionZoomOut );
|
||||
m_arrayMenu[VIEW_MENU]->addAction( actionNormalSize );
|
||||
m_arrayMenu[VIEW_MENU]->addAction( actionZoomToFit );
|
||||
|
||||
QMenu* modules_menu = m_pcModulesHandle->createMenus( menuBar() );
|
||||
connect( modules_menu, SIGNAL( triggered(QAction *) ), this, SLOT( selectModule(QAction *) ) );
|
||||
|
||||
m_arrayMenu[WINDOW_MENU] = menuBar()->addMenu( tr( "&Window" ) );
|
||||
updateWindowMenu();
|
||||
connect( menuWindow, SIGNAL( aboutToShow() ), this, SLOT( updateWindowMenu() ) );
|
||||
connect( m_arrayMenu[WINDOW_MENU], SIGNAL( aboutToShow() ), this, SLOT( updateWindowMenu() ) );
|
||||
|
||||
menuBar()->addSeparator();
|
||||
|
||||
menuHelp = menuBar()->addMenu( tr( "&Help" ) );
|
||||
menuHelp->addAction( actionAbout );
|
||||
menuHelp->addAction( actionAboutQt );
|
||||
m_arrayMenu[ABOUT_MENU] = menuBar()->addMenu( tr( "&Help" ) );
|
||||
m_arrayMenu[ABOUT_MENU]->addAction( actionAbout );
|
||||
m_arrayMenu[ABOUT_MENU]->addAction( actionAboutQt );
|
||||
}
|
||||
|
||||
Void plaYUVerApp::createToolBars()
|
||||
|
||||
+28
-8
@@ -34,6 +34,8 @@
|
||||
#include <QMainWindow>
|
||||
#include "TypeDef.h"
|
||||
|
||||
#include "ModulesHandle.h"
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
@@ -41,7 +43,7 @@ class SubWindowHandle;
|
||||
|
||||
class plaYUVerApp: public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
plaYUVerApp();
|
||||
@@ -60,7 +62,10 @@ private Q_SLOTS:
|
||||
void pause();
|
||||
void stop();
|
||||
void playEvent();
|
||||
void seekSliderEvent(int new_frame_num );
|
||||
void seekSliderEvent( int new_frame_num );
|
||||
|
||||
void selectModule( QAction * );
|
||||
|
||||
/**
|
||||
* Scale the image by a given factor
|
||||
* @param factor factor of scale. Ex: 120 scale the image up by 20% and
|
||||
@@ -80,14 +85,16 @@ private Q_SLOTS:
|
||||
/*
|
||||
* Drag and drop functions
|
||||
*/
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
void dropEvent(QDropEvent *event);
|
||||
void dragEnterEvent( QDragEnterEvent *event );
|
||||
void dropEvent( QDropEvent *event );
|
||||
|
||||
void setActiveSubWindow( QWidget *window );
|
||||
void updatePixelValueStatusBar(const QPoint & pos);
|
||||
|
||||
private:
|
||||
QMdiArea *mdiArea;
|
||||
SubWindowHandle *m_pcCurrentSubWindow;
|
||||
ModulesHandle *m_pcModulesHandle;
|
||||
|
||||
QString m_cLastOpenPath;
|
||||
QTimer *playingTimer;
|
||||
@@ -112,10 +119,23 @@ private:
|
||||
QSignalMapper *mapperZoom;
|
||||
QSignalMapper *mapperWindow;
|
||||
|
||||
QMenu *menuFile;
|
||||
QMenu *menuView;
|
||||
QMenu *menuWindow;
|
||||
QMenu *menuHelp;
|
||||
/**
|
||||
* Array of menus for the main app
|
||||
* @param position description:
|
||||
* 0 - Window
|
||||
* 1 - File
|
||||
* 2 - View
|
||||
* 3 - Help
|
||||
*/
|
||||
enum MAIN_APP_MENU_LIST
|
||||
{
|
||||
FILE_MENU = 0,
|
||||
VIEW_MENU,
|
||||
WINDOW_MENU,
|
||||
ABOUT_MENU,
|
||||
TOTAL_MENUS,
|
||||
};
|
||||
QVector<QMenu*> m_arrayMenu;
|
||||
|
||||
QToolBar *toolbarFile;
|
||||
QToolBar *toolbarView;
|
||||
|
||||
Reference in new issue
Block a user