Revert stupid error in thumb ratio

parent fce0a6bc
......@@ -55,7 +55,7 @@ Generators::Generators(Monitor *monitor, const QString &path, QWidget *parent) :
m_preview->setMinimumSize(1, 1);
lay->addWidget(m_preview);
m_producer = new Mlt::Producer(*monitor->profile(), generatorTag.toUtf8().constData());
m_pixmap = QPixmap::fromImage(KThumb::getFrame(m_producer, 0, monitor->profile()->dar(), monitor->profile()->width(), monitor->profile()->height()));
m_pixmap = QPixmap::fromImage(KThumb::getFrame(m_producer, 0, monitor->profile()->width(), monitor->profile()->height()));
m_preview->setPixmap(m_pixmap.scaledToWidth(m_preview->width()));
QHBoxLayout *hlay = new QHBoxLayout;
hlay->addWidget(new QLabel(i18n("Duration")));
......@@ -92,7 +92,7 @@ void Generators::updateProducer(QDomElement,QDomElement effect,int)
}
int w = m_pixmap.width();
int h = m_pixmap.height();
m_pixmap = QPixmap::fromImage(KThumb::getFrame(m_producer, 0, 1.0, w, h));
m_pixmap = QPixmap::fromImage(KThumb::getFrame(m_producer, 0, w, h));
m_preview->setPixmap(m_pixmap.scaledToWidth(m_preview->width()));
}
......
......@@ -844,7 +844,7 @@ void ProjectClip::doExtractIntra()
{
Mlt::Producer *prod = thumbProducer();
if (prod == NULL || !prod->is_valid()) return;
int fullWidth = 150 * prod->profile()->sar() + 0.5;
int fullWidth = 150 * prod->profile()->dar() + 0.5;
double dar = prod->profile()->dar();
int max = prod->get_length();
int pos;
......@@ -862,7 +862,7 @@ void ProjectClip::doExtractIntra()
prod->seek(pos);
Mlt::Frame *frame = prod->get_frame();
if (frame && frame->is_valid()) {
img = KThumb::getFrame(frame, dar, fullWidth, 150);
img = KThumb::getFrame(frame, fullWidth, 150);
bin()->cachePixmap(path, img);
emit thumbReady(pos, img);
}
......@@ -889,7 +889,7 @@ void ProjectClip::doExtractImage()
{
Mlt::Producer *prod = thumbProducer();
if (prod == NULL || !prod->is_valid()) return;
int frameWidth = 150 * prod->profile()->sar() + 0.5;
int frameWidth = 150 * prod->profile()->dar() + 0.5;
bool ok = false;
QDir thumbFolder = bin()->getCacheDir(CacheThumbs, &ok);
int max = prod->get_length();
......@@ -911,7 +911,7 @@ void ProjectClip::doExtractImage()
prod->seek(pos);
Mlt::Frame *frame = prod->get_frame();
if (frame && frame->is_valid()) {
img = KThumb::getFrame(frame, prod->profile()->dar(), frameWidth, 150);
img = KThumb::getFrame(frame, frameWidth, 150);
bin()->cachePixmap(path, img);
emit thumbReady(pos, img);
}
......@@ -923,7 +923,7 @@ void ProjectClip::slotExtractSubImage(QList <int> frames)
{
Mlt::Producer *prod = thumbProducer();
if (prod == NULL || !prod->is_valid()) return;
int fullWidth = 150 * prod->profile()->sar() + 0.5;
int fullWidth = 150 * prod->profile()->dar() + 0.5;
bool ok = false;
QDir thumbFolder = bin()->getCacheDir(CacheThumbs, &ok);
int max = prod->get_length();
......@@ -946,7 +946,7 @@ void ProjectClip::slotExtractSubImage(QList <int> frames)
prod->seek(pos);
Mlt::Frame *frame = prod->get_frame();
if (frame && frame->is_valid()) {
QImage img = KThumb::getFrame(frame, prod->profile()->dar(), fullWidth, 150);
QImage img = KThumb::getFrame(frame, fullWidth, 150);
if (!img.isNull()) {
img.save(path);
for (int i = 0; i < count(); ++i) {
......
......@@ -44,13 +44,13 @@ QPixmap KThumb::getImage(const QUrl &url, int frame, int width, int height)
QPixmap pix(width, height);
if (!url.isValid()) return pix;
Mlt::Producer *producer = new Mlt::Producer(profile, url.path().toUtf8().constData());
pix = QPixmap::fromImage(getFrame(producer, frame, profile.dar(), width, height));
pix = QPixmap::fromImage(getFrame(producer, frame, width, height));
delete producer;
return pix;
}
//static
QImage KThumb::getFrame(Mlt::Producer *producer, int framepos, double dar, int displayWidth, int height)
QImage KThumb::getFrame(Mlt::Producer *producer, int framepos, int displayWidth, int height)
{
if (producer == NULL || !producer->is_valid()) {
QImage p(displayWidth, height, QImage::Format_ARGB32_Premultiplied);
......@@ -65,14 +65,14 @@ QImage KThumb::getFrame(Mlt::Producer *producer, int framepos, double dar, int d
producer->seek(framepos);
Mlt::Frame *frame = producer->get_frame();
const QImage p = getFrame(frame, dar, displayWidth, height);
const QImage p = getFrame(frame, displayWidth, height);
delete frame;
return p;
}
//static
QImage KThumb::getFrame(Mlt::Frame *frame, double dar, int width, int height)
QImage KThumb::getFrame(Mlt::Frame *frame, int width, int height)
{
if (frame == NULL || !frame->is_valid()) {
QImage p(width, height, QImage::Format_ARGB32_Premultiplied);
......@@ -89,9 +89,9 @@ QImage KThumb::getFrame(Mlt::Frame *frame, double dar, int width, int height)
QImage image(ow, oh, QImage::Format_RGBA8888);
memcpy(image.bits(), imagedata, ow * oh * 4);
if (!image.isNull()) {
if (dar != 1.0 || ow > (2 * width)) {
if (ow > (2 * width)) {
// there was a scaling problem, do it manually
image = image.scaled(dar * height, height);
image = image.scaled(width, height);
}
return image;
/*p.fill(QColor(100, 100, 100, 70));
......
......@@ -38,8 +38,8 @@ 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, double dar, int displayWidth, int height);
QImage getFrame(Mlt::Frame *frame, double dar, int width, int height);
QImage getFrame(Mlt::Producer *producer, int framepos, int displayWidth, int height);
QImage getFrame(Mlt::Frame *frame, int width, int height);
/** @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
* */
......
......@@ -484,7 +484,7 @@ void DvdWizardMenu::buildImage()
profile.set_explicit(true);
Mlt::Producer *producer = new Mlt::Producer(profile, m_view.background_image->url().path().toUtf8().constData());
if (producer && producer->is_valid()) {
pix = QPixmap::fromImage(KThumb::getFrame(producer, 0, 1, m_width, m_height));
pix = QPixmap::fromImage(KThumb::getFrame(producer, 0, m_width, m_height));
m_movieLength = producer->get_length();
}
if (producer) delete producer;
......
......@@ -296,9 +296,9 @@ void DvdWizardVob::slotAddVobFile(QUrl url, const QString &chapters, bool checkF
}
}
if (producer && producer->is_valid() && !producer->is_blank()) {
int width = 45.0 * profile.sar();
int width = 45.0 * profile.dar();
if (width % 2 == 1) width++;
item->setData(0, Qt::DecorationRole, QPixmap::fromImage(KThumb::getFrame(producer, 0, profile.dar(), width, 45)));
item->setData(0, Qt::DecorationRole, QPixmap::fromImage(KThumb::getFrame(producer, 0, width, 45)));
int playTime = producer->get_playtime();
item->setText(1, Timecode::getStringTimecode(playTime, profile.fps()));
item->setData(1, Qt::UserRole, playTime);
......@@ -740,9 +740,9 @@ void DvdWizardVob::slotTranscodedClip(const QString &src, const QString &transco
}
}
if (producer && producer->is_valid() && !producer->is_blank()) {
int width = 45.0 * profile.sar();
int width = 45.0 * profile.dar();
if (width % 2 == 1) width++;
item->setData(0, Qt::DecorationRole, QPixmap::fromImage(KThumb::getFrame(producer, 0, profile.dar(), width, 45)));
item->setData(0, Qt::DecorationRole, QPixmap::fromImage(KThumb::getFrame(producer, 0, width, 45)));
int playTime = producer->get_playtime();
item->setText(1, Timecode::getStringTimecode(playTime, profile.fps()));
item->setData(1, Qt::UserRole, playTime);
......
......@@ -135,7 +135,6 @@ void ProducerQueue::processFileProperties()
requestClipInfo info;
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
double dar = m_binController->profile()->dar();
while (!m_requestList.isEmpty()) {
m_infoMutex.lock();
info = m_requestList.takeFirst();
......@@ -161,8 +160,8 @@ void ProducerQueue::processFileProperties()
if (frameNumber > 0) prod->seek(frameNumber);
Mlt::Frame *frame = prod->get_frame();
if (frame && frame->is_valid()) {
int fullWidth = info.imageHeight * m_binController->profile()->sar() + 0.5;
QImage img = KThumb::getFrame(frame, dar, fullWidth, info.imageHeight);
int fullWidth = info.imageHeight * m_binController->profile()->dar() + 0.5;
QImage img = KThumb::getFrame(frame, fullWidth, info.imageHeight);
emit replyGetImage(info.clipId, img);
}
delete frame;
......@@ -442,7 +441,7 @@ void ProducerQueue::processFileProperties()
if (info.xml.hasAttribute(QStringLiteral("templatetext")))
producer->set("templatetext", info.xml.attribute(QStringLiteral("templatetext")).toUtf8().constData());
int fullWidth = info.imageHeight * m_binController->profile()->sar() + 0.5;
int fullWidth = info.imageHeight * m_binController->profile()->dar() + 0.5;
int frameNumber = ProjectClip::getXmlProperty(info.xml, QStringLiteral("kdenlive:thumbnailFrame"), QStringLiteral("-1")).toInt();
if ((!info.replaceProducer && !EffectsList::property(info.xml, QStringLiteral("kdenlive:file_hash")).isEmpty()) || proxyProducer) {
......@@ -463,7 +462,7 @@ void ProducerQueue::processFileProperties()
glProd->attach(converter);
frame = glProd->get_frame();
if (frame && frame->is_valid()) {
img = KThumb::getFrame(frame, dar, fullWidth, info.imageHeight);
img = KThumb::getFrame(frame, fullWidth, info.imageHeight);
emit replyGetImage(info.clipId, img);
}
delete glProd;
......@@ -471,7 +470,7 @@ void ProducerQueue::processFileProperties()
if (frameNumber > 0) producer->seek(frameNumber);
frame = producer->get_frame();
if (frame && frame->is_valid()) {
img = KThumb::getFrame(frame, dar, fullWidth, info.imageHeight);
img = KThumb::getFrame(frame, fullWidth, info.imageHeight);
emit replyGetImage(info.clipId, img);
}
}
......@@ -645,10 +644,10 @@ void ProducerQueue::processFileProperties()
glProd->attach(scaler);
glProd->attach(converter);
frame = glProd->get_frame();
img = KThumb::getFrame(frame, dar, fullWidth, info.imageHeight);
img = KThumb::getFrame(frame, fullWidth, info.imageHeight);
delete glProd;
} else {
img = KThumb::getFrame(frame, dar, fullWidth, info.imageHeight);
img = KThumb::getFrame(frame, fullWidth, info.imageHeight);
}
emit replyGetImage(info.clipId, img);
}
......@@ -686,7 +685,7 @@ void ProducerQueue::processFileProperties()
else {
tmpProd = producer;
}
QImage img = KThumb::getFrame(frame, dar, fullWidth, info.imageHeight);
QImage img = KThumb::getFrame(frame, fullWidth, info.imageHeight);
if (frameNumber == -1) {
// No user specipied frame, look for best one
int variance = KThumb::imageVariance(img);
......@@ -696,7 +695,7 @@ void ProducerQueue::processFileProperties()
frameNumber = duration > 100 ? 100 : duration / 2 ;
tmpProd->seek(frameNumber);
frame = tmpProd->get_frame();
img = KThumb::getFrame(frame, dar, fullWidth, info.imageHeight);
img = KThumb::getFrame(frame, fullWidth, info.imageHeight);
}
}
if (KdenliveSettings::gpu_accel()) {
......@@ -862,7 +861,7 @@ void ProducerQueue::slotMultiStreamProducerFound(const QString &path, QList<int>
return;
}
int width = 60.0 * m_binController->profile()->sar();
int width = 60.0 * m_binController->profile()->dar();
if (width % 2 == 1) width++;
QPointer<QDialog> dialog = new QDialog(qApp->activeWindow());
......@@ -887,7 +886,7 @@ void ProducerQueue::slotMultiStreamProducerFound(const QString &path, QList<int>
for (int j = 1; j < video_list.count(); ++j) {
Mlt::Producer multiprod(* m_binController->profile(), path.toUtf8().constData());
multiprod.set("video_index", video_list.at(j));
QImage thumb = KThumb::getFrame(&multiprod, 0, m_binController->profile()->dar(), width, 60);
QImage thumb = KThumb::getFrame(&multiprod, 0, width, 60);
QGroupBox *streamFrame = new QGroupBox(i18n("Video stream %1", video_list.at(j)), mainWidget);
mainLayout->addWidget(streamFrame);
streamFrame->setProperty("vindex", video_list.at(j));
......
......@@ -184,14 +184,14 @@ int Render::renderHeight() const
QImage Render::extractFrame(int frame_position, const QString &path, int width, int height)
{
if (width == -1) {
width = renderWidth();
width = frameRenderWidth();
height = renderHeight();
} else if (width % 2 == 1) width++;
if (!path.isEmpty()) {
Mlt::Producer *producer = new Mlt::Producer(*m_qmlView->profile(), path.toUtf8().constData());
if (producer) {
if (producer->is_valid()) {
QImage img = KThumb::getFrame(producer, frame_position, m_qmlView->profile()->dar(), width, height);
QImage img = KThumb::getFrame(producer, frame_position, width, height);
delete producer;
return img;
}
......@@ -220,7 +220,7 @@ QImage Render::extractFrame(int frame_position, const QString &path, int width,
else {
frame = m_mltProducer->get_frame();
}
QImage img = KThumb::getFrame(frame, m_qmlView->profile()->dar(), width, height);
QImage img = KThumb::getFrame(frame, width, height);
delete frame;
return img;
}
......
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