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
b7faa9d3
Commit
b7faa9d3
authored
Aug 08, 2015
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swscale/alphablend: support packed pixel formats
Signed-off-by:
Michael Niedermayer
<
michael@niedermayer.cc
>
parent
16df02fd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
11 deletions
+53
-11
alphablend.c
libswscale/alphablend.c
+42
-0
utils.c
libswscale/utils.c
+11
-11
No files found.
libswscale/alphablend.c
View file @
b7faa9d3
...
...
@@ -68,6 +68,48 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
}
}
}
}
else
{
int
alpha_pos
=
desc
->
comp
[
plane_count
].
offset_plus1
-
1
;
int
w
=
c
->
srcW
;
for
(
y
=
srcSliceY
;
y
<
srcSliceH
;
y
++
)
{
if
(
sixteen_bits
)
{
const
uint16_t
*
s
=
src
[
0
]
+
srcStride
[
0
]
*
y
+
2
*!
alpha_pos
;
const
uint16_t
*
a
=
src
[
0
]
+
srcStride
[
0
]
*
y
+
alpha_pos
;
uint16_t
*
d
=
dst
[
0
]
+
dstStride
[
0
]
*
y
;
if
((
!
isBE
(
c
->
srcFormat
))
==
!
HAVE_BIGENDIAN
)
{
for
(
x
=
0
;
x
<
w
;
x
++
)
{
for
(
plane
=
0
;
plane
<
plane_count
;
plane
++
)
{
unsigned
target
=
plane
&&
!
(
desc
->
flags
&
AV_PIX_FMT_FLAG_RGB
)
?
1
<<
desc
->
comp
[
0
].
depth_minus1
:
0
;
int
x_index
=
(
plane_count
+
1
)
*
x
;
unsigned
u
=
s
[
x_index
+
plane
]
*
a
[
x_index
]
+
target
*
(
max
-
a
[
x_index
])
+
off
;
d
[
plane_count
*
x
+
plane
]
=
av_clip
((
u
+
(
u
>>
shift
))
>>
shift
,
0
,
max
);
}
}
}
else
{
for
(
x
=
0
;
x
<
w
;
x
++
)
{
for
(
plane
=
0
;
plane
<
plane_count
;
plane
++
)
{
unsigned
target
=
plane
&&
!
(
desc
->
flags
&
AV_PIX_FMT_FLAG_RGB
)
?
1
<<
desc
->
comp
[
0
].
depth_minus1
:
0
;
int
x_index
=
(
plane_count
+
1
)
*
x
;
unsigned
aswap
=
av_bswap16
(
a
[
x_index
]);
unsigned
u
=
av_bswap16
(
s
[
x_index
+
plane
])
*
aswap
+
target
*
(
max
-
aswap
)
+
off
;
d
[
plane_count
*
x
+
plane
]
=
av_clip
((
u
+
(
u
>>
shift
))
>>
shift
,
0
,
max
);
}
}
}
}
else
{
const
uint8_t
*
s
=
src
[
0
]
+
srcStride
[
0
]
*
y
+
!
alpha_pos
;
const
uint8_t
*
a
=
src
[
0
]
+
srcStride
[
0
]
*
y
+
alpha_pos
;
uint8_t
*
d
=
dst
[
0
]
+
dstStride
[
0
]
*
y
;
for
(
x
=
0
;
x
<
w
;
x
++
)
{
for
(
plane
=
0
;
plane
<
plane_count
;
plane
++
)
{
unsigned
target
=
plane
&&
!
(
desc
->
flags
&
AV_PIX_FMT_FLAG_RGB
)
?
128
:
0
;
int
x_index
=
(
plane_count
+
1
)
*
x
;
unsigned
u
=
s
[
x_index
+
plane
]
*
a
[
x_index
]
+
target
*
(
255
-
a
[
x_index
])
+
128
;
d
[
plane_count
*
x
+
plane
]
=
(
257
*
u
)
>>
16
;
}
}
}
}
}
return
0
;
...
...
libswscale/utils.c
View file @
b7faa9d3
...
...
@@ -982,11 +982,11 @@ static uint16_t * alloc_gamma_tbl(double e)
static
enum
AVPixelFormat
alphaless_fmt
(
enum
AVPixelFormat
fmt
)
{
switch
(
fmt
)
{
//
case AV_PIX_FMT_ARGB: return AV_PIX_FMT_RGB24;
//
case AV_PIX_FMT_RGBA: return AV_PIX_FMT_RGB24;
//
case AV_PIX_FMT_ABGR: return AV_PIX_FMT_BGR24;
//
case AV_PIX_FMT_BGRA: return AV_PIX_FMT_BGR24;
//
case AV_PIX_FMT_YA8: return AV_PIX_FMT_GRAY8;
case
AV_PIX_FMT_ARGB
:
return
AV_PIX_FMT_RGB24
;
case
AV_PIX_FMT_RGBA
:
return
AV_PIX_FMT_RGB24
;
case
AV_PIX_FMT_ABGR
:
return
AV_PIX_FMT_BGR24
;
case
AV_PIX_FMT_BGRA
:
return
AV_PIX_FMT_BGR24
;
case
AV_PIX_FMT_YA8
:
return
AV_PIX_FMT_GRAY8
;
//
// case AV_PIX_FMT_YUVA420P: return AV_PIX_FMT_YUV420P;
// case AV_PIX_FMT_YUVA422P: return AV_PIX_FMT_YUV422P;
...
...
@@ -997,13 +997,13 @@ static enum AVPixelFormat alphaless_fmt(enum AVPixelFormat fmt)
case
AV_PIX_FMT_GBRAP16LE
:
return
AV_PIX_FMT_GBRP16
;
case
AV_PIX_FMT_GBRAP16BE
:
return
AV_PIX_FMT_GBRP16
;
//
case AV_PIX_FMT_RGBA64LE: return AV_PIX_FMT_RGB48;
//
case AV_PIX_FMT_RGBA64BE: return AV_PIX_FMT_RGB48;
//
case AV_PIX_FMT_BGRA64LE: return AV_PIX_FMT_BGR48;
//
case AV_PIX_FMT_BGRA64BE: return AV_PIX_FMT_BGR48;
case
AV_PIX_FMT_RGBA64LE
:
return
AV_PIX_FMT_RGB48
;
case
AV_PIX_FMT_RGBA64BE
:
return
AV_PIX_FMT_RGB48
;
case
AV_PIX_FMT_BGRA64LE
:
return
AV_PIX_FMT_BGR48
;
case
AV_PIX_FMT_BGRA64BE
:
return
AV_PIX_FMT_BGR48
;
//
case AV_PIX_FMT_YA16BE: return AV_PIX_FMT_GRAY16;
//
case AV_PIX_FMT_YA16LE: return AV_PIX_FMT_GRAY16;
case
AV_PIX_FMT_YA16BE
:
return
AV_PIX_FMT_GRAY16
;
case
AV_PIX_FMT_YA16LE
:
return
AV_PIX_FMT_GRAY16
;
// case AV_PIX_FMT_YUVA420P9BE: return AV_PIX_FMT_YUV420P9;
// case AV_PIX_FMT_YUVA422P9BE: return AV_PIX_FMT_YUV422P9;
...
...
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