Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Kdenlive
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
259
Issues
259
List
Boards
Labels
Service Desk
Milestones
Merge Requests
14
Merge Requests
14
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Multimedia
Kdenlive
Commits
a2cb2600
Commit
a2cb2600
authored
Dec 09, 2020
by
Jean-Baptiste Mardelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add normalizers to MLT thumbcreator, fixing Kdeinit crash
CCBUG: 430122
parent
2d6f0afe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
14 deletions
+25
-14
thumbnailer/mltpreview.cpp
thumbnailer/mltpreview.cpp
+23
-12
thumbnailer/mltpreview.h
thumbnailer/mltpreview.h
+2
-2
No files found.
thumbnailer/mltpreview.cpp
View file @
a2cb2600
...
...
@@ -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 @
a2cb2600
...
...
@@ -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
Markdown
is supported
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