]> git.sesse.net Git - kdenlive/commitdiff
Add colorspace and luma range to advanced clip properties.
authorDan Dennedy <dan@dennedy.org>
Tue, 19 Oct 2010 06:14:08 +0000 (06:14 +0000)
committerDan Dennedy <dan@dennedy.org>
Tue, 19 Oct 2010 06:14:08 +0000 (06:14 +0000)
svn path=/trunk/kdenlive/; revision=5022

src/clipproperties.cpp
src/docclipbase.cpp
src/projectlist.cpp
src/renderer.cpp
src/widgets/clipproperties_ui.ui

index f2e07813d53b84bf7a6615b2d6d004ef81fb8db0..202d79d5da74bfd17f6d270675ed63397d8b70fa 100644 (file)
@@ -117,6 +117,24 @@ ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidg
     if (props.contains("video_max")) {
         m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
     }
+    
+    m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(601), 601);
+    m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(709), 709);
+    m_view.clip_colorspace->addItem(ProfilesDialog::getColorspaceDescription(240), 240);
+    if (props.contains("force_colorspace")) {
+        m_view.clip_force_colorspace->setChecked(true);
+        m_view.clip_colorspace->setEnabled(true);
+        m_view.clip_colorspace->setCurrentIndex(m_view.clip_colorspace->findData(props.value("force_colorspace").toInt()));
+    } else if (props.contains("colorspace")) {
+        m_view.clip_colorspace->setCurrentIndex(m_view.clip_colorspace->findData(props.value("colorspace").toInt()));
+    }
+    connect(m_view.clip_force_colorspace, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
+    connect(m_view.clip_colorspace, SIGNAL(currentIndexChanged(int)), this, SLOT(slotModified()));
+    
+    if (props.contains("full_luma")) {
+        m_view.clip_full_luma->setChecked(true);
+    }
+    connect(m_view.clip_full_luma, SIGNAL(toggled(bool)), this, SLOT(slotModified()));
 
     // Check for Metadata
     QMap<QString, QString> meta = m_clip->metadata();
@@ -134,6 +152,7 @@ ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidg
     connect(m_view.clip_force_threads, SIGNAL(toggled(bool)), m_view.clip_threads, SLOT(setEnabled(bool)));
     connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
     connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
+    connect(m_view.clip_force_colorspace, SIGNAL(toggled(bool)), m_view.clip_colorspace, SLOT(setEnabled(bool)));
 
     if (props.contains("audiocodec"))
         QTreeWidgetItem *item = new QTreeWidgetItem(m_view.clip_aproperties, QStringList() << i18n("Audio codec") << props.value("audiocodec"));
@@ -425,6 +444,16 @@ ClipProperties::ClipProperties(QList <DocClipBase *>cliplist, Timecode tc, QMap
     if (props.contains("video_max")) {
         m_view.clip_vindex->setMaximum(props.value("video_max").toInt());
     }
+    
+    if (commonproperties.contains("force_colorspace") && !commonproperties.value("force_colorspace").isEmpty() && commonproperties.value("force_colorspace").toInt() != 0) {
+        m_view.clip_force_colorspace->setChecked(true);
+        m_view.clip_colorspace->setEnabled(true);
+        m_view.clip_colorspace->setCurrentIndex(m_view.clip_colorspace->findData(commonproperties.value("force_colorspace").toInt()));
+    }
+    
+    if (commonproperties.contains("full_luma") && !commonproperties.value("full_luma").isEmpty()) {
+        m_view.clip_full_luma->setChecked(true);
+    }
 
     connect(m_view.clip_force_ar, SIGNAL(toggled(bool)), m_view.clip_ar, SLOT(setEnabled(bool)));
     connect(m_view.clip_force_progressive, SIGNAL(toggled(bool)), m_view.clip_progressive, SLOT(setEnabled(bool)));
@@ -432,6 +461,7 @@ ClipProperties::ClipProperties(QList <DocClipBase *>cliplist, Timecode tc, QMap
     connect(m_view.clip_force_vindex, SIGNAL(toggled(bool)), m_view.clip_vindex, SLOT(setEnabled(bool)));
     connect(m_view.clip_force_aindex, SIGNAL(toggled(bool)), m_view.clip_aindex, SLOT(setEnabled(bool)));
     connect(m_view.clip_force_out, SIGNAL(toggled(bool)), m_view.clip_out, SLOT(setEnabled(bool)));
+    connect(m_view.clip_force_colorspace, SIGNAL(toggled(bool)), m_view.clip_colorspace, SLOT(setEnabled(bool)));
 
     m_view.tabWidget->removeTab(METATAB);
     m_view.tabWidget->removeTab(MARKERTAB);
@@ -631,6 +661,25 @@ QMap <QString, QString> ClipProperties::properties()
     } else if (m_old_props.contains("audio_index")) {
         props["audio_index"].clear();
     }
+    
+    int colorspace = m_view.clip_colorspace->itemData(m_view.clip_colorspace->currentIndex()).toInt();
+    if (m_view.clip_force_colorspace->isChecked()) {
+        if (colorspace != m_old_props.value("force_colorspace").toInt()) {
+            props["force_colorspace"] = QString::number(colorspace);
+            m_clipNeedsRefresh = true;
+        }
+    } else if (m_old_props.contains("force_colorspace")) {
+        props["force_colorspace"].clear();
+        m_clipNeedsRefresh = true;
+    }
+
+    if (m_view.clip_full_luma->isChecked()) {
+        props["full_luma"] = QString::number(1);
+        m_clipNeedsRefresh = true;
+    } else if (m_old_props.contains("full_luma")) {
+        props["full_luma"].clear();
+        m_clipNeedsRefresh = true;
+    }
 
     // If we adjust several clips, return now
     if (m_clip == NULL) {
index 31c0ca252114371c191a9ae448f878743e57ad9e..fa6b898d9cf62cd5ba2c396702950c18825115ef 100644 (file)
@@ -520,6 +520,8 @@ Mlt::Producer *DocClipBase::audioProducer(int track)
         m_audioTrackProducers.at(track)->set("video_index", -1);
         if (m_properties.contains("audio_index")) m_audioTrackProducers.at(track)->set("audio_index", m_properties.value("audio_index").toInt());
         m_audioTrackProducers.at(track)->set("id", QString(getId() + '_' + QString::number(track) + "_audio").toUtf8().data());
+        if (m_properties.contains("force_colorspace")) m_audioTrackProducers.at(track)->set("force_colorspace", m_properties.value("force_colorspace").toInt());
+        if (m_properties.contains("full_luma")) m_audioTrackProducers.at(track)->set("set.force_full_luma", m_properties.value("full_luma").toInt());
     }
     return m_audioTrackProducers.at(track);
 }
@@ -539,6 +541,8 @@ Mlt::Producer *DocClipBase::videoProducer()
         m_videoOnlyProducer->set("audio_index", -1);
         if (m_properties.contains("video_index")) m_videoOnlyProducer->set("video_index", m_properties.value("video_index").toInt());
         m_videoOnlyProducer->set("id", QString(getId() + "_video").toUtf8().data());
+        if (m_properties.contains("force_colorspace")) m_videoOnlyProducer->set("force_colorspace", m_properties.value("force_colorspace").toInt());
+        if (m_properties.contains("full_luma")) m_videoOnlyProducer->set("set.force_full_luma", m_properties.value("full_luma").toInt());
     }
     return m_videoOnlyProducer;
 }
@@ -585,6 +589,8 @@ Mlt::Producer *DocClipBase::producer(int track)
             m_baseTrackProducers[track]->set("skip_loop_filter", "all");
             m_baseTrackProducers[track]->set("skip_frame", "bidir");
         }
+        if (m_properties.contains("force_colorspace")) m_baseTrackProducers[track]->set("force_colorspace", m_properties.value("force_colorspace").toInt());
+        if (m_properties.contains("full_luma")) m_baseTrackProducers[track]->set("set.force_full_luma", m_properties.value("full_luma").toInt());
     }
     return m_baseTrackProducers.at(track);
 }
@@ -924,6 +930,16 @@ void DocClipBase::setProperty(const QString &key, const QString &value)
             m_properties.remove("audio_index");
             setProducerProperty("audio_index", m_properties.value("default_audio").toInt());
         } else setProducerProperty("audio_index", value.toInt());
+    } else if (key == "force_colorspace") {
+        if (value.isEmpty()) {
+            m_properties.remove("force_colorspace");
+            resetProducerProperty("force_colorspace");
+        } else setProducerProperty("force_colorspace", value.toInt());
+    } else if (key == "full_luma") {
+        if (value.isEmpty()) {
+            m_properties.remove("full_luma");
+            resetProducerProperty("set.force_full_luma");
+        } else setProducerProperty("set.force_full_luma", value.toInt());
     }
 }
 
index 8489cbfb5218d4f7f3d23a144ff8aa7f08120560..b41fc50e8d33f926283d8749aa4aaaeb597c6d7c 100644 (file)
@@ -255,6 +255,8 @@ void ProjectList::editClipSelection(QList<QTreeWidgetItem *> list)
     commonproperties.insert("threads", "-");
     commonproperties.insert("video_index", "-");
     commonproperties.insert("audio_index", "-");
+    commonproperties.insert("force_colorspace", "-");
+    commonproperties.insert("full_luma", "-");
 
     bool allowDurationChange = true;
     int commonDuration = -1;
@@ -592,6 +594,8 @@ void ProjectList::slotUpdateClipProperties(const QString &id, QMap <QString, QSt
         } else if (properties.contains("colour") || properties.contains("xmldata") || properties.contains("force_aspect_ratio") || properties.contains("templatetext")) {
             slotRefreshClipThumbnail(item);
             emit refreshClip();
+        } else if (properties.contains("full_luma") || properties.contains("force_colorspace")) {
+            emit refreshClip();
         }
     }
 }
index a47b3cda227e31674b66e0bff7261e468ad35730..74f4ee80e12cfce25362d5d29a65ffbade222c02 100644 (file)
@@ -551,6 +551,14 @@ void Render::getFileProperties(const QDomElement xml, const QString &clipId, int
         int aindex = xml.attribute("audio_index").toInt();
         if (aindex != 0) producer->set("audio_index", aindex);
     }
+    if (xml.hasAttribute("force_colorspace")) {
+        int colorspace = xml.attribute("force_colorspace").toInt();
+        if (colorspace != 0) producer->set("force_colorspace", colorspace);
+    }
+    if (xml.hasAttribute("full_luma")) {
+        int full_luma = xml.attribute("full_luma").toInt();
+        if (full_luma != 0) producer->set("set.force_full_luma", full_luma);
+    }
 
     // setup length here as otherwise default length (currently 15000 frames in MLT) will be taken even if outpoint is larger
     if (xml.attribute("type").toInt() == COLOR || xml.attribute("type").toInt() == TEXT
@@ -2059,6 +2067,10 @@ int Render::mltChangeClipSpeed(ItemInfo info, ItemInfo speedIndependantInfo, dou
                 slowprod->set("force_progressive", original->parent().get_int("force_progressive"));
             int ix = original->parent().get_int("video_index");
             if (ix != 0) slowprod->set("video_index", ix);
+            int colorspace = original->parent().get_int("force_colorspace");
+            if (colorspace != 0) slowprod->set("force_colorspace", colorspace);
+            int full_luma = original->parent().get_int("set.force_full_luma");
+            if (full_luma != 0) slowprod->set("set.force_full_luma", full_luma);
             m_slowmotionProducers.insert(url, slowprod);
         }
         Mlt::Producer *clip = trackPlaylist.replace_with_blank(clipIndex);
@@ -2132,6 +2144,10 @@ int Render::mltChangeClipSpeed(ItemInfo info, ItemInfo speedIndependantInfo, dou
             if (threads != 0) slowprod->set("threads", threads);
             int ix = original->parent().get_int("video_index");
             if (ix != 0) slowprod->set("video_index", ix);
+            int colorspace = original->parent().get_int("force_colorspace");
+            if (colorspace != 0) slowprod->set("force_colorspace", colorspace);
+            int full_luma = original->parent().get_int("set.force_full_luma");
+            if (full_luma != 0) slowprod->set("set.force_full_luma", full_luma);
             m_slowmotionProducers.insert(url, slowprod);
         }
         Mlt::Producer *clip = trackPlaylist.replace_with_blank(clipIndex);
index a5cb70b6a614a20595116c30dd386faddc58d5f0..05ad26d43d1258e33a34f9c438471138e9bb2c15 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>284</width>
-    <height>458</height>
+    <width>306</width>
+    <height>478</height>
    </rect>
   </property>
   <property name="windowTitle">
        <string>Advanced</string>
       </attribute>
       <layout class="QGridLayout" name="gridLayout_3">
-       <item row="8" column="2">
+       <item row="11" column="2">
         <spacer name="verticalSpacer">
          <property name="orientation">
           <enum>Qt::Vertical</enum>
          </property>
         </widget>
        </item>
-       <item row="5" column="2">
+       <item row="6" column="2">
         <widget class="QSpinBox" name="clip_vindex">
          <property name="enabled">
           <bool>false</bool>
          </property>
         </widget>
        </item>
-       <item row="6" column="2">
+       <item row="7" column="2">
         <widget class="QSpinBox" name="clip_aindex">
          <property name="enabled">
           <bool>false</bool>
          </property>
         </widget>
        </item>
-       <item row="4" column="1">
+       <item row="5" column="1">
         <widget class="QCheckBox" name="clip_force_threads">
          <property name="text">
           <string>Decoding threads</string>
          </property>
         </widget>
        </item>
-       <item row="5" column="1">
+       <item row="6" column="1">
         <widget class="QCheckBox" name="clip_force_vindex">
          <property name="text">
           <string>Video index</string>
          </property>
         </widget>
        </item>
-       <item row="6" column="1">
+       <item row="7" column="1">
         <widget class="QCheckBox" name="clip_force_aindex">
          <property name="text">
           <string>Audio index</string>
          </property>
         </widget>
        </item>
-       <item row="4" column="2">
+       <item row="5" column="2">
         <widget class="QSpinBox" name="clip_threads">
          <property name="enabled">
           <bool>false</bool>
          </property>
         </widget>
        </item>
+       <item row="8" column="1">
+        <widget class="QCheckBox" name="clip_force_colorspace">
+         <property name="text">
+          <string>Force colorspace</string>
+         </property>
+        </widget>
+       </item>
+       <item row="8" column="2">
+        <widget class="KComboBox" name="clip_colorspace">
+         <property name="enabled">
+          <bool>false</bool>
+         </property>
+        </widget>
+       </item>
+       <item row="9" column="1">
+        <widget class="QCheckBox" name="clip_full_luma">
+         <property name="text">
+          <string>Full luma range</string>
+         </property>
+        </widget>
+       </item>
       </layout>
      </widget>
     </widget>