Skip to content

Commit

Permalink
Qt GUI Updates:
Browse files Browse the repository at this point in the history
- Added Highlight Reconstruction to Qt Gui
- Deleted BMP, PNG and JPG export
- Added ProRes 4444 export (but only 8 bit atm)
  • Loading branch information
masc4ii committed Jul 23, 2017
1 parent 3ddb153 commit 478aeca
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 32 deletions.
4 changes: 2 additions & 2 deletions platform/qt/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundleExecutable</key>
<string>MLV App</string>
<key>CFBundleIdentifier</key>
<string>1234.MLV App</string>
<string>magiclantern.MLV App</string>
<key>NOTE</key>
<string>This file was generated by Qt/QMake.</string>
<key>CFBundleTypeExtensions</key>
Expand All @@ -25,6 +25,6 @@
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleShortVersionString</key>
<string>0.1 alpha</string>
<string>0.2 alpha</string>
</dict>
</plist>
12 changes: 8 additions & 4 deletions platform/qt/MLVApp.pro
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ SOURCES += \
../../src/mlv/video_mlv.c \
../../src/processing/processing.c \
../../src/processing/raw_processing.c \
InfoDialog.cpp
InfoDialog.cpp \
StatusDialog.cpp


HEADERS += \
Expand All @@ -58,17 +59,20 @@ HEADERS += \
../../src/processing/raw_processing.h \
../../src/mlv_include.h \
InfoDialog.h \
MyApplication.h
MyApplication.h \
StatusDialog.h


FORMS += \
MainWindow.ui \
InfoDialog.ui
InfoDialog.ui \
StatusDialog.ui

RESOURCES += \
ressources.qrc

QMAKE_INFO_PLIST = Info.plist

DISTFILES += \
Info.plist
Info.plist \
FFmpeg/ffmpeg
96 changes: 73 additions & 23 deletions platform/qt/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <QThread>
#include <QTime>

#define VERSION "0.1 alpha"
#define VERSION "0.2 alpha"

#define MAX_RAM 2048

Expand All @@ -18,8 +18,9 @@ MainWindow::MainWindow(QWidget *parent) :
{
ui->setupUi(this);

//Init the Info Dialog
//Init the Dialogs
m_pInfoDialog = new InfoDialog( this );
m_pStatusDialog = new StatusDialog( this );

//Dont show the Faithful combobox
ui->comboBox->setVisible( false );
Expand Down Expand Up @@ -86,6 +87,7 @@ MainWindow::~MainWindow()
{
killTimer( m_timerId );
killTimer( m_timerCacheId );
delete m_pStatusDialog;
delete m_pInfoDialog;
delete ui;
}
Expand Down Expand Up @@ -423,62 +425,110 @@ void MainWindow::on_actionGoto_First_Frame_triggered()
}

//Export clip
//Making a ProRes file:
/*
$ ffmpeg -r 25 -i frame%04d.png -c:v prores_ks -profile:v 4444 output.mov
...or... -c:v prores_ks -profile:v hq output.mov
...or... -c:v prores output.mov
*/
void MainWindow::on_actionExport_triggered()
{
//Stop playback if active
ui->actionPlay->setChecked( false );

QString saveFileName = m_lastSaveFileName.left( m_lastSaveFileName.lastIndexOf( "." ) );
saveFileName.append( ".bmp" );
saveFileName.append( ".mov" );

//File Dialog
QString fileName = QFileDialog::getSaveFileName( this, tr("Export..."),
saveFileName,
tr("Images (*.bmp *.png *.jpg)") );
tr("Movie (*.mov)") );

//Exit if not an BMP file or aborted
//Exit if not an MOV file or aborted
if( fileName == QString( "" )
&& ( !fileName.endsWith( ".bmp", Qt::CaseInsensitive )
|| !fileName.endsWith( ".png", Qt::CaseInsensitive )
|| !fileName.endsWith( ".jpg", Qt::CaseInsensitive ) ) ) return;
&& ( !fileName.endsWith( ".mov", Qt::CaseInsensitive ) ) ) return;

//Delete file if exists
QFile *file = new QFile( fileName );
if( file->exists() ) file->remove();
delete file;

//Disable GUI drawing
m_dontDraw = true;

// we always get amaze frames for exporting
setMlvAlwaysUseAmaze( m_pMlvObject );

//StatusDialog
m_pStatusDialog->ui->progressBar->setMaximum( getMlvFrames( m_pMlvObject ) );
m_pStatusDialog->ui->progressBar->setValue( 0 );
m_pStatusDialog->show();

//Create temp pngs
for( uint32_t i = 0; i < getMlvFrames( m_pMlvObject ); i++ )
{
//Append frame number
QString numberedFileName = fileName.left( fileName.lastIndexOf( "." ) );
numberedFileName.append( QString( "_%1" ).arg( (uint)i, 5, 10, QChar( '0' ) ) );
numberedFileName.append( fileName.right( 4 ) );
numberedFileName.append( QString( ".png" ) );

//Get frame from library
getMlvProcessedFrame8( m_pMlvObject, i, m_pRawImage );

//Write file
if( fileName.endsWith( ".bmp", Qt::CaseInsensitive ) )
{
QImage( ( unsigned char *) m_pRawImage, getMlvWidth(m_pMlvObject), getMlvHeight(m_pMlvObject), QImage::Format_RGB888 )
.save( numberedFileName, "bmp", -1 );
}
else if( fileName.endsWith( ".png", Qt::CaseInsensitive ) )
{
QImage( ( unsigned char *) m_pRawImage, getMlvWidth(m_pMlvObject), getMlvHeight(m_pMlvObject), QImage::Format_RGB888 )
QImage( ( unsigned char *) m_pRawImage, getMlvWidth(m_pMlvObject), getMlvHeight(m_pMlvObject), QImage::Format_RGB888 )
.save( numberedFileName, "png", -1 );
}
else if( fileName.endsWith( ".jpg", Qt::CaseInsensitive ) )
{
QImage( ( unsigned char *) m_pRawImage, getMlvWidth(m_pMlvObject), getMlvHeight(m_pMlvObject), QImage::Format_RGB888 )
.save( numberedFileName, "jpg", 100 );
}

m_pStatusDialog->ui->progressBar->setValue( i );
m_pStatusDialog->ui->progressBar->repaint();
qApp->processEvents();
}

//If we don't like amaze we switch it off again
if( !ui->checkBoxUseAmaze->isChecked() ) setMlvDontAlwaysUseAmaze( m_pMlvObject );

//Enable GUI drawing
m_dontDraw = false;

QString numberedFileName = fileName.left( fileName.lastIndexOf( "." ) );
QString output = numberedFileName;
numberedFileName.append( QString( "_\%05d" ) );
numberedFileName.append( QString( ".png" ) );
output.append( QString( ".mov" ) );

QString program = QCoreApplication::applicationDirPath();
program.append( QString( "/ffmpeg\"" ) );
program.prepend( QString( "\"" ) );
program.append( QString( " -r 25 -i %1 -c:v prores_ks -profile:v 4444 %2" ).arg( numberedFileName ).arg( output ) );
qDebug() << program;
QProcess::execute( program );

//Update Status
m_pStatusDialog->ui->progressBar->setValue( m_pStatusDialog->ui->progressBar->maximum() );
m_pStatusDialog->ui->progressBar->repaint();
qApp->processEvents();

//Clean up
for( uint32_t i = 0; i < getMlvFrames( m_pMlvObject ); i++ )
{
//Append frame number
QString numberedFileName = fileName.left( fileName.lastIndexOf( "." ) );
numberedFileName.append( QString( "_%1" ).arg( (uint)i, 5, 10, QChar( '0' ) ) );
numberedFileName.append( QString( ".png" ) );

//Delete file
QFile *file = new QFile( numberedFileName );
if( file->exists() ) file->remove();
delete file;
}

//Hide Status Dialog
m_pStatusDialog->hide();
}

void MainWindow::on_checkBoxHighLightReconstruction_toggled(bool checked)
{
if( checked ) processingEnableHighlightReconstruction( m_pProcessingObject );
else processingDisableHighlightReconstruction( m_pProcessingObject );
m_frameChanged = true;
}
4 changes: 4 additions & 0 deletions platform/qt/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <QFileOpenEvent>
#include "../../src/mlv_include.h"
#include "InfoDialog.h"
#include "StatusDialog.h"

namespace Ui {
class MainWindow;
Expand Down Expand Up @@ -47,9 +48,12 @@ private slots:
void on_actionGoto_First_Frame_triggered();
void on_actionExport_triggered();

void on_checkBoxHighLightReconstruction_toggled(bool checked);

private:
Ui::MainWindow *ui;
InfoDialog *m_pInfoDialog;
StatusDialog *m_pStatusDialog;
mlvObject_t *m_pMlvObject;
processingObject_t *m_pProcessingObject;
QLabel *m_pRawImageLabel;
Expand Down
13 changes: 10 additions & 3 deletions platform/qt/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1194</width>
<height>765</height>
<width>1197</width>
<height>792</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -790,6 +790,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxHighLightReconstruction">
<property name="text">
<string>Highlight reconstruction</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxUseAmaze">
<property name="text">
Expand Down Expand Up @@ -822,7 +829,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1194</width>
<width>1197</width>
<height>22</height>
</rect>
</property>
Expand Down
13 changes: 13 additions & 0 deletions platform/qt/StatusDialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "StatusDialog.h"

StatusDialog::StatusDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::StatusDialog)
{
ui->setupUi(this);
}

StatusDialog::~StatusDialog()
{
delete ui;
}
21 changes: 21 additions & 0 deletions platform/qt/StatusDialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef STATUSDIALOG_H
#define STATUSDIALOG_H

#include <QDialog>
#include "ui_StatusDialog.h"

namespace Ui {
class StatusDialog;
}

class StatusDialog : public QDialog
{
Q_OBJECT

public:
explicit StatusDialog(QWidget *parent = 0);
~StatusDialog();
Ui::StatusDialog *ui;
};

#endif // STATUSDIALOG_H
28 changes: 28 additions & 0 deletions platform/qt/StatusDialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>StatusDialog</class>
<widget class="QDialog" name="StatusDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>369</width>
<height>40</height>
</rect>
</property>
<property name="windowTitle">
<string>Export...</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

0 comments on commit 478aeca

Please sign in to comment.