Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
810c5089
Commit
810c5089
authored
May 02, 2022
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_guided: fix reallocation of memory per every frame's plane processing
parent
17a4237a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
48 deletions
+62
-48
vf_guided.c
libavfilter/vf_guided.c
+62
-48
No files found.
libavfilter/vf_guided.c
View file @
810c5089
...
@@ -59,6 +59,20 @@ typedef struct GuidedContext {
...
@@ -59,6 +59,20 @@ typedef struct GuidedContext {
int
planewidth
[
4
];
int
planewidth
[
4
];
int
planeheight
[
4
];
int
planeheight
[
4
];
float
*
I
;
float
*
II
;
float
*
P
;
float
*
IP
;
float
*
meanI
;
float
*
meanII
;
float
*
meanP
;
float
*
meanIP
;
float
*
A
;
float
*
B
;
float
*
meanA
;
float
*
meanB
;
int
(
*
box_slice
)(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
);
int
(
*
box_slice
)(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
);
}
GuidedContext
;
}
GuidedContext
;
...
@@ -197,38 +211,19 @@ static int guided_##name(AVFilterContext *ctx, GuidedContext *s,
...
@@ -197,38 +211,19 @@ static int guided_##name(AVFilterContext *ctx, GuidedContext *s,
\
\
ThreadData t; \
ThreadData t; \
const int nb_threads = ff_filter_get_nb_threads(ctx); \
const int nb_threads = ff_filter_get_nb_threads(ctx); \
float *I; \
float *I = s->I; \
float *II; \
float *II = s->II; \
float *P; \
float *P = s->P; \
float *IP; \
float *IP = s->IP; \
float *meanI; \
float *meanI = s->meanI; \
float *meanII; \
float *meanII = s->meanII; \
float *meanP; \
float *meanP = s->meanP; \
float *meanIP; \
float *meanIP = s->meanIP; \
float *A; \
float *A = s->A; \
float *B; \
float *B = s->B; \
float *meanA; \
float *meanA = s->meanA; \
float *meanB; \
float *meanB = s->meanB; \
\
I = av_calloc(w * h, sizeof(float)); \
II = av_calloc(w * h, sizeof(float)); \
P = av_calloc(w * h, sizeof(float)); \
IP = av_calloc(w * h, sizeof(float)); \
meanI = av_calloc(w * h, sizeof(float)); \
meanII = av_calloc(w * h, sizeof(float)); \
meanP = av_calloc(w * h, sizeof(float)); \
meanIP = av_calloc(w * h, sizeof(float)); \
\
A = av_calloc(w * h, sizeof(float)); \
B = av_calloc(w * h, sizeof(float)); \
meanA = av_calloc(w * h, sizeof(float)); \
meanB = av_calloc(w * h, sizeof(float)); \
\
\
if (!I || !II || !P || !IP || !meanI || !meanII || !meanP || \
!meanIP || !A || !B || !meanA || !meanB) { \
ret = AVERROR(ENOMEM); \
goto end; \
} \
for (int i = 0;i < h;i++) { \
for (int i = 0;i < h;i++) { \
for (int j = 0;j < w;j++) { \
for (int j = 0;j < w;j++) { \
int x = i * w + j; \
int x = i * w + j; \
...
@@ -280,19 +275,7 @@ static int guided_##name(AVFilterContext *ctx, GuidedContext *s,
...
@@ -280,19 +275,7 @@ static int guided_##name(AVFilterContext *ctx, GuidedContext *s,
meanB[x] * maxval; \
meanB[x] * maxval; \
} \
} \
} \
} \
end: \
\
av_freep(&I); \
av_freep(&II); \
av_freep(&P); \
av_freep(&IP); \
av_freep(&meanI); \
av_freep(&meanII); \
av_freep(&meanP); \
av_freep(&meanIP); \
av_freep(&A); \
av_freep(&B); \
av_freep(&meanA); \
av_freep(&meanB); \
return ret; \
return ret; \
}
}
...
@@ -352,11 +335,10 @@ static int process_frame(FFFrameSync *fs)
...
@@ -352,11 +335,10 @@ static int process_frame(FFFrameSync *fs)
static
int
config_output
(
AVFilterLink
*
outlink
)
static
int
config_output
(
AVFilterLink
*
outlink
)
{
{
AVFilterContext
*
ctx
=
outlink
->
src
;
AVFilterContext
*
ctx
=
outlink
->
src
;
GuidedContext
*
s
=
ctx
->
priv
;
GuidedContext
*
s
=
ctx
->
priv
;
AVFilterLink
*
mainlink
=
ctx
->
inputs
[
0
];
AVFilterLink
*
mainlink
=
ctx
->
inputs
[
0
];
FFFrameSyncIn
*
in
;
FFFrameSyncIn
*
in
;
int
ret
;
int
w
,
h
,
ret
;
if
(
s
->
guidance
==
ON
)
{
if
(
s
->
guidance
==
ON
)
{
if
(
ctx
->
inputs
[
0
]
->
w
!=
ctx
->
inputs
[
1
]
->
w
||
if
(
ctx
->
inputs
[
0
]
->
w
!=
ctx
->
inputs
[
1
]
->
w
||
...
@@ -366,12 +348,30 @@ static int config_output(AVFilterLink *outlink)
...
@@ -366,12 +348,30 @@ static int config_output(AVFilterLink *outlink)
}
}
}
}
outlink
->
w
=
mainlink
->
w
;
outlink
->
w
=
w
=
mainlink
->
w
;
outlink
->
h
=
mainlink
->
h
;
outlink
->
h
=
h
=
mainlink
->
h
;
outlink
->
time_base
=
mainlink
->
time_base
;
outlink
->
time_base
=
mainlink
->
time_base
;
outlink
->
sample_aspect_ratio
=
mainlink
->
sample_aspect_ratio
;
outlink
->
sample_aspect_ratio
=
mainlink
->
sample_aspect_ratio
;
outlink
->
frame_rate
=
mainlink
->
frame_rate
;
outlink
->
frame_rate
=
mainlink
->
frame_rate
;
s
->
I
=
av_calloc
(
w
*
h
,
sizeof
(
*
s
->
I
));
s
->
II
=
av_calloc
(
w
*
h
,
sizeof
(
*
s
->
II
));
s
->
P
=
av_calloc
(
w
*
h
,
sizeof
(
*
s
->
P
));
s
->
IP
=
av_calloc
(
w
*
h
,
sizeof
(
*
s
->
IP
));
s
->
meanI
=
av_calloc
(
w
*
h
,
sizeof
(
*
s
->
meanI
));
s
->
meanII
=
av_calloc
(
w
*
h
,
sizeof
(
*
s
->
meanII
));
s
->
meanP
=
av_calloc
(
w
*
h
,
sizeof
(
*
s
->
meanP
));
s
->
meanIP
=
av_calloc
(
w
*
h
,
sizeof
(
*
s
->
meanIP
));
s
->
A
=
av_calloc
(
w
*
h
,
sizeof
(
*
s
->
A
));
s
->
B
=
av_calloc
(
w
*
h
,
sizeof
(
*
s
->
B
));
s
->
meanA
=
av_calloc
(
w
*
h
,
sizeof
(
*
s
->
meanA
));
s
->
meanB
=
av_calloc
(
w
*
h
,
sizeof
(
*
s
->
meanA
));
if
(
!
s
->
I
||
!
s
->
II
||
!
s
->
P
||
!
s
->
IP
||
!
s
->
meanI
||
!
s
->
meanII
||
!
s
->
meanP
||
!
s
->
meanIP
||
!
s
->
A
||
!
s
->
B
||
!
s
->
meanA
||
!
s
->
meanB
)
return
AVERROR
(
ENOMEM
);
if
(
s
->
guidance
==
OFF
)
if
(
s
->
guidance
==
OFF
)
return
0
;
return
0
;
...
@@ -460,6 +460,20 @@ static av_cold void uninit(AVFilterContext *ctx)
...
@@ -460,6 +460,20 @@ static av_cold void uninit(AVFilterContext *ctx)
GuidedContext
*
s
=
ctx
->
priv
;
GuidedContext
*
s
=
ctx
->
priv
;
if
(
s
->
guidance
==
ON
)
if
(
s
->
guidance
==
ON
)
ff_framesync_uninit
(
&
s
->
fs
);
ff_framesync_uninit
(
&
s
->
fs
);
av_freep
(
&
s
->
I
);
av_freep
(
&
s
->
II
);
av_freep
(
&
s
->
P
);
av_freep
(
&
s
->
IP
);
av_freep
(
&
s
->
meanI
);
av_freep
(
&
s
->
meanII
);
av_freep
(
&
s
->
meanP
);
av_freep
(
&
s
->
meanIP
);
av_freep
(
&
s
->
A
);
av_freep
(
&
s
->
B
);
av_freep
(
&
s
->
meanA
);
av_freep
(
&
s
->
meanB
);
return
;
return
;
}
}
...
...
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