Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
c73b2889
Commit
c73b2889
authored
Dec 21, 2014
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_boxblur: Support 10bit planar formats
parent
34f103b1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
19 deletions
+68
-19
vf_boxblur.c
libavfilter/vf_boxblur.c
+68
-19
No files found.
libavfilter/vf_boxblur.c
View file @
c73b2889
...
...
@@ -124,6 +124,9 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_YUVJ444P
,
AV_PIX_FMT_YUVJ422P
,
AV_PIX_FMT_YUVJ420P
,
AV_PIX_FMT_YUVJ440P
,
AV_PIX_FMT_GBRP
,
AV_PIX_FMT_YUV444P10
,
AV_PIX_FMT_YUV422P10
,
AV_PIX_FMT_YUV420P10
,
AV_PIX_FMT_YUVA420P10
,
AV_PIX_FMT_GBRP10
,
AV_PIX_FMT_NONE
};
...
...
@@ -142,8 +145,8 @@ static int config_input(AVFilterLink *inlink)
char
*
expr
;
int
ret
;
if
(
!
(
s
->
temp
[
0
]
=
av_malloc
(
FFMAX
(
w
,
h
)))
||
!
(
s
->
temp
[
1
]
=
av_malloc
(
FFMAX
(
w
,
h
))))
if
(
!
(
s
->
temp
[
0
]
=
av_malloc
(
2
*
FFMAX
(
w
,
h
)))
||
!
(
s
->
temp
[
1
]
=
av_malloc
(
2
*
FFMAX
(
w
,
h
))))
return
AVERROR
(
ENOMEM
);
s
->
hsub
=
desc
->
log2_chroma_w
;
...
...
@@ -203,7 +206,7 @@ static int config_input(AVFilterLink *inlink)
return
0
;
}
static
inline
void
blur
(
uint8_t
*
dst
,
int
dst_step
,
const
uint8_t
*
src
,
int
src_step
,
static
inline
void
blur
8
(
uint8_t
*
dst
,
int
dst_step
,
const
uint8_t
*
src
,
int
src_step
,
int
len
,
int
radius
)
{
/* Naive boxblur would sum source pixels from x-radius .. x+radius
...
...
@@ -245,34 +248,77 @@ static inline void blur(uint8_t *dst, int dst_step, const uint8_t *src, int src_
}
}
static
inline
void
blur16
(
uint16_t
*
dst
,
int
dst_step
,
const
uint16_t
*
src
,
int
src_step
,
int
len
,
int
radius
)
{
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
++
)
{
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
,
int
len
,
int
radius
,
int
pixsize
)
{
if
(
pixsize
==
1
)
blur8
(
dst
,
dst_step
,
src
,
src_step
,
len
,
radius
);
else
blur16
((
uint16_t
*
)
dst
,
dst_step
>>
1
,
(
const
uint16_t
*
)
src
,
src_step
>>
1
,
len
,
radius
);
}
static
inline
void
blur_power
(
uint8_t
*
dst
,
int
dst_step
,
const
uint8_t
*
src
,
int
src_step
,
int
len
,
int
radius
,
int
power
,
uint8_t
*
temp
[
2
])
int
len
,
int
radius
,
int
power
,
uint8_t
*
temp
[
2
]
,
int
pixsize
)
{
uint8_t
*
a
=
temp
[
0
],
*
b
=
temp
[
1
];
if
(
radius
&&
power
)
{
blur
(
a
,
1
,
src
,
src_step
,
len
,
radius
);
blur
(
a
,
pixsize
,
src
,
src_step
,
len
,
radius
,
pixsize
);
for
(;
power
>
2
;
power
--
)
{
uint8_t
*
c
;
blur
(
b
,
1
,
a
,
1
,
len
,
radius
);
blur
(
b
,
pixsize
,
a
,
pixsize
,
len
,
radius
,
pixsize
);
c
=
a
;
a
=
b
;
b
=
c
;
}
if
(
power
>
1
)
{
blur
(
dst
,
dst_step
,
a
,
1
,
len
,
radius
);
blur
(
dst
,
dst_step
,
a
,
pixsize
,
len
,
radius
,
pixsize
);
}
else
{
int
i
;
for
(
i
=
0
;
i
<
len
;
i
++
)
dst
[
i
*
dst_step
]
=
a
[
i
];
if
(
pixsize
==
1
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
dst
[
i
*
dst_step
]
=
a
[
i
];
}
else
for
(
i
=
0
;
i
<
len
;
i
++
)
*
(
uint16_t
*
)(
dst
+
i
*
dst_step
)
=
((
uint16_t
*
)
a
)[
i
];
}
}
else
{
int
i
;
for
(
i
=
0
;
i
<
len
;
i
++
)
dst
[
i
*
dst_step
]
=
src
[
i
*
src_step
];
if
(
pixsize
==
1
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
dst
[
i
*
dst_step
]
=
src
[
i
*
src_step
];
}
else
for
(
i
=
0
;
i
<
len
;
i
++
)
*
(
uint16_t
*
)(
dst
+
i
*
dst_step
)
=
*
(
uint16_t
*
)(
src
+
i
*
src_step
);
}
}
static
void
hblur
(
uint8_t
*
dst
,
int
dst_linesize
,
const
uint8_t
*
src
,
int
src_linesize
,
int
w
,
int
h
,
int
radius
,
int
power
,
uint8_t
*
temp
[
2
])
int
w
,
int
h
,
int
radius
,
int
power
,
uint8_t
*
temp
[
2
]
,
int
pixsize
)
{
int
y
;
...
...
@@ -280,12 +326,12 @@ static void hblur(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_li
return
;
for
(
y
=
0
;
y
<
h
;
y
++
)
blur_power
(
dst
+
y
*
dst_linesize
,
1
,
src
+
y
*
src_linesize
,
1
,
w
,
radius
,
power
,
temp
);
blur_power
(
dst
+
y
*
dst_linesize
,
pixsize
,
src
+
y
*
src_linesize
,
pixsize
,
w
,
radius
,
power
,
temp
,
pixsize
);
}
static
void
vblur
(
uint8_t
*
dst
,
int
dst_linesize
,
const
uint8_t
*
src
,
int
src_linesize
,
int
w
,
int
h
,
int
radius
,
int
power
,
uint8_t
*
temp
[
2
])
int
w
,
int
h
,
int
radius
,
int
power
,
uint8_t
*
temp
[
2
]
,
int
pixsize
)
{
int
x
;
...
...
@@ -293,8 +339,8 @@ static void vblur(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_li
return
;
for
(
x
=
0
;
x
<
w
;
x
++
)
blur_power
(
dst
+
x
,
dst_linesize
,
src
+
x
,
src_linesize
,
h
,
radius
,
power
,
temp
);
blur_power
(
dst
+
x
*
pixsize
,
dst_linesize
,
src
+
x
*
pixsize
,
src_linesize
,
h
,
radius
,
power
,
temp
,
pixsize
);
}
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
in
)
...
...
@@ -307,6 +353,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
int
cw
=
FF_CEIL_RSHIFT
(
inlink
->
w
,
s
->
hsub
),
ch
=
FF_CEIL_RSHIFT
(
in
->
height
,
s
->
vsub
);
int
w
[
4
]
=
{
inlink
->
w
,
cw
,
cw
,
inlink
->
w
};
int
h
[
4
]
=
{
in
->
height
,
ch
,
ch
,
in
->
height
};
const
AVPixFmtDescriptor
*
desc
=
av_pix_fmt_desc_get
(
inlink
->
format
);
const
int
depth
=
desc
->
comp
[
0
].
depth_minus1
+
1
;
const
int
pixsize
=
(
depth
+
7
)
/
8
;
out
=
ff_get_video_buffer
(
outlink
,
outlink
->
w
,
outlink
->
h
);
if
(
!
out
)
{
...
...
@@ -319,13 +368,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
hblur
(
out
->
data
[
plane
],
out
->
linesize
[
plane
],
in
->
data
[
plane
],
in
->
linesize
[
plane
],
w
[
plane
],
h
[
plane
],
s
->
radius
[
plane
],
s
->
power
[
plane
],
s
->
temp
);
s
->
temp
,
pixsize
);
for
(
plane
=
0
;
plane
<
4
&&
in
->
data
[
plane
]
&&
in
->
linesize
[
plane
];
plane
++
)
vblur
(
out
->
data
[
plane
],
out
->
linesize
[
plane
],
out
->
data
[
plane
],
out
->
linesize
[
plane
],
w
[
plane
],
h
[
plane
],
s
->
radius
[
plane
],
s
->
power
[
plane
],
s
->
temp
);
s
->
temp
,
pixsize
);
av_frame_free
(
&
in
);
...
...
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