diff --git a/src/mmg-qt/forms/main_window.h b/src/mmg-qt/forms/main_window.h
index b3654e603..2f8d89ab5 100644
--- a/src/mmg-qt/forms/main_window.h
+++ b/src/mmg-qt/forms/main_window.h
@@ -1,7 +1,7 @@
/********************************************************************************
** Form generated from reading UI file 'main_window.ui'
**
-** Created: Mon Apr 9 19:48:41 2012
+** Created: Mon Apr 9 23:10:51 2012
** by: Qt User Interface Compiler version 4.7.4
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
@@ -73,6 +73,8 @@ public:
QVBoxLayout *verticalLayout_9;
QGroupBox *groupBox_7;
QGridLayout *gridLayout_5;
+ QLabel *label_35;
+ QComboBox *muxThis;
QLabel *label_16;
QLineEdit *trackName;
QLabel *label_17;
@@ -301,7 +303,7 @@ public:
scrollArea->setWidgetResizable(true);
scrollAreaWidgetContents = new QWidget();
scrollAreaWidgetContents->setObjectName(QString::fromUtf8("scrollAreaWidgetContents"));
- scrollAreaWidgetContents->setGeometry(QRect(0, -366, 402, 757));
+ scrollAreaWidgetContents->setGeometry(QRect(0, 0, 402, 784));
verticalLayout_9 = new QVBoxLayout(scrollAreaWidgetContents);
verticalLayout_9->setSpacing(6);
verticalLayout_9->setContentsMargins(11, 11, 11, 11);
@@ -312,50 +314,60 @@ public:
gridLayout_5->setSpacing(6);
gridLayout_5->setContentsMargins(11, 11, 11, 11);
gridLayout_5->setObjectName(QString::fromUtf8("gridLayout_5"));
+ label_35 = new QLabel(groupBox_7);
+ label_35->setObjectName(QString::fromUtf8("label_35"));
+
+ gridLayout_5->addWidget(label_35, 0, 0, 1, 1);
+
+ muxThis = new QComboBox(groupBox_7);
+ muxThis->setObjectName(QString::fromUtf8("muxThis"));
+
+ gridLayout_5->addWidget(muxThis, 0, 1, 1, 1);
+
label_16 = new QLabel(groupBox_7);
label_16->setObjectName(QString::fromUtf8("label_16"));
- gridLayout_5->addWidget(label_16, 0, 0, 1, 1);
+ gridLayout_5->addWidget(label_16, 1, 0, 1, 1);
trackName = new QLineEdit(groupBox_7);
trackName->setObjectName(QString::fromUtf8("trackName"));
- gridLayout_5->addWidget(trackName, 0, 1, 1, 1);
+ gridLayout_5->addWidget(trackName, 1, 1, 1, 1);
label_17 = new QLabel(groupBox_7);
label_17->setObjectName(QString::fromUtf8("label_17"));
- gridLayout_5->addWidget(label_17, 1, 0, 1, 1);
+ gridLayout_5->addWidget(label_17, 2, 0, 1, 1);
trackLanguage = new QComboBox(groupBox_7);
trackLanguage->setObjectName(QString::fromUtf8("trackLanguage"));
- gridLayout_5->addWidget(trackLanguage, 1, 1, 1, 1);
+ gridLayout_5->addWidget(trackLanguage, 2, 1, 1, 1);
label_18 = new QLabel(groupBox_7);
label_18->setObjectName(QString::fromUtf8("label_18"));
- gridLayout_5->addWidget(label_18, 2, 0, 1, 1);
+ gridLayout_5->addWidget(label_18, 3, 0, 1, 1);
defaultTrackFlag = new QComboBox(groupBox_7);
defaultTrackFlag->setObjectName(QString::fromUtf8("defaultTrackFlag"));
- gridLayout_5->addWidget(defaultTrackFlag, 2, 1, 1, 1);
+ gridLayout_5->addWidget(defaultTrackFlag, 3, 1, 1, 1);
label_19 = new QLabel(groupBox_7);
label_19->setObjectName(QString::fromUtf8("label_19"));
- gridLayout_5->addWidget(label_19, 3, 0, 1, 1);
+ gridLayout_5->addWidget(label_19, 4, 0, 1, 1);
forcedTrackFlag = new QComboBox(groupBox_7);
forcedTrackFlag->setObjectName(QString::fromUtf8("forcedTrackFlag"));
- gridLayout_5->addWidget(forcedTrackFlag, 3, 1, 1, 1);
+ gridLayout_5->addWidget(forcedTrackFlag, 4, 1, 1, 1);
label_31 = new QLabel(groupBox_7);
label_31->setObjectName(QString::fromUtf8("label_31"));
- gridLayout_5->addWidget(label_31, 4, 0, 1, 1);
+ gridLayout_5->addWidget(label_31, 5, 0, 1, 1);
compression = new QComboBox(groupBox_7);
compression->addItem(QString());
@@ -363,12 +375,12 @@ public:
compression->addItem(QString::fromUtf8("ZLIB"));
compression->setObjectName(QString::fromUtf8("compression"));
- gridLayout_5->addWidget(compression, 4, 1, 1, 1);
+ gridLayout_5->addWidget(compression, 5, 1, 1, 1);
label_20 = new QLabel(groupBox_7);
label_20->setObjectName(QString::fromUtf8("label_20"));
- gridLayout_5->addWidget(label_20, 5, 0, 1, 1);
+ gridLayout_5->addWidget(label_20, 6, 0, 1, 1);
horizontalLayout_11 = new QHBoxLayout();
horizontalLayout_11->setSpacing(6);
@@ -384,7 +396,7 @@ public:
horizontalLayout_11->addWidget(browseTrackTags);
- gridLayout_5->addLayout(horizontalLayout_11, 5, 1, 1, 1);
+ gridLayout_5->addLayout(horizontalLayout_11, 6, 1, 1, 1);
verticalLayout_9->addWidget(groupBox_7);
@@ -476,15 +488,14 @@ public:
gridLayout_7->addWidget(setAspectRatio, 0, 0, 1, 1);
aspectRatio = new QComboBox(groupBox_9);
- aspectRatio->insertItems(0, QStringList()
- << QString::fromUtf8("4/3")
- << QString::fromUtf8("1.66")
- << QString::fromUtf8("16/9")
- << QString::fromUtf8("1.85")
- << QString::fromUtf8("2.00")
- << QString::fromUtf8("2.21")
- << QString::fromUtf8("2.35")
- );
+ aspectRatio->addItem(QString());
+ aspectRatio->addItem(QString::fromUtf8("4/3"));
+ aspectRatio->addItem(QString::fromUtf8("1.66"));
+ aspectRatio->addItem(QString::fromUtf8("16/9"));
+ aspectRatio->addItem(QString::fromUtf8("1.85"));
+ aspectRatio->addItem(QString::fromUtf8("2.00"));
+ aspectRatio->addItem(QString::fromUtf8("2.21"));
+ aspectRatio->addItem(QString::fromUtf8("2.35"));
aspectRatio->setObjectName(QString::fromUtf8("aspectRatio"));
aspectRatio->setEditable(true);
@@ -1086,7 +1097,8 @@ public:
QWidget::setTabOrder(mainTab, files);
QWidget::setTabOrder(files, tracks);
QWidget::setTabOrder(tracks, scrollArea);
- QWidget::setTabOrder(scrollArea, trackName);
+ QWidget::setTabOrder(scrollArea, muxThis);
+ QWidget::setTabOrder(muxThis, trackName);
QWidget::setTabOrder(trackName, trackLanguage);
QWidget::setTabOrder(trackLanguage, defaultTrackFlag);
QWidget::setTabOrder(defaultTrackFlag, forcedTrackFlag);
@@ -1203,6 +1215,12 @@ public:
label_2->setText(QApplication::translate("MainWindow", "Tracks, chapters, tags and attachments:", 0, QApplication::UnicodeUTF8));
label_3->setText(QApplication::translate("MainWindow", "Properties:", 0, QApplication::UnicodeUTF8));
groupBox_7->setTitle(QApplication::translate("MainWindow", "General options", 0, QApplication::UnicodeUTF8));
+ label_35->setText(QApplication::translate("MainWindow", "Mux this:", 0, QApplication::UnicodeUTF8));
+ muxThis->clear();
+ muxThis->insertItems(0, QStringList()
+ << QApplication::translate("MainWindow", "yes", 0, QApplication::UnicodeUTF8)
+ << QApplication::translate("MainWindow", "no", 0, QApplication::UnicodeUTF8)
+ );
label_16->setText(QApplication::translate("MainWindow", "Track name:", 0, QApplication::UnicodeUTF8));
label_17->setText(QApplication::translate("MainWindow", "Language:", 0, QApplication::UnicodeUTF8));
label_18->setText(QApplication::translate("MainWindow", "\"Default track\" flag:", 0, QApplication::UnicodeUTF8));
@@ -1232,6 +1250,8 @@ public:
browseTimecodes->setText(QApplication::translate("MainWindow", "Browse", 0, QApplication::UnicodeUTF8));
groupBox_9->setTitle(QApplication::translate("MainWindow", "Picture properties", 0, QApplication::UnicodeUTF8));
setAspectRatio->setText(QApplication::translate("MainWindow", "Set aspect ratio:", 0, QApplication::UnicodeUTF8));
+ aspectRatio->setItemText(0, QString());
+
setDisplayWidthHeight->setText(QApplication::translate("MainWindow", "Display width/height:", 0, QApplication::UnicodeUTF8));
label_25->setText(QApplication::translate("MainWindow", "x", 0, QApplication::UnicodeUTF8));
label_26->setText(QApplication::translate("MainWindow", "Stereoscopy:", 0, QApplication::UnicodeUTF8));
diff --git a/src/mmg-qt/forms/main_window.ui b/src/mmg-qt/forms/main_window.ui
index debf9c602..71ffb33ad 100644
--- a/src/mmg-qt/forms/main_window.ui
+++ b/src/mmg-qt/forms/main_window.ui
@@ -82,9 +82,9 @@
0
- -366
+ 0
402
- 757
+ 784
@@ -95,6 +95,27 @@
-
+
+
+ Mux this:
+
+
+
+ -
+
+
-
+
+ yes
+
+
+ -
+
+ no
+
+
+
+
+ -
Track name:
@@ -104,10 +125,10 @@
- -
+
-
- -
+
-
Language:
@@ -117,10 +138,10 @@
- -
+
-
- -
+
-
"Default track" flag:
@@ -130,7 +151,7 @@
- -
+
-
-
@@ -149,7 +170,7 @@
- -
+
-
"Forced track" flag:
@@ -159,7 +180,7 @@
- -
+
-
-
@@ -173,7 +194,7 @@
- -
+
-
Compression:
@@ -183,7 +204,7 @@
- -
+
-
-
@@ -202,7 +223,7 @@
- -
+
-
Tags:
@@ -212,7 +233,7 @@
- -
+
-
-
@@ -383,6 +404,11 @@
true
+
-
+
+
+
+
-
4/3
@@ -1280,6 +1306,7 @@
files
tracks
scrollArea
+ muxThis
trackName
trackLanguage
defaultTrackFlag
diff --git a/src/mmg-qt/main_window.cpp b/src/mmg-qt/main_window.cpp
index 24f1d78d9..cd13aafac 100644
--- a/src/mmg-qt/main_window.cpp
+++ b/src/mmg-qt/main_window.cpp
@@ -50,7 +50,5 @@ void
MainWindow::addFile(QString const &fileName,
bool /*append*/) {
FileIdentifier identifier{ this, fileName };
- if (!identifier.identify())
- return;
-
+ mxinfo(boost::format("res; %1%\n") % identifier.identify());
}
diff --git a/src/mmg-qt/source_file.cpp b/src/mmg-qt/source_file.cpp
new file mode 100644
index 000000000..67b88abda
--- /dev/null
+++ b/src/mmg-qt/source_file.cpp
@@ -0,0 +1,53 @@
+#include "common/common_pch.h"
+
+#include "common/qt.h"
+#include "mmg-qt/source_file.h"
+
+SourceFile::SourceFile(QString const &fileName)
+ : m_fileName(fileName)
+ , m_type(FILE_TYPE_IS_UNKNOWN)
+ , m_appended(false)
+{
+}
+
+SourceFile::~SourceFile() {
+}
+
+bool
+SourceFile::isValid()
+ const {
+ return !m_container.isEmpty();
+}
+
+void
+SourceFile::setContainer(QString const &container) {
+ m_container = container;
+ m_type = container == "AAC" ? FILE_TYPE_AAC
+ : container == "AC3" ? FILE_TYPE_AC3
+ : container == "AVC/h.264" ? FILE_TYPE_AVC_ES
+ : container == "AVI" ? FILE_TYPE_AVI
+ : container == "Dirac" ? FILE_TYPE_DIRAC
+ : container == "DTS" ? FILE_TYPE_DTS
+ : container == "FLAC" ? FILE_TYPE_FLAC
+ : container == "IVF (VP8)" ? FILE_TYPE_IVF
+ : container == "Matroska" ? FILE_TYPE_MATROSKA
+ : container == "MP2/MP3" ? FILE_TYPE_MP3
+ : container == "MPEG video elementary stream" ? FILE_TYPE_MPEG_ES
+ : container == "MPEG program stream" ? FILE_TYPE_MPEG_PS
+ : container == "MPEG transport stream" ? FILE_TYPE_MPEG_TS
+ : container == "Ogg/OGM" ? FILE_TYPE_OGM
+ : container == "PGSSUP" ? FILE_TYPE_PGSSUP
+ : container == "QuickTime/MP4" ? FILE_TYPE_QTMP4
+ : container == "RealMedia" ? FILE_TYPE_REAL
+ : container == "SRT subtitles" ? FILE_TYPE_SRT
+ : container == "SSA/ASS subtitles" ? FILE_TYPE_SSA
+ : container == "TrueHD" ? FILE_TYPE_TRUEHD
+ : container == "TTA" ? FILE_TYPE_TTA
+ : container == "USF subtitles" ? FILE_TYPE_USF
+ : container == "VC1 elementary stream" ? FILE_TYPE_VC1
+ : container == "VobBtn" ? FILE_TYPE_VOBBTN
+ : container == "VobSub" ? FILE_TYPE_VOBSUB
+ : container == "WAV" ? FILE_TYPE_WAV
+ : container == "WAVPACK" ? FILE_TYPE_WAVPACK4
+ : FILE_TYPE_IS_UNKNOWN;
+}
diff --git a/src/mmg-qt/source_file.h b/src/mmg-qt/source_file.h
new file mode 100644
index 000000000..ed64d99fa
--- /dev/null
+++ b/src/mmg-qt/source_file.h
@@ -0,0 +1,37 @@
+#ifndef MTX_MMGQT_SOURCE_FILE_H
+#define MTX_MMGQT_SOURCE_FILE_H
+
+#include "common/common_pch.h"
+
+#include
+#include
+#include
+#include
+
+#include "common/file_types.h"
+#include "common/qt.h"
+
+#include "mmg-qt/track.h"
+
+class SourceFile;
+typedef std::shared_ptr SourceFilePtr;
+
+class SourceFile: public QObject {
+ Q_OBJECT;
+public:
+ QHash m_properties;
+ QString m_fileName, m_container;
+ QList m_tracks;
+
+ file_type_e m_type;
+ bool m_appended;
+
+public:
+ explicit SourceFile(QString const &fileName);
+ virtual ~SourceFile();
+
+ virtual void setContainer(QString const &container);
+ virtual bool isValid() const;
+};
+
+#endif // MTX_MMGQT_SOURCE_FILE_H
diff --git a/src/mmg-qt/track.cpp b/src/mmg-qt/track.cpp
new file mode 100644
index 000000000..66da3f536
--- /dev/null
+++ b/src/mmg-qt/track.cpp
@@ -0,0 +1,121 @@
+#include "common/common_pch.h"
+
+#include "common/iso639.h"
+#include "mmg-qt/source_file.h"
+#include "mmg-qt/track.h"
+#include "mmg-qt/util/settings.h"
+
+Track::Track(Track::Type type)
+ : m_file(nullptr)
+ , m_type(type)
+ , m_id(-1)
+ , m_muxThis(true)
+ , m_setAspectRatio(true)
+ , m_aacIsSBR(false)
+ , m_defaultTrackFlagWasSet(false)
+ , m_defaultTrackFlag(0)
+ , m_forcedTrackFlag(0)
+ , m_stereoscopy(0)
+ , m_cues(0)
+ , m_compression(CompDefault)
+{
+}
+
+Track::~Track() {
+}
+
+bool
+Track::isType(Type type)
+ const {
+ return type == m_type;
+}
+
+bool
+Track::isAudio()
+ const {
+ return Audio == m_type;
+}
+
+bool
+Track::isVideo()
+ const {
+ return Video == m_type;
+}
+
+bool
+Track::isSubtitles()
+ const {
+ return Subtitles == m_type;
+}
+
+bool
+Track::isButtons()
+ const {
+ return Buttons == m_type;
+}
+
+bool
+Track::isChapters()
+ const {
+ return Chapters == m_type;
+}
+
+bool
+Track::isGlobalTags()
+ const {
+ return GlobalTags == m_type;
+}
+
+bool
+Track::isTags()
+ const {
+ return Tags == m_type;
+}
+
+bool
+Track::isAttachment()
+ const {
+ return Attachment == m_type;
+}
+
+bool
+Track::isAppended()
+ const {
+ return nullptr == m_file ? false : m_file->m_appended;
+}
+
+void
+Track::setDefaults() {
+ auto &settings = Settings::get();
+
+ if (isAudio() && settings.m_setAudioDelayFromFileName)
+ m_delay = extractAudioDelayFromFileName();
+
+ if (settings.m_disableAVCompression && (isVideo() || isAudio()))
+ m_compression = CompNone;
+
+ m_forcedTrackFlag = m_properties[Q("forced_track")] == "1";
+ m_defaultTrackFlagWasSet = m_properties[Q("default_track")] == "1";
+ m_name = m_properties[Q("track_name")];
+ m_cropping = m_properties[Q("cropping")];
+ // m_stereoscopy = mapToStereoMode(m_properties[Q("stereo_mode")];
+
+ auto idx = map_to_iso639_2_code(to_utf8(m_language), true);
+ if (0 <= idx)
+ m_language = to_qs(iso639_languages[idx].iso639_2_code);
+
+ QRegExp re_displayDimensions{"^(\\d+)x(\\d+)$"};
+ if (-1 != re_displayDimensions.indexIn(m_properties[Q("display_dimensions")])) {
+ m_displayWidth = re_displayDimensions.cap(1);
+ m_displayHeight = re_displayDimensions.cap(1);
+ }
+}
+
+QString
+Track::extractAudioDelayFromFileName()
+ const {
+ QRegExp re{"delay\\s+(-?\\d+)", Qt::CaseInsensitive};
+ if (-1 == re.indexIn(m_file->m_fileName))
+ return "";
+ return re.cap(1);
+}
diff --git a/src/mmg-qt/track.h b/src/mmg-qt/track.h
new file mode 100644
index 000000000..5bae4fd71
--- /dev/null
+++ b/src/mmg-qt/track.h
@@ -0,0 +1,68 @@
+#ifndef MTX_MMGQT_TRACK_H
+#define MTX_MMGQT_TRACK_H
+
+#include "common/common_pch.h"
+
+#include
+#include
+#include
+
+#include "common/qt.h"
+
+class SourceFile;
+
+class Track;
+typedef std::shared_ptr