X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fdocclipbase.cpp;h=7b7574c6404ab171e1763970fccb401d2dcb99d5;hb=215c4e21f4953708f93038f350b03fdfadb18cdf;hp=02008ccb925b478868ef4e6be494faeaeeb59b5e;hpb=000c8e2337fe448a6e35896f3ef1a95dedbb39c7;p=kdenlive diff --git a/src/docclipbase.cpp b/src/docclipbase.cpp index 02008ccb..7b7574c6 100644 --- a/src/docclipbase.cpp +++ b/src/docclipbase.cpp @@ -58,6 +58,14 @@ DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QStrin m_properties.insert(attributes.item(i).nodeName(), attributes.item(i).nodeValue()); } + if (xml.hasAttribute("cutzones")) { + QStringList cuts = xml.attribute("cutzones").split(";", QString::SkipEmptyParts); + for (int i = 0; i < cuts.count(); i++) { + QString z = cuts.at(i); + addCutZone(z.section('-', 0, 0).toInt(), z.section('-', 1, 1).toInt(), z.section('-', 2, 2)); + } + } + KUrl url = KUrl(xml.attribute("resource")); if (!m_properties.contains("file_hash") && !url.isEmpty()) getFileHash(url.path()); @@ -74,7 +82,7 @@ DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QStrin //if (!url.isEmpty() && QFile::exists(url.path())) { m_thumbProd = new KThumb(clipManager, url, m_id, m_properties.value("file_hash")); - if (m_clipType == AV || m_clipType == AUDIO) slotCreateAudioTimer(); + if (m_clipType == AV || m_clipType == AUDIO || m_clipType == PLAYLIST) slotCreateAudioTimer(); } //kDebug() << "type is video" << (m_clipType == AV) << " " << m_clipType; } @@ -132,7 +140,7 @@ void DocClipBase::slotCreateAudioTimer() void DocClipBase::askForAudioThumbs() { - if (m_thumbProd) m_thumbProd->askForAudioThumbs(getId()); + if (m_thumbProd && m_audioTimer) slotGetAudioThumbs(); } void DocClipBase::slotClearAudioCache() @@ -183,7 +191,7 @@ void DocClipBase::setClipType(CLIPTYPE type) m_clipType = type; m_properties.insert("type", QString::number((int) type)); - if (m_thumbProd && m_audioTimer == NULL && (m_clipType == AV || m_clipType == AUDIO)) + if (m_thumbProd && m_audioTimer == NULL && (m_clipType == AV || m_clipType == AUDIO || m_clipType == PLAYLIST)) slotCreateAudioTimer(); } @@ -245,6 +253,10 @@ bool DocClipBase::hasFileSize() const return true; } +qulonglong DocClipBase::fileSize() const +{ + return m_properties.value("file_size").toULongLong(); +} // virtual QDomElement DocClipBase::toXML() const @@ -258,7 +270,15 @@ QDomElement DocClipBase::toXML() const if (!i.value().isEmpty()) clip.setAttribute(i.key(), i.value()); } doc.appendChild(clip); - //kDebug()<<"/// CLIP XML: "< > data) { - //kDebug() << "CLIPBASE RECIEDVED AUDIO DATA*********************************************"; + //kDebug() << "CLIPBASE RECIEDVED AUDIO DATA*********************************************"; m_audioFrameCache = data; m_audioThumbCreated = true; emit gotAudioData(); @@ -292,7 +312,7 @@ QList < GenTime > DocClipBase::snapMarkers() const QList < GenTime > markers; for (int count = 0; count < m_snapMarkers.count(); ++count) { - markers.append(m_snapMarkers[count].time()); + markers.append(m_snapMarkers.at(count).time()); } return markers; @@ -376,23 +396,23 @@ GenTime DocClipBase::findPreviousSnapMarker(const GenTime & currTime) { int it; for (it = 0; it < m_snapMarkers.count(); it++) { - if (m_snapMarkers[it].time() >= currTime) + if (m_snapMarkers.at(it).time() >= currTime) break; } if (it == 0) return GenTime(); - else if (it == m_snapMarkers.count() - 1 && m_snapMarkers[it].time() < currTime) - return m_snapMarkers[it].time(); - else return m_snapMarkers[it-1].time(); + else if (it == m_snapMarkers.count() - 1 && m_snapMarkers.at(it).time() < currTime) + return m_snapMarkers.at(it).time(); + else return m_snapMarkers.at(it - 1).time(); } GenTime DocClipBase::findNextSnapMarker(const GenTime & currTime) { int it; for (it = 0; it < m_snapMarkers.count(); it++) { - if (m_snapMarkers[it].time() > currTime) + if (m_snapMarkers.at(it).time() > currTime) break; } - if (it < m_snapMarkers.count() && m_snapMarkers[it].time() > currTime) return m_snapMarkers[it].time(); + if (it < m_snapMarkers.count() && m_snapMarkers.at(it).time() > currTime) return m_snapMarkers.at(it).time(); return duration(); } @@ -408,15 +428,34 @@ QString DocClipBase::markerComment(GenTime t) return QString(); } +void DocClipBase::clearProducers() +{ + m_baseTrackProducers.clear(); +} + void DocClipBase::deleteProducers() { + kDebug() << "// CLIP KILL PRODS ct: " << m_baseTrackProducers.count(); + if (m_thumbProd) m_thumbProd->clearProducer(); + /*kDebug()<<"// CLIP KILL PRODS ct: "<clearProducer(); qDeleteAll(m_audioTrackProducers); m_audioTrackProducers.clear(); - delete m_videoOnlyProducer; - m_videoOnlyProducer = NULL; } void DocClipBase::setProducer(Mlt::Producer *producer, bool reset) @@ -424,6 +463,7 @@ void DocClipBase::setProducer(Mlt::Producer *producer, bool reset) if (producer == NULL) return; if (reset) { // Clear all previous producers + kDebug() << "/+++++++++++++++ DELETE ALL PRODS " << producer->get("id"); deleteProducers(); } QString id = producer->get("id"); @@ -439,8 +479,7 @@ void DocClipBase::setProducer(Mlt::Producer *producer, bool reset) } if (m_audioTrackProducers.at(pos) == NULL) m_audioTrackProducers[pos] = producer; return; - } - if (id.endsWith("video")) { + } else if (id.endsWith("video")) { m_videoOnlyProducer = producer; return; } @@ -471,6 +510,8 @@ Mlt::Producer *DocClipBase::audioProducer(int track) Mlt::Producer *base = producer(); m_audioTrackProducers[track] = new Mlt::Producer(*(base->profile()), base->get("resource")); if (m_properties.contains("force_aspect_ratio")) m_audioTrackProducers.at(track)->set("force_aspect_ratio", m_properties.value("force_aspect_ratio").toDouble()); + if (m_properties.contains("force_fps")) m_audioTrackProducers.at(track)->set("force_fps", m_properties.value("force_fps").toDouble()); + if (m_properties.contains("force_progressive")) m_audioTrackProducers.at(track)->set("force_progressive", m_properties.value("force_progressive").toInt()); if (m_properties.contains("threads")) m_audioTrackProducers.at(track)->set("threads", m_properties.value("threads").toInt()); 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()); @@ -490,6 +531,8 @@ Mlt::Producer *DocClipBase::videoProducer() if (i >= m_baseTrackProducers.count()) return NULL; m_videoOnlyProducer = new Mlt::Producer(*m_baseTrackProducers.at(i)->profile(), m_baseTrackProducers.at(i)->get("resource")); if (m_properties.contains("force_aspect_ratio")) m_videoOnlyProducer->set("force_aspect_ratio", m_properties.value("force_aspect_ratio").toDouble()); + if (m_properties.contains("force_fps")) m_videoOnlyProducer->set("force_fps", m_properties.value("force_fps").toDouble()); + if (m_properties.contains("force_progressive")) m_videoOnlyProducer->set("force_progressive", m_properties.value("force_progressive").toInt()); if (m_properties.contains("threads")) m_videoOnlyProducer->set("threads", m_properties.value("threads").toInt()); m_videoOnlyProducer->set("audio_index", -1); if (m_properties.contains("video_index")) m_videoOnlyProducer->set("video_index", m_properties.value("video_index").toInt()); @@ -533,6 +576,8 @@ Mlt::Producer *DocClipBase::producer(int track) } if (m_properties.contains("force_aspect_ratio")) m_baseTrackProducers[track]->set("force_aspect_ratio", m_properties.value("force_aspect_ratio").toDouble()); + if (m_properties.contains("force_fps")) m_baseTrackProducers[track]->set("force_fps", m_properties.value("force_fps").toDouble()); + if (m_properties.contains("force_progressive")) m_baseTrackProducers[track]->set("force_progressive", m_properties.value("force_progressive").toInt()); if (m_properties.contains("threads")) m_baseTrackProducers[track]->set("threads", m_properties.value("threads").toInt()); if (m_properties.contains("video_index")) m_baseTrackProducers[track]->set("video_index", m_properties.value("video_index").toInt()); if (m_properties.contains("audio_index")) m_baseTrackProducers[track]->set("audio_index", m_properties.value("audio_index").toInt()); @@ -571,6 +616,14 @@ void DocClipBase::setProducerProperty(const char *name, const char *data) } } +void DocClipBase::resetProducerProperty(const char *name) +{ + for (int i = 0; i < m_baseTrackProducers.count(); i++) { + if (m_baseTrackProducers.at(i) != NULL) + m_baseTrackProducers[i]->set(name, (const char*) NULL); + } +} + const char *DocClipBase::producerProperty(const char *name) const { for (int i = 0; i < m_baseTrackProducers.count(); i++) { @@ -711,6 +764,7 @@ QString DocClipBase::getClipHash() const QString hash; if (m_clipType == SLIDESHOW) hash = QCryptographicHash::hash(m_properties.value("resource").toAscii().data(), QCryptographicHash::Md5).toHex(); else if (m_clipType == COLOR) hash = QCryptographicHash::hash(m_properties.value("colour").toAscii().data(), QCryptographicHash::Md5).toHex(); + else if (m_clipType == TEXT) hash = QCryptographicHash::hash(QString("title" + getId() + m_properties.value("xmldata")).toUtf8().data(), QCryptographicHash::Md5).toHex(); else hash = m_properties.value("file_hash"); return hash; } @@ -764,12 +818,22 @@ void DocClipBase::setProperty(const QString &key, const QString &value) char *tmp = (char *) qstrdup(value.toUtf8().data()); setProducerProperty("xmldata", tmp); delete[] tmp; - //setProducerProperty("force_reload", 1); + setProducerProperty("force_reload", 1); } else if (key == "force_aspect_ratio") { if (value.isEmpty()) { m_properties.remove("force_aspect_ratio"); - setProducerProperty("force_aspect_ratio", 0); + resetProducerProperty("force_aspect_ratio"); } else setProducerProperty("force_aspect_ratio", value.toDouble()); + } else if (key == "force_fps") { + if (value.isEmpty()) { + m_properties.remove("force_fps"); + resetProducerProperty("force_fps"); + } else setProducerProperty("force_fps", value.toDouble()); + } else if (key == "force_progressive") { + if (value.isEmpty()) { + m_properties.remove("force_progressive"); + resetProducerProperty("force_progressive"); + } else setProducerProperty("force_progressive", value.toInt()); } else if (key == "threads") { if (value.isEmpty()) { m_properties.remove("threads"); @@ -796,16 +860,15 @@ QMap DocClipBase::properties() const bool DocClipBase::slotGetAudioThumbs() { if (m_thumbProd == NULL) return false; - if (!KdenliveSettings::audiothumbnails()) { + if (!KdenliveSettings::audiothumbnails() || m_audioTimer == NULL) { if (m_audioTimer != NULL) m_audioTimer->stop(); return false; } if (m_audioThumbCreated) { - if (m_audioTimer != NULL) m_audioTimer->stop(); + m_audioTimer->stop(); return false; } - if (m_audioTimer != NULL) - m_audioTimer->start(1500); + m_audioTimer->start(1500); double lengthInFrames = duration().frames(KdenliveSettings::project_fps()); m_thumbProd->getAudioThumbs(2, 0, lengthInFrames /*must be number of frames*/, 20); return true; @@ -816,3 +879,53 @@ bool DocClipBase::isPlaceHolder() const return m_placeHolder; } +void DocClipBase::addCutZone(int in, int out, QString desc) +{ + CutZoneInfo info; + info.zone = QPoint(in, out); + info.description = desc; + for (int i = 0; i < m_cutZones.count(); i++) + if (m_cutZones.at(i).zone == info.zone) { + return; + } + m_cutZones.append(info); +} + +bool DocClipBase::hasCutZone(QPoint p) const +{ + for (int i = 0; i < m_cutZones.count(); i++) + if (m_cutZones.at(i).zone == p) return true; + return false; +} + + +void DocClipBase::removeCutZone(int in, int out) +{ + QPoint p(in, out); + for (int i = 0; i < m_cutZones.count(); i++) { + if (m_cutZones.at(i).zone == p) { + m_cutZones.removeAt(i); + i--; + } + } +} + +void DocClipBase::updateCutZone(int oldin, int oldout, int in, int out, QString desc) +{ + QPoint old(oldin, oldout); + for (int i = 0; i < m_cutZones.size(); ++i) { + if (m_cutZones.at(i).zone == old) { + CutZoneInfo info; + info.zone = QPoint(in, out); + info.description = desc; + m_cutZones.replace(i, info); + break; + } + } +} + +QList DocClipBase::cutZones() const +{ + return m_cutZones; +} +