"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/widgets/slideshowgeneratorwidget.cpp" between
shotcut-20.09.01.tar.gz and shotcut-20.09.13.tar.gz

About: Shotcut is a cross-platform (Qt) advanced video editor.

slideshowgeneratorwidget.cpp  (shotcut-20.09.01):slideshowgeneratorwidget.cpp  (shotcut-20.09.13)
skipping to change at line 26 skipping to change at line 26
*/ */
#include "slideshowgeneratorwidget.h" #include "slideshowgeneratorwidget.h"
#include "Logger.h" #include "Logger.h"
#include "mltcontroller.h" #include "mltcontroller.h"
#include "settings.h" #include "settings.h"
#include "shotcut_mlt_properties.h" #include "shotcut_mlt_properties.h"
#include "widgets/producerpreviewwidget.h" #include "widgets/producerpreviewwidget.h"
#include <MltFilter.h>
#include <MltTransition.h>
#include <QComboBox> #include <QComboBox>
#include <QDebug> #include <QDebug>
#include <QDoubleSpinBox> #include <QDoubleSpinBox>
#include <QGridLayout> #include <QGridLayout>
#include <QLabel> #include <QLabel>
#include <QSpinBox> #include <QSpinBox>
#include <QtConcurrent/QtConcurrent> #include <QtConcurrent/QtConcurrent>
#include <math.h> #include <math.h>
skipping to change at line 145 skipping to change at line 142
grid->addWidget(new QLabel(tr("Transition softness")), 5, 0, Qt::AlignRight) ; grid->addWidget(new QLabel(tr("Transition softness")), 5, 0, Qt::AlignRight) ;
m_softnessSpinner = new QSpinBox(); m_softnessSpinner = new QSpinBox();
m_softnessSpinner->setToolTip(tr("Change the softness of the edge of the wip e.")); m_softnessSpinner->setToolTip(tr("Change the softness of the edge of the wip e."));
m_softnessSpinner->setSuffix(" %"); m_softnessSpinner->setSuffix(" %");
m_softnessSpinner->setMaximum(100); m_softnessSpinner->setMaximum(100);
m_softnessSpinner->setMinimum(0); m_softnessSpinner->setMinimum(0);
m_softnessSpinner->setValue(20); m_softnessSpinner->setValue(20);
connect(m_softnessSpinner, SIGNAL(valueChanged(int)), this, SLOT(on_paramete rChanged())); connect(m_softnessSpinner, SIGNAL(valueChanged(int)), this, SLOT(on_paramete rChanged()));
grid->addWidget(m_softnessSpinner, 5, 1); grid->addWidget(m_softnessSpinner, 5, 1);
m_preview = new ProducerPreviewWidget(m_clips->profile()->dar()); m_preview = new ProducerPreviewWidget(MLT.profile().dar());
grid->addWidget(m_preview, 6, 0, 1, 2, Qt::AlignCenter); grid->addWidget(m_preview, 6, 0, 1, 2, Qt::AlignCenter);
on_parameterChanged(); on_parameterChanged();
} }
SlideshowGeneratorWidget::~SlideshowGeneratorWidget() SlideshowGeneratorWidget::~SlideshowGeneratorWidget()
{ {
m_future.waitForFinished(); m_future.waitForFinished();
m_preview->stop(); m_preview->stop();
if(m_previewProducer) if(m_previewProducer)
skipping to change at line 169 skipping to change at line 166
} }
Mlt::Playlist* SlideshowGeneratorWidget::getSlideshow() Mlt::Playlist* SlideshowGeneratorWidget::getSlideshow()
{ {
SlideshowConfig config; SlideshowConfig config;
m_mutex.lock(); m_mutex.lock();
// take a snapshot of the config. // take a snapshot of the config.
config = m_config; config = m_config;
m_mutex.unlock(); m_mutex.unlock();
int framesPerClip = round(config.clipDuration * m_clips->profile()->fps()); int framesPerClip = round(config.clipDuration * MLT.profile().fps());
int count = m_clips->count(); int count = m_clips->count();
Mlt::Playlist* slideshow = new Mlt::Playlist(*m_clips->profile()); Mlt::Playlist* slideshow = new Mlt::Playlist(MLT.profile());
Mlt::ClipInfo info; Mlt::ClipInfo info;
// Copy clips // Copy clips
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
Mlt::ClipInfo* c = m_clips->clip_info(i, &info); Mlt::ClipInfo* c = m_clips->clip_info(i, &info);
if (c) if (c)
{ {
Mlt::Producer producer(*c->producer->profile(), "xml-string", MLT.XM L(c->producer).toUtf8().constData()); Mlt::Producer producer(MLT.profile(), "xml-string", MLT.XML(c->produ cer).toUtf8().constData());
slideshow->append(producer, c->frame_in, c->frame_in + framesPerClip - 1); slideshow->append(producer, c->frame_in, c->frame_in + framesPerClip - 1);
} }
} }
// Add filters // Add filters
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
Mlt::ClipInfo* c = slideshow->clip_info(i, &info); Mlt::ClipInfo* c = slideshow->clip_info(i, &info);
if (c && c->producer) if (c && c->producer)
{ {
attachAffineFilter(config, c->producer, c->frame_in + framesPerClip if (!c->producer->property_exists("meta.media.width")) {
- 1); delete c->producer->get_frame(); // makes avformat producer set
meta.media.width and .height
}
attachAffineFilter(config, c->producer, c->frame_count - 1);
attachBlurFilter(config, c->producer); attachBlurFilter(config, c->producer);
} }
} }
// Add transitions // Add transitions
int framesPerTransition = round(config.transitionDuration * m_clips->profile ()->fps()); int framesPerTransition = round(config.transitionDuration * MLT.profile().fp s());
if (framesPerTransition > (framesPerClip / 2 - 1)) if (framesPerTransition > (framesPerClip / 2 - 1))
{ {
framesPerTransition = (framesPerClip / 2 - 1); framesPerTransition = (framesPerClip / 2 - 1);
} }
if (framesPerTransition > 0) if (framesPerTransition > 0)
{ {
for (int i = 0; i < count - 1; i++) for (int i = 0; i < count - 1; i++)
{ {
Mlt::ClipInfo* c = slideshow->clip_info(i, &info); Mlt::ClipInfo* c = slideshow->clip_info(i, &info);
if (c->frame_count < framesPerTransition) if (c->frame_count < framesPerTransition)
skipping to change at line 229 skipping to change at line 229
// Create playlist mix // Create playlist mix
slideshow->mix(i, framesPerTransition); slideshow->mix(i, framesPerTransition);
QScopedPointer<Mlt::Producer> producer(slideshow->get_clip(i + 1)); QScopedPointer<Mlt::Producer> producer(slideshow->get_clip(i + 1));
if( producer.isNull() ) if( producer.isNull() )
{ {
break; break;
} }
producer->parent().set(kShotcutTransitionProperty, "lumaMix"); producer->parent().set(kShotcutTransitionProperty, "lumaMix");
// Add mix transition // Add mix transition
Mlt::Transition crossFade(*m_clips->profile(), "mix:-1"); Mlt::Transition crossFade(MLT.profile(), "mix:-1");
slideshow->mix_add(i + 1, &crossFade); slideshow->mix_add(i + 1, &crossFade);
// Add luma transition // Add luma transition
Mlt::Transition luma(*m_clips->profile(), Settings.playerGPU()? "mov it.luma_mix" : "luma"); Mlt::Transition luma(MLT.profile(), Settings.playerGPU()? "movit.lum a_mix" : "luma");
applyLumaTransitionProperties(&luma, config); applyLumaTransitionProperties(&luma, config);
slideshow->mix_add(i + 1, &luma); slideshow->mix_add(i + 1, &luma);
count++; count++;
i++; i++;
} }
} }
return slideshow; return slideshow;
} }
skipping to change at line 258 skipping to change at line 258
config.aspectConversion != ASPECT_CONVERSION_CROP_CENTER && config.aspectConversion != ASPECT_CONVERSION_CROP_CENTER &&
config.aspectConversion != ASPECT_CONVERSION_CROP_PAN) config.aspectConversion != ASPECT_CONVERSION_CROP_PAN)
{ {
return; return;
} }
mlt_rect beginRect; mlt_rect beginRect;
mlt_rect endRect; mlt_rect endRect;
beginRect.x = 0; beginRect.x = 0;
beginRect.y = 0; beginRect.y = 0;
beginRect.w = producer->profile()->width(); beginRect.w = MLT.profile().width();
beginRect.h = producer->profile()->height(); beginRect.h = MLT.profile().height();
beginRect.o = 1; beginRect.o = 1;
endRect.x = beginRect.x; endRect.x = beginRect.x;
endRect.y = beginRect.y; endRect.y = beginRect.y;
endRect.w = beginRect.w; endRect.w = beginRect.w;
endRect.h = beginRect.h; endRect.h = beginRect.h;
endRect.o = 1; endRect.o = 1;
double destDar = producer->profile()->dar(); double destDar = MLT.profile().dar();
double sourceW = producer->get_double("meta.media.width"); double sourceW = producer->get_double("meta.media.width");
double sourceH = producer->get_double("meta.media.height"); double sourceH = producer->get_double("meta.media.height");
double sourceAr = producer->get_double("aspect_ratio"); double sourceAr = producer->get_double("aspect_ratio");
double sourceDar = destDar; double sourceDar = destDar;
if (sourceW && sourceH && sourceAr) if (sourceW && sourceH && sourceAr)
{ {
sourceDar = sourceW * sourceAr / sourceH; sourceDar = sourceW * sourceAr / sourceH;
} }
if (sourceDar == destDar && config.zoomPercent == 0) if (sourceDar == destDar && config.zoomPercent == 0)
{ {
// Aspect ratios match and no zoom. No need for affine. // Aspect ratios match and no zoom. No need for affine.
return; return;
} }
if (config.aspectConversion == ASPECT_CONVERSION_CROP_CENTER || if (config.aspectConversion == ASPECT_CONVERSION_CROP_CENTER ||
config.aspectConversion == ASPECT_CONVERSION_CROP_PAN) config.aspectConversion == ASPECT_CONVERSION_CROP_PAN)
{ {
if (sourceDar > destDar) if (sourceDar > destDar)
{ {
// Crop sides to fit height // Crop sides to fit height
beginRect.w = (double)producer->profile()->width() * sourceDar / des beginRect.w = (double)MLT.profile().width() * sourceDar / destDar;
tDar; beginRect.h = MLT.profile().height();
beginRect.h = producer->profile()->height();
beginRect.y = 0; beginRect.y = 0;
endRect.w = beginRect.w; endRect.w = beginRect.w;
endRect.h = beginRect.h; endRect.h = beginRect.h;
endRect.y = beginRect.y; endRect.y = beginRect.y;
if(config.aspectConversion == ASPECT_CONVERSION_CROP_CENTER) if(config.aspectConversion == ASPECT_CONVERSION_CROP_CENTER)
{ {
beginRect.x = ((double)producer->profile()->width() - beginRect. w) / 2.0; beginRect.x = ((double)MLT.profile().width() - beginRect.w) / 2. 0;
endRect.x = beginRect.x; endRect.x = beginRect.x;
} }
else else
{ {
beginRect.x = 0; beginRect.x = 0;
endRect.x = (double)producer->profile()->width() - endRect.w; endRect.x = (double)MLT.profile().width() - endRect.w;
} }
} }
else if (destDar > sourceDar) else if (destDar > sourceDar)
{ {
// Crop top and bottom to fit width. // Crop top and bottom to fit width.
beginRect.w = producer->profile()->width(); beginRect.w = MLT.profile().width();
beginRect.h = (double)producer->profile()->height() * destDar / sour beginRect.h = (double)MLT.profile().height() * destDar / sourceDar;
ceDar;
beginRect.x = 0; beginRect.x = 0;
endRect.w = beginRect.w; endRect.w = beginRect.w;
endRect.h = beginRect.h; endRect.h = beginRect.h;
endRect.x = beginRect.x; endRect.x = beginRect.x;
if (config.aspectConversion == ASPECT_CONVERSION_CROP_CENTER) if (config.aspectConversion == ASPECT_CONVERSION_CROP_CENTER)
{ {
beginRect.y = ((double)producer->profile()->height() - beginRect .h) / 2.0; beginRect.y = ((double)MLT.profile().height() - beginRect.h) / 2 .0;
endRect.y = beginRect.y; endRect.y = beginRect.y;
} }
else else
{ {
beginRect.y = 0; beginRect.y = 0;
endRect.y = (double)producer->profile()->height() - endRect.h; endRect.y = (double)MLT.profile().height() - endRect.h;
} }
} }
} }
if (config.zoomPercent > 0) if (config.zoomPercent > 0)
{ {
double endScale = (double)config.zoomPercent / 100.0; double endScale = (double)config.zoomPercent / 100.0;
endRect.x = endRect.x - (endScale * endRect.w / 2.0); endRect.x = endRect.x - (endScale * endRect.w / 2.0);
endRect.y = endRect.y - (endScale * endRect.h / 2.0); endRect.y = endRect.y - (endScale * endRect.h / 2.0);
endRect.w = endRect.w + (endScale * endRect.w); endRect.w = endRect.w + (endScale * endRect.w);
skipping to change at line 344 skipping to change at line 344
} }
else if (config.zoomPercent < 0) else if (config.zoomPercent < 0)
{ {
double beginScale = -1.0 * (double)config.zoomPercent / 100.0; double beginScale = -1.0 * (double)config.zoomPercent / 100.0;
beginRect.x = beginRect.x - (beginScale * beginRect.w / 2.0); beginRect.x = beginRect.x - (beginScale * beginRect.w / 2.0);
beginRect.y = beginRect.y - (beginScale * beginRect.h / 2.0); beginRect.y = beginRect.y - (beginScale * beginRect.h / 2.0);
beginRect.w = beginRect.w + (beginScale * beginRect.w); beginRect.w = beginRect.w + (beginScale * beginRect.w);
beginRect.h = beginRect.h + (beginScale * beginRect.h); beginRect.h = beginRect.h + (beginScale * beginRect.h);
} }
Mlt::Filter filter(*producer->profile(), "affine"); Mlt::Filter filter(MLT.profile(), "affine");
filter.anim_set("transition.rect", beginRect, 0); filter.anim_set("transition.rect", beginRect, 0);
filter.anim_set("transition.rect", endRect, endPosition); filter.anim_set("transition.rect", endRect, endPosition);
filter.set("transition.fill", 1); filter.set("transition.fill", 1);
filter.set("transition.distort", 0); filter.set("transition.distort", 0);
filter.set("transition.valign", "middle"); filter.set("transition.valign", "middle");
filter.set("transition.halign", "center"); filter.set("transition.halign", "center");
filter.set("transition.threads", 0); filter.set("transition.threads", 0);
filter.set("background", "color:#000000"); filter.set("background", "color:#000000");
filter.set("shotcut:filter", "affineSizePosition"); filter.set(kShotcutFilterProperty, "affineSizePosition");
filter.set("shotcut:animIn", producer->frames_to_time(endPosition, mlt_time_ filter.set(kShotcutAnimInProperty, producer->frames_to_time(endPosition + 1,
clock)); mlt_time_clock));
filter.set("shotcut:animOut", producer->frames_to_time(0, mlt_time_clock)); filter.set(kShotcutAnimOutProperty, producer->frames_to_time(0, mlt_time_clo
ck));
producer->attach(filter); producer->attach(filter);
} }
void SlideshowGeneratorWidget::attachBlurFilter(SlideshowConfig& config, Mlt::Pr oducer* producer) void SlideshowGeneratorWidget::attachBlurFilter(SlideshowConfig& config, Mlt::Pr oducer* producer)
{ {
if (config.aspectConversion != ASPECT_CONVERSION_PAD_BLUR) if (config.aspectConversion != ASPECT_CONVERSION_PAD_BLUR)
{ {
return; return;
} }
mlt_rect rect; mlt_rect rect;
rect.x = 0; rect.x = 0;
rect.y = 0; rect.y = 0;
rect.w = producer->profile()->width(); rect.w = MLT.profile().width();
rect.h = producer->profile()->height(); rect.h = MLT.profile().height();
rect.o = 1; rect.o = 1;
double destDar = producer->profile()->dar(); double destDar = MLT.profile().dar();
double sourceW = producer->get_double("meta.media.width"); double sourceW = producer->get_double("meta.media.width");
double sourceH = producer->get_double("meta.media.height"); double sourceH = producer->get_double("meta.media.height");
double sourceAr = producer->get_double("aspect_ratio"); double sourceAr = producer->get_double("aspect_ratio");
double sourceDar = destDar; double sourceDar = destDar;
if( sourceW && sourceH && sourceAr ) if( sourceW && sourceH && sourceAr )
{ {
sourceDar = sourceW * sourceAr / sourceH; sourceDar = sourceW * sourceAr / sourceH;
} }
if (sourceDar == destDar) if (sourceDar == destDar)
{ {
// Aspect ratios match. No need for pad. // Aspect ratios match. No need for pad.
return; return;
} }
if (sourceDar > destDar) if (sourceDar > destDar)
{ {
// Blur top/bottom to pad. // Blur top/bottom to pad.
rect.h = producer->profile()->height() * destDar / sourceDar; rect.h = MLT.profile().height() * destDar / sourceDar;
rect.y = ((double)producer->profile()->height() - rect.h) / 2.0; rect.y = ((double)MLT.profile().height() - rect.h) / 2.0;
} }
else if (destDar > sourceDar) else if (destDar > sourceDar)
{ {
// Blur sides to pad. // Blur sides to pad.
rect.w = producer->profile()->width() * sourceDar / destDar; rect.w = MLT.profile().width() * sourceDar / destDar;
rect.x = ((double)producer->profile()->width() - rect.w) / 2.0; rect.x = ((double)MLT.profile().width() - rect.w) / 2.0;
} }
Mlt::Filter filter(*producer->profile(), "pillar_echo"); Mlt::Filter filter(MLT.profile(), "pillar_echo");
filter.set("rect", rect); filter.set("rect", rect);
filter.set("blur", 4); filter.set("blur", 4);
filter.set("shotcut:filter", "pillarEcho"); filter.set(kShotcutFilterProperty, "pillarEcho");
producer->attach(filter); producer->attach(filter);
} }
void SlideshowGeneratorWidget::applyLumaTransitionProperties(Mlt::Transition* lu ma, SlideshowConfig& config) void SlideshowGeneratorWidget::applyLumaTransitionProperties(Mlt::Transition* lu ma, SlideshowConfig& config)
{ {
int index = config.transitionStyle; int index = config.transitionStyle;
if (index == 0) { if (index == 0) {
// Random: pick any number other than 0 // Random: pick any number other than 0
index = rand() % 24 + 1; index = rand() % 24 + 1;
 End of changes. 25 change blocks. 
39 lines changed or deleted 38 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)