static void kdenlive_callback(void* /*ptr*/, int level, const char* fmt, va_list vl)
{
+// kDebug() << "log level" << level << QString().vsprintf(fmt, vl).simplified();
if (level > MLT_LOG_ERROR) return;
QString error;
QApplication::postEvent(qApp->activeWindow(), new MltErrorEvent(error.vsprintf(fmt, vl).simplified()));
if (m_mltConsumer) m_mltConsumer->set("full_screen", 1);
}
-void Render::buildConsumer(const QString profileName)
+void Render::buildConsumer(const QString &profileName)
{
delete m_blackClip;
m_blackClip = NULL;
setenv("MLT_PROFILE", tmp, 1);
m_mltProfile = new Mlt::Profile(tmp);
m_mltProfile->set_explicit(true);
+ kDebug()<<"// ********* PROFILE AR: "<<m_mltProfile->dar();
delete[] tmp;
m_blackClip = new Mlt::Producer(*m_mltProfile, "colour", "black");
return clip;
}
-int Render::resetProfile(const QString profileName, bool dropSceneList)
+int Render::resetProfile(const QString &profileName, bool dropSceneList)
{
QString scene;
if (!dropSceneList) scene = sceneList();
QImage Render::extractFrame(int frame_position, QString path, int width, int height)
{
if (width == -1) {
- width = renderWidth();
+ width = frameRenderWidth();
height = renderHeight();
} else if (width % 2 == 1) width++;
-
+ int dwidth = height * frameRenderWidth() / renderHeight();
if (!path.isEmpty()) {
Mlt::Producer *producer = new Mlt::Producer(*m_mltProfile, path.toUtf8().constData());
if (producer) {
if (producer->is_valid()) {
- QImage img = KThumb::getFrame(producer, frame_position, width, height);
+ QImage img = KThumb::getFrame(producer, frame_position, dwidth, width, height);
delete producer;
return img;
}
pix.fill(Qt::black);
return pix;
}
- return KThumb::getFrame(m_mltProducer, frame_position, width, height);
+ return KThumb::getFrame(m_mltProducer, frame_position, dwidth, width, height);
}
QPixmap Render::getImageThumbnail(KUrl url, int /*width*/, int /*height*/)
}
}
-void Render::getFileProperties(const QDomElement xml, const QString &clipId, int imageHeight, bool replaceProducer, bool selectClip)
+void Render::getFileProperties(const QDomElement &xml, const QString &clipId, int imageHeight, bool replaceProducer, bool selectClip)
{
QString path;
QLocale locale;
return;
}
- int width = (int)(imageHeight * m_mltProfile->dar() + 0.5);
+ int imageWidth = (int)((double) imageHeight * m_mltProfile->width() / m_mltProfile->height() + 0.5);
+ int fullWidth = (int)((double) imageHeight * m_mltProfile->dar() + 0.5);
QMap < QString, QString > filePropertyMap;
QMap < QString, QString > metadataPropertyMap;
int variance;
mlt_image_format format = mlt_image_rgb24a;
- int frame_width = width;
+ int frame_width = imageWidth;
int frame_height = imageHeight;
- QPixmap pix;
+ QImage img;
do {
variance = 100;
- uint8_t *data = frame->get_image(format, frame_width, frame_height, 0);
- QImage image((uchar *)data, frame_width, frame_height, QImage::Format_ARGB32_Premultiplied);
-
- if (!image.isNull()) {
- if (frame_width > (2 * width)) {
- // there was a scaling problem, do it manually
- QImage scaled = image.scaled(width, imageHeight);
- pix = QPixmap::fromImage(scaled.rgbSwapped());
- } else pix = QPixmap::fromImage(image.rgbSwapped());
- variance = KThumb::imageVariance(image);
- } else
- pix.fill(Qt::black);
-
+ img = KThumb::getFrame(frame, imageWidth, fullWidth, imageHeight);
+ variance = KThumb::imageVariance(img);
if (frameNumber == 0 && variance< 6) {
// Thumbnail is not interesting (for example all black, seek to fetch better thumb
frameNumber = 100;
variance = -1;
}
} while (variance == -1);
+ QPixmap pix = QPixmap::fromImage(img);
emit replyGetImage(clipId, pix);
} else if (frame->get_int("test_audio") == 0) {
- QPixmap pixmap = KIcon("audio-x-generic").pixmap(QSize(width, imageHeight));
+ QPixmap pixmap = KIcon("audio-x-generic").pixmap(QSize(fullWidth, imageHeight));
emit replyGetImage(clipId, pixmap);
filePropertyMap["type"] = "audio";
}
}
blockSignals(true);
- // WARNING: disabled because it caused crashes (see Kdenlive bug #2205 and #2206) - jbm
- /*if (KdenliveSettings::projectloading_avformatnovalidate())
- playlist.replace(">avformat</property>", ">avformat-novalidate</property>");
- else
- playlist.replace(">avformat-novalidate</property>", ">avformat</property>");*/
+
+ m_locale = QLocale();
+
m_mltProducer = new Mlt::Producer(*m_mltProfile, "xml-string", playlist.toUtf8().constData());
if (!m_mltProducer || !m_mltProducer->is_valid()) {
kDebug() << " WARNING - - - - -INVALID PLAYLIST: " << playlist.toUtf8().constData();
void Render::emitFrameUpdated(Mlt::Frame& frame)
{
- mlt_image_format format = mlt_image_rgb24a;
+ mlt_image_format format = mlt_image_rgb24;
int width = 0;
int height = 0;
const uchar* image = frame.get_image(format, width, height);
- QImage qimage(width, height, QImage::Format_ARGB32);
- memcpy(qimage.bits(), image, width * height * 4);
- emit frameUpdated(qimage.rgbSwapped());
+ QImage qimage(width, height, QImage::Format_RGB888);
+ memcpy(qimage.bits(), image, width * height * 3);
+ emit frameUpdated(qimage);
}
void Render::emitFrameNumber(double position)
return true;
}
-int Render::mltGetSpaceLength(const GenTime pos, int track, bool fromBlankStart)
+int Render::mltGetSpaceLength(const GenTime &pos, int track, bool fromBlankStart)
{
if (!m_mltProducer) {
kDebug() << "PLAYLIST NOT INITIALISED //////";
return trackProducer.get_playtime() - 1;
}
-void Render::mltInsertSpace(QMap <int, int> trackClipStartList, QMap <int, int> trackTransitionStartList, int track, const GenTime duration, const GenTime timeOffset)
+void Render::mltInsertSpace(QMap <int, int> trackClipStartList, QMap <int, int> trackTransitionStartList, int track, const GenTime &duration, const GenTime &timeOffset)
{
if (!m_mltProducer) {
kDebug() << "PLAYLIST NOT INITIALISED //////";
kWarning() << "// TRACTOR PROBLEM";
return -1;
}
-
+
//kDebug() << "Changing clip speed, set in and out: " << info.cropStart.frames(m_fps) << " to " << (info.endPos - info.startPos).frames(m_fps) - 1;
Mlt::Tractor tractor(service);
Mlt::Producer trackProducer(tractor.track(info.track));
}
delete clip;
-// if (tag.startsWith("ladspa")) tag = "ladspa";
m_isBlocked = true;
mlt_service_lock(service.get_service());
int ct = 0;
//double max = params.paramValue("max").toDouble();
double min = params.paramValue("min").toDouble();
double factor = params.paramValue("factor", "1").toDouble();
+ double paramOffset = params.paramValue("offset", "0").toDouble();
params.removeParam("starttag");
params.removeParam("endtag");
params.removeParam("keyframes");
params.removeParam("min");
params.removeParam("max");
params.removeParam("factor");
+ params.removeParam("offset");
int offset = 0;
// Special case, only one keyframe, means we want a constant value
if (keyFrames.count() == 1) {
}
filter->set("in", x1);
//kDebug() << "// ADDING KEYFRAME vals: " << min<<" / "<<max<<", "<<y1<<", factor: "<<factor;
- filter->set(starttag, m_locale.toString((min + y1) / factor).toUtf8().data());
+ filter->set(starttag, m_locale.toString(((min + y1) - paramOffset) / factor).toUtf8().data());
service.attach(*filter);
}
} else for (int i = 0; i < keyFrames.size() - 1; ++i) {
filter->set("in", x1);
filter->set("out", x2);
//kDebug() << "// ADDING KEYFRAME vals: " << min<<" / "<<max<<", "<<y1<<", factor: "<<factor;
- filter->set(starttag, m_locale.toString((min + y1) / factor).toUtf8().data());
- filter->set(endtag, m_locale.toString((min + y2) / factor).toUtf8().data());
+ filter->set(starttag, m_locale.toString(((min + y1) - paramOffset) / factor).toUtf8().data());
+ filter->set(endtag, m_locale.toString(((min + y2) - paramOffset) / factor).toUtf8().data());
service.attach(*filter);
offset = 1;
}
if (mute && trackProducer.get_int("hide") < 2 ) {
// We mute a track with sound
if (track == getLowestNonMutedAudioTrack(tractor)) audioMixingBroken = true;
+ kDebug()<<"Muting track: "<<track <<" / "<<getLowestNonMutedAudioTrack(tractor);
}
else if (!mute && trackProducer.get_int("hide") > 1 ) {
// We un-mute a previously muted track
if (!e.attribute("value").isEmpty()) {
map[name] = e.attribute("value");
}
- if (e.attribute("type") != "addedgeometry" && !e.attribute("factor").isEmpty() && e.attribute("factor").toDouble() > 0) {
- map[name] = m_locale.toString(map.value(name).toDouble() / e.attribute("factor").toDouble());
+ if (e.attribute("type") != "addedgeometry" && (e.attribute("factor", "1") != "1" || e.attribute("offset", "0") != "0")) {
+ map[name] = m_locale.toString((map.value(name).toDouble() - e.attribute("offset", "0").toDouble()) / e.attribute("factor", "1").toDouble());
//map[name]=map[name].replace(".",","); //FIXME how to solve locale conversion of . ,
}