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
567cab3b
Commit
567cab3b
authored
Feb 27, 2022
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_amplify: improve performance
parent
a2dbd177
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
13 deletions
+9
-13
vf_amplify.c
libavfilter/vf_amplify.c
+9
-13
No files found.
libavfilter/vf_amplify.c
View file @
567cab3b
...
...
@@ -96,8 +96,7 @@ typedef struct ThreadData {
}
ThreadData
;
#define AMPLIFY_SLICE(type, stype, clip) \
const stype llimit = s->llimit; \
const stype hlimit = s->hlimit; \
const stype limit[2] = { s->llimit, s->hlimit }; \
\
for (int p = 0; p < s->nb_planes; p++) { \
const int slice_start = (s->height[p] * jobnr) / nb_jobs; \
...
...
@@ -116,23 +115,19 @@ typedef struct ThreadData {
for (int y = slice_start; y < slice_end; y++) { \
for (int x = 0; x < s->linesize[p] / sizeof(type); x++) { \
stype src = *(type *)(in[radius]->data[p] + y * in[radius]->linesize[p] + x * sizeof(type));\
float diff, a
vg;
\
float diff, a
bs_diff, avg;
\
stype sum = 0; \
\
for (int i = 0; i < nb_inputs; i++) { \
sum += *(type *)(in[i]->data[p] + y * in[i]->linesize[p] + x * sizeof(type));\
} \
\
avg = sum
/ (float)nb_inputs;
\
avg = sum
* scale;
\
diff = src - avg; \
abs_diff = fabsf(diff); \
\
if (fabsf(diff) < threshold && fabsf(diff) > tolerance) { \
stype amp; \
if (diff < 0) { \
amp = -FFMIN(FFABS(diff * factor), llimit); \
} else { \
amp = FFMIN(FFABS(diff * factor), hlimit); \
} \
if (abs_diff < threshold && abs_diff > tolerance) { \
float amp = copysignf(fminf(abs_diff * factor, limit[diff >= 0]), diff); \
dst[x] = clip(src + amp, depth); \
} else { \
dst[x] = src; \
...
...
@@ -143,8 +138,8 @@ typedef struct ThreadData {
} \
}
#define CLIP8(x, depth) av_clip_uint8(
x
)
#define CLIP16(x, depth) av_clip_uintp2_c(
x
, depth)
#define CLIP8(x, depth) av_clip_uint8(
lrintf(x)
)
#define CLIP16(x, depth) av_clip_uintp2_c(
lrintf(x)
, depth)
#define NOP(x, depth) (x)
static
int
amplify_frame
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
...
...
@@ -157,6 +152,7 @@ static int amplify_frame(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs
const
int
nb_inputs
=
s
->
nb_inputs
;
const
float
threshold
=
s
->
threshold
;
const
float
tolerance
=
s
->
tolerance
;
const
float
scale
=
1
.
f
/
nb_inputs
;
const
float
factor
=
s
->
factor
;
const
int
depth
=
s
->
depth
;
...
...
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