Commit 27792e17 authored by Nicolas Carion's avatar Nicolas Carion
Browse files

More cleanup of profiles

parent 535965f8
......@@ -1169,52 +1169,51 @@ void KdenliveSettingsDialog::loadCurrentV4lProfileInfo()
if (!dir.exists()) {
dir.mkpath(QStringLiteral("."));
}
MltVideoProfile prof;
if (!dir.exists(QStringLiteral("video4linux"))) {
if (!ProfileRepository::get()->profileExists(dir.absoluteFilePath(QStringLiteral("video4linux")))) {
// No default formats found, build one
prof.width = 320;
prof.height = 200;
prof.frame_rate_num = 15;
prof.frame_rate_den = 1;
prof.display_aspect_num = 4;
prof.display_aspect_den = 3;
prof.sample_aspect_num = 1;
prof.sample_aspect_den = 1;
prof.progressive = 1;
prof.colorspace = 601;
ProfilesDialog::saveProfile(prof, dir.absoluteFilePath(QStringLiteral("video4linux")));
} else {
prof = ProfilesDialog::getVideoProfile(dir.absoluteFilePath(QStringLiteral("video4linux")));
}
m_configCapture.p_size->setText(QString::number(prof.width) + QLatin1Char('x') + QString::number(prof.height));
m_configCapture.p_fps->setText(QString::number(prof.frame_rate_num) + QLatin1Char('/') + QString::number(prof.frame_rate_den));
m_configCapture.p_aspect->setText(QString::number(prof.sample_aspect_num) + QLatin1Char('/') + QString::number(prof.sample_aspect_den));
m_configCapture.p_display->setText(QString::number(prof.display_aspect_num) + QLatin1Char('/') + QString::number(prof.display_aspect_den));
m_configCapture.p_colorspace->setText(ProfileRepository::getColorspaceDescription(prof.colorspace));
if (prof.progressive) {
std::unique_ptr<ProfileParam> prof(new ProfileParam(pCore->getCurrentProfile().get()));
prof->m_width = 320;
prof->m_height = 200;
prof->m_frame_rate_num = 15;
prof->m_frame_rate_den = 1;
prof->m_display_aspect_num = 4;
prof->m_display_aspect_den = 3;
prof->m_sample_aspect_num = 1;
prof->m_sample_aspect_den = 1;
prof->m_progressive = 1;
prof->m_colorspace = 601;
ProfileRepository::get()->saveProfile(prof.get(), dir.absoluteFilePath(QStringLiteral("video4linux")));
}
auto &prof = ProfileRepository::get()->getProfile(dir.absoluteFilePath(QStringLiteral("video4linux")));
m_configCapture.p_size->setText(QString::number(prof->width()) + QLatin1Char('x') + QString::number(prof->height()));
m_configCapture.p_fps->setText(QString::number(prof->frame_rate_num()) + QLatin1Char('/') + QString::number(prof->frame_rate_den()));
m_configCapture.p_aspect->setText(QString::number(prof->sample_aspect_num()) + QLatin1Char('/') + QString::number(prof->sample_aspect_den()));
m_configCapture.p_display->setText(QString::number(prof->display_aspect_num()) + QLatin1Char('/') + QString::number(prof->display_aspect_den()));
m_configCapture.p_colorspace->setText(ProfileRepository::getColorspaceDescription(prof->colorspace()));
if (prof->progressive()) {
m_configCapture.p_progressive->setText(i18n("Progressive"));
}
}
void KdenliveSettingsDialog::saveCurrentV4lProfile()
{
MltVideoProfile profile;
profile.description = QStringLiteral("Video4Linux capture");
profile.colorspace = ProfileRepository::getColorspaceFromDescription(m_configCapture.p_colorspace->text());
profile.width = m_configCapture.p_size->text().section('x', 0, 0).toInt();
profile.height = m_configCapture.p_size->text().section('x', 1, 1).toInt();
profile.sample_aspect_num = m_configCapture.p_aspect->text().section(QLatin1Char('/'), 0, 0).toInt();
profile.sample_aspect_den = m_configCapture.p_aspect->text().section(QLatin1Char('/'), 1, 1).toInt();
profile.display_aspect_num = m_configCapture.p_display->text().section(QLatin1Char('/'), 0, 0).toInt();
profile.display_aspect_den = m_configCapture.p_display->text().section(QLatin1Char('/'), 1, 1).toInt();
profile.frame_rate_num = m_configCapture.p_fps->text().section(QLatin1Char('/'), 0, 0).toInt();
profile.frame_rate_den = m_configCapture.p_fps->text().section(QLatin1Char('/'), 1, 1).toInt();
profile.progressive = m_configCapture.p_progressive->text() == i18n("Progressive");
std::unique_ptr<ProfileParam> profile(new ProfileParam(pCore->getCurrentProfile().get()));
profile->m_description = QStringLiteral("Video4Linux capture");
profile->m_colorspace = ProfileRepository::getColorspaceFromDescription(m_configCapture.p_colorspace->text());
profile->m_width = m_configCapture.p_size->text().section('x', 0, 0).toInt();
profile->m_height = m_configCapture.p_size->text().section('x', 1, 1).toInt();
profile->m_sample_aspect_num = m_configCapture.p_aspect->text().section(QLatin1Char('/'), 0, 0).toInt();
profile->m_sample_aspect_den = m_configCapture.p_aspect->text().section(QLatin1Char('/'), 1, 1).toInt();
profile->m_display_aspect_num = m_configCapture.p_display->text().section(QLatin1Char('/'), 0, 0).toInt();
profile->m_display_aspect_den = m_configCapture.p_display->text().section(QLatin1Char('/'), 1, 1).toInt();
profile->m_frame_rate_num = m_configCapture.p_fps->text().section(QLatin1Char('/'), 0, 0).toInt();
profile->m_frame_rate_den = m_configCapture.p_fps->text().section(QLatin1Char('/'), 1, 1).toInt();
profile->m_progressive = m_configCapture.p_progressive->text() == i18n("Progressive");
QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/profiles/"));
if (!dir.exists()) {
dir.mkpath(QStringLiteral("."));
}
ProfilesDialog::saveProfile(profile, dir.absoluteFilePath(QStringLiteral("video4linux")));
ProfileRepository::get()->saveProfile(profile.get(), dir.absoluteFilePath(QStringLiteral("video4linux")));
}
void KdenliveSettingsDialog::slotManageEncodingProfile()
......
......@@ -322,43 +322,6 @@ void ProfilesDialog::slotDeleteProfile()
}
// static
MltVideoProfile ProfilesDialog::getVideoProfile(const QString &name)
{
MltVideoProfile result;
QStringList profilesNames;
QStringList profilesFiles;
QStringList profilesFilter;
profilesFilter << QStringLiteral("*");
QString path;
bool isCustom = false;
if (name.contains(QLatin1Char('/'))) {
isCustom = true;
}
if (!isCustom) {
// List the Mlt profiles
QDir mltDir(KdenliveSettings::mltpath());
if (mltDir.exists(name)) {
path = mltDir.absoluteFilePath(name);
}
}
if (isCustom || path.isEmpty()) {
path = name;
}
if (path.isEmpty() || !QFile::exists(path)) {
if (name == QLatin1String("dv_pal")) {
// qCDebug(KDENLIVE_LOG) << "!!! WARNING, COULD NOT FIND DEFAULT MLT PROFILE";
return result;
}
if (name == KdenliveSettings::default_profile()) {
KdenliveSettings::setDefault_profile(QStringLiteral("dv_pal"));
}
// qCDebug(KDENLIVE_LOG) << "// WARNING, COULD NOT FIND PROFILE " << name;
return result;
}
return getProfileFromPath(path, name);
}
MltVideoProfile ProfilesDialog::getProfileFromPath(const QString &path, const QString &name)
{
......@@ -378,24 +341,7 @@ MltVideoProfile ProfilesDialog::getProfileFromPath(const QString &path, const QS
result.display_aspect_den = entries.value(QStringLiteral("display_aspect_den")).toInt();
result.colorspace = entries.value(QStringLiteral("colorspace")).toInt();
return result;
}
// static
MltVideoProfile ProfilesDialog::getVideoProfile(Mlt::Profile &profile)
{
MltVideoProfile result;
result.description = profile.description();
result.frame_rate_num = profile.frame_rate_num();
result.frame_rate_den = profile.frame_rate_den();
result.width = profile.width();
result.height = profile.height();
result.progressive = profile.progressive();
result.sample_aspect_num = profile.sample_aspect_num();
result.sample_aspect_den = profile.sample_aspect_den();
result.display_aspect_num = profile.display_aspect_num();
result.display_aspect_den = profile.display_aspect_den();
result.colorspace = profile.colorspace();
return result;
}
// static
......
......@@ -36,8 +36,6 @@ public:
explicit ProfilesDialog(const QString &profilePath, bool, QWidget *parent = nullptr);
void fillList(const QString &selectedProfile = QString());
static MltVideoProfile getVideoProfile(const QString &name);
static MltVideoProfile getVideoProfile(Mlt::Profile &profile);
static void saveProfile(MltVideoProfile &profile, QString profilePath = QString());
/** @brief Build a profile from it's url */
......
......@@ -28,6 +28,7 @@
#include "capture/v4lcapture.h"
#endif
#include <config-kdenlive.h>
#include "core.h"
#include <framework/mlt_version.h>
#include <mlt++/Mlt.h>
......@@ -282,12 +283,12 @@ void Wizard::slotUpdateCaptureParameters()
dir.mkpath(QStringLiteral("."));
}
if (dir.exists(QStringLiteral("video4linux"))) {
MltVideoProfile profileInfo = ProfilesDialog::getVideoProfile(dir.absoluteFilePath(QStringLiteral("video4linux")));
if (ProfileRepository::get()->profileExists(dir.absoluteFilePath(QStringLiteral("video4linux")))) {
auto& profileInfo = ProfileRepository::get()->getProfile(dir.absoluteFilePath(QStringLiteral("video4linux")));
m_capture.v4l_formats->addItem(
i18n("Current settings (%1x%2, %3/%4fps)", profileInfo.width, profileInfo.height, profileInfo.frame_rate_num, profileInfo.frame_rate_den),
QStringList() << QStringLiteral("unknown") << QString::number(profileInfo.width) << QString::number(profileInfo.height)
<< QString::number(profileInfo.frame_rate_num) << QString::number(profileInfo.frame_rate_den));
i18n("Current settings (%1x%2, %3/%4fps)", profileInfo->width(), profileInfo->height(), profileInfo->frame_rate_num(), profileInfo->frame_rate_den()),
QStringList() << QStringLiteral("unknown") << QString::number(profileInfo->width()) << QString::number(profileInfo->height())
<< QString::number(profileInfo->frame_rate_num()) << QString::number(profileInfo->frame_rate_den()));
}
QStringList pixelformats = formats.split('>', QString::SkipEmptyParts);
QString itemSize;
......@@ -317,22 +318,22 @@ void Wizard::slotUpdateCaptureParameters()
slotSaveCaptureFormat();
} else {
// No existing profile and no autodetected profiles
MltVideoProfile profileInfo;
profileInfo.width = 320;
profileInfo.height = 200;
profileInfo.frame_rate_num = 15;
profileInfo.frame_rate_den = 1;
profileInfo.display_aspect_num = 4;
profileInfo.display_aspect_den = 3;
profileInfo.sample_aspect_num = 1;
profileInfo.sample_aspect_den = 1;
profileInfo.progressive = 1;
profileInfo.colorspace = 601;
ProfilesDialog::saveProfile(profileInfo, dir.absoluteFilePath(QStringLiteral("video4linux")));
std::unique_ptr<ProfileParam> profileInfo(new ProfileParam(pCore->getCurrentProfile().get()));
profileInfo->m_width = 320;
profileInfo->m_height = 200;
profileInfo->m_frame_rate_num = 15;
profileInfo->m_frame_rate_den = 1;
profileInfo->m_display_aspect_num = 4;
profileInfo->m_display_aspect_den = 3;
profileInfo->m_sample_aspect_num = 1;
profileInfo->m_sample_aspect_den = 1;
profileInfo->m_progressive = 1;
profileInfo->m_colorspace = 601;
ProfileRepository::get()->saveProfile(profileInfo.get(), dir.absoluteFilePath(QStringLiteral("video4linux")));
m_capture.v4l_formats->addItem(
i18n("Default settings (%1x%2, %3/%4fps)", profileInfo.width, profileInfo.height, profileInfo.frame_rate_num, profileInfo.frame_rate_den),
QStringList() << QStringLiteral("unknown") << QString::number(profileInfo.width) << QString::number(profileInfo.height)
<< QString::number(profileInfo.frame_rate_num) << QString::number(profileInfo.frame_rate_den));
i18n("Default settings (%1x%2, %3/%4fps)", profileInfo->width(), profileInfo->height(), profileInfo->frame_rate_num(), profileInfo->frame_rate_den()),
QStringList() << QStringLiteral("unknown") << QString::number(profileInfo->width()) << QString::number(profileInfo->height())
<< QString::number(profileInfo->frame_rate_num()) << QString::number(profileInfo->frame_rate_den()));
}
}
m_capture.v4l_formats->blockSignals(false);
......@@ -858,23 +859,23 @@ void Wizard::slotSaveCaptureFormat()
if (format.isEmpty()) {
return;
}
MltVideoProfile profile;
profile.description = QStringLiteral("Video4Linux capture");
profile.colorspace = 601;
profile.width = format.at(1).toInt();
profile.height = format.at(2).toInt();
profile.sample_aspect_num = 1;
profile.sample_aspect_den = 1;
profile.display_aspect_num = format.at(1).toInt();
profile.display_aspect_den = format.at(2).toInt();
profile.frame_rate_num = format.at(3).toInt();
profile.frame_rate_den = format.at(4).toInt();
profile.progressive = 1;
std::unique_ptr<ProfileParam> profile(new ProfileParam(pCore->getCurrentProfile().get()));
profile->m_description = QStringLiteral("Video4Linux capture");
profile->m_colorspace = 601;
profile->m_width = format.at(1).toInt();
profile->m_height = format.at(2).toInt();
profile->m_sample_aspect_num = 1;
profile->m_sample_aspect_den = 1;
profile->m_display_aspect_num = format.at(1).toInt();
profile->m_display_aspect_den = format.at(2).toInt();
profile->m_frame_rate_num = format.at(3).toInt();
profile->m_frame_rate_den = format.at(4).toInt();
profile->m_progressive = 1;
QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/profiles/"));
if (!dir.exists()) {
dir.mkpath(QStringLiteral("."));
}
ProfilesDialog::saveProfile(profile, dir.absoluteFilePath(QStringLiteral("video4linux")));
ProfileRepository::get()->saveProfile(profile.get(), dir.absoluteFilePath(QStringLiteral("video4linux")));
}
void Wizard::slotUpdateDecklinkDevice(uint captureCard)
......
......@@ -86,8 +86,6 @@ public:
/** @brief Get a list of all clip ids that are inside a folder. */
QStringList getBinFolderClipIds(const QString &folderId) const;
/** @brief Returns current project profile. */
MltVideoProfile mltProfile() const;
const QString description() const;
void setUrl(const QUrl &url);
......
......@@ -1208,25 +1208,6 @@ Mlt::Profile *GLWidget::profile()
return m_monitorProfile;
}
void GLWidget::resetProfile(const MltVideoProfile &profile)
{
if ((m_consumer != nullptr) && !m_consumer->is_stopped()) {
m_consumer->stop();
m_consumer->purge();
}
free(m_monitorProfile->get_profile()->description);
m_monitorProfile->get_profile()->description = strdup(profile.description.toUtf8().data());
m_monitorProfile->set_colorspace(profile.colorspace);
m_monitorProfile->set_frame_rate(profile.frame_rate_num, profile.frame_rate_den);
m_monitorProfile->set_height(profile.height);
m_monitorProfile->set_width(profile.width);
m_monitorProfile->set_progressive(static_cast<int>(profile.progressive));
m_monitorProfile->set_sample_aspect(profile.sample_aspect_num, profile.sample_aspect_den);
m_monitorProfile->set_display_aspect(profile.display_aspect_num, profile.display_aspect_den);
m_monitorProfile->set_explicit(1);
reconfigure();
refreshSceneLayout();
}
void GLWidget::reloadProfile()
{
......
......@@ -96,7 +96,6 @@ public:
bool sendFrameForAnalysis;
void updateGamma();
Mlt::Profile *profile();
void resetProfile(const MltVideoProfile &profile);
void reloadProfile();
void lockMonitor();
void releaseMonitor();
......
......@@ -99,11 +99,6 @@ int CustomTrackScene::tracksCount() const
return m_timeline->visibleTracksCount();
}
MltVideoProfile CustomTrackScene::profile() const
{
return m_timeline->mltProfile();
}
void CustomTrackScene::setEditMode(TimelineMode::EditMode mode)
{
m_editMode = mode;
......
......@@ -33,7 +33,6 @@
#include "gentime.h"
class Timeline;
class MltVideoProfile;
class CustomTrackScene : public QGraphicsScene
{
......@@ -49,7 +48,6 @@ public:
void setScale(double scale, double vscale);
QPointF scale() const;
int tracksCount() const;
MltVideoProfile profile() const;
void setEditMode(TimelineMode::EditMode mode);
TimelineMode::EditMode editMode() const;
bool isZooming;
......
......@@ -1601,10 +1601,6 @@ int Timeline::hasTrackEffect(int trackIndex, const QString &tag, const QString &
return list.hasEffect(tag, id);
}
MltVideoProfile Timeline::mltProfile() const
{
return ProfilesDialog::getVideoProfile(*m_tractor->profile());
}
double Timeline::fps() const
{
......
......@@ -128,7 +128,6 @@ public:
const EffectsList getTrackEffects(int trackIndex);
QDomElement getTrackEffect(int trackIndex, int effectIndex);
int hasTrackEffect(int trackIndex, const QString &tag, const QString &id);
MltVideoProfile mltProfile() const;
double fps() const;
QPoint getTracksCount();
/** @brief Check if we have a blank space on selected track.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment