Upload application files. Currently it reads and displays the first frame of a YUV420p raw video sequence

This commit is contained in:
jfmcarreira committed 2014-01-26 23:47:19 +00:00
1 parent e9d78bd42e
commit 49364d2250
78 files changed
+6470

No files matched your search

Executable
+79
View File
@@ -0,0 +1,79 @@
###
### CMakeLists for playuver
###
######################################################################################
# Project Definition
######################################################################################
cmake_minimum_required( VERSION 2.8.9 )
PROJECT( playuver )
SET( PROJECT_NAME playuver )
SET( CMAKE_BUILD_TYPE Debug )
# Project directories
SET( SRC_DIR source )
SET( INC_DIR source )
SET( RSC_DIR resources )
SET( UI_DIR ui )
SET( EXTERNAL_SRC external_lib )
# Find includes in corresponding build directories
SET( CMAKE_INCLUDE_CURRENT_DIR ON )
# Instruct CMake to run moc automatically when needed.
SET( CMAKE_AUTOMOC ON )
######################################################################################
# Dependencies
######################################################################################
#FIND_PACKAGE( OpenCV REQUIRED )
######################################################################################
# Qt5 library
######################################################################################
FIND_PACKAGE( Qt5Core )
FIND_PACKAGE( Qt5Gui )
FIND_PACKAGE( Qt5Widgets )
INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ${INC_DIR} )
FILE( GLOB SOURCES_FILES ${SRC_DIR}/*.cpp )
FILE( GLOB HEADERS_FILES ${INC_DIR}/*.h )
FILE( GLOB FORMS_FILES ${UI_DIR}/*.ui )
FILE( GLOB RESOURCES_FILES ${RSC_DIR}/*.qrc )
INCLUDE_DIRECTORIES( ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS})
# QT5_WRAP_CPP( HEADERS_MOC_FILES ${HEADERS_FILES} )
QT5_WRAP_UI( FORMS_HEADERS_FILES ${FORMS_FILES} )
QT5_ADD_RESOURCES( RESOURCES_RCC_FILES ${RESOURCES_FILES} )
SET( QT_USE_QTOPENGL TRUE )
# Add compiler flags for building executables (-fPIE)
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}" )
######################################################################################
# External Libs
######################################################################################
INCLUDE_DIRECTORIES( ${EXTERNAL_SRC}/scode )
ADD_LIBRARY( Scode ${EXTERNAL_SRC}/scode/viewarea.cpp ${EXTERNAL_SRC}/scode/gridmanager.cpp ${EXTERNAL_SRC}/scode/scosettings.cpp )
SET( LIST_EXTERNAL_LIBS Scode )
######################################################################################
# Target App
######################################################################################
ADD_EXECUTABLE( ${PROJECT_NAME} ${SOURCES_FILES} ${HEADERS_MOC_FILES} ${FORMS_HEADERS_FILES} ${RESOURCES_RCC_FILES} )
TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${LIST_EXTERNAL_LIBS} ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Widgets_LIBRARIES} )
QT5_USE_MODULES( ${PROJECT_NAME} Core Gui Widgets )
Executable
+2338
View File
File diff suppressed because it is too large. Load diff
Executable
+6
View File
@@ -0,0 +1,6 @@
/** @mainpage plaYUVer Application
plaYUVer - open source raw video player
*/
+272
View File
@@ -0,0 +1,272 @@
/***************************************************************************
* This file is a part of SCode project *
* IT - Instituto de Telecomunicacoes *
* http://www.it.pt *
* *
* Copyright (C) 2008 by Ricardo N. Rocha Sardo *
* ricardo.sardo@co.it.pt *
* *
* 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., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <QBitmap>
#include <QPainter>
#include <QRect>
#include <QRectF>
#include <QPoint>
#include <QColor>
#include <QPen>
#include <QDebug>
#include "gridmanager.h"
#include "scosettings.h"
namespace SCode
{
////////////////////////////////////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////////////////////////////////////
GridManager::GridManager()
{
m_nearPos = QPoint();
}
////////////////////////////////////////////////////////////////////////////////
// Grid Drawer
////////////////////////////////////////////////////////////////////////////////
void GridManager::drawGrid( QPixmap &image, const QRect& area, QPainter *painter )
{
SCoSettings settings;
int offsetx = 0; // Grid offset doesn't applies to SCODE
int offsety = 0; // project for now...
int imageWidth = image.width();
int imageHeight = image.height();
int hSpacing = settings.gridHSpacing();
int vSpacing = settings.gridVSpacing();
QColor color = settings.gridColor();
Style style = settings.gridStyle();
// Set pen for solid line.
QPen mainPen = QPen( color, 1, Qt::SolidLine );
switch( style )
{
case IntersectionDot:
case IntersectionCross:
{
painter->setPen( mainPen );
// Draw crosses or dots on intersections
for( int x = offsetx; x <= area.right(); x += hSpacing )
{
if( x >= imageWidth )
break;
for( int y = offsety; y <= area.bottom(); y += vSpacing )
{
if( y >= imageHeight )
break;
if( x >= area.x() && y >= area.y() )
{
if( style == IntersectionDot )
painter->drawPoint( x, y ); // Dot
else
{ // Crosses:
painter->drawLine( x, y - 1, x, y + 1 ); // Ver.line
painter->drawLine( x - 1, y, x + 1, y ); // Hor.line
}
}
}
}
break;
}
case Dashed:
{
// Change pen to the dashed line
mainPen.setStyle( Qt::DashLine );
}
default: // Solid:
{
painter->setPen( mainPen );
// Draw vertical line
for( int x = offsetx; x <= area.right(); x += hSpacing )
{
if( x >= imageWidth )
break;
if( x >= area.x() )
{
// Always draw the full line otherwise the line stippling
// varies with the location of view area and we get glitchy
// patterns.
painter->drawLine( x, 0, x, imageHeight - 1 );
}
}
// Draw horizontal line
for( int y = offsety; y <= area.bottom(); y += vSpacing )
{
if( y >= imageHeight )
break;
if( y >= area.y() )
{
painter->drawLine( 0, y, imageWidth - 1, y );
}
}
break;
}
}
}
////////////////////////////////////////////////////////////////////////////////
QRect GridManager::rectContains( const QPoint &pos ) const
{
return rectContains( pos.x(), pos.y() );
}
QRect GridManager::rectContains( int x, int y ) const
{
QRect rect;
QPoint pos;
int multiPosX;
int multiPosY;
SCoSettings settings;
int hSpacing = settings.gridHSpacing();
int vSpacing = settings.gridVSpacing();
if( ( x < 0 ) || ( y < 0 ) )
{
return rect;
}
// Find the multiple factor for the fisrt (x,y) position of the grid that
// is less than the given (x,y)
multiPosX = x / hSpacing;
multiPosY = y / vSpacing;
// Grid intersection position (x,y) that is less than the given (x,y)
pos = QPoint( multiPosX * hSpacing, multiPosY * vSpacing );
rect = QRect( pos.x(), pos.y(), hSpacing, vSpacing );
return rect;
}
bool GridManager::contains( int x, int y )
{
int resX;
int resY;
SCoSettings settings;
int hSpacing = settings.gridHSpacing();
int vSpacing = settings.gridVSpacing();
if( ( x < hSpacing ) || ( y < vSpacing ) || ( x < 0 ) || ( y < 0 ) )
return false;
if( ( x == 0 ) && ( y == 0 ) )
return true;
resX = 0;
if( hSpacing )
resX = x % hSpacing;
resY = 0;
if( vSpacing )
resY = y % vSpacing;
if( resX || resY )
return false;
else
return true;
}
QPoint GridManager::nearPos( int x, int y )
{
if( ( x != -1 ) && ( y != -1 ) )
isNear( x, y );
return m_nearPos;
}
bool GridManager::isNear( int x, int y )
{
qreal rectWidth;
qreal rectHeight;
int multiPosX;
int multiPosY;
SCoSettings settings;
int hSpacing = settings.gridHSpacing();
int vSpacing = settings.gridVSpacing();
if( ( x < 0 ) || ( y < 0 ) )
{
m_nearPos = QPoint( -1, -1 );
return false;
}
// We go to consider an area with ray equal 25% of the distance between
// spaces of the gride. In this in case, we have one rectangle centered
// in 25% of this distance.
rectWidth = 2 * 0.25 * hSpacing;
rectHeight = 2 * 0.25 * vSpacing;
QRectF rect( 0, 0, rectWidth, rectHeight );
// Find the multiple factor for the fisrt (x,y) position of the grid that
// is less than the given (x,y)
multiPosX = x / hSpacing;
multiPosY = y / vSpacing;
QPointF gridPoint( 0, 0 );
int gx;
int gy;
// In the worse case we have 4 points of the gride surrounding
for( int j = 0; j < 2; j++ )
{
for( int i = 0; i < 2; i++ )
{
gx = ( int )( multiPosX * hSpacing + i * hSpacing );
gy = ( int )( multiPosY * vSpacing + j * vSpacing );
gridPoint.setX( gx );
gridPoint.setY( gy );
rect.moveCenter( gridPoint );
if( rect.contains( x, y ) )
{
m_nearPos = QPoint( gx, gy );
return true;
}
}
}
m_nearPos = QPoint( -1, -1 );
return false;
}
bool GridManager::isNear( const QPoint &pos )
{
return isNear( pos.x(), pos.y() );
}
} // NameSpace SCode
+99
View File
@@ -0,0 +1,99 @@
/***************************************************************************
* This file is a part of SCode project *
* IT - Instituto de Telecomunicacoes *
* http://www.it.pt *
* *
* Copyright (C) 2008 by Ricardo N. Rocha Sardo *
* ricardo.sardo@co.it.pt *
* *
* 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., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef SCODEGRID_H
#define SCODEGRID_H
#include <QRect>
#include <QColor>
#include <QPen>
class QPoint;
class QBitmap;
class QPainter;
namespace SCode
{
/**
*
*/
class GridManager
{
public:
enum Style
{
IntersectionDot = 0, IntersectionCross, Dashed, Solid
};
GridManager();
void drawGrid( QPixmap &image, const QRect& area, QPainter *painter );
/**
* @returns a QRect defined by the grid that contains the point (x, y).
*/
QRect rectContains( int x, int y ) const;
/**
* This is an overloaded member function, provided for convenience.
* @returns a QRect defined by the grid that contains the QPoint pos.
*/
QRect rectContains( const QPoint &pos ) const;
/**
* @returns @c true if the point (x, y) is over a grid crossing, otherwise
* returns @c false
*/
bool contains( int x, int y );
/**
* @returns @c true if the point (x, y) is near a grid crossing, otherwise
* returns @c false.
* @see @p nearPos()
*/
bool isNear( int x, int y );
/**
* This is an overloaded member function, provided for convenience.
* @returns @c true if the given point is near a grid crossing, otherwise
* returns @c false.
* @see @p nearPos()
*/
bool isNear( const QPoint &pos );
/**
* @returns the grid crossing position that is near the point (x,y). If
* either the x or y are iqual to -1 (default) than returns the last near
* grid position found by @p isNear().
*/
QPoint nearPos( int x = -1, int y = -1 );
private:
QPoint m_nearPos;
};
} // NameSpace SCode
#endif // SCODEGRID_H
+361
View File
@@ -0,0 +1,361 @@
/***************************************************************************
* This file is a part of SCode project *
* IT - Instituto de Telecomunicacoes *
* http://www.it.pt *
* *
* Copyright (C) 2008 by Ricardo N. Rocha Sardo *
* ricardo.sardo@co.it.pt *
* *
* 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., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <QDir>
#include "scosettings.h"
namespace SCode
{
SCoSettings::SCoSettings() :
m_settings( "IT", "SCoDE" )
{
}
// - - - - - - - - - - - - Main Window Settings - - - - - - - - - - - - - - - -
QPoint SCoSettings::mainWindowPos()
{
return m_settings.value( "MainWindow/pos", QPoint( 200, 200 ) ).toPoint();
}
void SCoSettings::setMainWindowPos( const QPoint & pos )
{
m_settings.setValue( "MainWindow/pos", pos );
}
QSize SCoSettings::mainWindowSize()
{
return m_settings.value( "MainWindow/size", QSize( 500, 400 ) ).toSize();
}
void SCoSettings::setMainWindowSize( const QSize & size )
{
m_settings.setValue( "MainWindow/size", size );
}
QString SCoSettings::lastOpenPath()
{
return m_settings.value( "MainWindow/lastOpenPath", QDir::homePath() ).toString();
}
void SCoSettings::setLastOpenPath( const QString & path )
{
m_settings.setValue( "MainWindow/lastOpenPath", path );
}
// - - - - - - - - - - - - - - Grid Settings - - - - - - - - - - - - - - - - - -
GridManager::Style SCoSettings::gridStyle()
{
return ( GridManager::Style )m_settings.value( "Grid/style", 0 ).toInt();
}
void SCoSettings::setGridStyle( GridManager::Style v )
{
m_settings.setValue( "Grid/style", v );
}
QColor SCoSettings::gridColor()
{
return m_settings.value( "Grid/color", QColor( Qt::white ) ).value<QColor>();
}
void SCoSettings::setGridColor( const QColor & v )
{
m_settings.setValue( "Grid/color", v );
}
int SCoSettings::gridHSpacing()
{
return m_settings.value( "Grid/hSpacing", 16 ).toInt();
}
void SCoSettings::setGridHSpacing( int v )
{
m_settings.setValue( "Grid/hSpacing", v );
}
int SCoSettings::gridVSpacing()
{
return m_settings.value( "Grid/vSpacing", 16 ).toInt();
}
void SCoSettings::setGridVSpacing( int v )
{
m_settings.setValue( "Grid/vSpacing", v );
}
// - - - - - - - - - - - - - Segmentation Settings - - - - - - - - - - - - - -
QBitArray SCoSettings::results2show()
{
QBitArray vectorRes( 20, false );
vectorRes.setBit( 16, true );
vectorRes.setBit( 17, true );
return m_settings.value( "Segmentation/vectorResults", vectorRes ).toBitArray();
}
void SCoSettings::setResults2show( QBitArray vectorRes )
{
m_settings.setValue( "Segmentation/vectorResults", vectorRes );
}
// - - - - - - - - - - - - - MMP-compound Encoder settings - - - - - - - - - - - - - - -
QString SCoSettings::binaryPath()
{
return m_settings.value( "MMP/binaryPath", QDir::currentPath() ).toString();
}
void SCoSettings::setBinaryPath( QString binaryPath )
{
m_settings.setValue( "MMP/binaryPath", binaryPath );
}
QString SCoSettings::oimagePath()
{
return m_settings.value( "MMP/oimagePath", QDir::currentPath() ).toString();
}
void SCoSettings::setOimagePath( QString oimagePath )
{
m_settings.setValue( "MMP/oimagePath", oimagePath );
}
int SCoSettings::blockSize()
{
return m_settings.value( "MMP/blockSize", 8 ).toInt();
}
void SCoSettings::setBlockSize( int blockSize )
{
m_settings.setValue( "MMP/blockSize", blockSize );
}
int SCoSettings::quantization()
{
return m_settings.value( "MMP/quantization", 4 ).toInt();
}
void SCoSettings::setQuantization( int quantization )
{
m_settings.setValue( "MMP/quantization", quantization );
}
int SCoSettings::predictionLevel()
{
return m_settings.value( "MMP/predictionLevel", 0 ).toInt();
}
void SCoSettings::setPredictionLevel( int predictionlevel )
{
m_settings.setValue( "MMP/predictionLevel", predictionlevel );
}
int SCoSettings::defineBounds()
{
return m_settings.value( "MMP/defineBounds", 1 ).toInt();
}
void SCoSettings::setDefineBounds( int definebounds )
{
m_settings.setValue( "MMP/defineBounds", definebounds );
}
int SCoSettings::lambda()
{
return m_settings.value( "MMP/lambda", 1000 ).toInt();
}
void SCoSettings::setLambda( int lambda )
{
m_settings.setValue( "MMP/lambda", lambda );
}
int SCoSettings::dictionary()
{
return m_settings.value( "MMP/dictionary", 5000 ).toInt();
}
void SCoSettings::setDictionary( int dictionary )
{
m_settings.setValue( "MMP/dictionary", dictionary );
}
int SCoSettings::radiusDistortion()
{
return m_settings.value( "MMP/radiusDistortion", 100 ).toInt();
}
void SCoSettings::setRadiusDistortion( int distortion )
{
m_settings.setValue( "MMP/radiusDistortion", distortion );
}
int SCoSettings::losslessDistance()
{
return m_settings.value( "MMP/losslessDistance", 0 ).toInt();
}
void SCoSettings::setLosslessDistance( int distance )
{
m_settings.setValue( "MMP/losslessDistance", distance );
}
int SCoSettings::mmpAutoSeg()
{
return m_settings.value( "MMP/autoSeg", 1 ).toInt();
}
void SCoSettings::setMmpAutoSeg( int autoSeg )
{
m_settings.setValue( "MMP/autoSeg", autoSeg );
}
/*
bool SCoSettings::fastMode()
{
return m_settings.value("MMP/fastMode", 1).toBool();
}
void SCoSettings::setFastMode( bool fastmode )
{
m_settings.setValue("MMP/fastMode" , fastmode);
}
*/
QBitArray SCoSettings::mmpTenCheckBoxs()
{
QBitArray bitArray( 10, false );
return m_settings.value( "MMP/tenCheckBoxs", bitArray ).toBitArray();
}
void SCoSettings::setMmpTenCheckBoxs( QBitArray tenCheckBoxs )
{
m_settings.setValue( "MMP/tenCheckBoxs", tenCheckBoxs );
}
// - - - - - - - - - - - - - MMP-compound Decoder settings - - - - - - - - - - - - - - -
QString SCoSettings::binaryPathDec()
{
return m_settings.value( "MMPdec/binaryPath", QDir::currentPath() ).toString();
}
void SCoSettings::setBinaryPathDec( QString binaryPath )
{
m_settings.setValue( "MMPdec/binaryPath", binaryPath );
}
QString SCoSettings::oimagePathDec()
{
return m_settings.value( "MMPdec/oimagePath", QDir::currentPath() ).toString();
}
void SCoSettings::setOimagePathDec( QString oimagePath )
{
m_settings.setValue( "MMPdec/oimagePath", oimagePath );
}
bool SCoSettings::optOutResDec()
{
return m_settings.value( "MMPdec/optOutRes", 0 ).toBool();
}
void SCoSettings::setOptOutResDec( bool par )
{
m_settings.setValue( "MMPdec/optOutRes", par );
}
QString SCoSettings::outResDec()
{
return m_settings.value( "MMPdec/outRes", "" ).toString();
}
void SCoSettings::setOutResDec( QString str )
{
m_settings.setValue( "MMPdec/outRes", str );
}
bool SCoSettings::optImgYDec()
{
return m_settings.value( "MMPdec/optImgY", 0 ).toBool();
}
void SCoSettings::setOptImgYDec( bool par )
{
m_settings.setValue( "MMPdec/optImgY", par );
}
QString SCoSettings::imgYDec()
{
return m_settings.value( "MMPdec/imgY", "" ).toString();
}
void SCoSettings::setImgYDec( QString str )
{
m_settings.setValue( "MMPdec/imgY", str );
}
bool SCoSettings::optImgUDec()
{
return m_settings.value( "MMPdec/optImgU", 0 ).toBool();
}
void SCoSettings::setOptImgUDec( bool par )
{
m_settings.setValue( "MMPdec/optImgU", par );
}
QString SCoSettings::imgUDec()
{
return m_settings.value( "MMPdec/imgU", "" ).toString();
}
void SCoSettings::setImgUDec( QString str )
{
m_settings.setValue( "MMPdec/imgU", str );
}
bool SCoSettings::optImgVDec()
{
return m_settings.value( "MMPdec/optImgV", 0 ).toBool();
}
void SCoSettings::setOptImgVDec( bool par )
{
m_settings.setValue( "MMPdec/optImgV", par );
}
QString SCoSettings::imgVDec()
{
return m_settings.value( "MMPdec/imgV", "" ).toString();
}
void SCoSettings::setImgVDec( QString str )
{
m_settings.setValue( "MMPdec/imgV", str );
}
} // namespace SCode
+150
View File
@@ -0,0 +1,150 @@
/***************************************************************************
* This file is a part of SCode project *
* IT - Instituto de Telecomunicacoes *
* http://www.it.pt *
* *
* Copyright (C) 2008 by Ricardo N. Rocha Sardo *
* ricardo.sardo@co.it.pt *
* *
* 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., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef SCODESCOSETTINGS_H
#define SCODESCOSETTINGS_H
#include <QSettings>
#include <QString>
#include <QSize>
#include <QPoint>
#include <QColor>
#include <QString>
#include <QBitArray>
#include "gridmanager.h"
namespace SCode
{
/**
@author Ricardo N. Rocha Sardo <ricardo.sardo@co.it.pt>
*/
class SCoSettings
{
public:
SCoSettings();
// - - - - - - - - - - Main Window Settings - - - - - - - - - - - - -
QPoint mainWindowPos();
void setMainWindowPos( const QPoint &v );
QSize mainWindowSize();
void setMainWindowSize( const QSize &v );
QString lastOpenPath();
void setLastOpenPath( const QString &v );
// - - - - - - - - - - - - Grid Settings - - - - - - - - - - - - - - -
GridManager::Style gridStyle();
void setGridStyle( GridManager::Style v );
QColor gridColor();
void setGridColor( const QColor &v );
int gridHSpacing();
void setGridHSpacing( int v );
int gridVSpacing();
void setGridVSpacing( int v );
// - - - - - - - - - - - Segmentation Settings - - - - - - - - - - - -
QBitArray results2show();
void setResults2show( QBitArray vectorRes );
// - - - - - - - - - - - - MMP-compound Encoder settings - - - - - - - - - - - -
QString binaryPath();
void setBinaryPath( QString binaryPath );
QString oimagePath();
void setOimagePath( QString binaryPath );
int blockSize();
void setBlockSize( int blockSize );
int quantization();
void setQuantization( int quantization );
int predictionLevel();
void setPredictionLevel( int predictionlevel );
int defineBounds();
void setDefineBounds( int definebounds );
int lambda();
void setLambda( int lambda );
int dictionary();
void setDictionary( int dictionary );
int radiusDistortion();
void setRadiusDistortion( int distortion );
int losslessDistance();
void setLosslessDistance( int distance );
QBitArray mmpTenCheckBoxs();
void setMmpTenCheckBoxs( QBitArray tenCheckBoxs );
int mmpAutoSeg();
void setMmpAutoSeg( int autoSeg );
// - - - - - - - - - - - - MMP-compound Decoder settings - - - - - - - - - - - -
QString binaryPathDec();
void setBinaryPathDec( QString binaryPath );
QString oimagePathDec();
void setOimagePathDec( QString binaryPath );
bool optOutResDec();
void setOptOutResDec( bool par );
QString outResDec();
void setOutResDec( QString str );
bool optImgYDec();
void setOptImgYDec( bool par );
QString imgYDec();
void setImgYDec( QString str );
bool optImgUDec();
void setOptImgUDec( bool par );
QString imgUDec();
void setImgUDec( QString str );
bool optImgVDec();
void setOptImgVDec( bool par );
QString imgVDec();
void setImgVDec( QString str );
private:
QSettings m_settings;
};
} // namespace SCode
#endif // SCODESCOSETTINGS_H
+753
View File
@@ -0,0 +1,753 @@
/***************************************************************************
* This file is a part of SCode project *
* IT - Instituto de Telecomunicacoes *
* http://www.it.pt *
* *
* Copyright (C) 2008 by Ricardo N. Rocha Sardo *
* ricardo.sardo@co.it.pt *
* *
* 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., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <cmath>
#include <QPainter>
#include <QPainterPath>
#include <QMouseEvent>
#include <QImage>
#include <QColor>
#include <QString>
#include <QPixmapCache>
#include <QRectF>
#include <QDebug>
#include "viewarea.h"
#include "gridmanager.h"
namespace SCode
{
static const QColor selectionColor = Qt::cyan;
static const QColor imageMaskColor = Qt::green;
static const QColor eraserColor = Qt::red;
ViewArea::ViewArea( QWidget *parent ) :
QWidget( parent )
{
setAttribute( Qt::WA_StaticContents );
// setAttribute( Qt::WA_NoBackground );
setMouseTracking( true );
m_pixmap = QPixmap();
m_grid = GridManager();
m_mask = QBitmap();
m_selectedArea = QRect();
m_zoomFactor = 1;
m_xOffset = 0;
m_yOffset = 0;
m_mode = NormalMode;
m_tool = NormalSelectionTool;
m_gridVisible = false;
m_snapToGrid = false;
m_blockTrackEnable = false;
}
void ViewArea::setImage( const QPixmap &pixmap )
{
m_pixmap = pixmap;
m_mask = QBitmap( pixmap.width(), pixmap.height() );
m_mask.clear();
updateSize();
update();
updateGeometry();
}
void ViewArea::clear()
{
m_pixmap = QPixmap();
m_mask = QBitmap();
m_mode = NormalMode;
updateSize();
update();
updateGeometry();
}
void ViewArea::clearMask()
{
m_mask.clear();
}
// QSize ViewArea::sizeHint() const
// {
// int w = m_pixmap.width()*m_zoomFactor;
// int h = m_pixmap.height()*m_zoomFactor;
// return QSize( w, h );
// }
void ViewArea::setZoomFactor( double f )
{
if( f == m_zoomFactor )
return;
m_zoomFactor = f;
emit( zoomFactorChanged( m_zoomFactor ) );
updateSize();
repaint();
updateGeometry();
}
void ViewArea::setMode( ViewMode mode )
{
if( m_mode == mode )
return;
m_mode = mode;
update();
}
void ViewArea::setNormalMode()
{
setMode( NormalMode );
}
void ViewArea::setMaskMode()
{
setMode( MaskMode );
}
void ViewArea::setMaskColor( const QColor &color )
{
m_maskColor = color;
update();
}
void ViewArea::setTool( Tool tool )
{
m_tool = tool;
}
void ViewArea::setMaskTool()
{
setMode( MaskMode );
setTool( MaskTool );
m_blockTrackEnable = true;
}
void ViewArea::setEraserTool()
{
setMode( MaskMode );
setTool( EraserTool );
m_blockTrackEnable = true;
}
void ViewArea::setNormalSelectionTool()
{
setMode( NormalMode );
setTool( NormalSelectionTool );
m_blockTrackEnable = false;
}
void ViewArea::setBlockSelectionTool()
{
setMode( NormalMode );
setTool( BlockSelectionTool );
m_blockTrackEnable = true;
}
void ViewArea::setGridVisible( bool enable )
{
m_gridVisible = enable;
update();
}
void ViewArea::setSnapToGrid( bool enable )
{
m_snapToGrid = enable;
}
void ViewArea::setSelectedArea( QRect &rect )
{
if( rect.isNull() )
{
update();
return;
}
QRect updateRect;
setNormalMode();
if( m_selectedArea.isNull() )
{
m_selectedArea = rect.normalized();
updateRect = m_selectedArea;
}
else
{
updateRect = m_selectedArea;
m_selectedArea = rect.normalized();
updateRect = updateRect.united( m_selectedArea );
}
updateRect.adjust( 0, 0, 1, 1 );
update( updateRect.normalized() );
}
////////////////////////////////////////////////////////////////////////////////
// Geometry Updates
////////////////////////////////////////////////////////////////////////////////
void ViewArea::updateSize()
{
int w = m_pixmap.width() * m_zoomFactor;
int h = m_pixmap.height() * m_zoomFactor;
setMinimumSize( w, h );
QWidget *p = parentWidget();
if( p )
{
// If the parent size is bigger than the minimum area to view the
// image, resize() will call resizeEvent(); otherwise, we need to
// perform the necessary updates (updateOffset).
resize( p->width(), p->height() );
}
if( w <= width() && h <= height() )
updateOffset();
}
void ViewArea::updateOffset()
{
if( width() > m_pixmap.width() * m_zoomFactor )
{
m_xOffset = ( width() - m_pixmap.width() * m_zoomFactor ) / 2;
}
else
{
m_xOffset = 0;
}
if( height() > m_pixmap.height() * m_zoomFactor )
{
m_yOffset = ( height() - m_pixmap.height() * m_zoomFactor ) / 2;
}
else
{
m_yOffset = 0;
}
}
////////////////////////////////////////////////////////////////////////////////
// Resize Event
////////////////////////////////////////////////////////////////////////////////
void ViewArea::resizeEvent( QResizeEvent */* event */)
{
if( size().isEmpty() || m_pixmap.isNull() )
return;
updateOffset();
}
////////////////////////////////////////////////////////////////////////////////
// Paint Event
////////////////////////////////////////////////////////////////////////////////
void ViewArea::paintEvent( QPaintEvent *event )
{
QRect winRect = event->rect();
if( size().isEmpty() || m_pixmap.isNull() )
return;
QPainter painter( this );
// Save the actual painter properties and scales the coordinate system.
painter.save();
painter.translate( m_xOffset, m_yOffset );
painter.scale( m_zoomFactor, m_zoomFactor );
// Draw the pixmap.
painter.drawPixmap( QPoint( 0, 0 ), m_pixmap );
// Draw the Grid if it's visible.
if( m_gridVisible )
{
// Do we need to draw the whole grid?
// To know that, we need to perform a transformation of the rectangle
// area that the painter needs to update - transform the windows
// coordinates (origin at the top-left corner of the widget), to the
// relatives coordinates of the image at it's original size (origin at
// the top-left corner of the image).
QRect vr = windowToView( winRect );
// Now we have the (to update) rectangle area on a coordinates system
// that has it's origin at the top-left corner of the image. That
// is, is referenced to the not scaled image.
// To know what image area we need to update, just intersects the
// rectangle area with the image area.
vr &= QRect( 0, 0, m_pixmap.width(), m_pixmap.height() );
// Set up for the grid drawer.
painter.setRenderHint( QPainter::Antialiasing );
// Draw grid.
m_grid.drawGrid( m_pixmap, vr, &painter );
}
painter.restore();
// Draw a border around the image.
if( m_xOffset || m_yOffset )
{
painter.setPen( Qt::black );
painter.drawRect( m_xOffset - 1, m_yOffset - 1, m_pixmap.width() * m_zoomFactor + 1, m_pixmap.height() * m_zoomFactor + 1 );
}
QRect sr = viewToWindow( m_selectedArea );
QRect ir = sr & winRect;
if( ( mode() == NormalMode ) && !selectedArea().isNull() )
{
if( m_newShape || m_blockTrackEnable )
{
// Set the tool color
QColor selectColor = selectionColor;
selectColor.setAlpha( 120 );
QBrush brush( selectColor );
if( m_blockTrackEnable )
painter.setBrush( Qt::NoBrush );
else
painter.setBrush( brush );
painter.setPen( Qt::darkCyan );
// painter.drawRect( sr/*m_selectedArea*/ );
}
else
{
// 1) Cover the image with a light gray except the selected area
QColor fill( Qt::lightGray );
fill.setAlpha( 150 );
QBrush brush( fill );
painter.setBrush( fill );
painter.setPen( Qt::NoPen );
QPainterPath myPath;
QRect imgr = viewToWindow( QRect( 0, 0, m_pixmap.width(), m_pixmap.height() ) );
myPath.addRect( imgr );
myPath.addRect( sr/*m_selectedArea*/);
painter.drawPath( myPath );
// 2) Draw the selection rectangle
painter.setBrush( Qt::NoBrush );
painter.setPen( Qt::darkCyan );
// painter.drawRect( sr/*m_selectedArea*/ );
}
if( !ir.isNull() )
painter.drawRect( sr/*m_selectedArea*/);
}
// Mask Mode ----------------------------------------------------------
if( mode() != MaskMode )
return;
QColor color;
QBrush brush;
// Draw Mask
// Set the tool color
if( m_maskColor.isValid() )
color = m_maskColor;
else
color = imageMaskColor;
color.setAlpha( 120 );
painter.setPen( color );
painter.save();
painter.translate( m_xOffset, m_yOffset );
painter.scale( m_zoomFactor, m_zoomFactor );
painter.drawPixmap( QPoint( 0, 0 ), m_mask );
painter.restore();
if( !m_selectedArea.isNull() )
{
if( m_newShape || m_blockTrackEnable )
{
switch( tool() )
{
case MaskTool:
{
if( m_maskColor.isValid() )
color = m_maskColor;
else
color = imageMaskColor;
break;
}
case EraserTool:
{
color = eraserColor;
break;
}
default:
color = selectionColor; // ?Problems!
}
color.setAlpha( 120 );
brush = QBrush( color );
if( m_blockTrackEnable )
painter.setBrush( Qt::NoBrush );
else
painter.setBrush( brush );
painter.setPen( color );
if( !ir.isNull() )
painter.drawRect( sr );
}
}
}
////////////////////////////////////////////////////////////////////////////////
// Mouse Events
////////////////////////////////////////////////////////////////////////////////
void ViewArea::wheelEvent( QWheelEvent *event )
{
double f;
f = m_zoomFactor + 0.001 * event->delta();
if( f < ( 32.0 / m_pixmap.width() ) )
f = 32.0 / m_pixmap.width();
setZoomFactor( f );
}
void ViewArea::mousePressEvent( QMouseEvent *event )
{
event->accept();
QPoint vpos = windowToView( event->pos() );
if( event->button() == Qt::LeftButton )
{
// Is the mouse over the image? If yes, save the mouse position;
// otherwise, QPoint( -1, -1 ) indicates an invalid position.
if( isPosValid( vpos ) )
{
m_lastPos = vpos;
}
else
{
m_lastPos = QPoint( -1, -1 );
return;
}
// If grid tracking
if( m_snapToGrid )
{
// Find if the cursor is near a grid intersection
bool isNear = m_grid.isNear( m_lastPos );
if( isNear )
{
// The grid 'near intersection' found when used isNear()
m_lastPos = m_grid.nearPos();
}
}
m_newShape = true;
if( tool() == NormalSelectionTool )
{
m_blockTrackEnable = false;
return;
}
if( mode() == MaskMode )
{
// Disable the block track to enable fill the block
m_blockTrackEnable = false;
}
// Block selection
m_selectedArea = m_grid.rectContains( m_lastPos );
QRect updateRect = viewToWindow( m_selectedArea );
updateRect.adjust( 0, 0, 1, 1 );
update( updateRect.normalized() );
}
}
void ViewArea::mouseMoveEvent( QMouseEvent *event )
{
event->accept();
QPoint actualPos = windowToView( event->pos() );
QRect updateRect;
emit positionChanged( actualPos );
// If mouse left button pressed
if( event->buttons() == Qt::LeftButton && m_lastPos != QPoint( -1, -1 ) )
{
// Grid tracking
if( m_snapToGrid )
{
// Find if the cursor is near a grid intersection
bool isNear = m_grid.isNear( actualPos );
if( isNear )
{
// Return the last grid near intersection found
actualPos = m_grid.nearPos();
}
}
updateRect = viewToWindow( m_selectedArea );
if( tool() == NormalSelectionTool )
{
// If the selection is only vertical or horizontal then we have one
// of the dimentions null.
if( actualPos.x() == m_lastPos.x() || actualPos.y() == m_lastPos.y() )
{
m_selectedArea = QRect();
}
// Selection from top to bottom
else if( m_lastPos.y() < actualPos.y() )
{
// From left to right
if( m_lastPos.x() < actualPos.x() )
{
QPoint bottomR = actualPos - QPoint( 1, 1 );
m_selectedArea = QRect( m_lastPos, bottomR );
}
// From right to left
else
{
QPoint topL( actualPos.x(), m_lastPos.y() );
QPoint bottomR( m_lastPos.x() - 1, actualPos.y() - 1 );
m_selectedArea = QRect( topL, bottomR );
}
}
// Selection from bottom to top
else
{
// From left to right
if( m_lastPos.x() < actualPos.x() )
{
QPoint topL( m_lastPos.x(), actualPos.y() );
QPoint bottomR( actualPos.x() - 1, m_lastPos.y() - 1 );
m_selectedArea = QRect( topL, bottomR );
}
// From right to left
else
{
QPoint bottomR = m_lastPos - QPoint( 1, 1 );
m_selectedArea = QRect( actualPos, bottomR );
}
}
}
else // if tool() == BlockSelectionTool || MaskTool || EraserTool
{
m_blockTrackEnable = false;
// If cursor is inside the selected area, we most redraw
// the selection rect because it may be smaller.
if( m_selectedArea.contains( actualPos ) )
{
m_selectedArea = m_grid.rectContains( m_lastPos );
}
m_selectedArea = m_selectedArea.united( m_grid.rectContains( actualPos ) );
}
// Intercept the selected area with the image area to limit the
// selection only to the image area, preventing it to come outside
// the image.
m_selectedArea &= QRect( 0, 0, m_pixmap.width(), m_pixmap.height() );
// Update only the united area
updateRect = updateRect.united( viewToWindow( m_selectedArea ) );
// "When rendering with a one pixel wide pen the QRect's
// boundary line will be rendered to the right and below the
// mathematical rectangle's boundary line.", in QT4 doc.
// Our selection pen width is 1, let's adjust the rendering area.
updateRect.adjust( 0, 0, 1, 1 );
update( updateRect.normalized() );
return;
}
// If no mouse button is pressed and bloks selection tool is set, then
// track the bloks.
if( m_blockTrackEnable )
{
updateRect = viewToWindow( m_selectedArea );
if( isPosValid( actualPos ) )
{
m_selectedArea = m_grid.rectContains( actualPos );
}
else
{
m_selectedArea = QRect();
}
updateRect = updateRect.united( viewToWindow( m_selectedArea ) );
updateRect.adjust( 0, 0, 1, 1 );
update( updateRect );
return;
}
}
void ViewArea::mouseReleaseEvent( QMouseEvent *event )
{
event->accept();
QPoint vpos = windowToView( event->pos() );
if( event->button() == Qt::LeftButton && m_lastPos != QPoint( -1, -1 ) )
{
// Normal Mode ------------------------------------------------------
if( mode() == NormalMode )
{
if( vpos == m_lastPos )
{
m_selectedArea = QRect();
if( tool() == BlockSelectionTool )
m_blockTrackEnable = true;
}
emit selectionChanged( m_selectedArea );
}
// Mask Mode -----------------------------------------------------------
else if( mode() == MaskMode )
{
if( !m_selectedArea.isNull() )
{
updateMask( m_selectedArea );
}
m_selectedArea = QRect();
m_blockTrackEnable = true;
}
m_newShape = false;
update();
unsetCursor();
m_lastPos = QPoint( -1, -1 );
}
}
////////////////////////////////////////////////////////////////////////////////
bool ViewArea::isPosValid( const QPoint &pos ) const
{
if( pos.x() < 0 || pos.y() < 0 || pos.x() >= m_pixmap.width() || pos.y() >= m_pixmap.height() )
return false;
else
return true;
}
////////////////////////////////////////////////////////////////////////////////
QPoint ViewArea::windowToView( const QPoint& pt ) const
{
QPoint p;
p.setX( static_cast<int>( ( pt.x() - m_xOffset ) / m_zoomFactor ) );
p.setY( static_cast<int>( ( pt.y() - m_yOffset ) / m_zoomFactor ) );
return p;
}
QRect ViewArea::windowToView( const QRect& rc ) const
{
QRect r;
r.setTopLeft( windowToView( rc.topLeft() ) );
// r.setRight ( (int)( ceil(( rc.right() - m_xOffset)/m_zoomFactor )));
// r.setBottom( (int)( ceil(( rc.bottom()- m_yOffset)/m_zoomFactor )));
// r.setRight ( static_cast<int>(( rc.right() - m_xOffset ) / m_zoomFactor +1));
// r.setBottom( static_cast<int>(( rc.bottom() - m_xOffset ) / m_zoomFactor+1));
r.setBottomRight( windowToView( rc.bottomRight() ) );
return r;
}
QPoint ViewArea::viewToWindow( const QPoint& pt ) const
{
QPoint p;
p.setX( static_cast<int>( pt.x() * m_zoomFactor + m_xOffset ) );
p.setY( static_cast<int>( pt.y() * m_zoomFactor + m_yOffset ) );
return p;
}
QRect ViewArea::viewToWindow( const QRect& rc ) const
{
QRect r;
r.setTopLeft( viewToWindow( rc.topLeft() ) );
// r.setRight ( (int)( ceil(( rc.right() +1+m_xOffset )*m_zoomFactor ) - 1 ));
// r.setBottom( (int)( ceil(( rc.bottom()+1+m_yOffset )*m_zoomFactor ) - 1 ));
// r.setRight ( (int)( ceil(( rc.right()+0.5)*m_zoomFactor )+ m_xOffset )-1);
// r.setBottom( (int)( ceil(( rc.bottom()+0.5)*m_zoomFactor ) +m_yOffset )-1);
// qDebug()<<"Right = "<< r.right();
// r.setRight ( static_cast<int>(( rc.right()+1) * m_zoomFactor + m_xOffset -1) );
// r.setBottom( static_cast<int>(( rc.bottom()+1) * m_zoomFactor + m_yOffset -1));
r.setBottomRight( viewToWindow( rc.bottomRight() ) );
return r;
}
////////////////////////////////////////////////////////////////////////////////
// Masks Management
////////////////////////////////////////////////////////////////////////////////
void ViewArea::updateMask( const QRect &rect )
{
switch( tool() )
{
case MaskTool:
{
// Add rect to the mask
QPainter painter( &m_mask );
painter.setBrush( Qt::color1 );
painter.setPen( Qt::NoPen );
painter.drawRect( rect );
painter.end();
break;
}
case EraserTool:
{
// Clears rect area in the mask
QPainter painter( &m_mask );
painter.setBrush( Qt::color0 );
painter.setPen( Qt::NoPen );
painter.drawRect( rect );
painter.end();
break;
}
default: /* Do Nothing */
;
}
}
} // NameSpace SCode
+165
View File
@@ -0,0 +1,165 @@
/***************************************************************************
* This file is a part of SCode project *
* IT - Instituto de Telecomunicacoes *
* http://www.it.pt *
* *
* Copyright (C) 2008 by Ricardo N. Rocha Sardo *
* ricardo.sardo@co.it.pt *
* *
* 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., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef VIEWAREA_H
#define VIEWAREA_H
#include <QWidget>
#include <QPixmap>
#include <QBitmap>
#include <QColor>
#include "gridmanager.h"
namespace SCode
{
/**
*
*/
class ViewArea: public QWidget
{
Q_OBJECT
public:
enum ViewMode
{
NormalMode, MaskMode,
};
enum Tool
{
NormalSelectionTool, BlockSelectionTool, MaskTool, EraserTool
};
ViewArea( QWidget *parent = 0 );
void setImage( const QPixmap &pixmap );
void setMode( ViewMode mode );
void setTool( Tool tool );
void setMaskColor( const QColor &color = QColor() );
/**
* Clears any contents.
*/
void clear();
/**
* Clears any mask content.
*/
void clearMask();
QPixmap image() const
{
return m_pixmap;
}
QBitmap mask() const
{
return m_mask;
}
QRect selectedArea() const
{
return m_selectedArea;
}
GridManager gridManager() const
{
return m_grid;
}
ViewMode mode() const
{
return m_mode;
}
Tool tool() const
{
return m_tool;
}
QColor maskColor() const
{
return m_maskColor;
}
// QSize sizeHint() const;
signals:
void selectionChanged( const QRect &rect );
void positionChanged( const QPoint &pos );
void zoomFactorChanged( double );
public slots:
void setNormalMode();
void setMaskMode();
void setMaskTool();
void setEraserTool();
void setNormalSelectionTool();
void setBlockSelectionTool();
void setGridVisible( bool enable );
void setSnapToGrid( bool enable );
void setSelectedArea( QRect &rect );
void setZoomFactor( double f );
protected:
void paintEvent( QPaintEvent *event );
void resizeEvent( QResizeEvent * event );
void mousePressEvent( QMouseEvent *event );
void mouseMoveEvent( QMouseEvent *event );
void mouseReleaseEvent( QMouseEvent *event );
void wheelEvent( QWheelEvent *event );
void updateSize();
void updateOffset();
private:
bool isPosValid( const QPoint &pos ) const;
void updateMask( const QRect &rect );
QPoint windowToView( const QPoint& pt ) const;
QRect windowToView( const QRect& rc ) const;
QPoint viewToWindow( const QPoint& pt ) const;
QRect viewToWindow( const QRect& rc ) const;
QPixmap m_pixmap;
QBitmap m_mask;
QRect m_selectedArea;
QPoint m_lastPos;
GridManager m_grid;
ViewMode m_mode;
Tool m_tool;
QColor m_maskColor;
double m_zoomFactor;
int m_xOffset;
int m_yOffset;
bool m_blockTrackEnable;
bool m_newShape;
bool m_gridVisible;
bool m_snapToGrid;
bool m_cursorInGrid;
bool flag; //lukas
};
} // NameSpace SCode
#endif // VIEWAREA_H
+5
View File
@@ -0,0 +1,5 @@
[Dolphin]
ShowPreview=true
Timestamp=2014,1,25,17,18,19
Version=3
ViewMode=1
Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 658 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 681 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 775 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 756 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 907 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 752 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 865 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 625 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 912 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 396 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 745 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 676 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 852 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 964 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 970 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 830 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 433 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

+50
View File
@@ -0,0 +1,50 @@
<RCC>
<qresource>
<file alias="images/copy.png">icons/copy.png</file>
<file alias="images/open.png">icons/open.png</file>
<file alias="images/paste.png">icons/paste.png</file>
<file alias="images/save.png">icons/save.png</file>
<file alias="images/saveas.png">icons/saveas.png</file>
<file alias="images/close.png">icons/close.png</file>
<file alias="images/exit.png">icons/exit.png</file>
<file alias="images/print.png">icons/print.png</file>
<file alias="images/zoomin.png">icons/zoomin.png</file>
<file alias="images/zoomout.png">icons/zoomout.png</file>
<file alias="images/zoomtonormal.png">icons/zoomtonormal.png</file>
<file alias="images/fittowindow.png">icons/fittowindow.png</file>
<file alias="images/qt.png">icons/qt.png</file>
<file alias="images/playuver.png">icons/playuver.png</file>
<file alias="images/image-selection.png">icons/image-selection.png</file>
<file alias="images/image-full.png">icons/image-full.png</file>
<file alias="images/histogram-log.png">icons/histogram-log.png</file>
<file alias="images/histogram-lin.png">icons/histogram-lin.png</file>
<file alias="images/channel-alpha.png">icons/channel-alpha-16.png</file>
<file alias="images/channel-luma.png">icons/channel-luma-16.png</file>
<file alias="images/channel-red.png">icons/channel-red-16.png</file>
<file alias="images/channel-green.png">icons/channel-green-16.png</file>
<file alias="images/channel-blue.png">icons/channel-blue-16.png</file>
<file alias="images/channel-all.png">icons/channel-all-16.png</file>
<file alias="images/tool-normal-selection.png">icons/tool-normal-selection-16.png</file>
<file alias="images/tool-block-selection.png">icons/tool-block-selection-16.png</file>
<file alias="images/tool-mask.png">icons/tool-mask-24.png</file>
<file alias="images/tool-eraser.png">icons/tool-eraser-22.png</file>
<file alias="images/dialogicon-grid.png">icons/configure-grid-22.png</file>
<file alias="images/dialogheader-grid.png">icons/configure-grid-48.png</file>
<file alias="images/hchain.png">icons/hchain-24.png</file>
<file alias="images/hchain-broken.png">icons/hchain-broken-24.png</file>
<file alias="images/convert-rgb.png">icons/convert-rgb-16.png</file>
<file alias="images/convert-grayscale.png">icons/convert-grayscale-16.png</file>
<file alias="images/convert-blackwhite.png">icons/convert-blackwhite-16.png</file>
<file alias="images/autoseg.png">icons/autoseg.png</file>
<file alias="images/autoseg2.png">icons/autoseg2.png</file>
<file alias="images/autoseg3.png">icons/autoseg3.png</file>
<file alias="images/autoseg4.png">icons/autoseg4.png</file>
<file alias="images/autoseg5.png">icons/autoseg5.png</file>
<file alias="images/autoseg4_small.png">icons/autoseg4_small.png</file>
<file alias="images/mmpcod.png">icons/mmpcod.png</file>
<file alias="images/mmpdec.png">icons/mmpdec.png</file>
<file alias="images/tool-notextmask-24.png">icons/tool-notextmask-24.png</file>
<file alias="images/tool-textmask-24.png">icons/tool-textmask-24.png</file>
<file alias="images/mmpdec2.png">icons/mmpdec2.png</file>
</qresource>
</RCC>
+297
View File
@@ -0,0 +1,297 @@
/* 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 imageinterface.cpp
\brief Sub windows handling
*/
#include <QtWidgets>
#include <QWidget>
#include <QPixmap>
#include <QBitmap>
#include <QColor>
#include "ImageInterface.h"
#include "viewarea.h"
namespace plaYUVer
{
ImageInterface::ImageInterface()
{
setAttribute( Qt::WA_DeleteOnClose );
isUntitled = true;
m_cViewArea = new ViewArea( this );
// m_cViewArea = new QLabel( this );
// m_cViewArea->setScaledContents( true );
// m_cViewArea->setBackgroundRole( QPalette::Base );
// //m_cViewArea->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Ignored );
// m_cViewArea->setScaledContents( false );
setWidgetResizable( true );
setAttribute( Qt::WA_DeleteOnClose );
setMinimumSize( 150, 150 );
setBackgroundRole( QPalette::Dark );
setWidget( m_cViewArea );
fileExists = false;
m_firsTime = true;
m_dScaleFactor = 1;
}
ImageInterface::~ImageInterface()
{
delete m_cViewArea;
}
bool ImageInterface::loadFile( const QString &fileName, UInt width, UInt height )
{
QApplication::setOverrideCursor( Qt::WaitCursor );
m_currStream.init( fileName, width, height );
m_currStream.readFrame();
if( m_currStream.checkErrors( READING ) )
{
QMessageBox::warning( this, tr( "plaYUVer" ), tr( "Cannot read %1." ).arg( fileName ) );
return false;
}
QApplication::restoreOverrideCursor();
//QImage image( fileName );
//m_cViewArea->setImage( QPixmap::fromImage( image ) );
m_cViewArea->setImage( QPixmap::fromImage( m_currStream.getFrameQImage() ) );
normalSize();
m_cCurrFileName = fileName;
sizeHint();
return true;
}
bool ImageInterface::save()
{
if( isUntitled )
{
return saveAs();
}
else
{
return saveFile( m_cCurrFileName );
}
}
bool ImageInterface::saveAs()
{
QString fileName = QFileDialog::getSaveFileName( this, tr( "Save As" ), m_cCurrFileName );
if( fileName.isEmpty() )
return false;
return saveFile( fileName );
}
bool ImageInterface::saveFile( const QString &fileName )
{
return true;
}
Void ImageInterface::normalSize()
{
m_dScaleFactor = 1.0;
//m_cViewArea->resize( m_dScaleFactor * m_cViewArea->pixmap()->size() );
m_cViewArea->setZoomFactor( m_dScaleFactor );
}
Void ImageInterface::zoomToFit()
{
// Scale to a smaller size that the real to a nicer look
QSize niceFit( viewport()->size().width() - 10, viewport()->size().height() - 10 );
if( m_currStream.getWidth() <= niceFit.width() && m_currStream.getHeight() <= niceFit.height() )
{
normalSize();
return;
}
scaleView( niceFit );
}
Void ImageInterface::scaleView( Double factor )
{
//Q_ASSERT( m_cViewArea->pixmap() );
m_dScaleFactor *= factor;
m_cViewArea->setZoomFactor( m_dScaleFactor );
//m_cViewArea->resize( m_dScaleFactor * m_cViewArea->pixmap()->size() );
adjustScrollBar( m_dScaleFactor );
}
Void ImageInterface::scaleView( Int width, Int height )
{
scaleView( QSize( width, height ) );
}
Void ImageInterface::scaleView( const QSize & size )
{
QSize imgViewSize( m_currStream.getWidth(), m_currStream.getHeight() );
QSize newSize = imgViewSize;
newSize.scale( size, Qt::KeepAspectRatio );
// Calc the zoom factor
Double wfactor = 1;
Double hfactor = 1;
m_dScaleFactor = 1;
wfactor = ( Double )newSize.width() / imgViewSize.width();
hfactor = ( Double )newSize.height() / imgViewSize.height();
if( wfactor < hfactor )
scaleView( wfactor );
else
scaleView( hfactor );
}
Void ImageInterface::adjustScrollBar( Double factor )
{
QScrollBar *scrollBar = horizontalScrollBar();
scrollBar->setValue( int( factor * scrollBar->value() + ( ( factor - 1 ) * scrollBar->pageStep() / 2 ) ) );
scrollBar = verticalScrollBar();
scrollBar->setValue( int( factor * scrollBar->value() + ( ( factor - 1 ) * scrollBar->pageStep() / 2 ) ) );
}
/*
Note: Code imported from Qt4.4
*/
static bool sanityCheck( const QList<QWidget *> &widgets, const int index, const char *where )
{
if( index < 0 || index >= widgets.size() )
{
const char error[] = "index out of range";
Q_ASSERT_X( false, where, error );
qWarning( "%s:%s", where, error );
return false;
}
if( !widgets.at( index ) )
{
const char error[] = "null pointer";
Q_ASSERT_X( false, where, error );
qWarning( "%s:%s", where, error );
return false;
}
return true;
}
QSize ImageInterface::sizeHint()
{
QSize maxSize; // The size of the parent (viewport widget
// of the QMdiArea).
QWidget *p = parentWidget();
if( p )
{
maxSize = p->size();
}
QSize isize = QSize( m_currStream.getWidth() + 50, m_currStream.getHeight() + 50 );
// If the ImageInterface needs more space that the avaiable, we'll give
// to the subwindow a reasonable size preserving the image aspect ratio.
if( isize.width() < maxSize.width() && isize.height() < maxSize.height() )
{
return isize;
}
else
{
isize.scale( maxSize, Qt::KeepAspectRatio );
maxSize = isize;
}
return maxSize;
}
void ImageInterface::cascader( QList<QWidget *> &widgets, const QRect &domain )
{
if( widgets.isEmpty() )
return;
// Tunables:
const int topOffset = 0;
const int bottomOffset = 50;
const int leftOffset = 0;
const int rightOffset = 100;
const int dx = 10;
QStyleOptionTitleBar options;
options.initFrom( widgets.at( 0 ) );
int titleBarHeight = widgets.at( 0 )->style()->pixelMetric( QStyle::PM_TitleBarHeight, &options, widgets.at( 0 ) );
#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
// ### Remove this after the mac style has been fixed
if ( qobject_cast<QMacStyle *>( widgets.at( 0 )->style() ) )
titleBarHeight -= 4;
#endif
const QFontMetrics fontMetrics = QFontMetrics( QApplication::font( "QWorkspaceTitleBar" ) );
const int dy = qMax( titleBarHeight - ( titleBarHeight - fontMetrics.height() ) / 2, 1 );
const int n = widgets.size();
const int nrows = qMax( ( domain.height() - ( topOffset + bottomOffset ) ) / dy, 1 );
const int ncols = qMax( n / nrows + ( ( n % nrows ) ? 1 : 0 ), 1 );
const int dcol = ( domain.width() - ( leftOffset + rightOffset ) ) / ncols;
int i = 0;
for( int row = 0; row < nrows; ++row )
{
for( int col = 0; col < ncols; ++col )
{
const int x = leftOffset + row * dx + col * dcol;
const int y = topOffset + row * dy;
if( !sanityCheck( widgets, i, "SimpleCascader" ) )
continue;
QWidget *widget = widgets.at( i++ );
QRect newGeometry = QRect( QPoint( x, y ), widget->sizeHint() );
widget->setGeometry( QStyle::visualRect( widget->layoutDirection(), domain, newGeometry ) );
if( i == n )
return;
}
}
}
Void ImageInterface::closeEvent( QCloseEvent *event )
{
event->accept();
}
QString ImageInterface::userFriendlyCurrentFile()
{
return m_cCurrFileName;
//return strippedName( m_cCurrFileName );
}
QString ImageInterface::strippedName( const QString &fullFileName )
{
return QFileInfo( fullFileName ).fileName();
}
} // NAMESPACE
+133
View File
@@ -0,0 +1,133 @@
/* 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 imageinterface.h
\brief Sub windows handling
*/
#ifndef __IMAGEINTERFACE_H__
#define __IMAGEINTERFACE_H__
#include <QMdiSubWindow>
#include <QScrollArea>
#include <QLabel>
#include <QMdiArea>
#include <QWidget>
#include <QPixmap>
#include <QBitmap>
#include <QColor>
#include "TypeDef.h"
#include "InputStream.h"
#include "viewarea.h"
namespace plaYUVer
{
using namespace SCode;
class ImageInterface: public QScrollArea
{
Q_OBJECT
private:
//QLabel* m_cViewArea;
ViewArea* m_cViewArea;
QString m_cCurrFileName;
InputStream m_currStream;
Bool isUntitled;
Double m_dScaleFactor;
Bool fileExists;
Bool m_firsTime;
public:
ImageInterface();
~ImageInterface();
bool loadFile( const QString &fileName, UInt width, UInt height );
bool save();
bool saveAs();
bool saveFile( const QString &fileName );
/**
* Show the image at its original size
*/
Void normalSize();
/**
* Scale the image (zoomed in or out) to fit on the window.
*/
Void zoomToFit();
/**
* Scale the image by a given factor
* @param factor factor of scale. Ex: 1.2 scale the image up by 20% and
* 0.8 scale the image down by 25%
*/
Void scaleView( Double factor );
/**
* The current image size is scaled to a rectangle as large as possible
* inside (@p width, @p height ) preserving the aspect ratio.
*/
Void scaleView( Int width, Int height );
/**
* This is an overloaded member function, provided for convenience.
* Scales the image to a rectangle with the given size, preserving the
* aspect ratio.
*/
Void scaleView( const QSize & size );
Void adjustScrollBar( Double factor );
Double getScaleFactor()
{
return m_dScaleFactor;
}
QSize sizeHint();
/**
* Arranges all the listed widgets (normaly QMdiImageInterface) in a cascade
* pattern.
* @Note This function implementation is taken from the Qt source. The
* QMdiArea only have a function that arranges @b all the child windows.
*/
static void cascader( QList<QWidget *> &widgets, const QRect &domain );
QString userFriendlyCurrentFile();
QString strippedName( const QString &fullFileName );
QString currentFile()
{
return m_cCurrFileName;
}
protected:
Void closeEvent( QCloseEvent *event );
private slots:
};
} // NAMESPACE
#endif // __IMAGEINTERFACE_H__
+303
View File
@@ -0,0 +1,303 @@
/* 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 InputStream.cpp
\brief Input handling
*/
#include <cstdio>
#include <QtCore>
#include <QtDebug>
#include "InputStream.h"
#include "LibMemAlloc.h"
namespace plaYUVer
{
InputStream::InputStream()
{
m_iStatus = 0;
m_pFile = NULL;
m_pppcInputPel[0] = NULL;
m_pppcInputPel[1] = NULL;
m_pppcInputPel[2] = NULL;
m_pppcRGBPel = NULL;
m_eFormat = INVALID;
}
InputStream::~InputStream()
{
if( m_pFile )
fclose( m_pFile );
if( m_pppcInputPel[0] )
free_mem2Dpel( m_pppcInputPel[0] );
if( m_pppcInputPel[1] )
free_mem2Dpel( m_pppcInputPel[1] );
if( m_pppcInputPel[2] )
free_mem2Dpel( m_pppcInputPel[2] );
if( m_pppcRGBPel )
free_mem3Dpel( m_pppcRGBPel );
m_iStatus = 0;
}
QString InputStream::supportedReadFormats()
{
QString formats;
formats = "*.yuv " // Raw video
;
return formats;
}
QStringList InputStream::supportedReadFormatsList()
{
QStringList formats;
formats << "Raw video (*.yuv)";
return formats;
}
Void InputStream::init( QString filename, UInt width, UInt height )
{
if( width <= 0 || height <= 0 )
{
//Error
return;
}
m_cFilename = filename;
m_pFile = fopen( m_cFilename.toLocal8Bit().data(), "rb" );
if( m_pFile == NULL )
{
// Error
return;
}
m_uiWidth = width;
m_uiHeight = height;
m_eFormat = YUV_420p;
UInt64 frame_bytes_input = m_uiWidth * m_uiHeight * 1.5;
UInt64 alloc_memory;
fseek( m_pFile, 0, SEEK_END );
m_uiTotalFrameNum = ftell( m_pFile ) / ( frame_bytes_input );
fseek( m_pFile, 0, SEEK_SET );
alloc_memory = get_mem2Dpel( &( m_pppcInputPel[0] ), m_uiHeight, m_uiWidth );
if( !alloc_memory )
{
//Error
return;
}
alloc_memory = get_mem2Dpel( &( m_pppcInputPel[1] ), m_uiHeight / 2, m_uiWidth / 2 );
if( !alloc_memory )
{
//Error
return;
}
alloc_memory = get_mem2Dpel( &( m_pppcInputPel[2] ), m_uiHeight / 2, m_uiWidth / 2 );
if( !alloc_memory )
{
//Error
return;
}
get_mem3Dpel( &m_pppcRGBPel, 3, m_uiHeight, m_uiWidth );
if( !alloc_memory )
{
//Error
return;
}
m_iStatus = 1;
return;
}
static inline Pel iClip3Pel( Pel pel_value, Pel min_value, Pel max_value )
{
if( pel_value > max_value )
return max_value;
if( pel_value < min_value )
return min_value;
return pel_value;
}
static inline void yuvToRgb( int iY, int iU, int iV, int &iR, int &iG, int &iB )
{
iR = iY + 1402 * iV / 1000;
iG = iY - ( 101004 * iU + 209599 * iV ) / 293500;
iB = iY + 1772 * iU / 1000;
if( iR < 0 )
iR = 0;
if( iG < 0 )
iG = 0;
if( iB < 0 )
iB = 0;
if( iR > 255 )
iR = 255;
if( iG > 255 )
iG = 255;
if( iB > 255 )
iB = 255;
}
Void InputStream::YUV420toRGB()
{
Int iY, iU, iV, iR, iG, iB;
for( Int y = 0; y < m_uiHeight; y += 2 )
{
for( Int x = 0; x < m_uiWidth; x += 2 )
{
// Pixel (x, y).
iY = m_pppcInputPel[0][y][x];
iU = m_pppcInputPel[1][y >> 1][x >> 1];
iV = m_pppcInputPel[2][y >> 1][x >> 1];
iU -= 128;
iV -= 128;
yuvToRgb( iY, iU, iV, iR, iG, iB );
m_pppcRGBPel[0][y][x] = iR;
m_pppcRGBPel[1][y][x] = iG;
m_pppcRGBPel[2][y][x] = iB;
// Pixel (x+1, y)
iY = m_pppcInputPel[0][y][x + 1];
yuvToRgb( iY, iU, iV, iR, iG, iB );
m_pppcRGBPel[0][y][x + 1] = iR;
m_pppcRGBPel[1][y][x + 1] = iG;
m_pppcRGBPel[2][y][x + 1] = iB;
// Pixel (x, y+1)
iY = m_pppcInputPel[0][y + 1][x];
yuvToRgb( iY, iU, iV, iR, iG, iB );
m_pppcRGBPel[0][y + 1][x] = iR;
m_pppcRGBPel[1][y + 1][x] = iG;
m_pppcRGBPel[2][y + 1][x] = iB;
// Pixel (x+1, y+1)
iY = m_pppcInputPel[0][y + 1][x + 1];
yuvToRgb( iY, iU, iV, iR, iG, iB );
m_pppcRGBPel[0][y + 1][x + 1] = iR;
m_pppcRGBPel[1][y + 1][x + 1] = iG;
m_pppcRGBPel[2][y + 1][x + 1] = iB;
}
}
}
Void InputStream::readFrame()
{
UInt64 bytes_read = 0;
UInt64 frame_bytes_input = m_uiWidth * m_uiHeight * 1.5;
bytes_read = fread( &( m_pppcInputPel[0][0][0] ), sizeof(Pel), m_uiWidth * m_uiHeight, m_pFile );
if( bytes_read != ( m_uiWidth * m_uiHeight ) )
{
m_iErrorStatus = READING;
qDebug() << " Reading error !!!" << endl;
return;
}
bytes_read = fread( &( m_pppcInputPel[1][0][0] ), sizeof(Pel), m_uiWidth * m_uiHeight / 4, m_pFile );
if( bytes_read != ( m_uiWidth * m_uiHeight / 4 ) )
{
m_iErrorStatus = READING;
qDebug() << " Reading error !!!" << endl;
return;
}
bytes_read = fread( &( m_pppcInputPel[2][0][0] ), sizeof(Pel), m_uiWidth * m_uiHeight / 4, m_pFile );
if( bytes_read != ( m_uiWidth * m_uiHeight / 4 ) )
{
m_iErrorStatus = READING;
qDebug() << " Reading error !!!" << endl;
return;
}
YUV420toRGB();
return;
}
QImage InputStream::getFrameQImage()
{
// Create QImage
QImage img( m_uiWidth, m_uiHeight, QImage::Format_RGB888 );
UInt64 frame_bytes = m_uiWidth * m_uiHeight;
Pel pelR, pelG, pelB;
Pel* bufferRGB = &( m_pppcRGBPel[0][0][0] );
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( m_pppcRGBPel[0][y][x], m_pppcRGBPel[1][y][x], m_pppcRGBPel[2][y][x] ) );
//img.setPixel( x, y, qRgb( 0, 0, 255 ) );
}
}
}
else
{
Q_ASSERT( 0 );
}
return img;
}
Void InputStream::seekInput( Int new_frame_num )
{
UInt64 frame_bytes_input = m_uiWidth * m_uiHeight * 1.5;
UInt64 nbytes_seek = frame_bytes_input * new_frame_num;
fseek( m_pFile, nbytes_seek, SEEK_SET );
m_uiCurrFrameNum = new_frame_num;
}
Bool InputStream::checkErrors( Int error_type )
{
if( m_iErrorStatus == error_type )
{
m_iErrorStatus = NO_ERROR;
return true;
}
return false;
}
} // NAMESPACE
+126
View File
@@ -0,0 +1,126 @@
/* 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 InputStream.h
\brief Input handling
*/
#ifndef __INPUTSTREAM_H__
#define __INPUTSTREAM_H__
#include <iostream>
#include <cstdio>
#include <QtCore>
#include <QtGui>
#include "TypeDef.h"
namespace plaYUVer
{
typedef enum YUV_FILE_FORMATS
{
INVALID = 0, YUV_420p = 1,
} YUVFileFormats;
enum InputStream_Errors
{
NO_ERROR = 0, READING = 1,
};
class InputStream
{
private:
Int m_iStatus;
Int m_iErrorStatus;
QString m_cFilename;
FILE* m_pFile; /**< The input file pointer >*/
YUVFileFormats m_eFormat;
UInt m_uiWidth;
UInt m_uiHeight;
UInt m_uiTotalFrameNum;
UInt m_uiCurrFrameNum;
Pel** m_pppcInputPel[3];
Pel*** m_pppcRGBPel;
public:
InputStream();
~InputStream();
static QString supportedReadFormats();
static QStringList supportedReadFormatsList();
Void init( QString filename, UInt width, UInt height );
Void YUV420toRGB();
Void readFrame();
QImage getFrameQImage();
Void seekInput( Int new_frame_num );
Bool checkErrors( Int error_type );
Int getStatus()
{
return m_iStatus;
}
UInt getFrameNum()
{
return m_uiTotalFrameNum;
}
UInt getWidth()
{
return m_uiWidth;
}
UInt getHeight()
{
return m_uiHeight;
}
UInt getCurrFrameNum()
{
return m_uiCurrFrameNum;
}
Void setWidth( UInt new_width )
{
if( new_width > 0 && new_width % 2 == 0 )
{
m_uiWidth = new_width;
}
}
Void setHeight( UInt new_height )
{
if( new_height > 0 && new_height % 2 == 0 )
{
m_uiHeight = new_height;
}
}
};
} // NAMESPACE
#endif // __INPUTSTREAM_H__
+137
View File
@@ -0,0 +1,137 @@
/* 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 LibMemAlloc.cpp
\brief memory allocation functions
*/
#include "LibMemAlloc.h"
/*!
************************************************************************
* \brief
* Allocate 1D memory array -> Pel array1D[dim0
*
* \par Output:
* memory size in bytes
************************************************************************/
int get_mem1Dpel( Pel **array1D, int dim0 )
{
if( ( *array1D = ( Pel* )mem_calloc( dim0, sizeof(Pel) ) ) == NULL )
return 0;
return ( sizeof(Pel*) + dim0 * sizeof(Pel) );
}
/*!
************************************************************************
* \brief
* Allocate 2D memory array -> Pel array2D[dim0][dim1]
*
* \par Output:
* memory size in bytes
************************************************************************/
int get_mem2Dpel( Pel ***array2D, int dim0, int dim1 )
{
int i;
if( ( *array2D = ( Pel** )mem_malloc( dim0 * sizeof(Pel*) ) ) == NULL )
return 0;
if( ( *( *array2D ) = ( Pel* )mem_malloc( dim0 * dim1 * sizeof(Pel) ) ) == NULL )
return 0;
for( i = 1; i < dim0; i++ )
{
( *array2D )[i] = ( *array2D )[i - 1] + dim1;
}
return dim0 * ( sizeof(Pel*) + dim1 * sizeof(Pel) );
}
/*!
************************************************************************
* \brief
* Allocate 3D memory array -> Pel array3D[dim0][dim1][dim2]
*
* \par Output:
* memory size in bytes
************************************************************************
*/
int get_mem3Dpel( Pel ****array3D, int dim0, int dim1, int dim2 )
{
int i, mem_size = dim0 * sizeof(Pel**);
if( ( ( *array3D ) = ( Pel*** )malloc( dim0 * sizeof(Pel**) ) ) == NULL )
return 0;
mem_size += get_mem2Dpel( *array3D, dim0 * dim1, dim2 );
for( i = 1; i < dim0; i++ )
( *array3D )[i] = ( *array3D )[i - 1] + dim1;
return mem_size;
}
/*!
************************************************************************
* \brief
* free 1D memory array
* which was allocated with get_mem1Dpel()
************************************************************************
*/
void free_mem1Dpel( Pel *array1D )
{
if( array1D )
{
mem_free( array1D );
}
}
/*!
************************************************************************
* \brief
* free 2D memory array
* which was allocated with get_mem2Dpel()
************************************************************************
*/
void free_mem2Dpel( Pel **array2D )
{
if( array2D )
{
if( *array2D )
mem_free( *array2D );
mem_free( array2D );
}
}
/*!
************************************************************************
* \brief
* free 3D memory array
* which was allocated with get_mem3Dpel()
************************************************************************
*/
void free_mem3Dpel( Pel ***array3D )
{
if( array3D )
{
free_mem2Dpel( *array3D );
mem_free( array3D );
}
}
+70
View File
@@ -0,0 +1,70 @@
/* 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 LibMemAlloc.h
\brief memory allocation functions
*/
#ifndef __LIBMEMALLOC_H__
#define __LIBMEMALLOC_H__
#include <cstdlib>
#include <cstring>
#include "TypeDef.h"
extern int get_mem1Dpel( Pel **array2D, int dim0 );
extern int get_mem2Dpel( Pel ***array2D, int dim0, int dim1 );
extern int get_mem3Dpel( Pel ****array3D, int dim0, int dim1, int dim2 );
extern void free_mem1Dpel( Pel *array1D );
extern void free_mem2Dpel( Pel **array2D );
extern void free_mem3Dpel( Pel ***array3D );
/*!
************************************************************************
* \brief
* allocate and set memory aligned at SSE_MEMORY_ALIGNMENT
*
************************************************************************/
static inline void* mem_malloc( size_t nitems )
{
void *d;
if( ( d = malloc( nitems ) ) == NULL )
{
return NULL;
}
return d;
}
static inline void* mem_calloc( size_t nitems, size_t size )
{
size_t padded_size = nitems * size;
void *d = mem_malloc( padded_size );
memset( d, 0, ( int )padded_size );
return d;
}
static inline void mem_free( void *ptr )
{
if( ptr != NULL )
{
free( ptr );
ptr = NULL;
}
}
#endif // __LIBMEMALLOC_H__
+93
View File
@@ -0,0 +1,93 @@
/* 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 TypeDef.h
\brief Define basic types, new types and enumerations
*/
#ifndef __TYPEDEF_H__
#define __TYPEDEF_H__
// ====================================================================================================================
// Basic type redefinition
// ====================================================================================================================
typedef void Void;
typedef bool Bool;
typedef char Char;
typedef unsigned char UChar;
typedef short Short;
typedef unsigned short UShort;
typedef int Int;
typedef unsigned int UInt;
typedef double Double;
typedef float Float;
// ====================================================================================================================
// 64-bit integer type
// ====================================================================================================================
#ifdef _MSC_VER
typedef __int64 Int64;
#if _MSC_VER <= 1200 // MS VC6
typedef __int64 UInt64; // MS VC6 does not support unsigned __int64 to double conversion
#else
typedef unsigned __int64 UInt64;
#endif
#else
typedef long long Int64;
typedef unsigned long long UInt64;
#endif
// ====================================================================================================================
// Type definition
// ====================================================================================================================
typedef UChar Pel; ///< 8-bit pixel type
//typedef Short Pel; ///< 16-bit pixel type
// ====================================================================================================================
// Limits definition
// ====================================================================================================================
#define MAX_UINT 0xFFFFFFFFU ///< max. value of unsigned 32-bit integer
#define MAX_INT 2147483647 ///< max. value of signed 32-bit integer
#define MAX_INT64 0x7FFFFFFFFFFFFFFFLL ///< max. value of signed 64-bit integer
#define MAX_DOUBLE 1.7e+308 ///< max. value of double-type value
// ====================================================================================================================
// Macro functions
// ====================================================================================================================
#define DATA_ALIGN 1 ///< use 32-bit aligned malloc/free
#if DATA_ALIGN && _WIN32 && ( _MSC_VER > 1300 )
#define xMalloc( type, len ) _aligned_malloc( sizeof(type)*(len), 32 )
#define xFree( ptr ) _aligned_free ( ptr )
#define xMemSet( type, len, ptr )
#else
#define xMemSet( type, len, ptr ) memset ( ptr, 0, (len)*sizeof(type) )
#define xMalloc( type, len ) malloc ( sizeof(type)*(len) )
#define xFree( ptr ) free ( ptr )
#endif
#endif // __TYPEDEF_H__
+36
View File
@@ -0,0 +1,36 @@
/* 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 main.cp
\brief main file
*/
#include <QApplication>
#include "plaYUVerApp.h"
using namespace plaYUVer;
int main( int argc, char *argv[] )
{
QApplication a( argc, argv );
plaYUVerApp w;
w.show();
return a.exec();
}
+421
View File
@@ -0,0 +1,421 @@
/* This file is a part of plaYUVerApp project
* Copyright (C) 2014 by plaYUVerApp 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 plaYUVerApp.cpp
\brief Main definition of the plaYUVerApp app
*/
/*!
************************************************************************
* \file
* plaYUVerApp.cpp
* \brief
* Main definition of the plaYUVerApp App
************************************************************************
*/
#include <QtWidgets>
#include <QMdiArea>
#include <QtDebug>
#include "TypeDef.h"
#include "plaYUVerApp.h"
#include "ImageInterface.h"
#include "InputStream.h"
namespace plaYUVer
{
plaYUVerApp::plaYUVerApp()
{
setWindowModality( Qt::ApplicationModal );
mdiArea = new QMdiArea;
mdiArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded );
mdiArea->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );
setCentralWidget( mdiArea );
connect( mdiArea, SIGNAL( subWindowActivated(QMdiImageInterface*) ), this, SLOT( updateMenus() ) );
windowMapper = new QSignalMapper( this );
connect( windowMapper, SIGNAL( mapped(QWidget*) ), this, SLOT( setActiveImageInterface(QWidget*) ) );
createActions();
createMenus();
createToolBars();
createStatusBar();
updateMenus();
readSettings();
setWindowTitle( tr( "plaYUVerApp" ) );
setWindowIcon( QIcon( ":/images/plaYUVerApp.png" ) );
setUnifiedTitleAndToolBarOnMac( true );
}
Void plaYUVerApp::closeEvent( QCloseEvent *event )
{
mdiArea->closeAllSubWindows();
if( mdiArea->currentSubWindow() )
{
event->ignore();
}
else
{
writeSettings();
event->accept();
}
}
// ----------------------- File Functions -----------------------
void plaYUVerApp::open()
{
QString supported = tr( "Supported Files" );
QString formats = InputStream::supportedReadFormats();
formats.prepend( " (" );
formats.append( ")" );
supported.append( formats ); // supported=="Supported Files (*.pbm *.jpg...)"
QStringList filter;
filter << supported << InputStream::supportedReadFormatsList() << tr( "All Files (*)" );
QString fileName = QFileDialog::getOpenFileName( this, tr( "Open File" ), m_cLastOpenPath, filter.join( ";;" ) );
if( !fileName.isEmpty() )
{
m_cLastOpenPath = QFileInfo( fileName ).path();
QMdiSubWindow *existing = findImageInterface( fileName );
if( existing )
{
mdiArea->setActiveSubWindow( existing );
return;
}
ImageInterface *interfaceChild = new ImageInterface; //createImageInterface();
if( interfaceChild->loadFile( fileName, 1024, 768 ) )
{
addImageInterface( interfaceChild );
statusBar()->showMessage( tr( "File loaded" ), 2000 );
interfaceChild->show();
}
else
{
interfaceChild->close();
}
}
}
void plaYUVerApp::saveAs()
{
}
// ----------------------- Zoom Functions -----------------------
void plaYUVerApp::zoomIn()
{
scaleImage( 1.25 );
}
void plaYUVerApp::zoomOut()
{
scaleImage( 0.8 );
}
void plaYUVerApp::normalSize()
{
if( activeImageInterface() )
activeImageInterface()->normalSize();
}
void plaYUVerApp::zoomToFit()
{
if( activeImageInterface() )
activeImageInterface()->zoomToFit();
}
Void plaYUVerApp::scaleImage( Double factor )
{
if( activeImageInterface() )
{
activeImageInterface()->scaleView( factor );
zoomInAct->setEnabled( activeImageInterface()->getScaleFactor() < 3.0 );
zoomOutAct->setEnabled( activeImageInterface()->getScaleFactor() > 0.333 );
}
}
// ----------------------- About Functions -----------------------
void plaYUVerApp::about()
{
QMessageBox::about( this, tr( "About plaYUVerApp" ), tr( "The <b>plaYUVerApp</b> is an open-source raw video player " ) );
}
void plaYUVerApp::updateMenus()
{
Bool hasImageInterface = ( activeImageInterface() != 0 );
saveAsAct->setEnabled( hasImageInterface );
closeAct->setEnabled( hasImageInterface );
closeAllAct->setEnabled( hasImageInterface );
tileAct->setEnabled( hasImageInterface );
cascadeAct->setEnabled( hasImageInterface );
nextAct->setEnabled( hasImageInterface );
previousAct->setEnabled( hasImageInterface );
separatorAct->setVisible( hasImageInterface );
}
void plaYUVerApp::updateWindowMenu()
{
windowMenu->clear();
windowMenu->addAction( closeAct );
windowMenu->addAction( closeAllAct );
windowMenu->addSeparator();
windowMenu->addAction( tileAct );
windowMenu->addAction( cascadeAct );
windowMenu->addSeparator();
windowMenu->addAction( nextAct );
windowMenu->addAction( previousAct );
windowMenu->addAction( separatorAct );
updateMenus();
QList<QMdiSubWindow *> windows = mdiArea->subWindowList();
separatorAct->setVisible( !windows.isEmpty() );
for( Int i = 0; i < windows.size(); ++i )
{
ImageInterface *child = qobject_cast<ImageInterface *>( windows.at( i )->widget() );
QString text;
if( i < 9 )
{
text = tr( "&%1 %2" ).arg( i + 1 ).arg( child->userFriendlyCurrentFile() );
}
else
{
text = tr( "%1 %2" ).arg( i + 1 ).arg( child->userFriendlyCurrentFile() );
}
QAction *action = windowMenu->addAction( text );
action->setCheckable( true );
action->setChecked( child == activeImageInterface() );
connect( action, SIGNAL( triggered() ), windowMapper, SLOT( map() ) );
windowMapper->setMapping( action, windows.at( i ) );
}
}
ImageInterface *plaYUVerApp::createImageInterface()
{
ImageInterface *child = new ImageInterface;
mdiArea->addSubWindow( child );
return child;
}
void plaYUVerApp::addImageInterface( ImageInterface *child )
{
connect( child, SIGNAL( areaSelected( QRect ) ), this, SLOT( setSelection( QRect ) ) );
// Add the interface to the mdiArea
mdiArea->addSubWindow( child );
return;
}
Void plaYUVerApp::createActions()
{
// ------------ File ------------
openAct = new QAction( QIcon( ":/images/open.png" ), tr( "&Open..." ), this );
openAct->setShortcuts( QKeySequence::Open );
openAct->setStatusTip( tr( "Open an existing file" ) );
connect( openAct, SIGNAL( triggered() ), this, SLOT( open() ) );
saveAsAct = new QAction( QIcon( ":/images/saveas.png" ), tr( "Save &As..." ), this );
saveAsAct->setShortcuts( QKeySequence::SaveAs );
saveAsAct->setStatusTip( tr( "Save the document under a new name" ) );
connect( saveAsAct, SIGNAL( triggered() ), this, SLOT( saveAs() ) );
exitAct = new QAction( tr( "E&xit" ), this );
exitAct->setShortcuts( QKeySequence::Quit );
exitAct->setStatusTip( tr( "Exit the application" ) );
connect( exitAct, SIGNAL( triggered() ), qApp, SLOT( closeAllWindows() ) );
closeAct = new QAction( tr( "Cl&ose" ), this );
closeAct->setIcon( QIcon( ":/images/close.png" ) );
closeAct->setStatusTip( tr( "Close the active window" ) );
connect( closeAct, SIGNAL( triggered() ), mdiArea, SLOT( closeActiveSubWindows() ) );
closeAllAct = new QAction( tr( "Close &All" ), this );
closeAllAct->setStatusTip( tr( "Close all the windows" ) );
connect( closeAllAct, SIGNAL( triggered() ), mdiArea, SLOT( closeAllSubWindows() ) );
// ------------ View ------------
zoomInAct = new QAction( tr( "Zoom &In (25%)" ), this );
zoomInAct->setIcon( QIcon( ":/images/zoomin.png" ) );
zoomInAct->setShortcut( tr( "Ctrl++" ) );
zoomInAct->setStatusTip( tr( "Scale the image up by 25%" ) );
connect( zoomInAct, SIGNAL( triggered() ), this, SLOT( zoomIn() ) );
zoomOutAct = new QAction( tr( "Zoom &Out (25%)" ), this );
zoomOutAct->setIcon( QIcon( ":/images/zoomout.png" ) );
zoomOutAct->setShortcut( tr( "Ctrl+-" ) );
zoomOutAct->setStatusTip( tr( "Scale the image down by 25%" ) );
connect( zoomOutAct, SIGNAL( triggered() ), this, SLOT( zoomOut() ) );
normalSizeAct = new QAction( tr( "&Normal Size" ), this );
normalSizeAct->setIcon( QIcon( ":/images/zoomtonormal.png" ) );
normalSizeAct->setShortcut( tr( "Ctrl+N" ) );
normalSizeAct->setStatusTip( tr( "Show the image at its original size" ) );
connect( normalSizeAct, SIGNAL( triggered() ), this, SLOT( normalSize() ) );
zoomToFitAct = new QAction( tr( "Zoom to &Fit" ), this );
zoomToFitAct->setIcon( QIcon( ":/images/fittowindow.png" ) );
zoomToFitAct->setStatusTip( tr( "Zoom in or out to fit on the window." ) );
zoomToFitAct->setShortcut( tr( "Ctrl+F" ) );
connect( zoomToFitAct, SIGNAL( triggered() ), this, SLOT( zoomToFit() ) );
// ------------ Window ------------
tileAct = new QAction( tr( "&Tile" ), this );
tileAct->setStatusTip( tr( "Tile the windows" ) );
connect( tileAct, SIGNAL( triggered() ), mdiArea, SLOT( tileSubWindows() ) );
cascadeAct = new QAction( tr( "&Cascade" ), this );
cascadeAct->setStatusTip( tr( "Cascade the windows" ) );
connect( cascadeAct, SIGNAL( triggered() ), mdiArea, SLOT( cascadeSubWindows() ) );
nextAct = new QAction( tr( "Ne&xt" ), this );
nextAct->setShortcuts( QKeySequence::NextChild );
nextAct->setStatusTip( tr( "Move the focus to the next window" ) );
connect( nextAct, SIGNAL( triggered() ), mdiArea, SLOT( activateNextSubWindows() ) );
previousAct = new QAction( tr( "Pre&vious" ), this );
previousAct->setShortcuts( QKeySequence::PreviousChild );
previousAct->setStatusTip( tr( "Move the focus to the previous window" ) );
connect( previousAct, SIGNAL( triggered() ), mdiArea, SLOT( activatePreviousSubWindows() ) );
separatorAct = new QAction( this );
separatorAct->setSeparator( true );
// ------------ About ------------
aboutAct = new QAction( tr( "&About" ), this );
aboutAct->setStatusTip( tr( "Show the application's About box" ) );
connect( aboutAct, SIGNAL( triggered() ), this, SLOT( about() ) );
aboutQtAct = new QAction( tr( "About &Qt" ), this );
aboutQtAct->setIcon( QIcon( ":images/qt.png" ) );
aboutQtAct->setStatusTip( tr( "Show the Qt library's About box" ) );
connect( aboutQtAct, SIGNAL( triggered() ), qApp, SLOT( aboutQt() ) );
}
Void plaYUVerApp::createMenus()
{
fileMenu = menuBar()->addMenu( tr( "&File" ) );
fileMenu->addAction( openAct );
fileMenu->addSeparator();
fileMenu->addAction( saveAsAct );
fileMenu->addSeparator();
fileMenu->addAction( closeAct );
fileMenu->addAction( exitAct );
viewMenu = new QMenu( tr( "&View" ), this );
viewMenu->addAction( zoomInAct );
viewMenu->addAction( zoomOutAct );
viewMenu->addAction( normalSizeAct );
viewMenu->addAction( zoomToFitAct );
windowMenu = menuBar()->addMenu( tr( "&Window" ) );
updateWindowMenu();
connect( windowMenu, SIGNAL( aboutToShow() ), this, SLOT( updateWindowMenu() ) );
menuBar()->addSeparator();
helpMenu = menuBar()->addMenu( tr( "&Help" ) );
helpMenu->addAction( aboutAct );
helpMenu->addAction( aboutQtAct );
}
Void plaYUVerApp::createToolBars()
{
fileToolBar = addToolBar( tr( "File" ) );
fileToolBar->addAction( openAct );
fileToolBar->addAction( saveAsAct );
fileToolBar->addAction( closeAct );
viewToolBar = addToolBar( tr( "Zoom" ) );
viewToolBar->addAction( zoomInAct );
viewToolBar->addAction( zoomOutAct );
viewToolBar->addAction( normalSizeAct );
viewToolBar->addAction( zoomToFitAct );
}
Void plaYUVerApp::createStatusBar()
{
statusBar()->showMessage( tr( "Ready" ) );
}
Void plaYUVerApp::readSettings()
{
QSettings settings( "IT", "YUV Player" );
QPoint pos = settings.value( "pos", QPoint( 200, 200 ) ).toPoint();
QSize size = settings.value( "size", QSize( 400, 400 ) ).toSize();
move( pos );
resize( size );
}
Void plaYUVerApp::writeSettings()
{
QSettings settings( "IT", "YUV Player" );
settings.setValue( "pos", pos() );
settings.setValue( "size", size() );
}
ImageInterface *plaYUVerApp::activeImageInterface()
{
if( QMdiSubWindow *activeImageInterface = mdiArea->activeSubWindow() )
return qobject_cast<ImageInterface *>( activeImageInterface->widget() );
return 0;
}
QMdiSubWindow *plaYUVerApp::findImageInterface( const QString &fileName )
{
QString canonicalFilePath = QFileInfo( fileName ).canonicalFilePath();
foreach( QMdiSubWindow * window, mdiArea->subWindowList() ){
ImageInterface *mdiChild = qobject_cast<ImageInterface *>( window->widget() );
if( mdiChild->currentFile() == canonicalFilePath )
return window;
}
return 0;
}
void plaYUVerApp::setActiveImageInterface( QWidget *window )
{
if( !window )
return;
mdiArea->setActiveSubWindow( qobject_cast<QMdiSubWindow *>( window ) );
}
} // NAMESPACE
+125
View File
@@ -0,0 +1,125 @@
/* This file is a part of plaYUVerApp project
* Copyright (C) 2014 by plaYUVerApp 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 plaYUVerApp.h
\brief Main definition of the plaYUVerApp app
*/
#ifndef __PLAYUVERAPP_H__
#define __PLAYUVERAPP_H__
#include <QMainWindow>
#include "TypeDef.h"
class QAction;
class QMenu;
class QMdiArea;
class QMdiSubWindow;
class QSignalMapper;
namespace plaYUVer
{
class ImageInterface;
class plaYUVerApp: public QMainWindow
{
Q_OBJECT
public:
plaYUVerApp();
protected:
Void closeEvent( QCloseEvent *event );
private slots:
//! File functions
void open();
void saveAs();
//! View functions
void zoomIn();
void zoomOut();
void normalSize();
void zoomToFit();
//! Show a message box with some information about the plaYUVerApp App
void about();
void updateMenus();
void updateWindowMenu();
ImageInterface *createImageInterface();
void addImageInterface( ImageInterface *child );
void setActiveImageInterface( QWidget *window );
private:
Void createActions();
Void createMenus();
Void createToolBars();
Void createStatusBar();
Void readSettings();
Void writeSettings();
ImageInterface *activeImageInterface();
QMdiSubWindow *findImageInterface( const QString &fileName );
/**
* Scale the image by a given factor
* @param factor factor of scale. Ex: 1.2 scale the image up by 20% and
* 0.8 scale the image down by 25%
*/
Void scaleImage( Double factor );
QString m_cLastOpenPath;
QMdiArea *mdiArea;
QSignalMapper *windowMapper;
QMenu *fileMenu;
QMenu *viewMenu;
QMenu *windowMenu;
QMenu *helpMenu;
QToolBar *fileToolBar;
QToolBar *viewToolBar;
QAction *openAct;
QAction *saveAct;
QAction *saveAsAct;
QAction *exitAct;
QAction *closeAct;
QAction *closeAllAct;
QAction *zoomInAct;
QAction *zoomOutAct;
QAction *normalSizeAct;
QAction *zoomToFitAct;
QAction *tileAct;
QAction *cascadeAct;
QAction *nextAct;
QAction *previousAct;
QAction *separatorAct;
QAction *aboutAct;
QAction *aboutQtAct;
};
} // NAMESPACE
#endif // __PLAYUVERAPP_H__
+318
View File
@@ -0,0 +1,318 @@
/* 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 playuversettings.h
\brief plaYUVer app settings
*/
#include <QDir>
#include "plaYUVerSettings.h"
namespace plaYUVer
{
PlaYUVerSettings::PlaYUVerSettings() :
m_settings( "IT", "YUV Player" )
{
}
// - - - - - - - - - - - - Main Window Settings - - - - - - - - - - - - - - - -
QPoint PlaYUVerSettings::mainWindowPos()
{
return m_settings.value( "MainWindow/pos", QPoint( 200, 200 ) ).toPoint();
}
void PlaYUVerSettings::setMainWindowPos( const QPoint & pos )
{
m_settings.setValue( "MainWindow/pos", pos );
}
QSize PlaYUVerSettings::mainWindowSize()
{
return m_settings.value( "MainWindow/size", QSize( 500, 400 ) ).toSize();
}
void PlaYUVerSettings::setMainWindowSize( const QSize & size )
{
m_settings.setValue( "MainWindow/size", size );
}
QString PlaYUVerSettings::lastOpenPath()
{
return m_settings.value( "MainWindow/lastOpenPath", QDir::homePath() ).toString();
}
void PlaYUVerSettings::setLastOpenPath( const QString & path )
{
m_settings.setValue( "MainWindow/lastOpenPath", path );
}
// - - - - - - - - - - - - - Segmentation Settings - - - - - - - - - - - - - -
QBitArray PlaYUVerSettings::results2show()
{
QBitArray vectorRes( 20, false );
vectorRes.setBit( 16, true );
vectorRes.setBit( 17, true );
return m_settings.value( "Segmentation/vectorResults", vectorRes ).toBitArray();
}
void PlaYUVerSettings::setResults2show( QBitArray vectorRes )
{
m_settings.setValue( "Segmentation/vectorResults", vectorRes );
}
// - - - - - - - - - - - - - MMP-compound Encoder settings - - - - - - - - - - - - - - -
QString PlaYUVerSettings::binaryPath()
{
return m_settings.value( "MMP/binaryPath", QDir::currentPath() ).toString();
}
void PlaYUVerSettings::setBinaryPath( QString binaryPath )
{
m_settings.setValue( "MMP/binaryPath", binaryPath );
}
QString PlaYUVerSettings::oimagePath()
{
return m_settings.value( "MMP/oimagePath", QDir::currentPath() ).toString();
}
void PlaYUVerSettings::setOimagePath( QString oimagePath )
{
m_settings.setValue( "MMP/oimagePath", oimagePath );
}
int PlaYUVerSettings::blockSize()
{
return m_settings.value( "MMP/blockSize", 8 ).toInt();
}
void PlaYUVerSettings::setBlockSize( int blockSize )
{
m_settings.setValue( "MMP/blockSize", blockSize );
}
int PlaYUVerSettings::quantization()
{
return m_settings.value( "MMP/quantization", 4 ).toInt();
}
void PlaYUVerSettings::setQuantization( int quantization )
{
m_settings.setValue( "MMP/quantization", quantization );
}
int PlaYUVerSettings::predictionLevel()
{
return m_settings.value( "MMP/predictionLevel", 0 ).toInt();
}
void PlaYUVerSettings::setPredictionLevel( int predictionlevel )
{
m_settings.setValue( "MMP/predictionLevel", predictionlevel );
}
int PlaYUVerSettings::defineBounds()
{
return m_settings.value( "MMP/defineBounds", 1 ).toInt();
}
void PlaYUVerSettings::setDefineBounds( int definebounds )
{
m_settings.setValue( "MMP/defineBounds", definebounds );
}
int PlaYUVerSettings::lambda()
{
return m_settings.value( "MMP/lambda", 1000 ).toInt();
}
void PlaYUVerSettings::setLambda( int lambda )
{
m_settings.setValue( "MMP/lambda", lambda );
}
int PlaYUVerSettings::dictionary()
{
return m_settings.value( "MMP/dictionary", 5000 ).toInt();
}
void PlaYUVerSettings::setDictionary( int dictionary )
{
m_settings.setValue( "MMP/dictionary", dictionary );
}
int PlaYUVerSettings::radiusDistortion()
{
return m_settings.value( "MMP/radiusDistortion", 100 ).toInt();
}
void PlaYUVerSettings::setRadiusDistortion( int distortion )
{
m_settings.setValue( "MMP/radiusDistortion", distortion );
}
int PlaYUVerSettings::losslessDistance()
{
return m_settings.value( "MMP/losslessDistance", 0 ).toInt();
}
void PlaYUVerSettings::setLosslessDistance( int distance )
{
m_settings.setValue( "MMP/losslessDistance", distance );
}
int PlaYUVerSettings::mmpAutoSeg()
{
return m_settings.value( "MMP/autoSeg", 1 ).toInt();
}
void PlaYUVerSettings::setMmpAutoSeg( int autoSeg )
{
m_settings.setValue( "MMP/autoSeg", autoSeg );
}
/*
bool PlaYUVerSettings::fastMode()
{
return m_settings.value("MMP/fastMode", 1).toBool();
}
void PlaYUVerSettings::setFastMode( bool fastmode )
{
m_settings.setValue("MMP/fastMode" , fastmode);
}
*/
QBitArray PlaYUVerSettings::mmpTenCheckBoxs()
{
QBitArray bitArray( 10, false );
return m_settings.value( "MMP/tenCheckBoxs", bitArray ).toBitArray();
}
void PlaYUVerSettings::setMmpTenCheckBoxs( QBitArray tenCheckBoxs )
{
m_settings.setValue( "MMP/tenCheckBoxs", tenCheckBoxs );
}
// - - - - - - - - - - - - - MMP-compound Decoder settings - - - - - - - - - - - - - - -
QString PlaYUVerSettings::binaryPathDec()
{
return m_settings.value( "MMPdec/binaryPath", QDir::currentPath() ).toString();
}
void PlaYUVerSettings::setBinaryPathDec( QString binaryPath )
{
m_settings.setValue( "MMPdec/binaryPath", binaryPath );
}
QString PlaYUVerSettings::oimagePathDec()
{
return m_settings.value( "MMPdec/oimagePath", QDir::currentPath() ).toString();
}
void PlaYUVerSettings::setOimagePathDec( QString oimagePath )
{
m_settings.setValue( "MMPdec/oimagePath", oimagePath );
}
bool PlaYUVerSettings::optOutResDec()
{
return m_settings.value( "MMPdec/optOutRes", 0 ).toBool();
}
void PlaYUVerSettings::setOptOutResDec( bool par )
{
m_settings.setValue( "MMPdec/optOutRes", par );
}
QString PlaYUVerSettings::outResDec()
{
return m_settings.value( "MMPdec/outRes", "" ).toString();
}
void PlaYUVerSettings::setOutResDec( QString str )
{
m_settings.setValue( "MMPdec/outRes", str );
}
bool PlaYUVerSettings::optImgYDec()
{
return m_settings.value( "MMPdec/optImgY", 0 ).toBool();
}
void PlaYUVerSettings::setOptImgYDec( bool par )
{
m_settings.setValue( "MMPdec/optImgY", par );
}
QString PlaYUVerSettings::imgYDec()
{
return m_settings.value( "MMPdec/imgY", "" ).toString();
}
void PlaYUVerSettings::setImgYDec( QString str )
{
m_settings.setValue( "MMPdec/imgY", str );
}
bool PlaYUVerSettings::optImgUDec()
{
return m_settings.value( "MMPdec/optImgU", 0 ).toBool();
}
void PlaYUVerSettings::setOptImgUDec( bool par )
{
m_settings.setValue( "MMPdec/optImgU", par );
}
QString PlaYUVerSettings::imgUDec()
{
return m_settings.value( "MMPdec/imgU", "" ).toString();
}
void PlaYUVerSettings::setImgUDec( QString str )
{
m_settings.setValue( "MMPdec/imgU", str );
}
bool PlaYUVerSettings::optImgVDec()
{
return m_settings.value( "MMPdec/optImgV", 0 ).toBool();
}
void PlaYUVerSettings::setOptImgVDec( bool par )
{
m_settings.setValue( "MMPdec/optImgV", par );
}
QString PlaYUVerSettings::imgVDec()
{
return m_settings.value( "MMPdec/imgV", "" ).toString();
}
void PlaYUVerSettings::setImgVDec( QString str )
{
m_settings.setValue( "MMPdec/imgV", str );
}
} // NAMESPACE
+133
View File
@@ -0,0 +1,133 @@
/* 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 playuversettings.h
\brief plaYUVer app settings
*/
#ifndef __PLAYUVERSETTINGS_H__
#define __PLAYUVERSETTINGS_H__
#include <QSettings>
#include <QString>
#include <QSize>
#include <QPoint>
#include <QColor>
#include <QString>
#include <QBitArray>
#include "gridmanager.h"
namespace plaYUVer
{
class PlaYUVerSettings
{
public:
PlaYUVerSettings();
// - - - - - - - - - - Main Window Settings - - - - - - - - - - - - -
QPoint mainWindowPos();
void setMainWindowPos( const QPoint &v );
QSize mainWindowSize();
void setMainWindowSize( const QSize &v );
QString lastOpenPath();
void setLastOpenPath( const QString &v );
// - - - - - - - - - - - Segmentation Settings - - - - - - - - - - - -
QBitArray results2show();
void setResults2show( QBitArray vectorRes );
// - - - - - - - - - - - - MMP-compound Encoder settings - - - - - - - - - - - -
QString binaryPath();
void setBinaryPath( QString binaryPath );
QString oimagePath();
void setOimagePath( QString binaryPath );
int blockSize();
void setBlockSize( int blockSize );
int quantization();
void setQuantization( int quantization );
int predictionLevel();
void setPredictionLevel( int predictionlevel );
int defineBounds();
void setDefineBounds( int definebounds );
int lambda();
void setLambda( int lambda );
int dictionary();
void setDictionary( int dictionary );
int radiusDistortion();
void setRadiusDistortion( int distortion );
int losslessDistance();
void setLosslessDistance( int distance );
QBitArray mmpTenCheckBoxs();
void setMmpTenCheckBoxs( QBitArray tenCheckBoxs );
int mmpAutoSeg();
void setMmpAutoSeg( int autoSeg );
// - - - - - - - - - - - - MMP-compound Decoder settings - - - - - - - - - - - -
QString binaryPathDec();
void setBinaryPathDec( QString binaryPath );
QString oimagePathDec();
void setOimagePathDec( QString binaryPath );
bool optOutResDec();
void setOptOutResDec( bool par );
QString outResDec();
void setOutResDec( QString str );
bool optImgYDec();
void setOptImgYDec( bool par );
QString imgYDec();
void setImgYDec( QString str );
bool optImgUDec();
void setOptImgUDec( bool par );
QString imgUDec();
void setImgUDec( QString str );
bool optImgVDec();
void setOptImgVDec( bool par );
QString imgVDec();
void setImgVDec( QString str );
private:
QSettings m_settings;
};
} // NAMESPACE
#endif // __PLAYUVERSETTINGS_H__