Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
dee74405
Commit
dee74405
authored
Nov 01, 2015
by
Timothy Gu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vf_boxblur: Templatize blur{8,16}
Reviewed-by:
Michael Niedermayer
<
michael@niedermayer.cc
>
parent
c03044c8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
66 deletions
+44
-66
vf_boxblur.c
libavfilter/vf_boxblur.c
+44
-66
No files found.
libavfilter/vf_boxblur.c
View file @
dee74405
...
@@ -204,10 +204,7 @@ static int config_input(AVFilterLink *inlink)
...
@@ -204,10 +204,7 @@ static int config_input(AVFilterLink *inlink)
return
0
;
return
0
;
}
}
static
inline
void
blur8
(
uint8_t
*
dst
,
int
dst_step
,
const
uint8_t
*
src
,
int
src_step
,
/* Naive boxblur would sum source pixels from x-radius .. x+radius
int
len
,
int
radius
)
{
/* Naive boxblur would sum source pixels from x-radius .. x+radius
* for destination pixel x. That would be O(radius*width).
* for destination pixel x. That would be O(radius*width).
* If you now look at what source pixels represent 2 consecutive
* If you now look at what source pixels represent 2 consecutive
* output pixels, then you see they are almost identical and only
* output pixels, then you see they are almost identical and only
...
@@ -221,58 +218,39 @@ static inline void blur8(uint8_t *dst, int dst_step, const uint8_t *src, int src
...
@@ -221,58 +218,39 @@ static inline void blur8(uint8_t *dst, int dst_step, const uint8_t *src, int src
* and subtracting 1 input pixel.
* and subtracting 1 input pixel.
* The following code adopts this faster variant.
* The following code adopts this faster variant.
*/
*/
const
int
length
=
radius
*
2
+
1
;
#define BLUR(type, depth) \
const
int
inv
=
((
1
<<
16
)
+
length
/
2
)
/
length
;
static inline void blur ## depth(type *dst, int dst_step, const type *src, \
int
x
,
sum
=
src
[
radius
*
src_step
];
int src_step, int len, int radius) \
{ \
for
(
x
=
0
;
x
<
radius
;
x
++
)
const int length = radius*2 + 1; \
sum
+=
src
[
x
*
src_step
]
<<
1
;
const int inv = ((1<<16) + length/2)/length; \
int x, sum = src[radius*src_step]; \
sum
=
sum
*
inv
+
(
1
<<
15
);
\
for (x = 0; x < radius; x++) \
for
(
x
=
0
;
x
<=
radius
;
x
++
)
{
sum += src[x*src_step]<<1; \
sum
+=
(
src
[(
radius
+
x
)
*
src_step
]
-
src
[(
radius
-
x
)
*
src_step
])
*
inv
;
\
dst
[
x
*
dst_step
]
=
sum
>>
16
;
sum = sum*inv + (1<<15); \
}
\
for (x = 0; x <= radius; x++) { \
for
(;
x
<
len
-
radius
;
x
++
)
{
sum += (src[(radius+x)*src_step] - src[(radius-x)*src_step])*inv; \
sum
+=
(
src
[(
radius
+
x
)
*
src_step
]
-
src
[(
x
-
radius
-
1
)
*
src_step
])
*
inv
;
dst[x*dst_step] = sum>>16; \
dst
[
x
*
dst_step
]
=
sum
>>
16
;
} \
}
\
for (; x < len-radius; x++) { \
for
(;
x
<
len
;
x
++
)
{
sum += (src[(radius+x)*src_step] - src[(x-radius-1)*src_step])*inv; \
sum
+=
(
src
[(
2
*
len
-
radius
-
x
-
1
)
*
src_step
]
-
src
[(
x
-
radius
-
1
)
*
src_step
])
*
inv
;
dst[x*dst_step] = sum >>16; \
dst
[
x
*
dst_step
]
=
sum
>>
16
;
} \
}
\
for (; x < len; x++) { \
sum += (src[(2*len-radius-x-1)*src_step] - src[(x-radius-1)*src_step])*inv; \
dst[x*dst_step] = sum>>16; \
} \
}
}
static
inline
void
blur16
(
uint16_t
*
dst
,
int
dst_step
,
const
uint16_t
*
src
,
int
src_step
,
BLUR
(
uint8_t
,
8
)
int
len
,
int
radius
)
BLUR
(
uint16_t
,
16
)
{
const
int
length
=
radius
*
2
+
1
;
const
int
inv
=
((
1
<<
16
)
+
length
/
2
)
/
length
;
int
x
,
sum
=
src
[
radius
*
src_step
];
for
(
x
=
0
;
x
<
radius
;
x
++
)
sum
+=
src
[
x
*
src_step
]
<<
1
;
sum
=
sum
*
inv
+
(
1
<<
15
);
for
(
x
=
0
;
x
<=
radius
;
x
++
)
{
sum
+=
(
src
[(
radius
+
x
)
*
src_step
]
-
src
[(
radius
-
x
)
*
src_step
])
*
inv
;
dst
[
x
*
dst_step
]
=
sum
>>
16
;
}
for
(;
x
<
len
-
radius
;
x
++
)
{
#undef BLUR
sum
+=
(
src
[(
radius
+
x
)
*
src_step
]
-
src
[(
x
-
radius
-
1
)
*
src_step
])
*
inv
;
dst
[
x
*
dst_step
]
=
sum
>>
16
;
}
for
(;
x
<
len
;
x
++
)
{
sum
+=
(
src
[(
2
*
len
-
radius
-
x
-
1
)
*
src_step
]
-
src
[(
x
-
radius
-
1
)
*
src_step
])
*
inv
;
dst
[
x
*
dst_step
]
=
sum
>>
16
;
}
}
static
inline
void
blur
(
uint8_t
*
dst
,
int
dst_step
,
const
uint8_t
*
src
,
int
src_step
,
static
inline
void
blur
(
uint8_t
*
dst
,
int
dst_step
,
const
uint8_t
*
src
,
int
src_step
,
int
len
,
int
radius
,
int
pixsize
)
int
len
,
int
radius
,
int
pixsize
)
...
...
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