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
f53c26c6
Unverified
Commit
f53c26c6
authored
Oct 25, 2016
by
Rodger Combs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi/vf_overlay: support NV12 and NV21
Tested-by: Michael on x86-32/64 linux, mingw, mips/arm qemu linux
parent
bf709098
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
5 deletions
+37
-5
vf_overlay.c
libavfilter/vf_overlay.c
+17
-5
filter-video.mak
tests/fate/filter-video.mak
+10
-0
overlay_nv12
tests/filtergraphs/overlay_nv12
+5
-0
overlay_nv21
tests/filtergraphs/overlay_nv21
+5
-0
No files found.
libavfilter/vf_overlay.c
View file @
f53c26c6
...
@@ -125,6 +125,7 @@ typedef struct OverlayContext {
...
@@ -125,6 +125,7 @@ typedef struct OverlayContext {
int
main_pix_step
[
4
];
///< steps per pixel for each plane of the main output
int
main_pix_step
[
4
];
///< steps per pixel for each plane of the main output
int
overlay_pix_step
[
4
];
///< steps per pixel for each plane of the overlay
int
overlay_pix_step
[
4
];
///< steps per pixel for each plane of the overlay
int
hsub
,
vsub
;
///< chroma subsampling values
int
hsub
,
vsub
;
///< chroma subsampling values
const
AVPixFmtDescriptor
*
main_desc
;
///< format descriptor for main input
double
var_values
[
VAR_VARS_NB
];
double
var_values
[
VAR_VARS_NB
];
char
*
x_expr
,
*
y_expr
;
char
*
x_expr
,
*
y_expr
;
...
@@ -215,7 +216,9 @@ static int query_formats(AVFilterContext *ctx)
...
@@ -215,7 +216,9 @@ static int query_formats(AVFilterContext *ctx)
/* overlay formats contains alpha, for avoiding conversion with alpha information loss */
/* overlay formats contains alpha, for avoiding conversion with alpha information loss */
static
const
enum
AVPixelFormat
main_pix_fmts_yuv420
[]
=
{
static
const
enum
AVPixelFormat
main_pix_fmts_yuv420
[]
=
{
AV_PIX_FMT_YUV420P
,
AV_PIX_FMT_YUVJ420P
,
AV_PIX_FMT_YUVA420P
,
AV_PIX_FMT_NONE
AV_PIX_FMT_YUV420P
,
AV_PIX_FMT_YUVJ420P
,
AV_PIX_FMT_YUVA420P
,
AV_PIX_FMT_NV12
,
AV_PIX_FMT_NV21
,
AV_PIX_FMT_NONE
};
};
static
const
enum
AVPixelFormat
overlay_pix_fmts_yuv420
[]
=
{
static
const
enum
AVPixelFormat
overlay_pix_fmts_yuv420
[]
=
{
AV_PIX_FMT_YUVA420P
,
AV_PIX_FMT_NONE
AV_PIX_FMT_YUVA420P
,
AV_PIX_FMT_NONE
...
@@ -470,6 +473,7 @@ static av_always_inline void blend_plane(AVFilterContext *ctx,
...
@@ -470,6 +473,7 @@ static av_always_inline void blend_plane(AVFilterContext *ctx,
int
x
,
int
y
,
int
x
,
int
y
,
int
main_has_alpha
)
int
main_has_alpha
)
{
{
OverlayContext
*
ol
=
ctx
->
priv
;
int
src_wp
=
AV_CEIL_RSHIFT
(
src_w
,
hsub
);
int
src_wp
=
AV_CEIL_RSHIFT
(
src_w
,
hsub
);
int
src_hp
=
AV_CEIL_RSHIFT
(
src_h
,
vsub
);
int
src_hp
=
AV_CEIL_RSHIFT
(
src_h
,
vsub
);
int
dst_wp
=
AV_CEIL_RSHIFT
(
dst_w
,
hsub
);
int
dst_wp
=
AV_CEIL_RSHIFT
(
dst_w
,
hsub
);
...
@@ -479,14 +483,20 @@ static av_always_inline void blend_plane(AVFilterContext *ctx,
...
@@ -479,14 +483,20 @@ static av_always_inline void blend_plane(AVFilterContext *ctx,
uint8_t
*
s
,
*
sp
,
*
d
,
*
dp
,
*
a
,
*
ap
;
uint8_t
*
s
,
*
sp
,
*
d
,
*
dp
,
*
a
,
*
ap
;
int
jmax
,
j
,
k
,
kmax
;
int
jmax
,
j
,
k
,
kmax
;
int
dst_plane
=
ol
->
main_desc
->
comp
[
i
].
plane
;
int
dst_offset
=
ol
->
main_desc
->
comp
[
i
].
offset
;
int
dst_step
=
ol
->
main_desc
->
comp
[
i
].
step
;
j
=
FFMAX
(
-
yp
,
0
);
j
=
FFMAX
(
-
yp
,
0
);
sp
=
src
->
data
[
i
]
+
j
*
src
->
linesize
[
i
];
sp
=
src
->
data
[
i
]
+
j
*
src
->
linesize
[
i
];
dp
=
dst
->
data
[
i
]
+
(
yp
+
j
)
*
dst
->
linesize
[
i
];
dp
=
dst
->
data
[
dst_plane
]
+
(
yp
+
j
)
*
dst
->
linesize
[
dst_plane
]
+
dst_offset
;
ap
=
src
->
data
[
3
]
+
(
j
<<
vsub
)
*
src
->
linesize
[
3
];
ap
=
src
->
data
[
3
]
+
(
j
<<
vsub
)
*
src
->
linesize
[
3
];
for
(
jmax
=
FFMIN
(
-
yp
+
dst_hp
,
src_hp
);
j
<
jmax
;
j
++
)
{
for
(
jmax
=
FFMIN
(
-
yp
+
dst_hp
,
src_hp
);
j
<
jmax
;
j
++
)
{
k
=
FFMAX
(
-
xp
,
0
);
k
=
FFMAX
(
-
xp
,
0
);
d
=
dp
+
xp
+
k
;
d
=
dp
+
(
xp
+
k
)
*
dst_step
;
s
=
sp
+
k
;
s
=
sp
+
k
;
a
=
ap
+
(
k
<<
hsub
);
a
=
ap
+
(
k
<<
hsub
);
...
@@ -525,10 +535,10 @@ static av_always_inline void blend_plane(AVFilterContext *ctx,
...
@@ -525,10 +535,10 @@ static av_always_inline void blend_plane(AVFilterContext *ctx,
}
}
*
d
=
FAST_DIV255
(
*
d
*
(
255
-
alpha
)
+
*
s
*
alpha
);
*
d
=
FAST_DIV255
(
*
d
*
(
255
-
alpha
)
+
*
s
*
alpha
);
s
++
;
s
++
;
d
++
;
d
+=
dst_step
;
a
+=
1
<<
hsub
;
a
+=
1
<<
hsub
;
}
}
dp
+=
dst
->
linesize
[
i
];
dp
+=
dst
->
linesize
[
dst_plane
];
sp
+=
src
->
linesize
[
i
];
sp
+=
src
->
linesize
[
i
];
ap
+=
(
1
<<
vsub
)
*
src
->
linesize
[
3
];
ap
+=
(
1
<<
vsub
)
*
src
->
linesize
[
3
];
}
}
...
@@ -626,6 +636,8 @@ static int config_input_main(AVFilterLink *inlink)
...
@@ -626,6 +636,8 @@ static int config_input_main(AVFilterLink *inlink)
s
->
hsub
=
pix_desc
->
log2_chroma_w
;
s
->
hsub
=
pix_desc
->
log2_chroma_w
;
s
->
vsub
=
pix_desc
->
log2_chroma_h
;
s
->
vsub
=
pix_desc
->
log2_chroma_h
;
s
->
main_desc
=
pix_desc
;
s
->
main_is_packed_rgb
=
s
->
main_is_packed_rgb
=
ff_fill_rgba_map
(
s
->
main_rgba_map
,
inlink
->
format
)
>=
0
;
ff_fill_rgba_map
(
s
->
main_rgba_map
,
inlink
->
format
)
>=
0
;
s
->
main_has_alpha
=
ff_fmt_is_in
(
inlink
->
format
,
alpha_pix_fmts
);
s
->
main_has_alpha
=
ff_fmt_is_in
(
inlink
->
format
,
alpha_pix_fmts
);
...
...
tests/fate/filter-video.mak
View file @
f53c26c6
...
@@ -172,6 +172,16 @@ FATE_FILTER_VSYNTH-$(call ALLYES, SPLIT_FILTER SCALE_FILTER PAD_FILTER OVERLAY_F
...
@@ -172,6 +172,16 @@ FATE_FILTER_VSYNTH-$(call ALLYES, SPLIT_FILTER SCALE_FILTER PAD_FILTER OVERLAY_F
fate-filter-overlay_yuv420: tests/data/filtergraphs/overlay_yuv420
fate-filter-overlay_yuv420: tests/data/filtergraphs/overlay_yuv420
fate-filter-overlay_yuv420: CMD = framecrc -c:v pgmyuv -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay_yuv420
fate-filter-overlay_yuv420: CMD = framecrc -c:v pgmyuv -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay_yuv420
FATE_FILTER_VSYNTH-$(call ALLYES, SPLIT_FILTER SCALE_FILTER PAD_FILTER OVERLAY_FILTER) += fate-filter-overlay_nv12
fate-filter-overlay_nv12: tests/data/filtergraphs/overlay_nv12
fate-filter-overlay_nv12: CMD = framecrc -c:v pgmyuv -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay_nv12
fate-filter-overlay_nv12: REF = $(SRC_PATH)/tests/ref/fate/filter-overlay_yuv420
FATE_FILTER_VSYNTH-$(call ALLYES, SPLIT_FILTER SCALE_FILTER PAD_FILTER OVERLAY_FILTER) += fate-filter-overlay_nv21
fate-filter-overlay_nv21: tests/data/filtergraphs/overlay_nv21
fate-filter-overlay_nv21: CMD = framecrc -c:v pgmyuv -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay_nv21
fate-filter-overlay_nv21: REF = $(SRC_PATH)/tests/ref/fate/filter-overlay_yuv420
FATE_FILTER_VSYNTH-$(call ALLYES, SPLIT_FILTER SCALE_FILTER PAD_FILTER OVERLAY_FILTER) += fate-filter-overlay_yuv422
FATE_FILTER_VSYNTH-$(call ALLYES, SPLIT_FILTER SCALE_FILTER PAD_FILTER OVERLAY_FILTER) += fate-filter-overlay_yuv422
fate-filter-overlay_yuv422: tests/data/filtergraphs/overlay_yuv422
fate-filter-overlay_yuv422: tests/data/filtergraphs/overlay_yuv422
fate-filter-overlay_yuv422: CMD = framecrc -c:v pgmyuv -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay_yuv422
fate-filter-overlay_yuv422: CMD = framecrc -c:v pgmyuv -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay_yuv422
...
...
tests/filtergraphs/overlay_nv12
0 → 100644
View file @
f53c26c6
sws_flags=+accurate_rnd+bitexact;
split [main][over];
[over] scale=88:72, pad=96:80:4:4 [overf];
[main] format=nv12 [mainf];
[mainf][overf] overlay=240:16:format=yuv420, format=yuv420p
tests/filtergraphs/overlay_nv21
0 → 100644
View file @
f53c26c6
sws_flags=+accurate_rnd+bitexact;
split [main][over];
[over] scale=88:72, pad=96:80:4:4 [overf];
[main] format=nv21 [mainf];
[mainf][overf] overlay=240:16:format=yuv420, format=yuv420p
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