Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
8b46d75e
F
Ffmpeg
项目概览
小白菜888
/
Ffmpeg
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Ffmpeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8b46d75e
编写于
4月 19, 2003
作者:
F
Fabrice Bellard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rgba32 support
Originally committed as revision 1795 to
svn://svn.ffmpeg.org/ffmpeg/trunk
上级
6d93f194
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
72 addition
and
9 deletion
+72
-9
libavformat/png.c
libavformat/png.c
+72
-9
未找到文件。
libavformat/png.c
浏览文件 @
8b46d75e
...
...
@@ -63,6 +63,7 @@ typedef struct PNGDecodeState {
uint32_t
palette
[
256
];
uint8_t
*
crow_buf
;
uint8_t
*
empty_row
;
uint8_t
*
tmp_row
;
int
crow_size
;
/* compressed row size (include filter type) */
int
row_size
;
/* decompressed row size */
int
y
;
...
...
@@ -91,6 +92,7 @@ static void png_zfree(void *opaque, void *ptr)
}
/* XXX: optimize */
/* NOTE: 'dst' can be equal to 'last' */
static
void
png_filter_row
(
uint8_t
*
dst
,
int
filter_type
,
uint8_t
*
src
,
uint8_t
*
last
,
int
size
,
int
bpp
)
{
...
...
@@ -159,7 +161,33 @@ static void png_filter_row(uint8_t *dst, int filter_type,
static
void
png_handle_row
(
PNGDecodeState
*
s
)
{
uint8_t
*
ptr
,
*
last_row
;
ptr
=
s
->
image_buf
+
s
->
image_linesize
*
s
->
y
;
/* need to swap bytes correctly for RGB_ALPHA */
if
(
s
->
color_type
==
PNG_COLOR_TYPE_RGB_ALPHA
)
{
int
j
,
w
;
unsigned
int
r
,
g
,
b
,
a
;
const
uint8_t
*
src
;
png_filter_row
(
s
->
tmp_row
,
s
->
crow_buf
[
0
],
s
->
crow_buf
+
1
,
s
->
empty_row
,
s
->
row_size
,
s
->
bpp
);
memcpy
(
s
->
empty_row
,
s
->
tmp_row
,
s
->
row_size
);
src
=
s
->
tmp_row
;
w
=
s
->
width
;
for
(
j
=
0
;
j
<
w
;
j
++
)
{
r
=
src
[
0
];
g
=
src
[
1
];
b
=
src
[
2
];
a
=
src
[
3
];
*
(
uint32_t
*
)
ptr
=
(
a
<<
24
)
|
(
r
<<
16
)
|
(
g
<<
8
)
|
b
;
ptr
+=
4
;
src
+=
4
;
}
}
else
{
/* in normal case, we avoid one copy */
if
(
s
->
y
==
0
)
last_row
=
s
->
empty_row
;
else
...
...
@@ -167,6 +195,7 @@ static void png_handle_row(PNGDecodeState *s)
png_filter_row
(
ptr
,
s
->
crow_buf
[
0
],
s
->
crow_buf
+
1
,
last_row
,
s
->
row_size
,
s
->
bpp
);
}
}
static
int
png_decode_idat
(
PNGDecodeState
*
s
,
ByteIOContext
*
f
,
int
length
)
...
...
@@ -282,6 +311,10 @@ static int png_read(ByteIOContext *f,
s
->
color_type
==
PNG_COLOR_TYPE_RGB
)
{
info
->
pix_fmt
=
PIX_FMT_RGB24
;
s
->
row_size
=
s
->
width
*
3
;
}
else
if
(
s
->
bit_depth
==
8
&&
s
->
color_type
==
PNG_COLOR_TYPE_RGB_ALPHA
)
{
info
->
pix_fmt
=
PIX_FMT_RGBA32
;
s
->
row_size
=
s
->
width
*
4
;
}
else
if
(
s
->
bit_depth
==
8
&&
s
->
color_type
==
PNG_COLOR_TYPE_GRAY
)
{
info
->
pix_fmt
=
PIX_FMT_GRAY8
;
...
...
@@ -292,7 +325,7 @@ static int png_read(ByteIOContext *f,
s
->
row_size
=
(
s
->
width
+
7
)
>>
3
;
}
else
if
(
s
->
color_type
==
PNG_COLOR_TYPE_PALETTE
)
{
info
->
pix_fmt
=
PIX_FMT_PAL8
;
s
->
row_size
=
s
->
width
;
;
s
->
row_size
=
s
->
width
;
}
else
{
goto
fail
;
}
...
...
@@ -319,6 +352,11 @@ static int png_read(ByteIOContext *f,
s
->
empty_row
=
av_mallocz
(
s
->
row_size
);
if
(
!
s
->
empty_row
)
goto
fail
;
if
(
s
->
color_type
==
PNG_COLOR_TYPE_RGB_ALPHA
)
{
s
->
tmp_row
=
av_malloc
(
s
->
row_size
);
if
(
!
s
->
tmp_row
)
goto
fail
;
}
/* compressed row */
s
->
crow_buf
=
av_malloc
(
s
->
crow_size
);
if
(
!
s
->
crow_buf
)
...
...
@@ -386,6 +424,8 @@ static int png_read(ByteIOContext *f,
the_end:
inflateEnd
(
&
s
->
zstream
);
av_free
(
s
->
crow_buf
);
av_free
(
s
->
empty_row
);
av_free
(
s
->
tmp_row
);
return
ret
;
fail:
ret
=
-
1
;
...
...
@@ -431,6 +471,11 @@ static int png_write(ByteIOContext *f, AVImageInfo *info)
z_stream
zstream
;
switch
(
info
->
pix_fmt
)
{
case
PIX_FMT_RGBA32
:
bit_depth
=
8
;
color_type
=
PNG_COLOR_TYPE_RGB_ALPHA
;
row_size
=
info
->
width
*
4
;
break
;
case
PIX_FMT_RGB24
:
bit_depth
=
8
;
color_type
=
PNG_COLOR_TYPE_RGB
;
...
...
@@ -512,7 +557,24 @@ static int png_write(ByteIOContext *f, AVImageInfo *info)
for
(
y
=
0
;
y
<
info
->
height
;
y
++
)
{
/* XXX: do filtering */
ptr
=
info
->
pict
.
data
[
0
]
+
y
*
info
->
pict
.
linesize
[
0
];
if
(
color_type
==
PNG_COLOR_TYPE_RGB_ALPHA
)
{
uint8_t
*
d
;
int
j
,
w
;
unsigned
int
v
;
w
=
info
->
width
;
d
=
crow_buf
+
1
;
for
(
j
=
0
;
j
<
w
;
j
++
)
{
v
=
((
uint32_t
*
)
ptr
)[
j
];
d
[
0
]
=
v
>>
16
;
d
[
1
]
=
v
>>
8
;
d
[
2
]
=
v
;
d
[
3
]
=
v
>>
24
;
d
+=
4
;
}
}
else
{
memcpy
(
crow_buf
+
1
,
ptr
,
row_size
);
}
crow_buf
[
0
]
=
PNG_FILTER_VALUE_NONE
;
zstream
.
avail_in
=
row_size
+
1
;
zstream
.
next_in
=
crow_buf
;
...
...
@@ -561,7 +623,8 @@ AVImageFormat png_image_format = {
"png"
,
png_probe
,
png_read
,
(
1
<<
PIX_FMT_RGB24
)
|
(
1
<<
PIX_FMT_GRAY8
)
|
(
1
<<
PIX_FMT_MONOBLACK
)
|
(
1
<<
PIX_FMT_PAL8
),
(
1
<<
PIX_FMT_RGBA32
)
|
(
1
<<
PIX_FMT_RGB24
)
|
(
1
<<
PIX_FMT_GRAY8
)
|
(
1
<<
PIX_FMT_MONOBLACK
)
|
(
1
<<
PIX_FMT_PAL8
),
png_write
,
};
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录