]> git.sesse.net Git - kdenlive/blobdiff - src/profilesdialog.cpp
Complete rewrite of the video4linux capture to use MLT, in progress.
[kdenlive] / src / profilesdialog.cpp
index 0486072fad815a8a0924f957ec443a43764178d0..c9aa53c29f53d02588d7f7c357910ade2a2df235 100644 (file)
@@ -411,7 +411,7 @@ bool ProfilesDialog::matchProfile(int width, int height, double fps, double par,
         // when using image, compare with display width
         profileWidth = profile.height * profile.display_aspect_num / profile.display_aspect_den + 0.5;
     } else profileWidth = profile.width;
-    if (width != profileWidth || height != profile.height || (fps > 0 && qAbs(profile.frame_rate_num / profile.frame_rate_den - fps) > 0.4) || (par > 0 && qAbs(profile.sample_aspect_num / profile.sample_aspect_den - par) > 0.1)) return false;
+    if (width != profileWidth || height != profile.height || (fps > 0 && qAbs((double) profile.frame_rate_num / profile.frame_rate_den - fps) > 0.4) || (!isImage && par > 0 && qAbs((double) profile.sample_aspect_num / profile.sample_aspect_den - par) > 0.1)) return false;
     return true;
 }
 
@@ -453,7 +453,7 @@ QMap <QString, QString> ProfilesDialog::getProfilesFromProperties(int width, int
                 double profile_fps = values.value("frame_rate_num").toDouble() / values.value("frame_rate_den").toDouble();
                 double profile_par = values.value("sample_aspect_num").toDouble() / values.value("sample_aspect_den").toDouble();
                 if ((fps <= 0 || qAbs(profile_fps - fps) < 0.5) && (par <= 0 || qAbs(profile_par - par) < 0.1))
-                    result.insert(profiles.at(j), values.value("description"));
+                    result.insert(customProfiles.at(i) + profiles.at(j), values.value("description"));
             }
         }
     }
@@ -490,15 +490,17 @@ QString ProfilesDialog::getPathFromDescription(const QString profileDesc)
 }
 
 // static
-void ProfilesDialog::saveProfile(MltVideoProfile &profile)
+void ProfilesDialog::saveProfile(MltVideoProfile &profile, QString profilePath)
 {
-    int i = 0;
-    QString customName = "profiles/customprofile";
-    QString profilePath = KStandardDirs::locateLocal("appdata", customName + QString::number(i));
-    kDebug() << " TYING PROFILE FILE: " << profilePath;
-    while (KIO::NetAccess::exists(KUrl(profilePath), KIO::NetAccess::SourceSide, 0)) {
-        i++;
+    if (profilePath.isEmpty()) {
+        int i = 0;
+        QString customName = "profiles/customprofile";
         profilePath = KStandardDirs::locateLocal("appdata", customName + QString::number(i));
+        kDebug() << " TYING PROFILE FILE: " << profilePath;
+        while (KIO::NetAccess::exists(KUrl(profilePath), KIO::NetAccess::SourceSide, 0)) {
+            i++;
+            profilePath = KStandardDirs::locateLocal("appdata", customName + QString::number(i));
+        }
     }
     QFile file(profilePath);
     if (!file.open(QIODevice::WriteOnly)) {
@@ -569,6 +571,15 @@ QString ProfilesDialog::getColorspaceDescription(int colorspace)
     }
 }
 
+//static
+int ProfilesDialog::getColorspaceFromDescription(const QString &description)
+{
+    //TODO: should the descriptions be translated?
+    if (description == "SMPTE240M") return 240;
+    if (description == "ITU-R 709") return 709;
+    return 601;
+}
+
 #include "profilesdialog.moc"