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
bob
bob.io.video
Commits
54da7712
Commit
54da7712
authored
Oct 19, 2018
by
Amir MOHAMMADI
Browse files
Merge branch 'frame-free-fix' into 'master'
Frame free fix Closes
#12
See merge request
!13
parents
3b63f6c0
fca6f02d
Pipeline
#24447
passed with stages
in 14 minutes and 40 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bob/io/video/cpp/utils.cpp
View file @
54da7712
...
...
@@ -472,10 +472,9 @@ boost::shared_ptr<AVStream> bob::io::video::make_stream(
}
static
void
deallocate_frame
(
AVFrame
*
f
)
{
if
(
f
)
{
if
(
f
->
data
[
0
])
av_free
(
f
->
data
[
0
]);
av_free
(
f
);
}
if
(
f
->
data
[
0
])
av_freep
(
&
f
->
data
[
0
]);
av_frame_unref
(
f
);
av_frame_free
(
&
f
);
}
boost
::
shared_ptr
<
AVFrame
>
...
...
@@ -496,7 +495,7 @@ bob::io::video::make_frame(const std::string& filename,
int
ok
=
av_image_alloc
(
retval
->
data
,
retval
->
linesize
,
codec
->
width
,
codec
->
height
,
codec
->
pix_fmt
,
1
);
if
(
ok
<
0
)
{
av_free
(
retval
);
av_
frame_
free
(
&
retval
);
boost
::
format
m
(
"bob::io::video::av_image_alloc(data, linesize, width=%d, height=%d, 1) failed: cannot allocate frame/picture buffer start reading or writing video file `%s'"
);
m
%
codec
->
width
%
codec
->
height
%
filename
;
throw
std
::
runtime_error
(
m
.
str
());
...
...
@@ -506,7 +505,7 @@ bob::io::video::make_frame(const std::string& filename,
}
static
void
deallocate_empty_frame
(
AVFrame
*
f
)
{
if
(
f
)
av
_free
(
f
);
av_frame
_free
(
&
f
);
}
boost
::
shared_ptr
<
AVFrame
>
bob
::
io
::
video
::
make_empty_frame
(
const
std
::
string
&
filename
)
{
...
...
bob/io/video/test.py
View file @
54da7712
...
...
@@ -92,6 +92,33 @@ def test_video_reader_attributes():
assert
isinstance
(
iv
.
info
,
str
)
def
test_memory_leak
():
import
psutil
import
tempfile
import
gc
from
.
import
reader
from
bob.io.base
import
save
my_video
=
numpy
.
random
.
random_integers
(
0
,
255
,
(
10
,
3
,
256
*
4
,
256
*
4
))
with
tempfile
.
NamedTemporaryFile
(
suffix
=
'.avi'
)
as
f
:
save
(
my_video
.
astype
(
'uint8'
),
f
.
name
)
del
my_video
gc
.
collect
()
for
i
in
range
(
20
):
vd
=
reader
(
f
.
name
)
for
frame
in
vd
:
pass
del
frame
del
vd
gc
.
collect
()
if
i
==
0
:
first
=
psutil
.
virtual_memory
().
used
last
=
psutil
.
virtual_memory
().
used
assert
(
last
-
first
)
/
first
<
0.003
,
"Looks like we have a memory leak!"
def
write_unicode_temp_file
():
prefix
=
'bobtest_straße_'
...
...
conda/meta.yaml
View file @
54da7712
...
...
@@ -58,6 +58,7 @@ test:
-
coverage
-
sphinx
-
sphinx_rtd_theme
-
psutil
about
:
home
:
https://www.idiap.ch/software/bob/
...
...
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