Skip to content
GitLab
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
42f21317
Commit
42f21317
authored
Apr 09, 2020
by
Jean-Baptiste Mardelle
Browse files
Fix marker dialog thumbnails with movit.
Fixes
#618
parent
8be5b547
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/bin/projectclip.cpp
View file @
42f21317
...
...
@@ -80,7 +80,6 @@ RTTR_REGISTRATION
ProjectClip
::
ProjectClip
(
const
QString
&
id
,
const
QIcon
&
thumb
,
const
std
::
shared_ptr
<
ProjectItemModel
>
&
model
,
std
::
shared_ptr
<
Mlt
::
Producer
>
producer
)
:
AbstractProjectItem
(
AbstractProjectItem
::
ClipItem
,
id
,
model
)
,
ClipController
(
id
,
std
::
move
(
producer
))
,
m_thumbsProducer
(
nullptr
)
{
m_markerModel
=
std
::
make_shared
<
MarkerListModel
>
(
id
,
pCore
->
projectManager
()
->
undoStack
());
m_clipStatus
=
StatusReady
;
...
...
@@ -128,7 +127,6 @@ void ProjectClip::importEffects(const std::shared_ptr<Mlt::Producer> &producer)
ProjectClip
::
ProjectClip
(
const
QString
&
id
,
const
QDomElement
&
description
,
const
QIcon
&
thumb
,
const
std
::
shared_ptr
<
ProjectItemModel
>
&
model
)
:
AbstractProjectItem
(
AbstractProjectItem
::
ClipItem
,
id
,
model
)
,
ClipController
(
id
)
,
m_thumbsProducer
(
nullptr
)
{
m_clipStatus
=
StatusWaiting
;
m_thumbnail
=
thumb
;
...
...
@@ -526,8 +524,6 @@ std::shared_ptr<Mlt::Producer> ProjectClip::thumbProducer()
if
(
KdenliveSettings
::
gpu_accel
())
{
// TODO: when the original producer changes, we must reload this thumb producer
m_thumbsProducer
=
softClone
(
ClipController
::
getPassPropertiesList
());
Mlt
::
Filter
converter
(
*
prod
->
profile
(),
"avcolor_space"
);
m_thumbsProducer
->
attach
(
converter
);
}
else
{
QString
mltService
=
m_masterProducer
->
get
(
"mlt_service"
);
const
QString
mltResource
=
m_masterProducer
->
get
(
"resource"
);
...
...
@@ -827,7 +823,11 @@ std::shared_ptr<Mlt::Producer> ProjectClip::softClone(const char *list)
{
QString
service
=
QString
::
fromLatin1
(
m_masterProducer
->
get
(
"mlt_service"
));
QString
resource
=
QString
::
fromUtf8
(
m_masterProducer
->
get
(
"resource"
));
std
::
shared_ptr
<
Mlt
::
Producer
>
clone
(
new
Mlt
::
Producer
(
*
m_masterProducer
->
profile
(),
service
.
toUtf8
().
constData
(),
resource
.
toUtf8
().
constData
()));
std
::
shared_ptr
<
Mlt
::
Producer
>
clone
(
new
Mlt
::
Producer
(
*
pCore
->
thumbProfile
(),
service
.
toUtf8
().
constData
(),
resource
.
toUtf8
().
constData
()));
Mlt
::
Filter
scaler
(
*
pCore
->
thumbProfile
(),
"swscale"
);
Mlt
::
Filter
converter
(
pCore
->
getCurrentProfile
()
->
profile
(),
"avcolor_space"
);
clone
->
attach
(
scaler
);
clone
->
attach
(
converter
);
Mlt
::
Properties
original
(
m_masterProducer
->
get_properties
());
Mlt
::
Properties
cloneProps
(
clone
->
get_properties
());
cloneProps
.
pass_list
(
original
,
list
);
...
...
src/bin/projectclip.h
View file @
42f21317
...
...
@@ -150,7 +150,7 @@ public:
bool
isReady
()
const
;
/** @brief Returns this clip's producer. */
std
::
shared_ptr
<
Mlt
::
Producer
>
thumbProducer
();
std
::
shared_ptr
<
Mlt
::
Producer
>
thumbProducer
()
override
;
/** @brief Recursively disable/enable bin effects. */
void
setBinEffectsEnabled
(
bool
enabled
)
override
;
...
...
@@ -260,7 +260,6 @@ public slots:
private:
/** @brief Generate and store file hash if not available. */
const
QString
getFileHash
();
std
::
shared_ptr
<
Mlt
::
Producer
>
m_thumbsProducer
;
QMutex
m_producerMutex
;
QMutex
m_thumbMutex
;
QFuture
<
void
>
m_thumbThread
;
...
...
src/dialogs/markerdialog.cpp
View file @
42f21317
...
...
@@ -34,7 +34,6 @@
MarkerDialog
::
MarkerDialog
(
ClipController
*
clip
,
const
CommentedTime
&
t
,
const
Timecode
&
tc
,
const
QString
&
caption
,
QWidget
*
parent
)
:
QDialog
(
parent
)
,
m_clip
(
clip
)
,
m_dar
(
4.0
/
3.0
)
{
setFont
(
QFontDatabase
::
systemFont
(
QFontDatabase
::
SmallestReadableFont
));
setupUi
(
this
);
...
...
@@ -55,25 +54,24 @@ MarkerDialog::MarkerDialog(ClipController *clip, const CommentedTime &t, const T
if
(
m_clip
!=
nullptr
)
{
m_in
->
setRange
(
0
,
m_clip
->
getFramePlaytime
());
m_previewTimer
->
setInterval
(
5
00
);
m_previewTimer
->
setInterval
(
1
00
);
connect
(
m_previewTimer
,
&
QTimer
::
timeout
,
this
,
&
MarkerDialog
::
slotUpdateThumb
);
m_dar
=
pCore
->
getCurrentDar
();
int
width
=
Kdenlive
::
DefaultThumbHeight
*
m_dar
;
QPixmap
p
(
width
,
Kdenlive
::
DefaultThumbHeight
);
int
width
=
200
*
pCore
->
getCurrentDar
();
QPixmap
p
(
width
,
200
);
p
.
fill
(
Qt
::
transparent
);
switch
(
m_clip
->
clipType
())
{
case
ClipType
::
Video
:
case
ClipType
::
AV
:
case
ClipType
::
SlideShow
:
case
ClipType
::
Playlist
:
m_previewTimer
->
start
(
);
QTimer
::
singleShot
(
0
,
this
,
&
MarkerDialog
::
slotUpdateThumb
);
connect
(
this
,
&
MarkerDialog
::
updateThumb
,
m_previewTimer
,
static_cast
<
void
(
QTimer
::*
)()
>
(
&
QTimer
::
start
));
break
;
case
ClipType
::
Image
:
case
ClipType
::
Text
:
case
ClipType
::
QText
:
case
ClipType
::
Color
:
m_previewTimer
->
start
(
);
QTimer
::
singleShot
(
0
,
this
,
&
MarkerDialog
::
slotUpdateThumb
);
// p = m_clip->pixmap(m_in->getValue(), width, height);
break
;
// UNKNOWN, AUDIO, VIRTUAL:
...
...
@@ -82,8 +80,7 @@ MarkerDialog::MarkerDialog(ClipController *clip, const CommentedTime &t, const T
}
if
(
!
p
.
isNull
())
{
clip_thumb
->
setFixedWidth
(
p
.
width
());
clip_thumb
->
setFixedHeight
(
p
.
height
());
clip_thumb
->
setScaledContents
(
true
);
clip_thumb
->
setPixmap
(
p
);
}
connect
(
m_in
,
&
TimecodeDisplay
::
timeCodeEditingFinished
,
this
,
&
MarkerDialog
::
updateThumb
);
...
...
@@ -107,11 +104,9 @@ void MarkerDialog::slotUpdateThumb()
{
m_previewTimer
->
stop
();
int
pos
=
m_in
->
getValue
();
int
width
=
Kdenlive
::
DefaultThumbHeight
*
m_dar
;
/*m_image = KThumb::getFrame(m_producer, pos, swidth, width, 100);
const QPixmap p = QPixmap::fromImage(m_image);*/
const
QPixmap
p
=
m_clip
->
pixmap
(
pos
,
width
,
Kdenlive
::
DefaultThumbHeight
);
const
QPixmap
p
=
m_clip
->
pixmap
(
pos
);
if
(
!
p
.
isNull
())
{
clip_thumb
->
setFixedSize
(
p
.
width
(),
p
.
height
());
clip_thumb
->
setPixmap
(
p
);
}
else
{
qCDebug
(
KDENLIVE_LOG
)
<<
"!!!!!!!!!!! ERROR CREATING THUMB"
;
...
...
src/dialogs/markerdialog.h
View file @
42f21317
...
...
@@ -54,7 +54,6 @@ private slots:
private:
ClipController
*
m_clip
;
TimecodeDisplay
*
m_in
;
double
m_dar
;
QTimer
*
m_previewTimer
;
signals:
...
...
src/mltcontroller/clipcontroller.cpp
View file @
42f21317
...
...
@@ -29,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include
"lib/audio/audioStreamInfo.h"
#include
"profiles/profilemodel.hpp"
#include
"bin/clipcreator.hpp"
#include
"doc/kthumb.h"
#include
"core.h"
#include
"kdenlive_debug.h"
...
...
@@ -51,6 +52,7 @@ ClipController::ClipController(const QString &clipId, const std::shared_ptr<Mlt:
,
m_effectStack
(
producer
?
EffectStackModel
::
construct
(
producer
,
{
ObjectType
::
BinClip
,
clipId
.
toInt
()},
pCore
->
undoStack
())
:
nullptr
)
,
m_hasAudio
(
false
)
,
m_hasVideo
(
false
)
,
m_thumbsProducer
(
nullptr
)
,
m_producerLock
(
QReadWriteLock
::
Recursive
)
,
m_controllerBinId
(
clipId
)
{
...
...
@@ -693,41 +695,21 @@ QPixmap ClipController::pixmap(int framePosition, int width, int height)
{
// TODO refac this should use the new thumb infrastructure
QReadLocker
lock
(
&
m_producerLock
);
m_masterProducer
->
seek
(
framePosition
);
Mlt
::
Frame
*
frame
=
m_masterProducer
->
get_frame
();
if
(
thumbProducer
()
==
nullptr
)
{
return
QPixmap
();
}
m_thumbsProducer
->
seek
(
framePosition
);
QScopedPointer
<
Mlt
::
Frame
>
frame
(
m_thumbsProducer
->
get_frame
());
if
(
frame
==
nullptr
||
!
frame
->
is_valid
())
{
QPixmap
p
(
width
,
height
);
p
.
fill
(
QColor
(
Qt
::
red
).
rgb
());
return
p
;
}
frame
->
set
(
"rescale.interp"
,
"bilinear"
);
frame
->
set
(
"deinterlace_method"
,
"onefield"
);
frame
->
set
(
"top_field_first"
,
-
1
);
if
(
width
==
0
)
{
width
=
m_masterProducer
->
get_int
(
"meta.media.width"
);
if
(
width
==
0
)
{
width
=
m_masterProducer
->
get_int
(
"width"
);
}
}
if
(
height
==
0
)
{
height
=
m_masterProducer
->
get_int
(
"meta.media.height"
);
if
(
height
==
0
)
{
height
=
m_masterProducer
->
get_int
(
"height"
);
}
}
// int ow = frameWidth;
// int oh = height;
mlt_image_format
format
=
mlt_image_rgb24a
;
width
+=
width
%
2
;
height
+=
height
%
2
;
const
uchar
*
imagedata
=
frame
->
get_image
(
format
,
width
,
height
);
QImage
image
(
imagedata
,
width
,
height
,
QImage
::
Format_RGBA8888
);
QPixmap
pixmap
;
pixmap
.
convertFromImage
(
image
);
delete
frame
;
return
pixmap
;
frame
->
set
(
"rescale.interp"
,
"nearest"
);
QImage
img
=
KThumb
::
getFrame
(
frame
.
data
());
return
QPixmap
::
fromImage
(
img
/*.scaled(height, width, Qt::KeepAspectRatio)*/
);
}
void
ClipController
::
setZone
(
const
QPoint
&
zone
)
...
...
src/mltcontroller/clipcontroller.h
View file @
42f21317
...
...
@@ -95,6 +95,9 @@ public:
/** @brief Returns the MLT's producer id */
const
QString
binId
()
const
;
/** @brief Returns this clip's producer. */
virtual
std
::
shared_ptr
<
Mlt
::
Producer
>
thumbProducer
()
=
0
;
/** @brief Returns the clip's duration */
GenTime
getPlaytime
()
const
;
int
getFramePlaytime
()
const
;
...
...
@@ -238,6 +241,7 @@ protected:
bool
m_hasVideo
;
/** @brief Store clip url temporarily while the clip controller has not been created. */
QString
m_temporaryUrl
;
std
::
shared_ptr
<
Mlt
::
Producer
>
m_thumbsProducer
;
private:
/** @brief Mutex to protect the producer properties on read/write */
...
...
src/ui/markerdialog_ui.ui
View file @
42f21317
...
...
@@ -6,8 +6,8 @@
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
386
</width>
<height>
12
6
</height>
<width>
482
</width>
<height>
1
9
2
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
...
...
@@ -79,8 +79,14 @@
</item>
<item
row=
"0"
column=
"0"
rowspan=
"5"
>
<widget
class=
"QLabel"
name=
"clip_thumb"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"MinimumExpanding"
vsizetype=
"Preferred"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"frameShape"
>
<enum>
QFrame::
NoFrame
</enum>
<enum>
QFrame::
Box
</enum>
</property>
<property
name=
"text"
>
<string>
Image preview
</string>
...
...
@@ -101,11 +107,6 @@
<extends>
QComboBox
</extends>
<header>
kcombobox.h
</header>
</customwidget>
<customwidget>
<class>
QLineEdit
</class>
<extends>
QLineEdit
</extends>
<header>
klineedit.h
</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment