Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
22b985d5
Commit
22b985d5
authored
10 years ago
by
Vittorio Giovara
Browse files
Options
Downloads
Patches
Plain Diff
hqdn3d: check memory allocations and propagate errors
parent
70d246d5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libavfilter/vf_hqdn3d.c
+26
-16
26 additions, 16 deletions
libavfilter/vf_hqdn3d.c
with
26 additions
and
16 deletions
libavfilter/vf_hqdn3d.c
+
26
−
16
View file @
22b985d5
...
@@ -121,11 +121,11 @@ static void denoise_spatial(HQDN3DContext *s,
...
@@ -121,11 +121,11 @@ static void denoise_spatial(HQDN3DContext *s,
}
}
av_always_inline
av_always_inline
static
void
denoise_depth
(
HQDN3DContext
*
s
,
static
int
denoise_depth
(
HQDN3DContext
*
s
,
uint8_t
*
src
,
uint8_t
*
dst
,
uint8_t
*
src
,
uint8_t
*
dst
,
uint16_t
*
line_ant
,
uint16_t
**
frame_ant_ptr
,
uint16_t
*
line_ant
,
uint16_t
**
frame_ant_ptr
,
int
w
,
int
h
,
int
sstride
,
int
dstride
,
int
w
,
int
h
,
int
sstride
,
int
dstride
,
int16_t
*
spatial
,
int16_t
*
temporal
,
int
depth
)
int16_t
*
spatial
,
int16_t
*
temporal
,
int
depth
)
{
{
// FIXME: For 16bit depth, frame_ant could be a pointer to the previous
// FIXME: For 16bit depth, frame_ant could be a pointer to the previous
// filtered frame rather than a separate buffer.
// filtered frame rather than a separate buffer.
...
@@ -134,6 +134,8 @@ static void denoise_depth(HQDN3DContext *s,
...
@@ -134,6 +134,8 @@ static void denoise_depth(HQDN3DContext *s,
if
(
!
frame_ant
)
{
if
(
!
frame_ant
)
{
uint8_t
*
frame_src
=
src
;
uint8_t
*
frame_src
=
src
;
*
frame_ant_ptr
=
frame_ant
=
av_malloc
(
w
*
h
*
sizeof
(
uint16_t
));
*
frame_ant_ptr
=
frame_ant
=
av_malloc
(
w
*
h
*
sizeof
(
uint16_t
));
if
(
!
frame_ant
)
return
AVERROR
(
ENOMEM
);
for
(
y
=
0
;
y
<
h
;
y
++
,
src
+=
sstride
,
frame_ant
+=
w
)
for
(
y
=
0
;
y
<
h
;
y
++
,
src
+=
sstride
,
frame_ant
+=
w
)
for
(
x
=
0
;
x
<
w
;
x
++
)
for
(
x
=
0
;
x
<
w
;
x
++
)
frame_ant
[
x
]
=
LOAD
(
x
);
frame_ant
[
x
]
=
LOAD
(
x
);
...
@@ -148,15 +150,25 @@ static void denoise_depth(HQDN3DContext *s,
...
@@ -148,15 +150,25 @@ static void denoise_depth(HQDN3DContext *s,
denoise_temporal
(
src
,
dst
,
frame_ant
,
denoise_temporal
(
src
,
dst
,
frame_ant
,
w
,
h
,
sstride
,
dstride
,
temporal
,
depth
);
w
,
h
,
sstride
,
dstride
,
temporal
,
depth
);
emms_c
();
emms_c
();
return
0
;
}
}
#define denoise(...) \
#define denoise(...) \
switch (s->depth) {\
do { \
case 8: denoise_depth(__VA_ARGS__, 8); break;\
int ret = AVERROR_INVALIDDATA; \
case 9: denoise_depth(__VA_ARGS__, 9); break;\
switch (s->depth) { \
case 10: denoise_depth(__VA_ARGS__, 10); break;\
case 8: ret = denoise_depth(__VA_ARGS__, 8); break; \
case 16: denoise_depth(__VA_ARGS__, 16); break;\
case 9: ret = denoise_depth(__VA_ARGS__, 9); break; \
}
case 10: ret = denoise_depth(__VA_ARGS__, 10); break; \
case 16: ret = denoise_depth(__VA_ARGS__, 16); break; \
} \
if (ret < 0) { \
av_frame_free(&out); \
if (!direct) \
av_frame_free(&in); \
return ret; \
} \
} while (0)
static
int16_t
*
precalc_coefs
(
double
dist25
,
int
depth
)
static
int16_t
*
precalc_coefs
(
double
dist25
,
int
depth
)
{
{
...
@@ -280,13 +292,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
...
@@ -280,13 +292,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
HQDN3DContext
*
s
=
inlink
->
dst
->
priv
;
HQDN3DContext
*
s
=
inlink
->
dst
->
priv
;
AVFilterLink
*
outlink
=
inlink
->
dst
->
outputs
[
0
];
AVFilterLink
*
outlink
=
inlink
->
dst
->
outputs
[
0
];
AVFrame
*
out
;
AVFrame
*
out
;
int
direct
,
c
;
int
c
,
direct
=
av_frame_is_writable
(
in
)
;
if
(
av_frame_is_writable
(
in
))
{
if
(
direct
)
{
direct
=
1
;
out
=
in
;
out
=
in
;
}
else
{
}
else
{
direct
=
0
;
out
=
ff_get_video_buffer
(
outlink
,
outlink
->
w
,
outlink
->
h
);
out
=
ff_get_video_buffer
(
outlink
,
outlink
->
w
,
outlink
->
h
);
if
(
!
out
)
{
if
(
!
out
)
{
av_frame_free
(
&
in
);
av_frame_free
(
&
in
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment