Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
Kdenlive
Commits
83003d02
Commit
83003d02
authored
May 14, 2021
by
Jean-Baptiste Mardelle
Browse files
Port remaining cache and cut jobs to tasks, start removal of jobmanager
parent
8db7e33c
Changes
21
Hide whitespace changes
Inline
Side-by-side
src/assets/view/widgets/buttonparamwidget.cpp
View file @
83003d02
...
...
@@ -22,7 +22,6 @@
#include "buttonparamwidget.hpp"
#include "assets/model/assetparametermodel.hpp"
#include "jobs/filtertask.h"
#include "jobs/jobmanager.h"
#include "assets/model/assetcommand.hpp"
#include "core.h"
#include <mlt++/Mlt.h>
...
...
src/bin/abstractprojectitem.cpp
View file @
83003d02
...
...
@@ -23,7 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "abstractprojectitem.h"
#include "bin.h"
#include "core.h"
#include "jobs/jobmanager.h"
#include "macros.hpp"
#include "projectitemmodel.h"
...
...
@@ -170,17 +169,6 @@ QVariant AbstractProjectItem::getData(DataType type) const
case
ClipHasAudioAndVideo
:
data
=
hasAudioAndVideo
();
break
;
case
JobType
:
if
(
itemType
()
==
ClipItem
)
{
auto
jobIds
=
pCore
->
jobManager
()
->
getPendingJobsIds
(
clipId
());
if
(
jobIds
.
empty
())
{
jobIds
=
pCore
->
jobManager
()
->
getFinishedJobsIds
(
clipId
());
}
if
(
jobIds
.
size
()
>
0
)
{
data
=
QVariant
(
pCore
->
jobManager
()
->
getJobType
(
jobIds
[
0
]));
}
}
break
;
case
JobStatus
:
if
(
itemType
()
==
ClipItem
)
{
data
=
QVariant
::
fromValue
(
pCore
->
taskManager
.
jobStatus
({
ObjectType
::
BinClip
,
m_binId
.
toInt
()}));
...
...
@@ -199,25 +187,20 @@ QVariant AbstractProjectItem::getData(DataType type) const
case
JobProgress
:
if
(
itemType
()
==
ClipItem
)
{
data
=
pCore
->
taskManager
.
getJobProgressForClip
({
ObjectType
::
BinClip
,
m_binId
.
toInt
()});
/*
auto jobIds = pCore->jobManager()->getPendingJobsIds(clipId());
if (jobIds.size() > 0) {
data = QVariant(pCore->jobManager()->getJobProgressForClip(jobIds[0], clipId()));
} else {
data = QVariant(0);
}*/
}
break
;
case
JobSuccess
:
if
(
itemType
()
==
ClipItem
)
{
// TODO: reimplement ?
/*if (itemType() == ClipItem) {
auto jobIds = pCore->jobManager()->getFinishedJobsIds(clipId());
if (jobIds.size() > 0) {
// Check the last job status
data = QVariant(pCore->jobManager()->jobSucceded(jobIds[jobIds.size() - 1]));
} else {
data
=
QVariant
(
true
);
}
}
}*/
data
=
QVariant
(
true
);
break
;
case
ClipStatus
:
data
=
QVariant
(
m_clipStatus
);
...
...
src/bin/abstractprojectitem.h
View file @
83003d02
...
...
@@ -132,8 +132,6 @@ public:
DataInPoint
,
// Outpoint of the subclip (0 for clips)
DataOutPoint
,
// If there is a running job, which type
JobType
,
// Current progress of the job
JobProgress
,
// error message if job crashes (not fully implemented)
...
...
src/bin/projectclip.cpp
View file @
83003d02
...
...
@@ -27,11 +27,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "doc/kdenlivedoc.h"
#include "doc/kthumb.h"
#include "effects/effectstack/model/effectstackmodel.hpp"
#include "jobs/jobmanager.h"
#include "jobs/audiolevelstask.h"
#include "jobs/cliploadtask.h"
#include "jobs/proxytask.h"
#include "jobs/cache
job.hpp
"
#include "jobs/cache
task.h
"
#include "kdenlivesettings.h"
#include "lib/audio/audioStreamInfo.h"
#include "mltcontroller/clipcontroller.h"
...
...
@@ -371,18 +370,16 @@ size_t ProjectClip::frameDuration() const
void
ProjectClip
::
reloadProducer
(
bool
refreshOnly
,
bool
isProxy
,
bool
forceAudioReload
)
{
// we find if there are some loading job on that clip
//pCore->jobManager()->hasPendingJob(clipId(), AbstractClipJob::LOADJOB, &loadjobId);
QMutexLocker
lock
(
&
m_thumbMutex
);
if
(
refreshOnly
)
{
// In that case, we only want a new thumbnail.
// We thus set up a thumb job. We must make sure that there is no pending LOADJOB
// Clear cache first
ThumbnailCache
::
get
()
->
invalidateThumbsForClip
(
clipId
());
//
pCore->
job
Manager
()->
discardJobs(
clipId
(), Abstract
ClipJob::THUMB
JOB);
pCore
->
task
Manager
.
discardJobs
(
{
ObjectType
::
BinClip
,
m_binId
.
toInt
()
}
,
Abstract
Task
::
CACHE
JOB
);
pCore
->
taskManager
.
discardJobs
({
ObjectType
::
BinClip
,
m_binId
.
toInt
()},
AbstractTask
::
LOADJOB
);
m_thumbsProducer
.
reset
();
ClipLoadTask
::
start
({
ObjectType
::
BinClip
,
m_binId
.
toInt
()},
QDomElement
(),
true
,
-
1
,
-
1
,
this
);
//emit pCore->jobManager()->startJob<ThumbJob>({clipId()}, loadjobId, QString(), -1, true, true);
}
else
{
// If another load job is running?
pCore
->
taskManager
.
discardJobs
({
ObjectType
::
BinClip
,
m_binId
.
toInt
()});
...
...
@@ -414,8 +411,6 @@ void ProjectClip::reloadProducer(bool refreshOnly, bool isProxy, bool forceAudio
discardAudioThumb
();
}
ClipLoadTask
::
start
({
ObjectType
::
BinClip
,
m_binId
.
toInt
()},
xml
,
false
,
-
1
,
-
1
,
this
);
//int loadJob = pCore->jobManager()->startJob<LoadJob>({clipId()}, loadjobId, QString(), xml);
//emit pCore->jobManager()->startJob<ThumbJob>({clipId()}, loadJob, QString(), -1, true, true);
}
}
}
...
...
@@ -596,10 +591,7 @@ bool ProjectClip::setProducer(std::shared_ptr<Mlt::Producer> producer, bool repl
emit
refreshPropertiesPanel
();
if
(
KdenliveSettings
::
hoverPreview
()
&&
(
m_clipType
==
ClipType
::
AV
||
m_clipType
==
ClipType
::
Video
||
m_clipType
==
ClipType
::
Playlist
))
{
QTimer
::
singleShot
(
1000
,
this
,
[
this
]()
{
int
loadjobId
;
if
(
!
pCore
->
jobManager
()
->
hasPendingJob
(
m_binId
,
AbstractClipJob
::
CACHEJOB
,
&
loadjobId
))
{
emit
pCore
->
jobManager
()
->
startJob
<
CacheJob
>
({
m_binId
},
-
1
,
QString
());
}
CacheTask
::
start
({
ObjectType
::
BinClip
,
m_binId
.
toInt
()},
30
,
0
,
0
,
this
);
});
}
replaceInTimeline
();
...
...
@@ -1240,9 +1232,9 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
if
(
value
.
isEmpty
()
||
value
==
QLatin1String
(
"-"
))
{
// reset proxy
int
id
;
if
(
pCore
->
job
Manager
()
->
hasPendingJob
(
clipId
(),
Abstract
ClipJob
::
PROXYJOB
,
&
id
))
{
if
(
pCore
->
task
Manager
.
hasPendingJob
(
{
ObjectType
::
BinClip
,
m_binId
.
toInt
()
}
,
Abstract
Task
::
PROXYJOB
))
{
// The proxy clip is being created, abort
pCore
->
job
Manager
()
->
discardJobs
(
clipId
(),
Abstract
ClipJob
::
PROXYJOB
);
pCore
->
task
Manager
.
discardJobs
(
{
ObjectType
::
BinClip
,
m_binId
.
toInt
()
}
,
Abstract
Task
::
PROXYJOB
);
}
else
{
reload
=
true
;
refreshOnly
=
false
;
...
...
@@ -1252,7 +1244,6 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
setProducerProperty
(
QStringLiteral
(
"kdenlive:originalurl"
),
url
());
backupOriginalProperties
();
ProxyTask
::
start
({
ObjectType
::
BinClip
,
m_binId
.
toInt
()},
this
);
//emit pCore->jobManager()->startJob<ProxyJob>({clipId()}, -1, QString());
}
}
else
if
(
!
reload
)
{
const
QList
<
QString
>
propKeys
=
properties
.
keys
();
...
...
@@ -1311,9 +1302,8 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
if
(
reload
)
{
// producer has changed, refresh monitor and thumbnail
if
(
hasProxy
())
{
pCore
->
job
Manager
()
->
discardJobs
(
clipId
(),
Abstract
ClipJob
::
PROXYJOB
);
pCore
->
task
Manager
.
discardJobs
(
{
ObjectType
::
BinClip
,
m_binId
.
toInt
()
}
,
Abstract
Task
::
PROXYJOB
);
setProducerProperty
(
QStringLiteral
(
"_overwriteproxy"
),
1
);
//emit pCore->jobManager()->startJob<ProxyJob>({clipId()}, -1, QString());
ProxyTask
::
start
({
ObjectType
::
BinClip
,
m_binId
.
toInt
()},
this
);
}
else
{
reloadProducer
(
refreshOnly
,
properties
.
contains
(
QStringLiteral
(
"kdenlive:proxy"
)));
...
...
@@ -1784,17 +1774,14 @@ void ProjectClip::getThumbFromPercent(int percent)
{
// extract a maximum of 30 frames for bin preview
int
duration
=
getFramePlaytime
();
int
steps
=
qCeil
(
qMax
(
pCore
->
getCurrentFps
(),
double
(
duration
/
30
))
)
;
int
steps
=
qCeil
(
qMax
(
pCore
->
getCurrentFps
(),
double
(
duration
)
/
30
));
int
framePos
=
duration
*
percent
/
100
;
framePos
-=
framePos
%
steps
;
if
(
ThumbnailCache
::
get
()
->
hasThumbnail
(
m_binId
,
framePos
))
{
setThumbnail
(
ThumbnailCache
::
get
()
->
getThumbnail
(
m_binId
,
framePos
),
-
1
,
-
1
);
}
else
{
// Generate percent thumbs
int
id
;
if
(
!
pCore
->
jobManager
()
->
hasPendingJob
(
m_binId
,
AbstractClipJob
::
CACHEJOB
,
&
id
))
{
emit
pCore
->
jobManager
()
->
startJob
<
CacheJob
>
({
m_binId
},
-
1
,
QString
());
}
CacheTask
::
start
({
ObjectType
::
BinClip
,
m_binId
.
toInt
()},
30
,
0
,
0
,
this
);
}
}
...
...
src/bin/projectitemmodel.cpp
View file @
83003d02
...
...
@@ -27,11 +27,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "core.h"
#include "doc/kdenlivedoc.h"
#include "filewatcher.hpp"
#include "jobs/audiothumbjob.hpp"
#include "jobs/jobmanager.h"
#include "jobs/loadjob.hpp"
#include "jobs/thumbjob.hpp"
#include "jobs/cachejob.hpp"
#include "kdenlivesettings.h"
#include "macros.hpp"
#include "profiles/profilemodel.hpp"
...
...
@@ -729,10 +724,7 @@ bool ProjectItemModel::requestAddBinClip(QString &id, const QDomElement &descrip
ProjectClip
::
construct
(
id
,
description
,
m_blankThumb
,
std
::
static_pointer_cast
<
ProjectItemModel
>
(
shared_from_this
()));
bool
res
=
addItem
(
new_clip
,
parentId
,
undo
,
redo
);
if
(
res
)
{
ClipLoadTask
::
start
({
ObjectType
::
BinClip
,
id
.
toInt
()},
description
,
false
,
-
1
,
-
1
,
this
);
//int loadJob = emit pCore->jobManager()->startJob<LoadJob>({id}, -1, QString(), description, std::bind(readyCallBack, id));
int
loadJob
=
-
1
;
//emit pCore->jobManager()->startJob<ThumbJob>({id}, loadJob, QString(), 0, true);
ClipLoadTask
::
start
({
ObjectType
::
BinClip
,
id
.
toInt
()},
description
,
false
,
-
1
,
-
1
,
this
,
false
,
std
::
bind
(
readyCallBack
,
id
));
}
return
res
;
}
...
...
@@ -763,10 +755,6 @@ bool ProjectItemModel::requestAddBinClip(QString &id, const std::shared_ptr<Mlt:
bool
res
=
addItem
(
new_clip
,
parentId
,
undo
,
redo
);
if
(
res
)
{
new_clip
->
importEffects
(
producer
);
if
(
new_clip
->
statusReady
()
||
new_clip
->
sourceExists
())
{
int
blocking
=
pCore
->
jobManager
()
->
getBlockingJobId
(
id
,
AbstractClipJob
::
LOADJOB
);
//emit pCore->jobManager()->startJob<ThumbJob>({id}, blocking, QString(), -1, true);
}
}
return
res
;
}
...
...
@@ -788,10 +776,6 @@ bool ProjectItemModel::requestAddBinSubClip(QString &id, int in, int out, const
std
::
shared_ptr
<
ProjectSubClip
>
new_clip
=
ProjectSubClip
::
construct
(
id
,
clip
,
std
::
static_pointer_cast
<
ProjectItemModel
>
(
shared_from_this
()),
in
,
out
,
tc
,
zoneProperties
);
bool
res
=
addItem
(
new_clip
,
subId
,
undo
,
redo
);
if
(
res
)
{
int
parentJob
=
pCore
->
jobManager
()
->
getBlockingJobId
(
subId
,
AbstractClipJob
::
LOADJOB
);
//emit pCore->jobManager()->startJob<ThumbJob>({id}, parentJob, QString(), -1, true);
}
return
res
;
}
bool
ProjectItemModel
::
requestAddBinSubClip
(
QString
&
id
,
int
in
,
int
out
,
const
QMap
<
QString
,
QString
>
zoneProperties
,
const
QString
&
parentId
)
...
...
src/bin/projectsubclip.cpp
View file @
83003d02
...
...
@@ -26,8 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "doc/kdenlivedoc.h"
#include "doc/docundostack.hpp"
#include "bincommands.h"
#include "jobs/jobmanager.h"
#include "jobs/cachejob.hpp"
#include "jobs/cachetask.h"
#include "jobs/cliploadtask.h"
#include "utils/thumbnailcache.hpp"
...
...
@@ -209,10 +208,7 @@ void ProjectSubClip::getThumbFromPercent(int percent)
setThumbnail
(
ThumbnailCache
::
get
()
->
getThumbnail
(
m_parentClipId
,
m_inPoint
+
framePos
));
}
else
{
// Generate percent thumbs
int
id
;
if
(
!
pCore
->
jobManager
()
->
hasPendingJob
(
m_parentClipId
,
AbstractClipJob
::
CACHEJOB
,
&
id
))
{
emit
pCore
->
jobManager
()
->
startJob
<
CacheJob
>
({
m_parentClipId
},
-
1
,
QString
(),
30
,
m_inPoint
,
m_outPoint
);
}
CacheTask
::
start
({
ObjectType
::
BinClip
,
m_parentClipId
.
toInt
()},
30
,
m_inPoint
,
m_outPoint
,
this
);
}
}
...
...
src/core.cpp
View file @
83003d02
...
...
@@ -14,7 +14,6 @@ the Free Software Foundation, either version 3 of the License, or
#include "capture/mediacapture.h"
#include "doc/docundostack.hpp"
#include "doc/kdenlivedoc.h"
#include "jobs/jobmanager.h"
#include "kdenlive_debug.h"
#include "kdenlivesettings.h"
#include "library/librarywidget.h"
...
...
@@ -111,8 +110,6 @@ bool Core::build(bool testMode)
}
m_self
->
m_projectItemModel
=
ProjectItemModel
::
construct
();
// Job manager must be created before bin to correctly connect
m_self
->
m_jobManager
.
reset
(
new
JobManager
(
m_self
.
get
()));
return
true
;
}
...
...
@@ -302,11 +299,6 @@ std::shared_ptr<SubtitleModel> Core::getSubtitleModel(bool enforce)
return
nullptr
;
}
std
::
shared_ptr
<
JobManager
>
Core
::
jobManager
()
{
return
m_jobManager
;
}
LibraryWidget
*
Core
::
library
()
{
return
m_library
;
...
...
src/core.h
View file @
83003d02
...
...
@@ -30,7 +30,6 @@ the Free Software Foundation, either version 3 of the License, or
class
Bin
;
class
DocUndoStack
;
class
EffectStackModel
;
class
JobManager
;
class
KdenliveDoc
;
class
LibraryWidget
;
class
MainWindow
;
...
...
@@ -116,8 +115,6 @@ public:
void
selectTimelineItem
(
int
id
);
/** @brief Returns a pointer to the model of the project bin. */
std
::
shared_ptr
<
ProjectItemModel
>
projectItemModel
();
/** @brief Returns a pointer to the job manager. Please do not store it. */
std
::
shared_ptr
<
JobManager
>
jobManager
();
/** @brief Returns a pointer to the library. */
LibraryWidget
*
library
();
/** @brief Returns a pointer to the subtitle edit. */
...
...
@@ -265,7 +262,6 @@ private:
ProjectManager
*
m_projectManager
{
nullptr
};
MonitorManager
*
m_monitorManager
{
nullptr
};
std
::
shared_ptr
<
ProjectItemModel
>
m_projectItemModel
;
std
::
shared_ptr
<
JobManager
>
m_jobManager
;
Bin
*
m_binWidget
{
nullptr
};
LibraryWidget
*
m_library
{
nullptr
};
SubtitleEdit
*
m_subtitleWidget
{
nullptr
};
...
...
src/doc/kdenlivedoc.cpp
View file @
83003d02
...
...
@@ -32,7 +32,6 @@
#include "documentvalidator.h"
#include "docundostack.hpp"
#include "effects/effectsrepository.hpp"
#include "jobs/jobmanager.h"
#include "kdenlivesettings.h"
#include "mainwindow.h"
#include "mltcontroller/clipcontroller.h"
...
...
@@ -1389,7 +1388,7 @@ void KdenliveDoc::loadDocumentProperties()
void
KdenliveDoc
::
updateProjectProfile
(
bool
reloadProducers
,
bool
reloadThumbs
)
{
pCore
->
job
Manager
()
->
slotCancelJobs
();
pCore
->
task
Manager
.
slotCancelJobs
();
double
fps
=
pCore
->
getCurrentFps
();
double
fpsChanged
=
m_timecode
.
fps
()
/
fps
;
m_timecode
.
setFormat
(
fps
);
...
...
@@ -1409,7 +1408,7 @@ void KdenliveDoc::resetProfile(bool reloadThumbs)
void
KdenliveDoc
::
slotSwitchProfile
(
const
QString
&
profile_path
,
bool
reloadThumbs
)
{
// Discard all current jobs
pCore
->
job
Manager
()
->
slotCancelJobs
();
pCore
->
task
Manager
.
slotCancelJobs
();
pCore
->
setCurrentProfile
(
profile_path
);
updateProjectProfile
(
true
,
reloadThumbs
);
// In case we only have one clip in timeline,
...
...
@@ -1475,7 +1474,7 @@ void KdenliveDoc::switchProfile(std::unique_ptr<ProfileParam> &profile, const QS
switch
(
answer
)
{
case
KMessageBox
::
Yes
:
// Discard all current jobs
pCore
->
job
Manager
()
->
slotCancelJobs
();
pCore
->
task
Manager
.
slotCancelJobs
();
KdenliveSettings
::
setDefault_profile
(
profile
->
path
());
pCore
->
setCurrentProfile
(
profile
->
path
());
updateProjectProfile
(
true
);
...
...
@@ -1511,7 +1510,7 @@ void KdenliveDoc::switchProfile(std::unique_ptr<ProfileParam> &profile, const QS
.
arg
(
QString
::
number
(
double
(
profile
->
m_frame_rate_num
)
/
profile
->
m_frame_rate_den
,
'f'
,
2
));
QString
profilePath
=
ProfileRepository
::
get
()
->
saveProfile
(
profile
.
get
());
// Discard all current jobs
pCore
->
job
Manager
()
->
slotCancelJobs
();
pCore
->
task
Manager
.
slotCancelJobs
();
pCore
->
setCurrentProfile
(
profilePath
);
updateProjectProfile
(
true
);
emit
docModified
(
true
);
...
...
src/jobs/CMakeLists.txt
View file @
83003d02
set
(
kdenlive_SRCS
${
kdenlive_SRCS
}
jobs/abstractclipjob.cpp
jobs/audiothumbjob.cpp
jobs/abstracttask.cpp
jobs/taskmanager.cpp
jobs/audiolevelstask.cpp
...
...
@@ -11,14 +10,7 @@ set(kdenlive_SRCS
jobs/speedtask.cpp
jobs/transcodetask.cpp
jobs/filtertask.cpp
jobs/jobmanager.cpp
jobs/cachejob.cpp
jobs/loadjob.cpp
jobs/meltjob.cpp
jobs/scenesplitjob.cpp
jobs/thumbjob.cpp
jobs/transcodeclipjob.cpp
jobs/cutclipjob.cpp
jobs/filterclipjob.cpp
jobs/proxyclipjob.cpp
jobs/cachetask.cpp
#jobs/scenesplitjob.cpp
jobs/cuttask.cpp
PARENT_SCOPE
)
src/jobs/cachetask.cpp
0 → 100644
View file @
83003d02
/*
Copyright (C) 2021 Jean-Baptiste Mardelle <jb@kdenlive.org>
This file is part of Kdenlive. See www.kdenlive.org.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License or (at your option) version 3 or any later version
accepted by the membership of KDE e.V. (or its successor approved
by the membership of KDE e.V.), which shall act as a proxy
defined in Section 14 of version 3 of the license.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "cachetask.h"
#include "core.h"
#include "bin/projectitemmodel.h"
#include "bin/projectclip.h"
#include "kdenlivesettings.h"
#include "doc/kthumb.h"
#include "utils/thumbnailcache.hpp"
#include "xml/xml.hpp"
#include <QString>
#include <QImage>
#include <QFile>
#include <QtMath>
#include <klocalizedstring.h>
#include <set>
CacheTask
::
CacheTask
(
const
ObjectId
&
owner
,
int
thumbsCount
,
int
in
,
int
out
,
QObject
*
object
)
:
AbstractTask
(
owner
,
AbstractTask
::
CACHEJOB
,
object
)
,
m_fullWidth
(
qFuzzyCompare
(
pCore
->
getCurrentSar
(),
1.0
)
?
0
:
int
(
pCore
->
thumbProfile
()
->
height
()
*
pCore
->
getCurrentDar
()
+
0.5
))
,
m_thumbsCount
(
thumbsCount
)
,
m_in
(
in
)
,
m_out
(
out
)
{
if
(
m_fullWidth
%
2
>
0
)
{
m_fullWidth
++
;
}
}
CacheTask
::~
CacheTask
()
{
}
void
CacheTask
::
start
(
const
ObjectId
&
owner
,
int
thumbsCount
,
int
in
,
int
out
,
QObject
*
object
,
bool
force
)
{
CacheTask
*
task
=
new
CacheTask
(
owner
,
thumbsCount
,
in
,
out
,
object
);
if
(
pCore
->
taskManager
.
hasPendingJob
(
owner
,
AbstractTask
::
CACHEJOB
))
{
delete
task
;
task
=
0
;
}
if
(
task
)
{
// Otherwise, start a new audio levels generation thread.
task
->
m_isForce
=
force
;
pCore
->
taskManager
.
startTask
(
owner
.
second
,
task
);
}
}
void
CacheTask
::
generateThumbnail
(
std
::
shared_ptr
<
ProjectClip
>
binClip
)
{
// Fetch thumbnail
if
(
binClip
->
clipType
()
!=
ClipType
::
Audio
)
{
std
::
shared_ptr
<
Mlt
::
Producer
>
thumbProd
(
nullptr
);
int
duration
=
m_out
>
0
?
m_out
-
m_in
:
binClip
->
getFramePlaytime
();
std
::
set
<
int
>
frames
;
int
steps
=
qCeil
(
qMax
(
pCore
->
getCurrentFps
(),
double
(
duration
)
/
m_thumbsCount
));
int
pos
=
m_in
;
for
(
int
i
=
1
;
i
<=
m_thumbsCount
&&
pos
<=
m_in
+
duration
;
++
i
)
{
frames
.
insert
(
pos
);
pos
=
m_in
+
(
steps
*
i
);
}
int
size
=
int
(
frames
.
size
());
int
count
=
0
;
const
QString
clipId
=
QString
::
number
(
m_owner
.
second
);
for
(
int
i
:
frames
)
{
m_progress
=
100
*
count
/
size
;
QMetaObject
::
invokeMethod
(
m_object
,
"updateJobProgress"
);
count
++
;
if
(
m_isCanceled
)
{
break
;
}
if
(
ThumbnailCache
::
get
()
->
hasThumbnail
(
clipId
,
i
))
{
continue
;
}
if
(
thumbProd
==
nullptr
)
{
thumbProd
=
binClip
->
thumbProducer
();
}
if
(
thumbProd
==
nullptr
)
{
// Thumb producer not available
break
;
}
thumbProd
->
seek
(
i
);
QScopedPointer
<
Mlt
::
Frame
>
frame
(
thumbProd
->
get_frame
());
frame
->
set
(
"deinterlace_method"
,
"onefield"
);
frame
->
set
(
"top_field_first"
,
-
1
);
frame
->
set
(
"rescale.interp"
,
"nearest"
);
if
(
frame
!=
nullptr
&&
frame
->
is_valid
())
{
QImage
result
=
KThumb
::
getFrame
(
frame
.
data
(),
0
,
0
,
m_fullWidth
);
if
(
!
result
.
isNull
())
{
qDebug
()
<<
"==== CACHING FRAME: "
<<
i
;
ThumbnailCache
::
get
()
->
storeThumbnail
(
clipId
,
i
,
result
,
true
);
}
}
}
}
}
void
CacheTask
::
run
()
{
if
(
!
m_isCanceled
)
{
auto
binClip
=
pCore
->
projectItemModel
()
->
getClipByBinID
(
QString
::
number
(
m_owner
.
second
));
if
(
binClip
)
{
generateThumbnail
(
binClip
);
}
}
pCore
->
taskManager
.
taskDone
(
m_owner
.
second
,
this
);
return
;
}
src/jobs/cachetask.h
0 → 100644
View file @
83003d02
/*
Copyright (C) 2021 Jean-Baptiste Mardelle <jb@kdenlive.org>
This file is part of Kdenlive. See www.kdenlive.org.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License or (at your option) version 3 or any later version
accepted by the membership of KDE e.V. (or its successor approved
by the membership of KDE e.V.), which shall act as a proxy
defined in Section 14 of version 3 of the license.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CACHETASK_H
#define CACHETASK_H
#include "definitions.h"
#include "abstracttask.h"
#include <mlt++/MltProducer.h>
#include <mlt++/MltProfile.h>
#include <QRunnable>
#include <QDomElement>
#include <QObject>
#include <QList>
class
ProjectClip
;
class
CacheTask
:
public
AbstractTask
{
public:
CacheTask
(
const
ObjectId
&
owner
,
int
thumbsCount
,
int
in
,
int
out
,
QObject
*
object
);
virtual
~
CacheTask
();
static
void
start
(
const
ObjectId
&
owner
,
int
thumbsCount
=
30
,
int
in
=
0
,
int
out
=
0
,
QObject
*
object
=
nullptr
,
bool
force
=
false
);
protected:
void
run
()
override
;
private:
int
m_fullWidth
;
int
m_thumbsCount
;
int
m_in
;
int
m_out
;
bool
m_thumbOnly
;
std
::
function
<
void
()
>
m_readyCallBack
;
QString
m_errorMessage
;
void
generateThumbnail
(
std
::
shared_ptr
<
ProjectClip
>
binClip
);
};
#endif // CLIPLOADTASK_H
src/jobs/cutclipjob.cpp
View file @
83003d02
...
...
@@ -69,7 +69,7 @@ int CutClipJob::prepareJob(const std::shared_ptr<JobManager> &ptr, const std::ve
auto
binClip
=
pCore
->
projectItemModel
()
->
getClipByBinID
(
mainId
);
ClipType
::
ProducerType
type
=
binClip
->
clipType
();
if
(
type
!=
ClipType
::
AV
&&
type
!=
ClipType
::
Audio
&&
type
!=
ClipType
::
Video
)
{
//m_errorMessage.prepend(i18n("Cannot extract zone for this clip type."));
//m_errorMessage.pre
pCore->getCurrentFps())
pend(i18n("Cannot extract zone for this clip type."));
return
-
1
;
}
if
(
KdenliveSettings
::
ffmpegpath
().
isEmpty
())
{
...
...
src/jobs/cuttask.cpp
0 → 100644
View file @
83003d02
/***************************************************************************
* *
* Copyright (C) 2021 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "cuttask.h"
#include "bin/bin.h"
#include "mainwindow.h"
#include "bin/projectclip.h"
#include "bin/projectfolder.h"
#include "ui_cutjobdialog_ui.h"
#include "bin/projectitemmodel.h"
#include "profiles/profilemodel.hpp"
#include "core.h"
#include "kdenlive_debug.h"
#include "kdenlivesettings.h"
#include "macros.hpp"
#include "xml/xml.hpp"
#include <QThread>
#include <QProcess>
#include <KIO/RenameDialog>
#include <KLineEdit>
#include <klocalizedstring.h>
CutTask
::
CutTask
(
const
ObjectId
&
owner
,
const
QString
&
destination
,
const
QStringList
encodingParams
,
int
in
,
int
out
,
bool
addToProject
,
QObject
*
object
)
:
AbstractTask
(
owner
,
AbstractTask
::
CUTJOB
,
object
)
,
m_inPoint
(
GenTime
(
in
,
pCore
->
getCurrentFps
()))
,
m_outPoint
(
GenTime
(
out
,
pCore
->
getCurrentFps
()))
,
m_destination
(
destination
)
,
m_encodingParams
(
encodingParams
)