Commit 67257981 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix various aspect ratio issues and transparency of composite transition in some cases

parent e844edc0
......@@ -921,7 +921,7 @@ void ProjectClip::doExtractImage()
frame->set("deinterlace_method", "onefield");
frame->set("top_field_first", -1 );
if (frame && frame->is_valid()) {
img = KThumb::getFrame(frame, frameWidth, 150);
img = KThumb::getFrame(frame, frameWidth, 150, prod->profile()->sar() != 1);
bin()->cachePixmap(path, img);
emit thumbReady(pos, img);
}
......
......@@ -82,17 +82,16 @@ QImage KThumb::getFrame(Mlt::Producer *producer, int framepos, int displayWidth,
//static
QImage KThumb::getFrame(Mlt::Frame *frame, int width, int height)
QImage KThumb::getFrame(Mlt::Frame *frame, int width, int height, bool forceRescale)
{
if (frame == NULL || !frame->is_valid()) {
QImage p(width, height, QImage::Format_ARGB32_Premultiplied);
p.fill(QColor(Qt::red).rgb());
return p;
}
int ow = width;
int oh = height;
int ow = forceRescale ? 0 : width;
int oh = forceRescale ? 0 : height;
mlt_image_format format = mlt_image_rgb24a;
//frame->set("progressive", "1");
ow += ow % 2;
const uchar* imagedata = frame->get_image(format, ow, oh);
if (imagedata) {
......
......@@ -39,7 +39,7 @@ namespace KThumb
QPixmap getImage(const QUrl &url, int width, int height = -1);
QPixmap getImage(const QUrl &url, int frame, int width, int height = -1);
QImage getFrame(Mlt::Producer *producer, int framepos, int displayWidth, int height);
QImage getFrame(Mlt::Frame *frame, int width, int height);
QImage getFrame(Mlt::Frame *frame, int width, int height, bool forceRescale = false);
/** @brief Calculates image variance, useful to know if a thumbnail is interesting.
* @return an integer between 0 and 100. 0 means no variance, eg. black image while bigger values mean contrasted image
* */
......
......@@ -757,7 +757,9 @@ void initEffects::fillTransitionsList(Mlt::Repository *repository, EffectsList *
desc.appendChild(ret.createTextNode(i18n("A key-framable alpha-channel compositor for two frames.")));
paramList.append(quickParameterFill(ret, i18n("Geometry"), QStringLiteral("geometry"), QStringLiteral("geometry"), QStringLiteral("0%/0%:100%x100%:100"), QStringLiteral("-500;-500;-500;-500;0"), QStringLiteral("500;500;500;500;100")));
paramList.append(quickParameterFill(ret, i18n("Alpha Channel Operation"), QStringLiteral("operator"), QStringLiteral("list"), QStringLiteral("over"), QLatin1String(""), QLatin1String(""), QStringLiteral("over,and,or,xor"), i18n("Over,And,Or,Xor")));
paramList.append(quickParameterFill(ret, i18n("Align"), QStringLiteral("aligned"), QStringLiteral("bool"), QStringLiteral("0"), QStringLiteral("0"), QStringLiteral("1")));
paramList.append(quickParameterFill(ret, i18n("Align"), QStringLiteral("aligned"), QStringLiteral("bool"), QStringLiteral("1"), QStringLiteral("0"), QStringLiteral("1")));
paramList.append(quickParameterFill(ret, i18n("Align"), QStringLiteral("valign"), QStringLiteral("fixed"), QStringLiteral("middle"), QStringLiteral("middle"), QStringLiteral("middle")));
paramList.append(quickParameterFill(ret, i18n("Align"), QStringLiteral("halign"), QStringLiteral("fixed"), QStringLiteral("centre"), QStringLiteral("centre"), QStringLiteral("centre")));
paramList.append(quickParameterFill(ret, i18n("Fill"), QStringLiteral("fill"), QStringLiteral("bool"), QStringLiteral("1"), QStringLiteral("0"), QStringLiteral("1")));
paramList.append(quickParameterFill(ret, i18n("Distort"), QStringLiteral("distort"), QStringLiteral("bool"), QStringLiteral("0"), QStringLiteral("0"), QStringLiteral("1")));
paramList.append(quickParameterFill(ret, i18n("Wipe Method"), QStringLiteral("luma"), QStringLiteral("list"), QLatin1String(""), QLatin1String(""), QLatin1String(""), QStringLiteral("%lumaPaths"), QLatin1String("")));
......
......@@ -135,6 +135,7 @@ void ProducerQueue::processFileProperties()
requestClipInfo info;
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
bool forceThumbScale = m_binController->profile()->sar() != 1;
while (!m_requestList.isEmpty()) {
m_infoMutex.lock();
info = m_requestList.takeFirst();
......@@ -161,7 +162,7 @@ void ProducerQueue::processFileProperties()
Mlt::Frame *frame = prod->get_frame();
if (frame && frame->is_valid()) {
int fullWidth = info.imageHeight * m_binController->profile()->dar() + 0.5;
QImage img = KThumb::getFrame(frame, fullWidth, info.imageHeight);
QImage img = KThumb::getFrame(frame, fullWidth, info.imageHeight, forceThumbScale);
emit replyGetImage(info.clipId, img);
}
delete frame;
......@@ -483,7 +484,7 @@ void ProducerQueue::processFileProperties()
if (frameNumber > 0) producer->seek(frameNumber);
frame = producer->get_frame();
if (frame && frame->is_valid()) {
img = KThumb::getFrame(frame, fullWidth, info.imageHeight);
img = KThumb::getFrame(frame, fullWidth, info.imageHeight, forceThumbScale);
emit replyGetImage(info.clipId, img);
}
}
......@@ -659,7 +660,7 @@ void ProducerQueue::processFileProperties()
img = KThumb::getFrame(frame, fullWidth, info.imageHeight);
delete glProd;
} else {
img = KThumb::getFrame(frame, fullWidth, info.imageHeight);
img = KThumb::getFrame(frame, fullWidth, info.imageHeight, forceThumbScale);
}
emit replyGetImage(info.clipId, img);
}
......@@ -697,7 +698,7 @@ void ProducerQueue::processFileProperties()
else {
tmpProd = producer;
}
QImage img = KThumb::getFrame(frame, fullWidth, info.imageHeight);
QImage img = KThumb::getFrame(frame, fullWidth, info.imageHeight, forceThumbScale);
if (frameNumber == -1) {
// No user specipied frame, look for best one
int variance = KThumb::imageVariance(img);
......@@ -707,7 +708,7 @@ void ProducerQueue::processFileProperties()
frameNumber = duration > 100 ? 100 : duration / 2 ;
tmpProd->seek(frameNumber);
frame = tmpProd->get_frame();
img = KThumb::getFrame(frame, fullWidth, info.imageHeight);
img = KThumb::getFrame(frame, fullWidth, info.imageHeight, forceThumbScale);
}
}
if (KdenliveSettings::gpu_accel()) {
......@@ -889,7 +890,7 @@ void ProducerQueue::slotMultiStreamProducerFound(const QString &path, QList<int>
dialog->connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
dialog->connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
okButton->setText(i18n("Import selected clips"));
QLabel *lab1 = new QLabel(i18n("Additional streams for clip\n %1", path), mainWidget);
mainLayout->addWidget(lab1);
QList <QGroupBox*> groupList;
......
......@@ -520,8 +520,8 @@ void Monitor::slotForceSize(QAction *a)
if (resizeType > 0) {
// calculate size
QRect r = QApplication::desktop()->screenGeometry();
profileWidth = m_glMonitor->profileSize().width() * resizeType / 100;
profileHeight = m_glMonitor->profileSize().height() * resizeType / 100;
profileWidth = m_glMonitor->profile()->dar() * profileHeight;
if (profileWidth > r.width() * 0.8 || profileHeight > r.height() * 0.7) {
// reset action to free resize
QList< QAction * > list = m_forceSize->actions ();
......
......@@ -640,7 +640,6 @@ void TransitionHandler::rebuildTransitions(int mode, QList <int> videoTracks, in
if (mode == 1) {
transition.set("valign", "middle");
transition.set("halign", "centre");
transition.set("aligned", 0);
transition.set("fill", 1);
transition.set("geometry", compositeGeometry.toUtf8().constData());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment