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
c5ebeaa3
Commit
c5ebeaa3
authored
Aug 09, 2015
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swscale/alphablend: Support SWS_ALPHA_BLEND_CHECKERBOARD
Signed-off-by:
Michael Niedermayer
<
michael@niedermayer.cc
>
parent
87100e82
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
11 deletions
+21
-11
scaler.texi
doc/scaler.texi
+3
-0
alphablend.c
libswscale/alphablend.c
+16
-11
options.c
libswscale/options.c
+1
-0
swscale_internal.h
libswscale/swscale_internal.h
+1
-0
No files found.
doc/scaler.texi
View file @
c5ebeaa3
...
...
@@ -130,6 +130,9 @@ Default value is @samp{none}.
@item uniform_color
Blend onto a uniform background color
@item checkerboard
Blend onto a checkerboard
@item none
No blending
...
...
libswscale/alphablend.c
View file @
c5ebeaa3
...
...
@@ -32,10 +32,17 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
unsigned
off
=
1
<<
desc
->
comp
[
0
].
depth_minus1
;
unsigned
shift
=
desc
->
comp
[
0
].
depth_minus1
+
1
;
unsigned
max
=
(
1
<<
shift
)
-
1
;
int
target_table
[
3
];
int
target_table
[
2
][
3
];
for
(
plane
=
0
;
plane
<
plane_count
;
plane
++
)
target_table
[
plane
]
=
plane
&&
!
(
desc
->
flags
&
AV_PIX_FMT_FLAG_RGB
)
?
1
<<
desc
->
comp
[
0
].
depth_minus1
:
0
;
for
(
plane
=
0
;
plane
<
plane_count
;
plane
++
)
{
int
a
=
0
,
b
=
0
;
if
(
c
->
alphablend
==
SWS_ALPHA_BLEND_CHECKERBOARD
)
{
a
=
(
1
<<
desc
->
comp
[
0
].
depth_minus1
)
/
2
;
b
=
3
*
(
1
<<
desc
->
comp
[
0
].
depth_minus1
)
/
2
;
}
target_table
[
0
][
plane
]
=
plane
&&
!
(
desc
->
flags
&
AV_PIX_FMT_FLAG_RGB
)
?
1
<<
desc
->
comp
[
0
].
depth_minus1
:
a
;
target_table
[
1
][
plane
]
=
plane
&&
!
(
desc
->
flags
&
AV_PIX_FMT_FLAG_RGB
)
?
1
<<
desc
->
comp
[
0
].
depth_minus1
:
b
;
}
av_assert0
(
plane_count
==
nb_components
-
1
);
if
(
desc
->
flags
&
AV_PIX_FMT_FLAG_PLANAR
)
{
...
...
@@ -47,16 +54,15 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
const
uint16_t
*
s
=
src
[
plane
]
+
srcStride
[
plane
]
*
y
;
const
uint16_t
*
a
=
src
[
plane_count
]
+
srcStride
[
plane_count
]
*
y
;
uint16_t
*
d
=
dst
[
plane
]
+
dstStride
[
plane
]
*
y
;
unsigned
target
=
target_table
[
plane
];
if
((
!
isBE
(
c
->
srcFormat
))
==
!
HAVE_BIGENDIAN
)
{
for
(
x
=
0
;
x
<
w
;
x
++
)
{
unsigned
u
=
s
[
x
]
*
a
[
x
]
+
target
*
(
max
-
a
[
x
])
+
off
;
unsigned
u
=
s
[
x
]
*
a
[
x
]
+
target
_table
[((
x
^
y
)
>>
5
)
&
1
][
plane
]
*
(
max
-
a
[
x
])
+
off
;
d
[
x
]
=
av_clip
((
u
+
(
u
>>
shift
))
>>
shift
,
0
,
max
);
}
}
else
{
for
(
x
=
0
;
x
<
w
;
x
++
)
{
unsigned
aswap
=
av_bswap16
(
a
[
x
]);
unsigned
u
=
av_bswap16
(
s
[
x
])
*
aswap
+
target
*
(
max
-
aswap
)
+
off
;
unsigned
u
=
av_bswap16
(
s
[
x
])
*
aswap
+
target
_table
[((
x
^
y
)
>>
5
)
&
1
][
plane
]
*
(
max
-
aswap
)
+
off
;
d
[
x
]
=
av_clip
((
u
+
(
u
>>
shift
))
>>
shift
,
0
,
max
);
}
}
...
...
@@ -64,9 +70,8 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
const
uint8_t
*
s
=
src
[
plane
]
+
srcStride
[
plane
]
*
y
;
const
uint8_t
*
a
=
src
[
plane_count
]
+
srcStride
[
plane_count
]
*
y
;
uint8_t
*
d
=
dst
[
plane
]
+
dstStride
[
plane
]
*
y
;
unsigned
target
=
target_table
[
plane
];
for
(
x
=
0
;
x
<
w
;
x
++
)
{
unsigned
u
=
s
[
x
]
*
a
[
x
]
+
target
*
(
255
-
a
[
x
])
+
128
;
unsigned
u
=
s
[
x
]
*
a
[
x
]
+
target
_table
[((
x
^
y
)
>>
5
)
&
1
][
plane
]
*
(
255
-
a
[
x
])
+
128
;
d
[
x
]
=
(
257
*
u
)
>>
16
;
}
}
...
...
@@ -84,7 +89,7 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
for
(
x
=
0
;
x
<
w
;
x
++
)
{
for
(
plane
=
0
;
plane
<
plane_count
;
plane
++
)
{
int
x_index
=
(
plane_count
+
1
)
*
x
;
unsigned
u
=
s
[
x_index
+
plane
]
*
a
[
x_index
]
+
target_table
[
plane
]
*
(
max
-
a
[
x_index
])
+
off
;
unsigned
u
=
s
[
x_index
+
plane
]
*
a
[
x_index
]
+
target_table
[
((
x
^
y
)
>>
5
)
&
1
][
plane
]
*
(
max
-
a
[
x_index
])
+
off
;
d
[
plane_count
*
x
+
plane
]
=
av_clip
((
u
+
(
u
>>
shift
))
>>
shift
,
0
,
max
);
}
}
...
...
@@ -93,7 +98,7 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
for
(
plane
=
0
;
plane
<
plane_count
;
plane
++
)
{
int
x_index
=
(
plane_count
+
1
)
*
x
;
unsigned
aswap
=
av_bswap16
(
a
[
x_index
]);
unsigned
u
=
av_bswap16
(
s
[
x_index
+
plane
])
*
aswap
+
target_table
[
plane
]
*
(
max
-
aswap
)
+
off
;
unsigned
u
=
av_bswap16
(
s
[
x_index
+
plane
])
*
aswap
+
target_table
[
((
x
^
y
)
>>
5
)
&
1
][
plane
]
*
(
max
-
aswap
)
+
off
;
d
[
plane_count
*
x
+
plane
]
=
av_clip
((
u
+
(
u
>>
shift
))
>>
shift
,
0
,
max
);
}
}
...
...
@@ -105,7 +110,7 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
for
(
x
=
0
;
x
<
w
;
x
++
)
{
for
(
plane
=
0
;
plane
<
plane_count
;
plane
++
)
{
int
x_index
=
(
plane_count
+
1
)
*
x
;
unsigned
u
=
s
[
x_index
+
plane
]
*
a
[
x_index
]
+
target_table
[
plane
]
*
(
255
-
a
[
x_index
])
+
128
;
unsigned
u
=
s
[
x_index
+
plane
]
*
a
[
x_index
]
+
target_table
[
((
x
^
y
)
>>
5
)
&
1
][
plane
]
*
(
255
-
a
[
x_index
])
+
128
;
d
[
plane_count
*
x
+
plane
]
=
(
257
*
u
)
>>
16
;
}
}
...
...
libswscale/options.c
View file @
c5ebeaa3
...
...
@@ -81,6 +81,7 @@ static const AVOption swscale_options[] = {
{
"alphablend"
,
"mode for alpha -> non alpha"
,
OFFSET
(
alphablend
),
AV_OPT_TYPE_INT
,
{
.
i64
=
SWS_ALPHA_BLEND_NONE
},
0
,
SWS_ALPHA_BLEND_NB
-
1
,
VE
,
"alphablend"
},
{
"none"
,
"ignore alpha"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
SWS_ALPHA_BLEND_NONE
},
INT_MIN
,
INT_MAX
,
VE
,
"alphablend"
},
{
"uniform_color"
,
"blend onto a uniform color"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
SWS_ALPHA_BLEND_UNIFORM
},
INT_MIN
,
INT_MAX
,
VE
,
"alphablend"
},
{
"checkerboard"
,
"blend onto a checkerboard"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
SWS_ALPHA_BLEND_CHECKERBOARD
},
INT_MIN
,
INT_MAX
,
VE
,
"alphablend"
},
{
NULL
}
};
...
...
libswscale/swscale_internal.h
View file @
c5ebeaa3
...
...
@@ -78,6 +78,7 @@ typedef enum SwsDither {
typedef
enum
SwsAlphaBlend
{
SWS_ALPHA_BLEND_NONE
=
0
,
SWS_ALPHA_BLEND_UNIFORM
,
SWS_ALPHA_BLEND_CHECKERBOARD
,
SWS_ALPHA_BLEND_NB
,
}
SwsAlphaBlend
;
...
...
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