Merge branch 'devel' into features_recentfilelist

Conflicts:
	source/app/SubWindowHandle.h
	source/app/plaYUVerApp.h
This commit is contained in:
jfmcarreira committed 2014-10-03 01:44:38 +01:00
commit e9b5630ca3
38 files changed
+1392 -426

No files matched your search

+74
View File
@@ -0,0 +1,74 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* \file AboutDialog.cpp
* \brief About Dialog
* Based on the work of Glad Deschrijver <glad.deschrijver@gmail.com> in KTikZ project
*/
#include "AboutDialog.h"
#include <QApplication>
#include <QDialogButtonBox>
#include <QLabel>
#include <QTextEdit>
#include <QVBoxLayout>
AboutDialog::AboutDialog(QWidget *parent)
: QDialog(parent)
{
QLabel *pixmapLabel = new QLabel;
//pixmapLabel->setPixmap(QPixmap(":/icons/qtikz-128.png"));
QLabel *label = new QLabel(QString("<h1>%1 %2</h1><p>%3</p><p>%4</p>")
.arg(QApplication::applicationName())
.arg(QApplication::applicationVersion())
.arg(tr("Copyright 2014 Luis Lucas and Joao Carreira"))
.arg(tr("plaYUVer is an open-source QT based raw video player.")));
label->setWordWrap(true);
QWidget *topWidget = new QWidget;
QHBoxLayout *topLayout = new QHBoxLayout;
topLayout->addWidget(pixmapLabel);
topLayout->addWidget(label);
topWidget->setLayout(topLayout);
QTextEdit *textEdit = new QTextEdit(tr("<p>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.</p>"
"<p>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.</p>"));
textEdit->setReadOnly(true);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(topWidget);
mainLayout->addWidget(textEdit);
mainLayout->addWidget(buttonBox);
mainLayout->setSpacing(10);
buttonBox->setFocus();
setWindowTitle(tr("About %1").arg("playuver"));
}
@@ -18,44 +18,22 @@
*/
/**
* \file FilterFrame.h
* \brief Filter frame module
* \file AboutDialog.h
* \brief About Dialog
* Based on the work of Glad Deschrijver <glad.deschrijver@gmail.com> in KTikZ project
*/
#ifndef __FILTERFRAME_H__
#define __FILTERFRAME_H__
#ifndef __ABOUTDIALOG_H__
#define __ABOUTDIALOG_H__
#include "config.h"
#include "PlaYUVerDefs.h"
#include <iostream>
#include <cstdio>
#include "PlaYUVerFrame.h"
#include "PlaYUVerModuleIf.h"
#include <QDialog>
#include <cassert>
namespace plaYUVer
class AboutDialog : public QDialog
{
class FilterFrame: public PlaYUVerModuleIf
{
private:
PlaYUVerFrame* m_pcFilteredFrame;
Q_OBJECT
public:
FilterFrame();
virtual ~FilterFrame()
{
}
Void create( PlaYUVerFrame* InputFrame );
PlaYUVerFrame* process( PlaYUVerFrame* InputFrame );
Void destroy();
AboutDialog(QWidget *parent = 0);
};
} // NAMESPACE
#endif // __FILTERFRAME_H__
#endif // __ABOUTDIALOG_H__
+24 -6
View File
@@ -43,10 +43,12 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
// Config dialog
setStandardResolutionSizes();
struct PlaYUVerStream::StandardResolution stdRes = PlaYUVerStream::standardResolutionSizes();
standardResolutionNames = stdRes.stringListFullName;
standardResolutionSizes = stdRes.sizeResolution;
setObjectName( QStringLiteral( "ConfigureFormat" ) );
resize( 392, 350 );
resize( 392, 370 );
setWindowTitle( "Configure Resolution" );
setWindowIcon( QIcon( ":/images/configureformat.png" ) );
@@ -68,6 +70,20 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
MainLayout->addLayout( headLayout );
MainLayout->addItem( new QSpacerItem( 10, 20, QSizePolicy::Minimum ) );
// Filename layout
QHBoxLayout* filenameLayout = new QHBoxLayout();
QLabel* filenameLabel = new QLabel();
filenameLabel->setText( "Name" );
filenameLabel->setFont( menusFont );
m_labelFilename = new QLabel();
m_labelFilename->setText( "Test" );
filenameLayout->addWidget( filenameLabel );
filenameLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
filenameLayout->addWidget( m_labelFilename );
MainLayout->addLayout( filenameLayout );
// standardResolutionLayout
MainLayout->addItem( new QSpacerItem( 10, 20, QSizePolicy::Minimum ) );
QHBoxLayout* standardResolutionLayout = new QHBoxLayout();
@@ -177,16 +193,18 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
}
Int ConfigureFormatDialog::runConfigureFormatDialog( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate )
Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate )
{
// Set default values
m_labelFilename->setText( Filename );
//m_labelFilename->setText( QFileInfo( Filename ).fileName() );
m_spinBoxWidth->setValue( rWidth );
m_spinBoxheight->setValue( rHeight );
m_comboBoxPixelFormat->setCurrentIndex( rInputFormat >= 0 ? rInputFormat : 0 );
m_spinBoxFrameRate->setValue( rFrameRate );
for( Int i = 0; i < standardResolutionSizesList.size(); i++ )
for( Int i = 0; i < standardResolutionSizes.size(); i++ )
{
if( standardResolutionSizesList.at( i ) == QSize( rWidth, rHeight ) )
if( standardResolutionSizes.at( i ) == QSize( rWidth, rHeight ) )
{
m_comboBoxStandardResolution->setCurrentIndex( i );
}
@@ -208,7 +226,7 @@ void ConfigureFormatDialog::StandardResolutionSelection()
if( currIdx == -1 )
return;
QSize currSize = standardResolutionSizesList.at( currIdx );
QSize currSize = standardResolutionSizes.at( currIdx );
m_spinBoxWidth->setValue( currSize.width() );
m_spinBoxheight->setValue( currSize.height() );
}
+3 -18
View File
@@ -56,37 +56,22 @@ Q_OBJECT
public:
ConfigureFormatDialog( QWidget *parent = 0 );
Int runConfigureFormatDialog ( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate );
Int runConfigureFormatDialog ( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate );
private Q_SLOTS:
void StandardResolutionSelection();
private:
QStringList standardResolutionNames;
QList<QSize> standardResolutionSizesList;
QVector<QSize> standardResolutionSizes;
QLabel* m_labelFilename;
QComboBox *m_comboBoxStandardResolution;
QSpinBox *m_spinBoxWidth;
QSpinBox *m_spinBoxheight;
QComboBox *m_comboBoxPixelFormat;
QSpinBox *m_spinBoxFrameRate;
Void setStandardResolutionSizes()
{
ADD_STANDARD_RESOLUTION( "CIF (352x288)", 352, 288 );
ADD_STANDARD_RESOLUTION( "VGA (640x480)", 640, 480 );
ADD_STANDARD_RESOLUTION( "WVGA (832x480)", 832, 480 );
ADD_STANDARD_RESOLUTION( "XVGA (1024x768)", 1024, 768 );
ADD_STANDARD_RESOLUTION( "HD (1280x720)", 1280, 720 );
ADD_STANDARD_RESOLUTION( "SXGA- (1280x900)", 1280, 900 );
ADD_STANDARD_RESOLUTION( "SXGA (1280x1024)", 1280, 1024 );
ADD_STANDARD_RESOLUTION( "WSXGA (1440x900)", 1440, 900 );
ADD_STANDARD_RESOLUTION( "Full HD (1920x1080)", 1920, 1080 );
ADD_STANDARD_RESOLUTION( "WQXGA (2560x1600)", 2560, 1600 );
ADD_STANDARD_RESOLUTION( "Ultra HD (3840x2160)", 3840, 2160 );
ADD_STANDARD_RESOLUTION( "8K", 8192, 4608 );
}
};
} // NAMESPACE
+11 -4
View File
@@ -133,7 +133,7 @@ SubWindowHandle* ModulesHandle::enableModuleIf( PlaYUVerModuleIf *pcCurrModuleIf
}
else
{
windowName.append( pcSubWindow->userFriendlyCurrentFile() );
windowName.append( pcSubWindow->getWindowName() );
pcCurrModuleIf->m_pcSubWindow[0] = pcSubWindow;
}
windowName.append( " <" );
@@ -209,6 +209,12 @@ Void ModulesHandle::destroyModuleIf( PlaYUVerModuleIf *pcCurrModuleIf )
pcCurrModuleIf->m_pcSubWindow[i] = NULL;
}
}
if( pcCurrModuleIf->m_pcModuleStream )
{
pcCurrModuleIf->m_pcModuleStream->close();
delete pcCurrModuleIf->m_pcModuleStream;
pcCurrModuleIf->m_pcModuleStream = NULL;
}
pcCurrModuleIf->m_pcAction->setChecked( false );
pcCurrModuleIf->destroy();
}
@@ -262,14 +268,14 @@ Void ModulesHandle::applyAllModuleIf( PlaYUVerModuleIf *pcCurrModuleIf )
QApplication::setOverrideCursor( Qt::WaitCursor );
for( UInt f = 0; f < numberOfFrames; f++ )
{
applyModuleIf( pcCurrModuleIf, false, true );
//QCoreApplication::processEvents();
pcCurrModuleIf->m_pcModuleStream->writeFrame( pcCurrModuleIf->m_pcProcessedFrame );
for( UInt i = 0; i < numberOfWindows; i++ )
{
pcCurrModuleIf->m_pcSubWindow[i]->play();
pcCurrModuleIf->m_pcSubWindow[i]->playEvent();
}
applyModuleIf( pcCurrModuleIf, false, false );
QCoreApplication::processEvents();
pcCurrModuleIf->m_pcModuleStream->writeFrame( pcCurrModuleIf->m_pcProcessedFrame );
}
QApplication::restoreOverrideCursor();
}
@@ -466,6 +472,7 @@ Void ModulesHandle::updateMenus( Bool hasSubWindow )
currModuleAction = m_arrayModulesActions.at( i );
currModuleAction->setEnabled( hasSubWindow );
}
m_arrayActions[APPLY_ALL_ACT]->setEnabled( hasSubWindow );
m_arrayActions[SWAP_FRAMES_ACT]->setEnabled( hasSubWindow );
}
+2 -3
View File
@@ -102,8 +102,6 @@ private:
QDockWidget* m_pcDockWidget;
ModuleHandleDock* m_pcModuleDock;
PlaYUVerModuleDefinition m_cModuleDef;
PlaYUVerStream* m_pcModuleStream;
PlaYUVerFrame* m_pcProcessedFrame;
Double m_dMeasurementResult;
@@ -144,7 +142,8 @@ public:
PlaYUVerModuleDefinition getModuleDefinition() { return m_cModuleDef; }
protected:
virtual void run();
PlaYUVerModuleDefinition m_cModuleDef;
virtual void run();
};
} // NAMESPACE
+2 -2
View File
@@ -349,8 +349,8 @@ FramePropertiesSideBar::FramePropertiesSideBar( QWidget* parent, Bool *pbIsPlayi
statisticsLayout->addWidget( labelStdDevValue, 3, 1 );
statisticsLayout->addWidget( medianLabel, 4, 0 );
statisticsLayout->addWidget( labelMedianValue, 4, 1 );
statisticsLayout->addWidget( percentileLabel, 5, 0 );
statisticsLayout->addWidget( labelPercentileValue, 5, 1 );
// statisticsLayout->addWidget( percentileLabel, 5, 0 );
// statisticsLayout->addWidget( labelPercentileValue, 5, 1 );
QGroupBox *statisticsGroup = new QGroupBox( tr( "Statistics" ) );
statisticsGroup->setLayout( statisticsLayout );
+47 -12
View File
@@ -38,19 +38,30 @@ QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, QMdiArea
// Side bar area -----------------------------------------------------
QLabel *MetricLabel = new QLabel( tr( "Metric:" ) );
MetricLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
QLabel *RefLabel = new QLabel( tr( "Ref:" ) );
RefLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
QLabel *RecLabel = new QLabel( tr( "Rec:" ) );
RecLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
m_comboBoxRef = new QComboBox;
m_comboBoxMetric = new QComboBox;
m_comboBoxMetric->insertItems( 0, PlaYUVerFrame::supportedQualityMetricsList());
m_comboBoxMetric->setSizeAdjustPolicy( QComboBox::AdjustToContents );
m_comboBoxMetric->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed);
m_comboBoxRef = new QComboBox;
m_comboBoxRef->setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLength );
m_comboBoxRef->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed);
updateSubWindowList();
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget( RefLabel, 0, 0, Qt::AlignLeft );
mainLayout->addWidget( m_comboBoxRef, 0, 1, Qt::AlignLeft );
mainLayout->addWidget( MetricLabel, 0, 0, Qt::AlignLeft );
mainLayout->addWidget( m_comboBoxMetric, 0, 1, Qt::AlignLeft );
mainLayout->addWidget( RefLabel, 1, 0, Qt::AlignLeft );
mainLayout->addWidget( m_comboBoxRef, 1, 1, Qt::AlignLeft );
m_ppcLabelQualityLabel[LUMA] = new QLabel( "PSNR Y:" );
m_ppcLabelQualityLabel[LUMA]->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
@@ -75,7 +86,8 @@ QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, QMdiArea
qualityResultsLayout->addWidget( m_ppcLabelQualityLabel[CHROMA_V], 2, 0 );
qualityResultsLayout->addWidget( m_ppcLabelQualityValue[CHROMA_V], 2, 1 );
QGroupBox *statisticsGroup = new QGroupBox( tr( "Quality" ) );
//QGroupBox *statisticsGroup = new QGroupBox( tr( "Quality" ) );
QGroupBox *statisticsGroup = new QGroupBox;
statisticsGroup->setLayout( qualityResultsLayout );
statisticsGroup->setWhatsThis( tr( "<p>Here you can see the quality results calculated for the "
"selected windows." ) );
@@ -86,6 +98,7 @@ QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, QMdiArea
setLayout( mainLayout );
connect( m_comboBoxRef, SIGNAL( activated(int) ), this, SLOT( slotReferenceChanged(int) ) );
connect( m_comboBoxMetric, SIGNAL( currentIndexChanged(int) ), this, SLOT( slotQualityMetricChanged() ) );
}
@@ -112,22 +125,28 @@ Void QualityMeasurementSidebar::updateSubWindowList()
for( Int i = 0; i < m_pcMainWindowMdiArea->subWindowList().size(); i++ )
{
subWindow = qobject_cast<SubWindowHandle *>( m_pcMainWindowMdiArea->subWindowList().at( i ) );
currSubWindowName = subWindow->getWindowName();
if( !m_pcSelectedWindowListNames.contains( currSubWindowName ) && !subWindow->getIsModule() )
m_pcWindowListNames.append( currSubWindowName );
if( subWindow )
{
currSubWindowName = subWindow->getWindowShortName();
if( !m_pcSelectedWindowListNames.contains( currSubWindowName ) && !subWindow->getIsModule() )
{
m_pcWindowListNames.append( currSubWindowName );
//m_comboBoxRef->setItemText( currIdx++, currSubWindowName );
}
}
}
m_comboBoxRef->clear();
m_comboBoxRef->insertItems( 0, m_pcWindowListNames );
m_comboBoxRef->insertItems( -1, m_pcWindowListNames );
m_comboBoxRef->setCurrentIndex( -1 );
if( m_pcCurrentSubWindow )
{
if( SubWindowHandle* refSubWindow = m_pcCurrentSubWindow->getRefSubWindow() )
{
Int index = m_pcWindowListNames.indexOf( refSubWindow->getWindowName() );
Int index = m_pcWindowListNames.indexOf( refSubWindow->getWindowShortName() );
m_comboBoxRef->setCurrentIndex( index );
}
}
m_comboBoxRef->setSizeAdjustPolicy( QComboBox::AdjustToContents );
}
Void QualityMeasurementSidebar::updateCurrentWindow( SubWindowHandle *subWindow )
@@ -152,11 +171,15 @@ Void QualityMeasurementSidebar::updateSidebarData()
for( Int component = 0; component < 3; component++ )
{
quality = currFrame->getPSNR( refFrame, component );
quality = currFrame->getQuality( m_comboBoxMetric->currentIndex(), refFrame, component );
m_ppcLabelQualityValue[component]->setText( value.setNum( quality, 'f', 2 ) );
}
return;
}
else
{
m_comboBoxRef->setCurrentIndex( -1 );
}
}
for( Int component = 0; component < 3; component++ )
{
@@ -176,12 +199,24 @@ Void QualityMeasurementSidebar::slotReferenceChanged( Int index )
{
m_pcCurrentSubWindow->setRefSubWindow( subWindow );
updateSidebarData();
m_comboBoxRef->setCurrentIndex( index );
return;
}
}
}
m_comboBoxRef->setCurrentIndex( -1 );
else
{
m_comboBoxRef->setCurrentIndex( -1 );
}
}
Void QualityMeasurementSidebar::slotQualityMetricChanged()
{
QString labelQuality = PlaYUVerFrame::supportedQualityMetricsList().at( m_comboBoxMetric->currentIndex() );
m_ppcLabelQualityLabel[LUMA]->setText( labelQuality + " Y");
m_ppcLabelQualityLabel[CHROMA_U]->setText( labelQuality + " U");
m_ppcLabelQualityLabel[CHROMA_V]->setText( labelQuality + " V");
updateSidebarData();
}
} // NAMESPACE
+3
View File
@@ -63,6 +63,8 @@ private:
SubWindowHandle *m_pcCurrentSubWindow;
QComboBox *m_comboBoxMetric;
QComboBox *m_comboBoxRef;
QComboBox *m_comboBoxRec;
@@ -73,6 +75,7 @@ private:
private Q_SLOTS:
void slotReferenceChanged( int );
void slotQualityMetricChanged();
};
+28 -2
View File
@@ -94,7 +94,7 @@ Bool SubWindowHandle::loadFile( QString cFilename, Bool bForceDialog )
if( m_pCurrStream->guessFormat( cFilename, Width, Height, InputFormat, FrameRate ) || bForceDialog )
{
ConfigureFormatDialog formatDialog( this );
if( formatDialog.runConfigureFormatDialog( Width, Height, InputFormat, FrameRate ) == QDialog::Rejected )
if( formatDialog.runConfigureFormatDialog( cFilename, Width, Height, InputFormat, FrameRate ) == QDialog::Rejected )
{
return false;
}
@@ -118,6 +118,7 @@ Bool SubWindowHandle::loadFile( QString cFilename, Bool bForceDialog )
m_sStreamInfo.m_uiFrameRate = FrameRate;
m_cWindowName = m_pCurrStream->getStreamInformationString();
m_cWindowShortName = QFileInfo( cFilename ).fileName();
setWindowTitle( m_cWindowName );
return true;
}
@@ -205,8 +206,33 @@ Void SubWindowHandle::refreshFrame()
Bool SubWindowHandle::save( QString filename )
{
Bool iRet = false;
QApplication::setOverrideCursor( Qt::WaitCursor );
Bool iRet = m_pCurrStream->saveFrame( filename );
if( !m_pCurrStream )
{
if( !m_pcCurrFrame )
{
return false;
}
Int iFileFormat = PlaYUVerStream::INVALID_INPUT;
QStringList formatsExt = PlaYUVerStream::supportedReadFormatsExt();
QString currExt = QFileInfo( filename ).suffix();
if( formatsExt.contains( currExt ) )
{
iFileFormat = formatsExt.indexOf( currExt );
}
if( iFileFormat == PlaYUVerStream::YUVINPUT )
{
return false;
}
m_pcCurrFrame->FrametoRGB8();
QImage qimg = QImage( m_pcCurrFrame->getQImageBuffer(), m_pcCurrFrame->getWidth(), m_pcCurrFrame->getHeight(), QImage::Format_RGB888 );
iRet = qimg.save( filename );
}
else
{
iRet = m_pCurrStream->saveFrame( filename );
}
QApplication::restoreOverrideCursor();
return iRet;
}
+6 -5
View File
@@ -73,6 +73,9 @@ private:
QString m_cWindowName;
QString m_cWindowShortName;
QString m_cCurrFileName;
Bool m_bIsPlaying;
Bool m_bIsModule;
@@ -202,13 +205,11 @@ public:
{
return m_cWindowName;
}
QString userFriendlyCurrentFile()
QString getWindowShortName()
{
return m_cWindowName;
return m_cWindowShortName;
}
QString currentFile()
QString getCurrentFileName()
{
return m_sStreamInfo.m_cFilename;
}
+7 -2
View File
@@ -23,6 +23,7 @@
*/
#include <QApplication>
#include "config.h"
#include "plaYUVerApp.h"
#include "SubWindowHandle.h"
#ifdef USE_FERVOR
@@ -30,11 +31,15 @@
#endif
using namespace plaYUVer;
#if _WIN32
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
#endif
int main( int argc, char *argv[] )
{
QApplication a( argc, argv );
QApplication::setApplicationName("playuver");
QApplication::setApplicationVersion("PLAYUVER_VERSION");
QApplication::setApplicationName("PlaYUVer");
QApplication::setApplicationVersion(PLAYUVER_VERSION_STRING);
QApplication::setOrganizationName("pixlra");
QApplication::setOrganizationDomain("playuver.pixlra");
+86 -44
View File
@@ -48,7 +48,7 @@ plaYUVerApp::plaYUVerApp()
setWindowModality( Qt::ApplicationModal );
mdiArea = new QMdiArea;
mdiArea = new PlaYUVerMdiArea;
setCentralWidget( mdiArea );
//mdiArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded );
//mdiArea->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );
@@ -69,7 +69,7 @@ plaYUVerApp::plaYUVerApp()
readSettings();
setWindowTitle( tr( "plaYUVer" ) );
setWindowTitle( QApplication::applicationName() );
setWindowIcon( QIcon( ":/images/playuver.png" ) );
setUnifiedTitleAndToolBarOnMac( true );
@@ -83,6 +83,7 @@ plaYUVerApp::plaYUVerApp()
setAcceptDrops( true );
mdiArea->setAcceptDrops( true );
m_pcAboutDialog = NULL;
m_pcCurrentSubWindow = NULL;
}
@@ -101,13 +102,16 @@ Void plaYUVerApp::parseArgs( Int argc, Char *argv[] )
Void plaYUVerApp::about()
{
QString about_message;
about_message.append( "The <b>plaYUVer</b> is an open-source raw video player! " );
about_message.append( "Developed by " );
about_message.append( "João Carreira " );
about_message.append( "and " );
about_message.append( "Luís Lucas" );
QMessageBox::about( this, "About plaYUVer", about_message );
if (!m_pcAboutDialog)
m_pcAboutDialog = new AboutDialog(this);
m_pcAboutDialog->exec();
// QString about_message;
// about_message.append( "The <b>plaYUVer</b> is an open-source raw video player! " );
// about_message.append( "Developed by " );
// about_message.append( "João Carreira " );
// about_message.append( "and " );
// about_message.append( "Luís Lucas" );
// QMessageBox::about( this, "About plaYUVer", about_message );
}
Void plaYUVerApp::closeEvent( QCloseEvent *event )
@@ -212,12 +216,15 @@ Void plaYUVerApp::open()
<< formatsList
<< tr( "All Files (*)" );
QString fileName = QFileDialog::getOpenFileName( this, tr( "Open File" ), m_cLastOpenPath, filter.join( ";;" ) );
QStringList fileNameList = QFileDialog::getOpenFileNames( this, tr( "Open File" ), m_cLastOpenPath, filter.join( ";;" ) );
if( !fileName.isEmpty() )
for( Int i = 0; i < fileNameList.size(); i++ )
{
m_cLastOpenPath = QFileInfo( fileName ).path();
loadFile( fileName );
if( !fileNameList.at( i ).isEmpty() )
{
m_cLastOpenPath = QFileInfo( fileNameList.at( i ) ).path();
loadFile( fileNameList.at( i ) );
}
}
}
@@ -225,6 +232,7 @@ Void plaYUVerApp::save()
{
if( m_pcCurrentSubWindow )
{
SubWindowHandle *saveWindow = m_pcCurrentSubWindow;
QString supported = tr( "Supported Files (" );
QStringList formatsList;
QStringList formatsExt = PlaYUVerStream::supportedSaveFormatsExt();
@@ -253,7 +261,7 @@ Void plaYUVerApp::save()
if( !fileName.isEmpty() )
{
m_cLastOpenPath = QFileInfo( fileName ).path();
if( !m_pcCurrentSubWindow->save( fileName ) )
if( !saveWindow->save( fileName ) )
{
QApplication::restoreOverrideCursor();
QMessageBox::warning( this, tr( "plaYUVer" ), tr( "Cannot save file %1" ).arg( fileName ) );
@@ -267,7 +275,7 @@ Void plaYUVerApp::format()
{
if( m_pcCurrentSubWindow )
{
m_pcCurrentSubWindow->loadFile( m_pcCurrentSubWindow->currentFile(), true );
m_pcCurrentSubWindow->loadFile( m_pcCurrentSubWindow->getCurrentFileName(), true );
m_pcCurrentSubWindow = NULL;
chageSubWindowSelection();
}
@@ -435,8 +443,11 @@ Void plaYUVerApp::setTimerStatus()
}
if( status )
{
m_cTimer.start();
m_bIsPlaying = true;
if( !m_bIsPlaying )
{
m_cTimer.start();
m_bIsPlaying = true;
}
}
else
{
@@ -468,32 +479,57 @@ Void plaYUVerApp::play()
if( !m_pcCurrentSubWindow->getInputStream() )
return;
if( m_arrayActions[VIDEO_LOCK_ACT]->isChecked() && m_acPlayingSubWindows.size() )
if( !m_pcCurrentSubWindow->isPlaying() )
{
if( !m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) )
if( m_arrayActions[VIDEO_LOCK_ACT]->isChecked() && m_acPlayingSubWindows.size() )
{
if( !m_pcCurrentSubWindow->play() )
{
return;
}
m_acPlayingSubWindows.append( m_pcCurrentSubWindow );
m_pcCurrentSubWindow->seekAbsoluteEvent( m_acPlayingSubWindows.at( 0 )->getInputStream()->getCurrFrameNum() );
updateTotalFrameNum();
if( !m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) )
{
m_acPlayingSubWindows.append( m_pcCurrentSubWindow );
m_pcCurrentSubWindow->seekAbsoluteEvent( m_acPlayingSubWindows.at( 0 )->getInputStream()->getCurrFrameNum() );
updateTotalFrameNum();
}
}
else
{
m_pcPlayingTimer->stop();
m_acPlayingSubWindows.clear();
if( !m_pcCurrentSubWindow->play() )
{
return;
}
m_acPlayingSubWindows.append( m_pcCurrentSubWindow );
m_uiAveragePlayInterval = 0;
m_bIsPlaying = false;
}
startPlay();
m_arrayActions[PLAY_ACT]->setIcon( style()->standardIcon( QStyle::SP_MediaPause ) );
}
else
{
m_pcPlayingTimer->stop();
m_acPlayingSubWindows.clear();
if( !m_pcCurrentSubWindow->play() )
if( m_pcCurrentSubWindow )
{
return;
if( m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) )
{
for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ )
{
m_acPlayingSubWindows.at( i )->pause();
}
}
else
{
m_pcCurrentSubWindow->pause();
}
updateCurrFrameNum();
}
m_acPlayingSubWindows.append( m_pcCurrentSubWindow );
m_uiAveragePlayInterval = 0;
m_bIsPlaying = false;
setTimerStatus();
updateFrameProperties();
m_arrayActions[PLAY_ACT]->setIcon( style()->standardIcon( QStyle::SP_MediaPlay ) );
}
startPlay();
}
Void plaYUVerApp::pause()
@@ -883,7 +919,7 @@ SubWindowHandle* plaYUVerApp::findSubWindow( const QMdiArea* mdiArea, const QStr
foreach( QMdiSubWindow * window, mdiArea->subWindowList() ){
SubWindowHandle *mdiChild = qobject_cast<SubWindowHandle *>( window);
if( mdiChild->currentFile() == canonicalFilePath )
if( mdiChild->getCurrentFileName() == canonicalFilePath )
return mdiChild;
}
return 0;
@@ -944,12 +980,13 @@ Void plaYUVerApp::updateMenus()
m_pcZoomFactorSBox->setEnabled( hasSubWindow );
m_arrayActions[PLAY_ACT]->setEnabled( hasSubWindow );
m_arrayActions[PAUSE_ACT]->setEnabled( hasSubWindow );
//m_arrayActions[PAUSE_ACT]->setEnabled( hasSubWindow );
m_arrayActions[STOP_ACT]->setEnabled( hasSubWindow );
m_arrayActions[VIDEO_BACKWARD_ACT]->setEnabled( hasSubWindow );
m_arrayActions[VIDEO_FORWARD_ACT]->setEnabled( hasSubWindow );
m_arrayActions[VIDEO_LOOP_ACT]->setEnabled( hasSubWindow );
m_arrayActions[VIDEO_LOCK_ACT]->setEnabled( hasSubWindow );
m_arrayActions[VIDEO_LOCK_SELECTION_ACT]->setEnabled( hasSubWindow );
m_pcFrameSlider->setEnabled( hasSubWindow );
if( !hasSubWindow )
{
@@ -1000,11 +1037,11 @@ Void plaYUVerApp::updateWindowMenu()
QString text;
if( i < 9 )
{
text = tr( "&%1 %2" ).arg( i + 1 ).arg( child->userFriendlyCurrentFile() );
text = tr( "&%1 %2" ).arg( i + 1 ).arg( child->getWindowName() );
}
else
{
text = tr( "%1 %2" ).arg( i + 1 ).arg( child->userFriendlyCurrentFile() );
text = tr( "%1 %2" ).arg( i + 1 ).arg( child->getWindowName() );
}
QAction *action = m_arrayMenu[WINDOW_MENU]->addAction( text );
action->setCheckable( true );
@@ -1019,13 +1056,13 @@ Void plaYUVerApp::createActions()
m_arrayActions.resize( TOTAL_ACT );
// ------------ File ------------
m_arrayActions[OPEN_ACT] = new QAction( QIcon( ":/images/open.png" ), tr( "&Open..." ), this );
m_arrayActions[OPEN_ACT] = new QAction( QIcon( ":/images/open.png" ), tr( "&Open" ), this );
m_arrayActions[OPEN_ACT]->setIcon( style()->standardIcon( QStyle::SP_DialogOpenButton ) );
m_arrayActions[OPEN_ACT]->setShortcuts( QKeySequence::Open );
m_arrayActions[OPEN_ACT]->setStatusTip( tr( "Open stream" ) );
connect( m_arrayActions[OPEN_ACT], SIGNAL( triggered() ), this, SLOT( open() ) );
m_arrayActions[SAVE_ACT] = new QAction( QIcon( ":/images/save.png" ), tr( "&Save..." ), this );
m_arrayActions[SAVE_ACT] = new QAction( QIcon( ":/images/save.png" ), tr( "&Save Frame" ), this );
m_arrayActions[SAVE_ACT]->setIcon( style()->standardIcon( QStyle::SP_DialogSaveButton ) );
m_arrayActions[SAVE_ACT]->setShortcuts( QKeySequence::SaveAs );
m_arrayActions[SAVE_ACT]->setStatusTip( tr( "Save current frame" ) );
@@ -1033,18 +1070,20 @@ Void plaYUVerApp::createActions()
m_arrayActions[FORMAT_ACT] = new QAction( tr( "&Format" ), this );
m_arrayActions[FORMAT_ACT]->setIcon( QIcon( ":/images/configuredialog.png" ) );
m_arrayActions[FORMAT_ACT]->setShortcut( Qt::CTRL + Qt::Key_F );
m_arrayActions[FORMAT_ACT]->setStatusTip( tr( "Open format dialog" ) );
connect( m_arrayActions[FORMAT_ACT], SIGNAL( triggered() ), this, SLOT( format() ) );
m_arrayActions[RELOAD_ACT] = new QAction( tr( "&Reload" ), this );
m_arrayActions[RELOAD_ACT]->setIcon( style()->standardIcon( QStyle::SP_BrowserReload ) );
m_arrayActions[RELOAD_ACT]->setShortcut( Qt::CTRL + Qt::Key_R );
m_arrayActions[RELOAD_ACT]->setStatusTip( tr( "Reload current sequence" ) );
connect( m_arrayActions[RELOAD_ACT], SIGNAL( triggered() ), this, SLOT( reload() ) );
m_arrayActions[RELOAD_ALL_ACT] = new QAction( tr( "Reload All" ), this );
//m_arrayActions[RELOAD_ACT]->setIcon( QIcon( ":/images/configuredialog.png" ) );
m_arrayActions[RELOAD_ALL_ACT]->setStatusTip( tr( "Reload all sequences" ) );
connect( m_arrayActions[RELOAD_ALL_ACT], SIGNAL( triggered() ), this, SLOT( reload() ) );
connect( m_arrayActions[RELOAD_ALL_ACT], SIGNAL( triggered() ), this, SLOT( reloadAll() ) );
m_arrayActions[LOAD_ALL_ACT] = new QAction( tr( "Preload" ), this );
//m_arrayActions[LOAD_ALL_ACT]->setIcon( QIcon( ":/images/configuredialog.png" ) );
@@ -1094,18 +1133,19 @@ Void plaYUVerApp::createActions()
m_arrayActions[ZOOM_FIT_ACT] = new QAction( tr( "Zoom to &Fit" ), this );
m_arrayActions[ZOOM_FIT_ACT]->setIcon( QIcon( ":/images/fittowindow.png" ) );
m_arrayActions[ZOOM_FIT_ACT]->setStatusTip( tr( "Zoom in or out to fit on the window." ) );
m_arrayActions[ZOOM_FIT_ACT]->setShortcut( tr( "Ctrl+F" ) );
//m_arrayActions[ZOOM_FIT_ACT]->setShortcut( tr( "Ctrl+F" ) );
connect( m_arrayActions[ZOOM_FIT_ACT], SIGNAL( triggered() ), this, SLOT( zoomToFit() ) );
// ------------ Playing ------------
m_arrayActions[PLAY_ACT] = new QAction( "Play", this );
m_arrayActions[PLAY_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaPlay ) ) );
m_arrayActions[PLAY_ACT]->setShortcut( Qt::Key_Space );
connect( m_arrayActions[PLAY_ACT], SIGNAL( triggered() ), this, SLOT( play() ) );
m_arrayActions[PAUSE_ACT] = new QAction( "Pause", this );
m_arrayActions[PAUSE_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaPause ) ) );
connect( m_arrayActions[PAUSE_ACT], SIGNAL( triggered() ), this, SLOT( pause() ) );
// m_arrayActions[PAUSE_ACT] = new QAction( "Pause", this );
// m_arrayActions[PAUSE_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaPause ) ) );
// connect( m_arrayActions[PAUSE_ACT], SIGNAL( triggered() ), this, SLOT( pause() ) );
m_arrayActions[STOP_ACT] = new QAction( "Stop", this );
m_arrayActions[STOP_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaStop ) ) );
@@ -1116,11 +1156,13 @@ Void plaYUVerApp::createActions()
m_arrayActions[VIDEO_BACKWARD_ACT] = new QAction( "Video Backward", this );
m_arrayActions[VIDEO_BACKWARD_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaSeekBackward ) ) );
m_arrayActions[VIDEO_BACKWARD_ACT]->setShortcut( Qt::Key_Left );
connect( m_arrayActions[VIDEO_BACKWARD_ACT], SIGNAL( triggered() ), mapperSeekVideo, SLOT( map() ) );
mapperSeekVideo->setMapping( m_arrayActions[VIDEO_BACKWARD_ACT], 0 );
m_arrayActions[VIDEO_FORWARD_ACT] = new QAction( "Video Forward", this );
m_arrayActions[VIDEO_FORWARD_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaSeekForward ) ) );
m_arrayActions[VIDEO_FORWARD_ACT]->setShortcut( Qt::Key_Right );
connect( m_arrayActions[VIDEO_FORWARD_ACT], SIGNAL( triggered() ), mapperSeekVideo, SLOT( map() ) );
mapperSeekVideo->setMapping( m_arrayActions[VIDEO_FORWARD_ACT], 1 );
@@ -1247,7 +1289,7 @@ Void plaYUVerApp::createMenus()
m_arrayMenu[VIDEO_MENU] = menuBar()->addMenu( tr( "Video" ) );
m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[PLAY_ACT] );
m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[PAUSE_ACT] );
//m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[PAUSE_ACT] );
m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[STOP_ACT] );
m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[VIDEO_BACKWARD_ACT] );
m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[VIDEO_FORWARD_ACT] );
@@ -1307,7 +1349,7 @@ Void plaYUVerApp::createToolBars()
m_arrayToolBars[VIDEO_TOOLBAR] = new QToolBar( tr( "Video" ) );
m_arrayToolBars[VIDEO_TOOLBAR]->setAllowedAreas( Qt::TopToolBarArea | Qt::BottomToolBarArea );
m_arrayToolBars[VIDEO_TOOLBAR]->addAction( m_arrayActions[PLAY_ACT] );
m_arrayToolBars[VIDEO_TOOLBAR]->addAction( m_arrayActions[PAUSE_ACT] );
//m_arrayToolBars[VIDEO_TOOLBAR]->addAction( m_arrayActions[PAUSE_ACT] );
m_arrayToolBars[VIDEO_TOOLBAR]->addAction( m_arrayActions[STOP_ACT] );
m_arrayToolBars[VIDEO_TOOLBAR]->addAction( m_arrayActions[VIDEO_BACKWARD_ACT] );
m_arrayToolBars[VIDEO_TOOLBAR]->addWidget( m_pcFrameSlider );
@@ -1323,7 +1365,7 @@ Void plaYUVerApp::createToolBars()
m_pcTotalFrameNumLabel->setText( "-" );
m_arrayToolBars[VIDEO_TOOLBAR]->addWidget( m_pcTotalFrameNumLabel );
addToolBar( Qt::BottomToolBarArea, m_arrayToolBars[VIDEO_TOOLBAR] );
addToolBar( Qt::TopToolBarArea, m_arrayToolBars[VIDEO_TOOLBAR] );
}
Void plaYUVerApp::createDockWidgets()
+34 -3
View File
@@ -37,6 +37,7 @@
#include "ModulesHandle.h"
#include "PropertiesSidebar.h"
#include "QualityMeasurementSidebar.h"
#include "AboutDialog.h"
namespace plaYUVer
{
@@ -118,7 +119,36 @@ private Q_SLOTS:
void setSelectionTool();
private:
QMdiArea *mdiArea;
class PlaYUVerMdiArea: public QMdiArea
{
public:
PlaYUVerMdiArea( QWidget *parent = 0 ) :
QMdiArea( parent ),
m_pixmapLogo( ":/images/playuver-backgroud-logo.png" )
{
}
protected:
void paintEvent( QPaintEvent *event )
{
QMdiArea::paintEvent( event );
QPainter painter( viewport() );
QSize logoSize = 2 * size() / 3;
QPixmap pixFinalLogo = m_pixmapLogo.scaled(logoSize,Qt::KeepAspectRatio);
// Calculate the logo position - the bottom right corner of the mdi area.
int x = width() / 2 - pixFinalLogo.width() / 2;
int y = height() / 2 - pixFinalLogo.height() / 2;
painter.drawPixmap( x, y, pixFinalLogo );
}
private:
// Store the logo image.
QPixmap m_pixmapLogo;
};
//QMdiArea *mdiArea;
PlaYUVerMdiArea *mdiArea;
SubWindowHandle *m_pcCurrentSubWindow;
ModulesHandle *m_pcModulesHandle;
@@ -160,7 +190,6 @@ private:
static SubWindowHandle* findSubWindow( const QMdiArea* mdiArea, const QString& fileName );
static SubWindowHandle* findSubWindow( const QMdiArea* mdiArea, const SubWindowHandle* subWindow );
QVector<SubWindowHandle*> m_acPlayingSubWindows;
QSlider *m_pcFrameSlider;
QLabel *m_pcCurrFrameNumLabel;
@@ -229,7 +258,7 @@ private:
ZOOM_FIT_ACT,
ZOOM_NORMAL_ACT,
PLAY_ACT,
PAUSE_ACT,
/*PAUSE_ACT,*/
STOP_ACT,
VIDEO_FORWARD_ACT,
VIDEO_BACKWARD_ACT,
@@ -259,6 +288,8 @@ private:
PlaYUVerRecentFileListInfo m_aRecentFileStreamInfo;
AboutDialog* m_pcAboutDialog;
};
} // NAMESPACE
+222 -72
View File
@@ -390,30 +390,30 @@ Void PlaYUVerFrame::FrameToBuffer( Pel *output_buffer )
memcpy( output_buffer + frame_bytes_input * 5 / 4, &m_pppcInputPel[CHROMA_V][0][0], frame_bytes_input / 4 * sizeof(Pel) );
break;
case YUV444p:
memcpy( output_buffer + frame_bytes_input * 0, &m_pppcInputPel[LUMA][0][0], frame_bytes_input * sizeof(Pel) );
memcpy( output_buffer + frame_bytes_input * 1, &m_pppcInputPel[CHROMA_U][0][0], frame_bytes_input * sizeof(Pel) );
memcpy( output_buffer + frame_bytes_input * 2, &m_pppcInputPel[CHROMA_V][0][0],frame_bytes_input * sizeof(Pel) );
memcpy( output_buffer + frame_bytes_input * 0, &m_pppcInputPel[LUMA][0][0], frame_bytes_input * sizeof(Pel) );
memcpy( output_buffer + frame_bytes_input * 1, &m_pppcInputPel[CHROMA_U][0][0], frame_bytes_input * sizeof(Pel) );
memcpy( output_buffer + frame_bytes_input * 2, &m_pppcInputPel[CHROMA_V][0][0], frame_bytes_input * sizeof(Pel) );
break;
case YUV422p:
memcpy( output_buffer + frame_bytes_input * 0,&m_pppcInputPel[LUMA][0][0], frame_bytes_input * sizeof(Pel) );
memcpy( output_buffer + frame_bytes_input * 1,&m_pppcInputPel[CHROMA_U][0][0], frame_bytes_input / 2 * sizeof(Pel) );
memcpy( output_buffer + frame_bytes_input * 3 / 2,&m_pppcInputPel[CHROMA_V][0][0], frame_bytes_input / 2 * sizeof(Pel) );
memcpy( output_buffer + frame_bytes_input * 0, &m_pppcInputPel[LUMA][0][0], frame_bytes_input * sizeof(Pel) );
memcpy( output_buffer + frame_bytes_input * 1, &m_pppcInputPel[CHROMA_U][0][0], frame_bytes_input / 2 * sizeof(Pel) );
memcpy( output_buffer + frame_bytes_input * 3 / 2, &m_pppcInputPel[CHROMA_V][0][0], frame_bytes_input / 2 * sizeof(Pel) );
break;
case YUYV422:
for( UInt i = 0; i < m_uiHeight * m_uiWidth / 2; i++ )
{
*output_buffer++ = *pInputPelY++ ;
*output_buffer++ = *pInputPelU++ ;
*output_buffer++ = *pInputPelY++ ;
*output_buffer++ = *pInputPelV++ ;
*output_buffer++ = *pInputPelY++;
*output_buffer++ = *pInputPelU++;
*output_buffer++ = *pInputPelY++;
*output_buffer++ = *pInputPelV++;
}
break;
case GRAY:
memcpy( output_buffer + frame_bytes_input * 0, &m_pppcInputPel[LUMA][0][0], frame_bytes_input * sizeof(Pel) );
memcpy( output_buffer + frame_bytes_input * 0, &m_pppcInputPel[LUMA][0][0], frame_bytes_input * sizeof(Pel) );
break;
case RGB8:
FrametoRGB8();
memcpy( output_buffer, pcRGBPelInterlaced, frame_bytes_input * sizeof(Pel) * 3 );
memcpy( output_buffer, pcRGBPelInterlaced, frame_bytes_input * sizeof(Pel) * 3 );
break;
}
}
@@ -480,67 +480,73 @@ Void PlaYUVerFrame::copyFrom( PlaYUVerFrame* input_frame, UInt xPos, UInt yPos )
}
}
Double PlaYUVerFrame::getMSE( PlaYUVerFrame* Org, Int component )
{
Pel* pPelYUV = getPelBufferYUV()[component][0];
Pel* pOrgPelYUV = Org->getPelBufferYUV()[component][0];
Int aux_pel_1, aux_pel_2;
Int diff = 0;
Double ssd = 0;
UInt numberOfPixels = 0;
if( component == LUMA )
{
numberOfPixels = Org->getHeight() * Org->getWidth();
}
else
{
numberOfPixels = getChromaLength();
}
for( UInt i = 0; i < numberOfPixels; i++ )
{
aux_pel_1 = *pPelYUV++;
aux_pel_2 = *pOrgPelYUV++;
diff = aux_pel_1 - aux_pel_2;
ssd += ( Double )( diff * diff );
}
if( ssd == 0.0 )
{
return 0.0;
}
return ssd / ( Org->getWidth() * Org->getHeight() );
}
Double PlaYUVerFrame::getPSNR( PlaYUVerFrame* Org, Int component )
{
Double dPSNR = 100;
Double dMSE = getMSE( Org, component );
if( dMSE != 0 )
dPSNR = 10 * log10( 65025 / dMSE );
return dPSNR;
}
UInt64 PlaYUVerFrame::getBytesPerFrame()
{
return getBytesPerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat );
}
UInt64 PlaYUVerFrame::getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat )
{
switch( iPixelFormat )
{
case YUV420p:
return uiWidth * uiHeight * 1.5;
break;
case YUV444p:
return uiWidth * uiHeight * 3;
break;
case YUV422p:
case YUYV422:
return uiWidth * uiHeight * 2;
break;
case GRAY:
return uiWidth * uiHeight;
break;
case RGB8:
return uiWidth * uiHeight * 3;
break;
default:
return 0;
}
return 0;
}
UInt PlaYUVerFrame::getChromaWidth() const
{
switch( m_iPixelFormat )
{
case YUV420p:
return m_uiWidth * m_uiHeight * 1.5;
return m_uiWidth / 2;
break;
case YUV444p:
return m_uiWidth * m_uiHeight * 3;
break;
case YUV422p:
case YUYV422:
return m_uiWidth * m_uiHeight * 2;
case RGB8:
return m_uiWidth;
break;
case GRAY:
return m_uiWidth * m_uiHeight;
return 0;
break;
default:
return 0;
}
return 0;
}
UInt PlaYUVerFrame::getChromaHeight() const
{
switch( m_iPixelFormat )
{
case YUV420p:
case YUV422p:
case YUYV422:
return m_uiHeight / 2;
break;
case YUV444p:
case RGB8:
return m_uiWidth * m_uiHeight * 3;
return m_uiHeight;
case GRAY:
return 0;
break;
default:
return 0;
@@ -652,19 +658,19 @@ cv::Mat PlaYUVerFrame::getCvMat()
Int cvType = CV_8UC3;
switch( m_iPixelFormat )
{
case YUV420p:
case YUV444p:
case YUV422p:
case YUYV422:
case YUV420p:
case YUV444p:
case YUV422p:
case YUYV422:
cvType = CV_8UC3;
break;
case GRAY:
case GRAY:
cvType = CV_8UC1;
break;
case RGB8:
case RGB8:
cvType = CV_8UC3;
break;
default:
default:
break;
}
cv::Mat opencvFrame( m_uiHeight, m_uiWidth, cvType );
@@ -681,7 +687,6 @@ cv::Mat PlaYUVerFrame::getCvMat()
}
#endif
#ifdef USE_OPENCV
Void PlaYUVerFrame::copyFrom( cv::Mat* opencvFrame )
{
@@ -689,13 +694,13 @@ Void PlaYUVerFrame::copyFrom( cv::Mat* opencvFrame )
{
switch( opencvFrame->channels() )
{
case 1:
case 1:
m_iPixelFormat = GRAY;
break;
case 3:
case 3:
m_iPixelFormat = RGB8;
break;
default:
default:
return;
}
}
@@ -728,5 +733,150 @@ Void PlaYUVerFrame::copyFrom( cv::Mat* opencvFrame )
}
}
#endif
/**
* Quality Related Function API
*/
Double PlaYUVerFrame::getQuality( Int Metric, PlaYUVerFrame* Org, Int component )
{
switch( Metric )
{
case PSNR_METRIC:
return getPSNR( Org, component );
break;
case MSE_METRIC:
return getMSE( Org, component );
break;
case SSIM_METRIC:
return getSSIM( Org, component );
break;
default:
assert( 0 );
};
return 0;
}
// NAMESPACE
Double PlaYUVerFrame::getMSE( PlaYUVerFrame* Org, Int component )
{
Pel* pPelYUV = getPelBufferYUV()[component][0];
Pel* pOrgPelYUV = Org->getPelBufferYUV()[component][0];
Int aux_pel_1, aux_pel_2;
Int diff = 0;
Double ssd = 0;
UInt numberOfPixels = 0;
if( component == LUMA )
{
numberOfPixels = Org->getHeight() * Org->getWidth();
}
else
{
numberOfPixels = getChromaLength();
}
for( UInt i = 0; i < numberOfPixels; i++ )
{
aux_pel_1 = *pPelYUV++;
aux_pel_2 = *pOrgPelYUV++;
diff = aux_pel_1 - aux_pel_2;
ssd += ( Double )( diff * diff );
}
if( ssd == 0.0 )
{
return 0.0;
}
return ssd / ( Org->getWidth() * Org->getHeight() );
}
Double PlaYUVerFrame::getPSNR( PlaYUVerFrame* Org, Int component )
{
Double dPSNR = 100;
Double dMSE = getMSE( Org, component );
if( dMSE != 0 )
dPSNR = 10 * log10( 65025 / dMSE );
return dPSNR;
}
float compute_ssim( Pel **refImg, Pel **encImg, Int width, Int height, Int win_width, Int win_height, Int max_pel_value_comp, Int overlapSize )
{
static const float K1 = 0.01f, K2 = 0.03f;
float max_pix_value_sqd;
float C1, C2;
float win_pixels = ( float )( win_width * win_height );
#ifdef UNBIASED_VARIANCE
float win_pixels_bias = win_pixels - 1;
#else
float win_pixels_bias = win_pixels;
#endif
float mb_ssim, meanOrg, meanEnc;
float varOrg, varEnc, covOrgEnc;
int imeanOrg, imeanEnc, ivarOrg, ivarEnc, icovOrgEnc;
float cur_distortion = 0.0;
int i, j, n, m, win_cnt = 0;
max_pix_value_sqd = ( float )( max_pel_value_comp * max_pel_value_comp );
C1 = K1 * K1 * max_pix_value_sqd;
C2 = K2 * K2 * max_pix_value_sqd;
for( j = 0; j <= height - win_height; j += overlapSize )
{
for( i = 0; i <= width - win_width; i += overlapSize )
{
imeanOrg = 0;
imeanEnc = 0;
ivarOrg = 0;
ivarEnc = 0;
icovOrgEnc = 0;
for( n = j; n < j + win_height; n++ )
{
for( m = i; m < i + win_width; m++ )
{
imeanOrg += refImg[n][m];
imeanEnc += encImg[n][m];
ivarOrg += refImg[n][m] * refImg[n][m];
ivarEnc += encImg[n][m] * encImg[n][m];
icovOrgEnc += refImg[n][m] * encImg[n][m];
}
}
meanOrg = ( float )imeanOrg / win_pixels;
meanEnc = ( float )imeanEnc / win_pixels;
varOrg = ( ( float )ivarOrg - ( ( float )imeanOrg ) * meanOrg ) / win_pixels_bias;
varEnc = ( ( float )ivarEnc - ( ( float )imeanEnc ) * meanEnc ) / win_pixels_bias;
covOrgEnc = ( ( float )icovOrgEnc - ( ( float )imeanOrg ) * meanEnc ) / win_pixels_bias;
mb_ssim = ( float )( ( 2.0 * meanOrg * meanEnc + C1 ) * ( 2.0 * covOrgEnc + C2 ) );
mb_ssim /= ( float )( meanOrg * meanOrg + meanEnc * meanEnc + C1 ) * ( varOrg + varEnc + C2 );
cur_distortion += mb_ssim;
win_cnt++;
}
}
cur_distortion /= ( float )win_cnt;
if( cur_distortion >= 1.0 && cur_distortion < 1.01 ) // avoid float accuracy problem at very low QP(e.g.2)
cur_distortion = 1.0;
return cur_distortion;
}
Double PlaYUVerFrame::getSSIM( PlaYUVerFrame* Org, Int component )
{
Double dSSIM = 1;
if( component == LUMA )
{
dSSIM = compute_ssim( m_pppcInputPel[component], Org->getPelBufferYUV()[component], m_uiWidth, m_uiHeight, 8, 8, 255, 8 );
}
else
{
dSSIM = compute_ssim( m_pppcInputPel[component], Org->getPelBufferYUV()[component], getChromaWidth(), getChromaHeight(), 4, 4, 255, 8 );
}
return dSSIM;
}
} // NAMESPACE
+32 -7
View File
@@ -112,13 +112,13 @@ public:
Void FrameToBuffer( Pel* );
Void copyFrom( PlaYUVerFrame* );
Void copyFrom( PlaYUVerFrame*, UInt, UInt);
Double getMSE( PlaYUVerFrame* Org, Int component );
Double getPSNR( PlaYUVerFrame* Org, Int component );
Void copyFrom( PlaYUVerFrame*, UInt, UInt );
UInt64 getBytesPerFrame();
static UInt64 getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat );
UInt getChromaWidth() const;
UInt getChromaHeight() const;
UInt getChromaLength() const;
Pel*** getPelBufferYUV() const
@@ -146,6 +146,31 @@ public:
Void copyFrom( cv::Mat* );
#endif
enum QualityMetrics
{
NO_METRIC = -1,
PSNR_METRIC = 0,
MSE_METRIC,
SSIM_METRIC,
NUMBER_METRICS,
};
static QStringList supportedQualityMetricsList()
{
QStringList metrics;
metrics << "PSNR"
<< "MSE"
<< "SSIM" // SSIM
;
assert( metrics.size() == NUMBER_METRICS );
return metrics;
}
Double getQuality( Int Metric, PlaYUVerFrame* Org, Int component );
Double getMSE( PlaYUVerFrame* Org, Int component );
Double getPSNR( PlaYUVerFrame* Org, Int component );
Double getSSIM( PlaYUVerFrame* Org, Int component );
UInt getWidth() const
{
return m_uiWidth;
@@ -171,9 +196,9 @@ public:
return ( m_uiWidth > 0 ) && ( m_uiHeight > 0 ) && ( m_iPixelFormat >= 0 );
}
Bool haveSameFmt( PlaYUVerFrame* other ) const
{
return ( m_uiWidth == other->getWidth() ) && ( m_uiHeight == other->getHeight() ) && ( m_iPixelFormat == other->getPelFormat() );
}
{
return ( m_uiWidth == other->getWidth() ) && ( m_uiHeight == other->getHeight() ) && ( m_iPixelFormat == other->getPelFormat() );
}
private:
UInt m_uiWidth;
+173 -40
View File
@@ -38,6 +38,7 @@ PlaYUVerStream::PlaYUVerStream()
{
m_bInit = false;
m_bIsInput = true;
m_bIsOpened = false;
m_bLoadAll = false;
m_iErrorStatus = 0;
@@ -82,6 +83,7 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_
m_cFilename = filename;
m_uiWidth = width;
m_uiHeight = height;
m_iPixelFormat = input_format;
m_uiFrameRate = frame_rate;
if( m_bIsInput )
@@ -101,8 +103,6 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_
}
m_cFormatName = PlaYUVerStream::supportedReadFormatsExt().at( m_iFileFormat ).toUpper();
m_iPixelFormat = input_format;
#ifdef USE_FFMPEG
if( m_iFileFormat != YUVINPUT )
{
@@ -115,7 +115,7 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_
{
switch( m_iFileFormat )
{
case PGMINPUT:
case PGMINPUT:
break;
}
@@ -131,6 +131,7 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_
if( m_uiWidth <= 0 || m_uiHeight <= 0 || m_iPixelFormat < 0 )
{
qDebug( ) << "Incorrect configuration";
close();
return m_bInit;
}
@@ -141,6 +142,7 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_
m_ppcFrameBuffer[i] = new PlaYUVerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat );
if( !m_ppcFrameBuffer[i] )
{
qDebug( ) << "Cannot allocated frame buffer";
close();
return m_bInit;
}
@@ -150,14 +152,20 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_
UInt64 frame_bytes_input = m_pcCurrFrame->getBytesPerFrame();
if( !avStatus )
{
if( !openFile() )
{
close();
return m_bInit;
}
m_cFormatName = QString::fromUtf8( "YUV" );
m_cCodedName = QString::fromUtf8( "Raw Video" );
}
if( !avStatus && m_iFileFormat == YUVINPUT )
{
m_pFile = NULL;
Char *filename = new char[m_cFilename.length() + 1];
memcpy( filename, m_cFilename.toUtf8().constData(), m_cFilename.length() + 1 * sizeof(char) );
m_pFile = fopen( filename, m_bIsInput ? "rb" : "wb" );
delete[] filename;
if( m_pFile == NULL )
if( !openFile() )
{
close();
return m_bInit;
@@ -165,15 +173,26 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_
if( m_bIsInput )
{
fseek( m_pFile, 0, SEEK_END );
m_uiTotalFrameNum = ftell( m_pFile ) / ( frame_bytes_input );
UInt64 fileSize = ftell( m_pFile );
#if 0
if( fileSize % frame_bytes_input )
{
Int remaining = fileSize % frame_bytes_input;
qDebug( ) << "Incorrect configuration: failed ( fileSize % frame_bytes_input = " << remaining << " )" ;
close();
return m_bInit;
}
#endif
m_uiTotalFrameNum = fileSize / frame_bytes_input;
fseek( m_pFile, 0, SEEK_SET );
}
m_cFormatName = QString::fromUtf8( "YUV" );
m_cCodedName = QString::fromUtf8( "Raw Video" );
}
if( m_uiTotalFrameNum <= 0 )
if( m_bIsInput && m_uiTotalFrameNum <= 0 )
{
qDebug( ) << "Incorrect configuration: less than one frame";
close();
return m_bInit;
}
@@ -198,7 +217,6 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_
m_bInit = true;
seekInput( 0 );
//loadAll();
m_cTimer.start();
m_uiAveragePlayInterval = 0;
@@ -207,10 +225,34 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_
return m_bInit;
}
Bool PlaYUVerStream::openFile()
{
m_pFile = NULL;
Char *filename = new char[m_cFilename.length() + 1];
memcpy( filename, m_cFilename.toUtf8().constData(), m_cFilename.length() + 1 * sizeof(char) );
m_pFile = fopen( filename, m_bIsInput ? "rb" : "wb" );
delete[] filename;
if( m_pFile == NULL )
{
return false;
}
fseek( m_pFile, m_iCurrFrameNum >= 0 ? m_iCurrFrameNum : 0, SEEK_SET );
return true;
}
Void PlaYUVerStream::closeFile()
{
if( !m_bInit && m_pFile )
return;
fclose( m_pFile );
}
Void PlaYUVerStream::close()
{
if( m_pFile )
fclose( m_pFile );
if( !m_bInit )
return;
closeFile();
#ifdef USE_FFMPEG
m_cLibAvContext->closeAvFormat();
@@ -252,7 +294,7 @@ Void PlaYUVerStream::getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat,
{
rWidth = 0;
rHeight = 0;
rInputFormat = -1;
rInputFormat = PlaYUVerFrame::YUV420p;
rFrameRate = 30;
}
}
@@ -260,40 +302,106 @@ Void PlaYUVerStream::getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat,
Bool PlaYUVerStream::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate )
{
Bool bRet = false;
QString FilenameShort = QFileInfo( filename ).fileName();
QString fileExtension = QFileInfo( filename ).suffix();
if( !fileExtension.compare( "yuv" ) )
{
bRet = true;
// Guess resolution - match %dx%d
#if( QT_VERSION_PLAYUVER == 5 )
QRegularExpressionMatch resolutionMatch = QRegularExpression( "_\\d*x\\d*" ).match( filename );
if( resolutionMatch.hasMatch() )
{
QString resolutionString = resolutionMatch.captured( 0 );
if( resolutionString.startsWith( "_" ) || resolutionString.endsWith( "_" ) )
{
resolutionString.remove( "_" );
QStringList resolutionArgs = resolutionString.split( "x" );
qDebug( ) << "Found resolution = "
<< resolutionArgs;
if( resolutionArgs.size() == 2 )
{
rWidth = resolutionArgs.at( 0 ).toUInt();
rHeight = resolutionArgs.at( 1 ).toUInt();
}
}
}
#endif
// Guess pixel format
// Guess pixel format
QStringList formats_list = PlaYUVerFrame::supportedPixelFormatList();
for( Int i = 0; i < formats_list.size(); i++ )
{
if( filename.contains( formats_list.at( i ), Qt::CaseInsensitive ) )
if( FilenameShort.contains( formats_list.at( i ), Qt::CaseInsensitive ) )
{
rInputFormat = i;
break;
}
}
if( rWidth == 0 || rHeight == 0 )
{
// Guess resolution - match resolution name
Int iMatch = -1;
QStringList stdResName = standardResolutionSizes().stringListName;
for( Int i = 0; i < stdResName.size(); i++ )
{
if( FilenameShort.contains( stdResName.at( i ) ) )
{
if( iMatch >= 0 )
{
if( stdResName.at( i ).size() > stdResName.at( iMatch ).size() )
{
iMatch = i;
}
}
else
{
iMatch = i;
}
}
}
if( iMatch >= 0 )
{
rWidth = standardResolutionSizes().sizeResolution.at( iMatch ).width();
rHeight = standardResolutionSizes().sizeResolution.at( iMatch ).height();
}
// Guess resolution - match %dx%d
#if( QT_VERSION_PLAYUVER == 5 )
QRegularExpressionMatch resolutionMatch = QRegularExpression( "_\\d*x\\d*" ).match( FilenameShort );
if( resolutionMatch.hasMatch() )
{
QString resolutionString = resolutionMatch.captured( 0 );
if( resolutionString.startsWith( "_" ) || resolutionString.endsWith( "_" ) )
{
resolutionString.remove( "_" );
QStringList resolutionArgs = resolutionString.split( "x" );
qDebug( ) << "Found resolution = "
<< resolutionArgs;
if( resolutionArgs.size() == 2 )
{
rWidth = resolutionArgs.at( 0 ).toUInt();
rHeight = resolutionArgs.at( 1 ).toUInt();
}
}
}
#endif
}
// Guess resolution by file size
if( rWidth == 0 && rHeight == 0 )
{
Char *filename_char = new char[filename.length() + 1];
memcpy( filename_char, filename.toUtf8().constData(), filename.length() + 1 * sizeof(char) );
FILE* pF = fopen( filename_char, "rb" );
fseek( pF, 0, SEEK_END );
UInt64 uiFileSize = ftell( pF );
fclose( pF );
delete[] filename_char;
if( pF != NULL )
{
Int count = 0, module, frame_bytes, match;
QVector<QSize> sizeResolution = standardResolutionSizes().sizeResolution;
for( Int i = 0; i < sizeResolution.size(); i++ )
{
frame_bytes = PlaYUVerFrame::getBytesPerFrame( sizeResolution.at( i ).width(), sizeResolution.at( i ).height(), rInputFormat );
module = uiFileSize % frame_bytes;
if( module == 0 )
{
match = i;
count++;
}
}
if( count == 1 )
{
rWidth = sizeResolution.at( match ).width();
rHeight = sizeResolution.at( match ).height();
}
}
}
if( rWidth > 0 && rHeight > 0 && rInputFormat >= 0 )
bRet = false;
}
@@ -331,7 +439,7 @@ Void PlaYUVerStream::loadAll()
m_iCurrFrameNum = -1;
seekInput( 0 );
setNextFrame();
for( UInt i = m_uiFrameBufferIndex; i < m_uiFrameBufferSize ; i++ )
for( UInt i = m_uiFrameBufferIndex; i < m_uiFrameBufferSize; i++ )
{
readFrame();
setNextFrame();
@@ -434,8 +542,33 @@ Void PlaYUVerStream::writeFrame( PlaYUVerFrame *pcFrame )
Bool PlaYUVerStream::saveFrame( const QString& filename )
{
QImage qimg = QImage( m_pcCurrFrame->getQImageBuffer(), m_pcCurrFrame->getWidth(), m_pcCurrFrame->getHeight(), QImage::Format_RGB888 );
return qimg.save( filename );
Int iFileFormat = INVALID_INPUT;
QStringList formatsExt = PlaYUVerStream::supportedReadFormatsExt();
QString currExt = QFileInfo( filename ).suffix();
if( formatsExt.contains( currExt ) )
{
iFileFormat = formatsExt.indexOf( currExt );
}
if( iFileFormat == YUVINPUT )
{
PlaYUVerStream auxFrameStream;
if( !auxFrameStream.open( filename, m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiFrameRate, false ) )
{
return false;
}
auxFrameStream.writeFrame( m_pcCurrFrame );
auxFrameStream.close();
return true;
}
else
{
m_pcCurrFrame->FrametoRGB8();
QImage qimg = QImage( m_pcCurrFrame->getQImageBuffer(), m_pcCurrFrame->getWidth(), m_pcCurrFrame->getHeight(), QImage::Format_RGB888 );
return qimg.save( filename );
}
return false;
}
Void PlaYUVerStream::setNextFrame()
+41 -3
View File
@@ -42,6 +42,8 @@ private:
Bool m_bInit;
Bool m_bIsInput;
Bool m_bIsOpened;
Bool m_bLoadAll;
Int m_iErrorStatus;
@@ -156,7 +158,8 @@ public:
static QStringList supportedSaveFormatsExt()
{
QStringList formatsExt;
formatsExt << "bmp"
formatsExt << "yuv"
<< "bmp"
<< "jpeg"
<< "png" // portable network graphics
;
@@ -166,12 +169,43 @@ public:
static QStringList supportedSaveFormatsName()
{
QStringList formatsName;
formatsName << "Windows Bitmap"
formatsName << "Raw Video"
<< "Windows Bitmap"
<< "Joint Photographic Experts Group"
<< "Portable Network Graphics";
return formatsName;
}
#define REGIST_STANDARD_RESOLUTION( name, width, height) \
stdRes.stringListName.append( QString( name ) ); \
stdRes.stringListFullName.append( QString( "%1 (%2x%3)" ).arg( name ).arg( width ).arg( height ) ); \
stdRes.sizeResolution.append( QSize( width, height ) )
struct StandardResolution
{
QStringList stringListName;
QStringList stringListFullName;
QVector<QSize> sizeResolution;
};
static struct StandardResolution standardResolutionSizes()
{
struct StandardResolution stdRes;
REGIST_STANDARD_RESOLUTION( "CIF", 352, 288 );
REGIST_STANDARD_RESOLUTION( "VGA", 640, 480 );
REGIST_STANDARD_RESOLUTION( "WVGA", 832, 480 );
REGIST_STANDARD_RESOLUTION( "XVGA", 1024, 768 );
REGIST_STANDARD_RESOLUTION( "HD", 1280, 720 );
REGIST_STANDARD_RESOLUTION( "SXGA-", 1280, 900 );
REGIST_STANDARD_RESOLUTION( "SXGA", 1280, 1024 );
REGIST_STANDARD_RESOLUTION( "WSXGA", 1440, 900 );
REGIST_STANDARD_RESOLUTION( "FullHD", 1920, 1080 );
REGIST_STANDARD_RESOLUTION( "WQXGA", 2560, 1600 );
REGIST_STANDARD_RESOLUTION( "UltraHD", 3840, 2160 );
REGIST_STANDARD_RESOLUTION( "8K", 8192, 4608 );
return stdRes;
}
enum PlaYUVerStreamErrors
{
NO_STREAM_ERROR = 0,
@@ -184,7 +218,11 @@ public:
Bool open( QString filename, UInt width, UInt height, Int input_format, UInt frame_rate, Bool bInput = true );
Void close();
Bool guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate );
Bool openFile();
Void closeFile();
static Bool guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate );
Void getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate );
Void loadAll();
+1 -1
View File
@@ -40,7 +40,7 @@ extern "C"
#include <libavutil/avutil.h>
#include <libavutil/imgutils.h>
#include <libavutil/samplefmt.h>
#include <libavutil/timestamp.h>
//#include <libavutil/timestamp.h>
#include <libavformat/avformat.h>
}
+141
View File
@@ -0,0 +1,141 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* \file FilterComponent.cpp
* \brief Filter component frame module
*/
#include <cstdio>
#include "FilterComponent.h"
namespace plaYUVer
{
FilterComponent::FilterComponent()
{
m_pcFilteredFrame = NULL;
}
Void FilterComponent::createFilter( UInt uiWidth, UInt uiHeight )
{
m_pcFilteredFrame = NULL;
m_pcFilteredFrame = new PlaYUVerFrame( uiWidth, uiHeight, PlaYUVerFrame::GRAY );
}
PlaYUVerFrame* FilterComponent::filterComponent( PlaYUVerFrame* InputFrame, Int Component )
{
Pel*** pppOutputPelYUV = m_pcFilteredFrame->getPelBufferYUV();
Pel*** pppInputPelYUV = InputFrame->getPelBufferYUV();
memcpy( pppOutputPelYUV[LUMA][0], pppInputPelYUV[Component][0], m_pcFilteredFrame->getWidth() * m_pcFilteredFrame->getHeight() * sizeof(Pel) );
return m_pcFilteredFrame;
}
Void FilterComponent::destroy()
{
if( m_pcFilteredFrame )
delete m_pcFilteredFrame;
m_pcFilteredFrame = NULL;
}
PlaYUVerModuleDefinition FilterComponentLumaDef = {
FRAME_PROCESSING_MODULE, // Apply module to the frames or to the whole sequence.
// Currently only support for frame
"Filter Component", // Category (sub-menu)
"Luma", // Name
"Filter Y matrix of YUV frame", // Description
MODULE_REQUIRES_ONE_FRAME, // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES)
MODULE_REQUIRES_NOTHING, // Module requirements (check PlaYUVerModulesIf.h).
// Several requirements should be "or" between each others.
APPLY_WHILE_PLAYING, // Apply module while playing
};
FilterComponentLuma::FilterComponentLuma()
{
setModuleDefinition( FilterComponentLumaDef );
}
Void FilterComponentLuma::create( PlaYUVerFrame* InputFrame )
{
createFilter( InputFrame->getWidth(), InputFrame->getHeight() );
}
PlaYUVerFrame* FilterComponentLuma::process( PlaYUVerFrame* InputFrame )
{
return filterComponent( InputFrame, LUMA );
}
PlaYUVerModuleDefinition FilterComponentCbDef = {
FRAME_PROCESSING_MODULE, // Apply module to the frames or to the whole sequence.
// Currently only support for frame
"Filter Component", // Category (sub-menu)
"Chroma U", // Name
"Filter Y matrix of YUV frame", // Description
MODULE_REQUIRES_ONE_FRAME, // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES)
MODULE_REQUIRES_NOTHING, // Module requirements (check PlaYUVerModulesIf.h).
// Several requirements should be "or" between each others.
APPLY_WHILE_PLAYING, // Apply module while playing
};
FilterComponentChromaU::FilterComponentChromaU()
{
setModuleDefinition( FilterComponentCbDef );
}
Void FilterComponentChromaU::create( PlaYUVerFrame* InputFrame )
{
createFilter( InputFrame->getChromaWidth(), InputFrame->getChromaHeight() );
}
PlaYUVerFrame* FilterComponentChromaU::process( PlaYUVerFrame* InputFrame )
{
return filterComponent( InputFrame, CHROMA_U );
}
PlaYUVerModuleDefinition FilterComponentCrDef = {
FRAME_PROCESSING_MODULE, // Apply module to the frames or to the whole sequence.
// Currently only support for frame
"Filter Component", // Category (sub-menu)
"Chroma R", // Name
"Filter Y matrix of YUV frame", // Description
MODULE_REQUIRES_ONE_FRAME, // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES)
MODULE_REQUIRES_NOTHING, // Module requirements (check PlaYUVerModulesIf.h).
// Several requirements should be "or" between each others.
APPLY_WHILE_PLAYING, // Apply module while playing
};
FilterComponentChromaV::FilterComponentChromaV()
{
setModuleDefinition( FilterComponentCrDef );
}
Void FilterComponentChromaV::create( PlaYUVerFrame* InputFrame )
{
createFilter( InputFrame->getChromaWidth(), InputFrame->getChromaHeight() );
}
PlaYUVerFrame* FilterComponentChromaV::process( PlaYUVerFrame* InputFrame )
{
return filterComponent( InputFrame, CHROMA_V );
}
} // NAMESPACE
+90
View File
@@ -0,0 +1,90 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* \file FilterComponent.h
* \brief Filter component frame module
*/
#ifndef __FILTERCOMPONENT_H__
#define __FILTERCOMPONENT_H__
#include "config.h"
#include "PlaYUVerDefs.h"
#include <iostream>
#include <cstdio>
#include "PlaYUVerFrame.h"
#include "PlaYUVerModuleIf.h"
#include <cassert>
namespace plaYUVer
{
class FilterComponent
{
private:
PlaYUVerFrame* m_pcFilteredFrame;
public:
FilterComponent();
virtual ~FilterComponent()
{
}
Void createFilter( UInt uiWidth, UInt uiHeight );
PlaYUVerFrame* filterComponent( PlaYUVerFrame* InputFrame, Int Component );
Void destroy();
};
class FilterComponentLuma: public FilterComponent, public PlaYUVerModuleIf
{
public:
FilterComponentLuma();
virtual ~FilterComponentLuma()
{
}
Void create( PlaYUVerFrame* InputFrame );
PlaYUVerFrame* process( PlaYUVerFrame* InputFrame );
};
class FilterComponentChromaU: public FilterComponent, public PlaYUVerModuleIf
{
public:
FilterComponentChromaU();
virtual ~FilterComponentChromaU()
{
}
Void create( PlaYUVerFrame* InputFrame );
PlaYUVerFrame* process( PlaYUVerFrame* InputFrame );
};
class FilterComponentChromaV: public FilterComponent, public PlaYUVerModuleIf
{
public:
FilterComponentChromaV();
virtual ~FilterComponentChromaV()
{
}
Void create( PlaYUVerFrame* InputFrame );
PlaYUVerFrame* process( PlaYUVerFrame* InputFrame );
};
} // NAMESPACE
#endif // __FILTERFRAME_H__
-73
View File
@@ -1,73 +0,0 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* \file FilterFrame.cpp
* \brief Filter frame module
*/
#include <cstdio>
#include "FilterFrame.h"
#include "PlaYUVerFrame.h"
namespace plaYUVer
{
PlaYUVerModuleDefinition FilterFrameDef = {
FRAME_PROCESSING_MODULE, // Apply module to the frames or to the whole sequence.
// Currently only support for frame
"Filters", // Category (sub-menu)
"Y_Filter", // Name
"Filter Y matrix of YUV frame", // Description
MODULE_REQUIRES_ONE_FRAME, // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES)
MODULE_REQUIRES_NOTHING, // Module requirements (check PlaYUVerModulesIf.h).
// Several requirements should be "or" between each others.
APPLY_WHILE_PLAYING, // Apply module while playing
};
FilterFrame::FilterFrame()
{
setModuleDefinition( FilterFrameDef );
m_pcFilteredFrame = NULL;
}
Void FilterFrame::create( PlaYUVerFrame* InputFrame )
{
m_pcFilteredFrame = NULL;
m_pcFilteredFrame = new PlaYUVerFrame( InputFrame->getWidth(), InputFrame->getHeight(), PlaYUVerFrame::GRAY );
}
PlaYUVerFrame* FilterFrame::process( PlaYUVerFrame* InputFrame )
{
Pel*** pppOutputPelYUV = m_pcFilteredFrame->getPelBufferYUV();
Pel*** pppInputPelYUV = InputFrame->getPelBufferYUV();
memcpy( pppOutputPelYUV[LUMA][0], pppInputPelYUV[LUMA][0], m_pcFilteredFrame->getWidth() * m_pcFilteredFrame->getHeight() * sizeof(Pel) );
return m_pcFilteredFrame;
}
Void FilterFrame::destroy()
{
if( m_pcFilteredFrame )
delete m_pcFilteredFrame;
m_pcFilteredFrame = NULL;
}
} // NAMESPACE