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
1a3d4b88
Commit
1a3d4b88
authored
Mar 08, 2012
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
imgconvert: add macro pixdesc_has_alpha for checking if a pixel format has an alpha component
Reduce redundancy and simplify.
parent
174678ff
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
15 deletions
+5
-15
imgconvert.c
libavcodec/imgconvert.c
+5
-15
No files found.
libavcodec/imgconvert.c
View file @
1a3d4b88
...
...
@@ -55,9 +55,11 @@
#define deinterlace_line deinterlace_line_c
#endif
#define pixdesc_has_alpha(pixdesc) \
((pixdesc)->nb_components == 2 || (pixdesc)->nb_components == 4 || (pixdesc)->flags & PIX_FMT_PAL)
typedef
struct
PixFmtInfo
{
uint8_t
color_type
;
/**< color type (see FF_COLOR_xxx constants) */
uint8_t
is_alpha
:
1
;
/**< true if alpha can be specified */
uint8_t
padded_size
;
/**< padded size in bits if different from the non-padded size */
}
PixFmtInfo
;
...
...
@@ -109,12 +111,10 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
/* YUV formats with alpha plane */
[
PIX_FMT_YUVA420P
]
=
{
.
is_alpha
=
1
,
.
color_type
=
FF_COLOR_YUV
,
},
[
PIX_FMT_YUVA444P
]
=
{
.
is_alpha
=
1
,
.
color_type
=
FF_COLOR_YUV
,
},
...
...
@@ -140,7 +140,6 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
.
color_type
=
FF_COLOR_RGB
,
},
[
PIX_FMT_ARGB
]
=
{
.
is_alpha
=
1
,
.
color_type
=
FF_COLOR_RGB
,
},
[
PIX_FMT_RGB48BE
]
=
{
...
...
@@ -150,11 +149,9 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
.
color_type
=
FF_COLOR_RGB
,
},
[
PIX_FMT_RGBA64BE
]
=
{
.
is_alpha
=
1
,
.
color_type
=
FF_COLOR_RGB
,
},
[
PIX_FMT_RGBA64LE
]
=
{
.
is_alpha
=
1
,
.
color_type
=
FF_COLOR_RGB
,
},
[
PIX_FMT_RGB565BE
]
=
{
...
...
@@ -191,7 +188,6 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
.
color_type
=
FF_COLOR_GRAY
,
},
[
PIX_FMT_GRAY8A
]
=
{
.
is_alpha
=
1
,
.
color_type
=
FF_COLOR_GRAY
,
},
[
PIX_FMT_MONOWHITE
]
=
{
...
...
@@ -203,14 +199,12 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
/* paletted formats */
[
PIX_FMT_PAL8
]
=
{
.
is_alpha
=
1
,
.
color_type
=
FF_COLOR_RGB
,
},
[
PIX_FMT_UYYVYY411
]
=
{
.
color_type
=
FF_COLOR_YUV
,
},
[
PIX_FMT_ABGR
]
=
{
.
is_alpha
=
1
,
.
color_type
=
FF_COLOR_RGB
,
},
[
PIX_FMT_BGR48BE
]
=
{
...
...
@@ -220,11 +214,9 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
.
color_type
=
FF_COLOR_RGB
,
},
[
PIX_FMT_BGRA64BE
]
=
{
.
is_alpha
=
1
,
.
color_type
=
FF_COLOR_RGB
,
},
[
PIX_FMT_BGRA64LE
]
=
{
.
is_alpha
=
1
,
.
color_type
=
FF_COLOR_RGB
,
},
[
PIX_FMT_BGR565BE
]
=
{
...
...
@@ -279,11 +271,9 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
},
[
PIX_FMT_BGRA
]
=
{
.
is_alpha
=
1
,
.
color_type
=
FF_COLOR_RGB
,
},
[
PIX_FMT_RGBA
]
=
{
.
is_alpha
=
1
,
.
color_type
=
FF_COLOR_RGB
,
},
};
...
...
@@ -445,10 +435,10 @@ int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_
if
(
pf
->
color_type
==
FF_COLOR_GRAY
&&
ps
->
color_type
!=
FF_COLOR_GRAY
)
loss
|=
FF_LOSS_CHROMA
;
if
(
!
p
f
->
is_alpha
&&
(
ps
->
is_alpha
&&
has_alpha
))
if
(
!
p
ixdesc_has_alpha
(
dst_desc
)
&&
(
pixdesc_has_alpha
(
src_desc
)
&&
has_alpha
))
loss
|=
FF_LOSS_ALPHA
;
if
(
dst_pix_fmt
==
PIX_FMT_PAL8
&&
(
src_pix_fmt
!=
PIX_FMT_PAL8
&&
(
ps
->
color_type
!=
FF_COLOR_GRAY
||
(
p
s
->
is_alpha
&&
has_alpha
))))
(
src_pix_fmt
!=
PIX_FMT_PAL8
&&
(
ps
->
color_type
!=
FF_COLOR_GRAY
||
(
p
ixdesc_has_alpha
(
src_desc
)
&&
has_alpha
))))
loss
|=
FF_LOSS_COLORQUANT
;
return
loss
;
...
...
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