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
0469baf1
Commit
0469baf1
authored
Apr 21, 2003
by
Fabrice Bellard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added img_get_alpha_info()
Originally committed as revision 1809 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
a059da12
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
3 deletions
+93
-3
avcodec.h
libavcodec/avcodec.h
+6
-2
imgconvert.c
libavcodec/imgconvert.c
+59
-1
imgconvert_template.h
libavcodec/imgconvert_template.h
+28
-0
No files found.
libavcodec/avcodec.h
View file @
0469baf1
...
@@ -15,8 +15,8 @@ extern "C" {
...
@@ -15,8 +15,8 @@ extern "C" {
#define LIBAVCODEC_VERSION_INT 0x000406
#define LIBAVCODEC_VERSION_INT 0x000406
#define LIBAVCODEC_VERSION "0.4.6"
#define LIBAVCODEC_VERSION "0.4.6"
#define LIBAVCODEC_BUILD 466
5
#define LIBAVCODEC_BUILD 466
6
#define LIBAVCODEC_BUILD_STR "466
5
"
#define LIBAVCODEC_BUILD_STR "466
6
"
#define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR
#define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR
...
@@ -1276,6 +1276,10 @@ int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
...
@@ -1276,6 +1276,10 @@ int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
int
avcodec_find_best_pix_fmt
(
int
pix_fmt_mask
,
int
src_pix_fmt
,
int
avcodec_find_best_pix_fmt
(
int
pix_fmt_mask
,
int
src_pix_fmt
,
int
has_alpha
,
int
*
loss_ptr
);
int
has_alpha
,
int
*
loss_ptr
);
#define FF_ALPHA_TRANSP 0x0001
/* image has some totally transparent pixels */
#define FF_ALPHA_SEMI_TRANSP 0x0002
/* image has some transparent pixels */
int
img_get_alpha_info
(
AVPicture
*
src
,
int
pix_fmt
,
int
width
,
int
height
);
/* convert among pixel formats */
/* convert among pixel formats */
int
img_convert
(
AVPicture
*
dst
,
int
dst_pix_fmt
,
int
img_convert
(
AVPicture
*
dst
,
int
dst_pix_fmt
,
AVPicture
*
src
,
int
pix_fmt
,
AVPicture
*
src
,
int
pix_fmt
,
...
...
libavcodec/imgconvert.c
View file @
0469baf1
...
@@ -475,7 +475,9 @@ static void img_copy_plane(uint8_t *dst, int dst_wrap,
...
@@ -475,7 +475,9 @@ static void img_copy_plane(uint8_t *dst, int dst_wrap,
}
}
}
}
/* copy image 'src' to 'dst' */
/**
* Copy image 'src' to 'dst'.
*/
void
img_copy
(
AVPicture
*
dst
,
AVPicture
*
src
,
void
img_copy
(
AVPicture
*
dst
,
AVPicture
*
src
,
int
pix_fmt
,
int
width
,
int
height
)
int
pix_fmt
,
int
width
,
int
height
)
{
{
...
@@ -1808,6 +1810,62 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
...
@@ -1808,6 +1810,62 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
return
ret
;
return
ret
;
}
}
/* NOTE: we scan all the pixels to have an exact information */
static
int
get_alpha_info_pal8
(
AVPicture
*
src
,
int
width
,
int
height
)
{
const
unsigned
char
*
p
;
int
src_wrap
,
ret
,
x
,
y
;
unsigned
int
a
;
uint32_t
*
palette
=
(
uint32_t
*
)
src
->
data
[
1
];
p
=
src
->
data
[
0
];
src_wrap
=
src
->
linesize
[
0
]
-
width
;
ret
=
0
;
for
(
y
=
0
;
y
<
height
;
y
++
)
{
for
(
x
=
0
;
x
<
width
;
x
++
)
{
a
=
palette
[
p
[
0
]]
>>
24
;
if
(
a
==
0x00
)
{
ret
|=
FF_ALPHA_TRANSP
;
}
else
if
(
a
!=
0xff
)
{
ret
|=
FF_ALPHA_SEMI_TRANSP
;
}
p
++
;
}
p
+=
src_wrap
;
}
return
ret
;
}
/**
* Tell if an image really has transparent alpha values.
* @return ored mask of FF_ALPHA_xxx constants
*/
int
img_get_alpha_info
(
AVPicture
*
src
,
int
pix_fmt
,
int
width
,
int
height
)
{
PixFmtInfo
*
pf
=
&
pix_fmt_info
[
pix_fmt
];
int
ret
;
pf
=
&
pix_fmt_info
[
pix_fmt
];
/* no alpha can be represented in format */
if
(
!
pf
->
is_alpha
)
return
0
;
switch
(
pix_fmt
)
{
case
PIX_FMT_RGBA32
:
ret
=
get_alpha_info_rgba32
(
src
,
width
,
height
);
break
;
case
PIX_FMT_RGB555
:
ret
=
get_alpha_info_rgb555
(
src
,
width
,
height
);
break
;
case
PIX_FMT_PAL8
:
ret
=
get_alpha_info_pal8
(
src
,
width
,
height
);
break
;
default:
/* we do not know, so everything is indicated */
ret
=
FF_ALPHA_TRANSP
|
FF_ALPHA_SEMI_TRANSP
;
break
;
}
return
ret
;
}
#ifdef HAVE_MMX
#ifdef HAVE_MMX
#define DEINT_INPLACE_LINE_LUM \
#define DEINT_INPLACE_LINE_LUM \
...
...
libavcodec/imgconvert_template.h
View file @
0469baf1
...
@@ -814,6 +814,34 @@ static void glue(RGB_NAME, _to_pal8)(AVPicture *dst, AVPicture *src,
...
@@ -814,6 +814,34 @@ static void glue(RGB_NAME, _to_pal8)(AVPicture *dst, AVPicture *src,
#endif
/* defined(FMT_RGB24) || defined(FMT_RGBA32) */
#endif
/* defined(FMT_RGB24) || defined(FMT_RGBA32) */
#ifdef RGBA_IN
static
int
glue
(
get_alpha_info_
,
RGB_NAME
)(
AVPicture
*
src
,
int
width
,
int
height
)
{
const
unsigned
char
*
p
;
int
src_wrap
,
ret
,
x
,
y
;
unsigned
int
r
,
g
,
b
,
a
;
p
=
src
->
data
[
0
];
src_wrap
=
src
->
linesize
[
0
]
-
BPP
*
width
;
ret
=
0
;
for
(
y
=
0
;
y
<
height
;
y
++
)
{
for
(
x
=
0
;
x
<
width
;
x
++
)
{
RGBA_IN
(
r
,
g
,
b
,
a
,
p
);
if
(
a
==
0x00
)
{
ret
|=
FF_ALPHA_TRANSP
;
}
else
if
(
a
!=
0xff
)
{
ret
|=
FF_ALPHA_SEMI_TRANSP
;
}
p
+=
BPP
;
}
p
+=
src_wrap
;
}
return
ret
;
}
#endif
/* RGBA_IN */
#undef RGB_IN
#undef RGB_IN
#undef RGBA_IN
#undef RGBA_IN
#undef RGB_OUT
#undef RGB_OUT
...
...
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