From: Dan Dennedy Date: Tue, 19 Oct 2010 06:14:08 +0000 (+0000) Subject: Add colorspace and luma range to advanced clip properties. X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=642e331fccf0045a24794442cf1d15a33ed7d422;p=kdenlive Add colorspace and luma range to advanced clip properties. svn path=/trunk/kdenlive/; revision=5022 --- diff --git a/src/clipproperties.cpp b/src/clipproperties.cpp index f2e07813..202d79d5 100644 --- a/src/clipproperties.cpp +++ b/src/clipproperties.cpp @@ -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 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 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 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 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) { diff --git a/src/docclipbase.cpp b/src/docclipbase.cpp index 31c0ca25..fa6b898d 100644 --- a/src/docclipbase.cpp +++ b/src/docclipbase.cpp @@ -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()); } } diff --git a/src/projectlist.cpp b/src/projectlist.cpp index 8489cbfb..b41fc50e 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -255,6 +255,8 @@ void ProjectList::editClipSelection(QList 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 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); diff --git a/src/widgets/clipproperties_ui.ui b/src/widgets/clipproperties_ui.ui index a5cb70b6..05ad26d4 100644 --- a/src/widgets/clipproperties_ui.ui +++ b/src/widgets/clipproperties_ui.ui @@ -6,8 +6,8 @@ 0 0 - 284 - 458 + 306 + 478 @@ -556,7 +556,7 @@ Advanced - + Qt::Vertical @@ -583,7 +583,7 @@ - + false @@ -596,7 +596,7 @@ - + false @@ -609,28 +609,28 @@ - + Decoding threads - + Video index - + Audio index - + false @@ -694,6 +694,27 @@ + + + + Force colorspace + + + + + + + false + + + + + + + Full luma range + + +