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
a6e04898
Commit
a6e04898
authored
Dec 09, 2020
by
Jean-Baptiste Mardelle
Browse files
Add normalizers to MLT thumbcreator, fixing Kdeinit crash
CCBUG: 430122
parent
9a1da839
Pipeline
#43500
passed with stage
in 10 minutes and 35 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
thumbnailer/mltpreview.cpp
View file @
a6e04898
...
...
@@ -24,7 +24,6 @@
#include <QImage>
#include <QVarLengthArray>
#include <QtGlobal>
#include <QDebug>
extern
"C"
{
...
...
@@ -49,12 +48,10 @@ MltPreview::~MltPreview()
bool
MltPreview
::
create
(
const
QString
&
path
,
int
width
,
int
height
,
QImage
&
img
)
{
auto
*
profile
=
new
Mlt
::
Profile
();
Mlt
::
Producer
*
producer
=
new
Mlt
::
Producer
(
*
profile
,
path
.
toUtf8
().
data
());
std
::
unique_ptr
<
Mlt
::
Profile
>
profile
(
new
Mlt
::
Profile
()
)
;
std
::
shared_ptr
<
Mlt
::
Producer
>
producer
(
new
Mlt
::
Producer
(
*
profile
.
get
()
,
path
.
toUtf8
().
data
())
)
;
if
(
producer
->
is_blank
())
{
delete
producer
;
delete
profile
;
return
false
;
}
int
frame
=
75
;
...
...
@@ -70,6 +67,24 @@ bool MltPreview::create(const QString &path, int width, int height, QImage &img)
wanted_height
=
height
;
wanted_width
=
height
*
ar
;
}
// We don't need audio
producer
->
set
(
"audio_index"
,
-
1
);
// Add normalizers
Mlt
::
Filter
scaler
(
*
profile
.
get
(),
"swscale"
);
Mlt
::
Filter
padder
(
*
profile
.
get
(),
"resize"
);
Mlt
::
Filter
converter
(
*
profile
.
get
(),
"avcolor_space"
);
if
(
scaler
.
is_valid
())
{
producer
->
attach
(
scaler
);
}
if
(
padder
.
is_valid
())
{
producer
->
attach
(
padder
);
}
if
(
converter
.
is_valid
())
{
producer
->
attach
(
converter
);
}
// img = getFrame(producer, frame, width, height);
while
(
variance
<=
40
&&
ct
<
4
)
{
...
...
@@ -78,27 +93,23 @@ bool MltPreview::create(const QString &path, int width, int height, QImage &img)
frame
+=
100
*
ct
;
ct
++
;
}
delete
producer
;
delete
profile
;
return
(
!
img
.
isNull
());
}
QImage
MltPreview
::
getFrame
(
Mlt
::
Producer
*
producer
,
int
framepos
,
int
width
,
int
height
)
QImage
MltPreview
::
getFrame
(
std
::
shared_ptr
<
Mlt
::
Producer
>
producer
,
int
framepos
,
int
width
,
int
height
)
{
QImage
mltImage
(
width
,
height
,
QImage
::
Format_ARGB32
_Premultiplied
);
QImage
mltImage
(
width
,
height
,
QImage
::
Format_ARGB32
);
if
(
producer
==
nullptr
)
{
return
mltImage
;
}
producer
->
seek
(
framepos
);
Mlt
::
Frame
*
frame
=
producer
->
get_frame
();
if
(
frame
==
nullptr
)
{
if
(
frame
==
nullptr
||
!
frame
->
is_valid
()
)
{
return
mltImage
;
}
mlt_image_format
format
=
mlt_image_rgb24a
;
const
uchar
*
imagedata
=
frame
->
get_image
(
format
,
width
,
height
);
if
(
imagedata
!=
nullptr
)
{
memcpy
(
mltImage
.
bits
(),
imagedata
,
width
*
height
*
4
);
...
...
thumbnailer/mltpreview.h
View file @
a6e04898
...
...
@@ -23,7 +23,7 @@
#define MLTPREVIEW_H
#include <kio/thumbcreator.h>
#include <memory>
#include <mlt++/Mlt.h>
#include <QObject>
...
...
@@ -38,7 +38,7 @@ public:
protected:
static
uint
imageVariance
(
const
QImage
&
image
);
QImage
getFrame
(
Mlt
::
Producer
*
producer
,
int
framepos
,
int
width
,
int
height
);
QImage
getFrame
(
std
::
shared_ptr
<
Mlt
::
Producer
>
producer
,
int
framepos
,
int
width
,
int
height
);
};
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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