Merge branch 'devel' of https://github.com/pixlra/playuver into devel

This commit is contained in:
Luis Lucas
2015-02-22 03:01:24 +00:00
13 changed files with 178 additions and 147 deletions
+3 -3
View File
@@ -41,9 +41,6 @@ OPTION( PLAYUVER_WERROR "Warnings as errors" OFF )
OPTION( PLAYUVER_THREADED_MODULES "Use threads for modules" OFF )
OPTION( USE_QT4 "Build with QT4" OFF )
ADD_FEATURE_INFO(Fervor USE_FERVOR "Fervor lib includes check for updates feature.")
ADD_FEATURE_INFO(WErrors PLAYUVER_WERROR "Warnings as errors" )
#####################################################################################
# Qt library
######################################################################################
@@ -102,6 +99,9 @@ IF( USE_FFMPEG )
ENDIF()
SET_PACKAGE_PROPERTIES(FFmpeg PROPERTIES URL "http://ffmpeg.org/" DESCRIPTION "Libav library support in PlaYUVerStream" TYPE OPTIONAL)
ADD_FEATURE_INFO(Fervor USE_FERVOR "Fervor lib includes check for updates feature.")
ADD_FEATURE_INFO(WErrors PLAYUVER_WERROR "Warnings as errors" )
IF( WIN32 )
INCLUDE( cmake/Win32.cmake )
ENDIF()
+1 -1
View File
@@ -159,7 +159,7 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
m_comboBoxPixelFormat->clear();
for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ )
{
m_comboBoxPixelFormat->insertItem( i, PlaYUVerFrame::supportedPixelFormatListNames()[i].data() );
m_comboBoxPixelFormat->insertItem( i, PlaYUVerFrame::supportedPixelFormatListNames()[i].c_str() );
}
m_comboBoxPixelFormat->setCurrentIndex( 1 );
+7 -6
View File
@@ -452,22 +452,23 @@ Void ModulesHandle::applyAllModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf )
QString supported = tr( "Supported Files (" );
QStringList formatsList;
QStringList formatsExt = PlaYUVerStream::supportedWriteFormatsExt();
QStringList formatsName = PlaYUVerStream::supportedWriteFormatsName();
std::vector<std::string> formatsExt = PlaYUVerStream::supportedWriteFormatsExt();
std::vector<std::string> formatsName = PlaYUVerStream::supportedWriteFormatsName();
for( Int i = 0; i < formatsName.size(); i++ )
for( UInt i = 0; i < formatsName.size(); i++ )
{
QString currFmt;
supported.append( " *." );
supported.append( formatsExt[i] );
currFmt.append( formatsName[i] );
supported.append( QString::fromStdString( formatsExt[i] ) );
currFmt.append( QString::fromStdString( formatsName[i] ) );
currFmt.append( " (*." );
currFmt.append( formatsExt[i] );
currFmt.append( QString::fromStdString( formatsExt[i] ) );
currFmt.append( ")" );
formatsList << currFmt;
}
supported.append( " )" );
QStringList filter;
filter << supported
<< formatsList
+1 -1
View File
@@ -131,7 +131,7 @@ Void QualityHandle::slotQualityMetricChanged( Int idx )
Void QualityHandle::slotSelectReference()
{
DialogSubWindowSelector dialogWindowSelection( this, m_pcMainWindowManager, 1, 1 );
DialogSubWindowSelector dialogWindowSelection( this, m_pcMainWindowManager, SubWindowHandle::VIDEO_SUBWINDOW, 1, 1 );
if( dialogWindowSelection.exec() == QDialog::Accepted )
{
VideoSubWindow* pcVideoSubWindow;
+2
View File
@@ -192,6 +192,7 @@ Void VideoHandle::readSettings()
{
QSettings appSettings;
m_arrayActions[VIDEO_LOOP_ACT]->setChecked( appSettings.value( "VideoHandle/Repeat", false ).toBool() );
m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->setChecked( appSettings.value( "VideoHandle/VideoZoomLock", false ).toBool() );
if( !appSettings.value( "VideoHandle/FrameProperties", true ).toBool() )
m_pcFramePropertiesDock->close();
}
@@ -200,6 +201,7 @@ Void VideoHandle::writeSettings()
{
QSettings appSettings;
appSettings.setValue( "VideoHandle/Repeat", m_arrayActions[VIDEO_LOOP_ACT]->isChecked() );
appSettings.setValue( "VideoHandle/VideoZoomLock", m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->isChecked() );
appSettings.setValue( "VideoHandle/FrameProperties", m_pcFramePropertiesSideBar->isVisible() );
}
+29 -15
View File
@@ -91,8 +91,8 @@ Void plaYUVerApp::parseArgs( Int argc, Char *argv[] )
{
loadFile( argv[i] );
}
// m_pcWindowHandle->tileSubWindows();
// zoomToFitAll();
m_pcWindowHandle->tileSubWindows();
zoomToFitAll();
}
}
@@ -218,17 +218,17 @@ Void plaYUVerApp::open()
{
QString supported = tr( "Supported Files (" );
QStringList formatsList;
QStringList formatsExt = PlaYUVerStream::supportedReadFormatsExt();
QStringList formatsName = PlaYUVerStream::supportedReadFormatsName();
std::vector<std::string> formatsExt = PlaYUVerStream::supportedReadFormatsExt();
std::vector<std::string> formatsName = PlaYUVerStream::supportedReadFormatsName();
for( Int i = 0; i < formatsName.size(); i++ )
for( UInt i = 0; i < formatsName.size(); i++ )
{
QString currFmt;
supported.append( " *." );
supported.append( formatsExt[i] );
currFmt.append( formatsName[i] );
supported.append( QString::fromStdString( formatsExt[i] ) );
currFmt.append( QString::fromStdString( formatsName[i] ) );
currFmt.append( " (*." );
currFmt.append( formatsExt[i] );
currFmt.append( QString::fromStdString( formatsExt[i] ) );
currFmt.append( ")" );
formatsList << currFmt;
}
@@ -265,17 +265,17 @@ Void plaYUVerApp::save()
VideoSubWindow *saveWindow = m_pcCurrentVideoSubWindow;
QString supported = tr( "Supported Files (" );
QStringList formatsList;
QStringList formatsExt = PlaYUVerStream::supportedSaveFormatsExt();
QStringList formatsName = PlaYUVerStream::supportedSaveFormatsName();
std::vector<std::string> formatsExt = PlaYUVerStream::supportedSaveFormatsExt();
std::vector<std::string> formatsName = PlaYUVerStream::supportedSaveFormatsName();
for( Int i = 0; i < formatsName.size(); i++ )
for( UInt i = 0; i < formatsName.size(); i++ )
{
QString currFmt;
supported.append( " *." );
supported.append( formatsExt[i] );
currFmt.append( formatsName[i] );
supported.append( QString::fromStdString( formatsExt[i] ) );
currFmt.append( QString::fromStdString( formatsName[i] ) );
currFmt.append( " (*." );
currFmt.append( formatsExt[i] );
currFmt.append( QString::fromStdString( formatsExt[i] ) );
currFmt.append( ")" );
formatsList << currFmt;
}
@@ -409,7 +409,6 @@ Void plaYUVerApp::zoomToFitAll()
updateZoomFactorSBox();
}
Void plaYUVerApp::scaleFrame( int ratio )
{
if( m_pcCurrentSubWindow )
@@ -846,6 +845,20 @@ Void plaYUVerApp::updateRecentFileActions()
m_arrayMenu[RECENT_MENU]->setEnabled( m_aRecentFileStreamInfo.size() > 0 ? true : false );
}
Void plaYUVerApp::checkRecentFileActions()
{
Int i = 0;
while( i < m_aRecentFileStreamInfo.size() )
{
if( !QFileInfo::exists( m_aRecentFileStreamInfo.at( i ).m_cFilename ) )
{
m_aRecentFileStreamInfo.remove( i );
continue;
}
i++;
}
}
Void plaYUVerApp::readSettings()
{
QSettings appSettings;
@@ -862,6 +875,7 @@ Void plaYUVerApp::readSettings()
QVariant value = appSettings.value( "MainWindow/RecentFileList" );
m_aRecentFileStreamInfo = value.value<PlaYUVerStreamInfoVector>();
checkRecentFileActions();
updateRecentFileActions();
m_appModuleVideo->readSettings();
+1
View File
@@ -124,6 +124,7 @@ private:
Void addStreamInfoToRecentList( PlaYUVerStreamInfo streamInfo );
Void updateRecentFileActions();
Void checkRecentFileActions();
Void readSettings();
Void writeSettings();
+8
View File
@@ -26,6 +26,7 @@
#define __TYPEDEF_H__
#include <string>
#include <algorithm>
namespace plaYUVer
{
@@ -116,6 +117,13 @@ enum RGBcomponent
COLOR_A,
};
inline std::string lowercase( const std::string& in )
{
std::string out;
transform( in.begin(), in.end(), std::back_inserter( out ), tolower );
return out;
}
} // NAMESPACE
#endif // __TYPEDEF_H__
+116 -114
View File
@@ -27,116 +27,73 @@
#include <vector>
#include "LibMemory.h"
#include "PlaYUVerStream.h"
#include <QImage>
#include <QString>
#include <QFileInfo>
#ifdef USE_FFMPEG
#include "LibAvContextHandle.h"
#endif
#ifdef USE_OPENCV
#include <opencv2/opencv.hpp>
#endif
namespace plaYUVer
{
enum PlaYUVerStreamInputFormats
std::vector<std::string> PlaYUVerStream::supportedReadFormatsExt()
{
INVALID_INPUT = -1,
YUVINPUT = 0,
#ifdef USE_FFMPEG
AVIINPUT,
MP4INPUT,
WMVINPUT,
PGMINPUT,
PNGINPUT,
BMPINPUT,
JPEGINPUT,
#endif
TOTAL_INPUT_FORMATS
};
QStringList PlaYUVerStream::supportedReadFormatsExt()
{
QStringList formatsExt;
formatsExt << "yuv"
// Raw video
#ifdef USE_FFMPEG
<< "avi"
// Audio video interleaved
<< "mp4"
// MP4
<< "wmv"
// Windows media video
<< "pgm"
<< "png"
<< "bmp"
<< "jpg"
#endif
;
//assert( formatsExt.size() == TOTAL_INPUT_FORMATS );
std::vector<std::string> formatsExt;
formatsExt.push_back( "yuv" );
std::vector<std::string> libAvFmt = LibAvContextHandle::supportedReadFormatsExt();
formatsExt.insert( formatsExt.end(), libAvFmt.begin(), libAvFmt.end() );
return formatsExt;
}
QStringList PlaYUVerStream::supportedReadFormatsName()
std::vector<std::string> PlaYUVerStream::supportedReadFormatsName()
{
QStringList formatsName;
formatsName << "Raw video"
#ifdef USE_FFMPEG
<< "Audio video interleaved"
<< "MPEG4"
<< "Windows media video"
<< "Portable Grayscale Map"
<< "Portable Network Graphics"
<< "Windows Bitmap"
<< "Joint Photographic Experts Group"
#endif
;
//assert( formatsName.size() == TOTAL_INPUT_FORMATS );
std::vector<std::string> formatsName;
formatsName.push_back( "Raw video" );
std::vector<std::string> libAvFmt = LibAvContextHandle::supportedReadFormatsName();
formatsName.insert( formatsName.end(), libAvFmt.begin(), libAvFmt.end() );
return formatsName;
}
enum PlaYUVerStreamOutputFormats
std::vector<std::string> PlaYUVerStream::supportedWriteFormatsExt()
{
INVALID_OUTPUT = -1,
YUVOUTPUT = 0,
TOTAL_OUTPUT_FORMATS
};
QStringList PlaYUVerStream::supportedWriteFormatsExt()
{
QStringList formatsExt;
formatsExt << "yuv" // raw video
;
assert( formatsExt.size() == TOTAL_OUTPUT_FORMATS );
std::vector<std::string> formatsExt;
formatsExt.push_back( "yuv" );
return formatsExt;
}
QStringList PlaYUVerStream::supportedWriteFormatsName()
std::vector<std::string> PlaYUVerStream::supportedWriteFormatsName()
{
QStringList formatsName;
formatsName << "Raw video";
assert( formatsName.size() == TOTAL_OUTPUT_FORMATS );
std::vector<std::string> formatsName;
formatsName.push_back( "Raw video" );
return formatsName;
}
QStringList PlaYUVerStream::supportedSaveFormatsExt()
std::vector<std::string> PlaYUVerStream::supportedSaveFormatsExt()
{
QStringList formatsExt;
formatsExt << supportedWriteFormatsExt()
<< "bmp"
<< "jpeg"
<< "png" // portable network graphics
;
formatsExt.removeDuplicates();
std::vector<std::string> formatsExt;
std::vector<std::string> writeExt = supportedWriteFormatsExt();
formatsExt.insert( formatsExt.begin(), writeExt.begin(), writeExt.end() );
formatsExt.push_back( "bmp" );
formatsExt.push_back( "bmp" );
formatsExt.push_back( "jpeg" );
formatsExt.push_back( "png" );
sort( formatsExt.begin(), formatsExt.end() );
formatsExt.erase( unique( formatsExt.begin(), formatsExt.end() ), formatsExt.end() );
return formatsExt;
}
QStringList PlaYUVerStream::supportedSaveFormatsName()
std::vector<std::string> PlaYUVerStream::supportedSaveFormatsName()
{
QStringList formatsName;
formatsName << supportedWriteFormatsName()
<< "Windows Bitmap"
<< "Joint Photographic Experts Group"
<< "Portable Network Graphics";
formatsName.removeDuplicates();
std::vector<std::string> formatsName;
std::vector<std::string> writeName = supportedWriteFormatsName();
formatsName.insert( formatsName.begin(), writeName.begin(), writeName.end() );
formatsName.push_back( "Windows Bitmap" );
formatsName.push_back( "Windows Bitmap" );
formatsName.push_back( "Joint Photographic Experts Group" );
formatsName.push_back( "Portable Network Graphics" );
sort( formatsName.begin(), formatsName.end() );
formatsName.erase( unique( formatsName.begin(), formatsName.end() ), formatsName.end() );
return formatsName;
}
@@ -199,15 +156,38 @@ PlaYUVerStream::~PlaYUVerStream()
close();
}
Bool PlaYUVerStream::open( std::string filename, std::string resolution, std::string input_format_name, UInt frame_rate, Bool bInput )
{
UInt width;
UInt height;
Int input_format = -1;
sscanf( resolution.c_str(), "%ux%u", &width, &height );
if( width <= 0 || height <= 0 )
{
return false;
}
for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ )
{
if( PlaYUVerFrame::supportedPixelFormatListNames()[i] == input_format_name )
{
input_format = i;
break;
}
}
if( width > 0 && height > 0 && input_format >= 0 )
{
return open( filename, width, height, input_format, frame_rate, bInput );
}
return false;
}
Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int input_format, UInt frame_rate, Bool bInput )
{
if( m_bInit )
{
close();
}
QString qtFilename = QString::fromStdString( filename );
m_bInit = false;
m_bIsInput = bInput;
m_cFilename = filename;
@@ -224,11 +204,15 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in
{
m_iFileFormat = INVALID_HANDLER;
QStringList formatsExt = PlaYUVerStream::supportedReadFormatsExt();
QString currExt = QFileInfo( qtFilename ).suffix();
if( formatsExt.contains( currExt ) )
std::string currExt = filename.substr( filename.find_last_of( "." ) + 1 );
for( UInt i = 0; i < PlaYUVerStream::supportedReadFormatsExt().size(); i++ )
{
m_iFileFormat = formatsExt.indexOf( currExt );
if( PlaYUVerStream::supportedReadFormatsExt()[i] == currExt )
{
m_iFileFormat = i;
m_cFormatName = PlaYUVerStream::supportedReadFormatsExt()[i];
break;
}
}
if( m_iFileFormat == INVALID_HANDLER )
{
@@ -236,15 +220,13 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in
throw "Invalid file format";
return m_bInit;
}
m_cFormatName = PlaYUVerStream::supportedReadFormatsExt().at( m_iFileFormat ).toUpper().toStdString();
if( m_iFileFormat == YUVINPUT )
if( m_cFormatName == "yuv" )
{
m_uiStreamHandler = YUV_IO;
}
#ifdef USE_FFMPEG
if( m_iFileFormat != YUVINPUT )
else
{
m_uiStreamHandler = FFMPEG;
}
@@ -264,7 +246,7 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in
}
else
{
m_iFileFormat = YUVOUTPUT;
m_iFileFormat = 0;
m_uiStreamHandler = YUV_IO;
m_uiFrameBufferSize = 1;
}
@@ -407,7 +389,7 @@ Void PlaYUVerStream::close()
freeMem1D<Pel>( m_pStreamBuffer );
if( m_pchFilename )
delete [] m_pchFilename;
delete[] m_pchFilename;
m_bLoadAll = false;
m_bInit = false;
@@ -574,32 +556,52 @@ Bool PlaYUVerStream::saveFrame( const std::string& filename )
Bool PlaYUVerStream::saveFrame( const std::string& filename, PlaYUVerFrame *saveFrame )
{
QString qtString = QString::fromStdString( filename );
Int iFileFormat = INVALID_OUTPUT;
Int iFileFormat = INVALID_HANDLER;
std::string fmtExt;
QStringList formatsExt = PlaYUVerStream::supportedSaveFormatsExt();
QString currExt = QFileInfo( qtString ).suffix();
if( formatsExt.contains( currExt ) )
{
iFileFormat = formatsExt.indexOf( currExt );
}
//std::string currExt = QFileInfo( qtString ).suffix().toStdString();
std::string currExt = filename.substr( filename.find_last_of( "." ) + 1 );
if( iFileFormat < TOTAL_OUTPUT_FORMATS )
for( UInt i = 0; i < PlaYUVerStream::supportedSaveFormatsExt().size(); i++ )
{
PlaYUVerStream auxFrameStream;
if( !auxFrameStream.open( filename, saveFrame->getWidth(), saveFrame->getHeight(), saveFrame->getPelFormat(), 1, false ) )
if( PlaYUVerStream::supportedSaveFormatsExt()[i] == currExt )
{
return false;
iFileFormat = i;
fmtExt = PlaYUVerStream::supportedSaveFormatsExt()[i];
break;
}
auxFrameStream.writeFrame( saveFrame );
auxFrameStream.close();
return true;
}
else
if( iFileFormat != INVALID_HANDLER )
{
saveFrame->fillRGBBuffer();
QImage qimg = QImage( saveFrame->getRGBBuffer(), saveFrame->getWidth(), saveFrame->getHeight(), QImage::Format_RGB32 );
return qimg.save( qtString );
if( fmtExt == "yuv" )
{
PlaYUVerStream auxFrameStream;
if( !auxFrameStream.open( filename, saveFrame->getWidth(), saveFrame->getHeight(), saveFrame->getPelFormat(), 1, false ) )
{
return false;
}
auxFrameStream.writeFrame( saveFrame );
auxFrameStream.close();
return true;
}
#if 0
else
{
saveFrame->fillRGBBuffer();
QImage qimg = QImage( saveFrame->getRGBBuffer(), saveFrame->getWidth(), saveFrame->getHeight(), QImage::Format_RGB32 );
return qimg.save( qtString );
}
#endif
#ifdef USE_OPENCV
else
{
cv::Mat* image;
saveFrame->getCvMat( (Void**)&image );
return cv::imwrite( filename, *image );
}
#endif
}
return false;
}
+7 -7
View File
@@ -29,7 +29,6 @@
#include <iostream>
#include <fstream>
#include <cstdio>
#include <QStringList>
#include "PlaYUVerFrame.h"
namespace plaYUVer
@@ -95,12 +94,12 @@ private:
public:
static QStringList supportedReadFormatsExt();
static QStringList supportedReadFormatsName();
static QStringList supportedWriteFormatsExt();
static QStringList supportedWriteFormatsName();
static QStringList supportedSaveFormatsExt();
static QStringList supportedSaveFormatsName();
static std::vector<std::string> supportedReadFormatsExt();
static std::vector<std::string> supportedReadFormatsName();
static std::vector<std::string> supportedWriteFormatsExt();
static std::vector<std::string> supportedWriteFormatsName();
static std::vector<std::string> supportedSaveFormatsExt();
static std::vector<std::string> supportedSaveFormatsName();
static std::vector<PlaYUVerStdResolution> stdResolutionSizes();
@@ -116,6 +115,7 @@ public:
END_OF_SEQ,
};
Bool open( std::string filename, std::string resolution, std::string input_format, UInt frame_rate, Bool bInput = true );
Bool open( std::string filename, UInt width, UInt height, Int input_format, UInt frame_rate, Bool bInput = true );
Void close();
+1
View File
@@ -23,6 +23,7 @@
*/
#include "AbsoluteFrameDifference.h"
#include <cstdlib>
namespace plaYUVer
{
+1
View File
@@ -23,6 +23,7 @@
*/
#include <cstdio>
#include <cstring>
#include "FilterComponent.h"
namespace plaYUVer
+1
View File
@@ -26,6 +26,7 @@
#define __PLAYUVERMODULESFACTORY_H__
#include <functional>
#include <map>
#include "PlaYUVerModuleIf.h"
namespace plaYUVer