Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
7e6d70d0
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,发现更多精彩内容 >>
提交
7e6d70d0
编写于
2月 09, 2003
作者:
F
Fabrice Bellard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added paletted 8 bit format support
Originally committed as revision 1560 to
svn://svn.ffmpeg.org/ffmpeg/trunk
上级
f70f7c6d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
122 addition
and
2 deletion
+122
-2
libavcodec/avcodec.h
libavcodec/avcodec.h
+3
-2
libavcodec/imgconvert.c
libavcodec/imgconvert.c
+119
-0
未找到文件。
libavcodec/avcodec.h
浏览文件 @
7e6d70d0
...
...
@@ -16,8 +16,8 @@ extern "C" {
#define LIBAVCODEC_VERSION_INT 0x000406
#define LIBAVCODEC_VERSION "0.4.6"
#define LIBAVCODEC_BUILD 465
5
#define LIBAVCODEC_BUILD_STR "465
5
"
#define LIBAVCODEC_BUILD 465
6
#define LIBAVCODEC_BUILD_STR "465
6
"
enum
CodecID
{
CODEC_ID_NONE
,
...
...
@@ -86,6 +86,7 @@ enum PixelFormat {
PIX_FMT_GRAY8
,
PIX_FMT_MONOWHITE
,
/* 0 is white */
PIX_FMT_MONOBLACK
,
/* 0 is black */
PIX_FMT_PAL8
,
/* 8 bit with RGBA palette */
PIX_FMT_NB
,
};
...
...
libavcodec/imgconvert.c
浏览文件 @
7e6d70d0
...
...
@@ -108,6 +108,12 @@ static PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
.
name
=
"monob"
,
.
nb_components
=
1
,
.
is_packed
=
1
,
.
is_gray
=
1
,
},
/* paletted formats */
[
PIX_FMT_PAL8
]
=
{
.
name
=
"pal8"
,
.
nb_components
=
1
,
.
is_packed
=
1
,
.
is_paletted
=
1
,
},
};
void
avcodec_get_chroma_sub_sample
(
int
pix_fmt
,
int
*
h_shift
,
int
*
v_shift
)
...
...
@@ -188,10 +194,19 @@ int avpicture_fill(AVPicture *picture, UINT8 *ptr,
picture
->
data
[
2
]
=
NULL
;
picture
->
linesize
[
0
]
=
(
width
+
7
)
>>
3
;
return
picture
->
linesize
[
0
]
*
height
;
case
PIX_FMT_PAL8
:
size2
=
(
size
+
3
)
&
~
3
;
picture
->
data
[
0
]
=
ptr
;
picture
->
data
[
1
]
=
ptr
+
size2
;
/* palette is stored here as 256 32 bit words */
picture
->
data
[
2
]
=
NULL
;
picture
->
linesize
[
0
]
=
width
;
picture
->
linesize
[
1
]
=
4
;
return
size2
+
256
*
4
;
default:
picture
->
data
[
0
]
=
NULL
;
picture
->
data
[
1
]
=
NULL
;
picture
->
data
[
2
]
=
NULL
;
picture
->
data
[
3
]
=
NULL
;
return
-
1
;
}
}
...
...
@@ -678,6 +693,38 @@ static void gray_to_ ## rgb_name(AVPicture *dst, AVPicture *src, \
p += src_wrap; \
q += dst_wrap; \
} \
} \
\
static void pal8_to_ ## rgb_name(AVPicture *dst, AVPicture *src, \
int width, int height) \
{ \
const unsigned char *p; \
unsigned char *q; \
int r, g, b, dst_wrap, src_wrap; \
int x, y; \
uint32_t v;\
const uint32_t *palette;\
\
p = src->data[0]; \
src_wrap = src->linesize[0] - width; \
palette = (uint32_t *)src->data[1];\
\
q = dst->data[0]; \
dst_wrap = dst->linesize[0] - BPP * width; \
\
for(y=0;y<height;y++) { \
for(x=0;x<width;x++) { \
v = palette[p[0]];\
r = (v >> 16) & 0xff;\
g = (v >> 8) & 0xff;\
b = (v) & 0xff;\
RGB_OUT(q, r, g, b); \
q += BPP; \
p ++; \
} \
p += src_wrap; \
q += dst_wrap; \
} \
}
/* copy bit n to bits 0 ... n - 1 */
...
...
@@ -977,6 +1024,58 @@ static void gray_to_monoblack(AVPicture *dst, AVPicture *src,
gray_to_mono
(
dst
,
src
,
width
,
height
,
0x00
);
}
/* this is maybe slow, but allows for extensions */
static
inline
unsigned
char
gif_clut_index
(
UINT8
r
,
UINT8
g
,
UINT8
b
)
{
return
((((
r
)
/
47
)
%
6
)
*
6
*
6
+
(((
g
)
/
47
)
%
6
)
*
6
+
(((
b
)
/
47
)
%
6
));
}
/* XXX: put jpeg quantize code instead */
static
void
rgb24_to_pal8
(
AVPicture
*
dst
,
AVPicture
*
src
,
int
width
,
int
height
)
{
const
unsigned
char
*
p
;
unsigned
char
*
q
;
int
r
,
g
,
b
,
dst_wrap
,
src_wrap
;
int
x
,
y
,
i
;
static
const
uint8_t
pal_value
[
6
]
=
{
0x00
,
0x33
,
0x66
,
0x99
,
0xcc
,
0xff
};
uint32_t
*
pal
;
p
=
src
->
data
[
0
];
src_wrap
=
src
->
linesize
[
0
]
-
3
*
width
;
q
=
dst
->
data
[
0
];
dst_wrap
=
dst
->
linesize
[
0
]
-
width
;
for
(
y
=
0
;
y
<
height
;
y
++
)
{
for
(
x
=
0
;
x
<
width
;
x
++
)
{
r
=
p
[
0
];
g
=
p
[
1
];
b
=
p
[
2
];
q
[
0
]
=
gif_clut_index
(
r
,
g
,
b
);
q
++
;
p
+=
3
;
}
p
+=
src_wrap
;
q
+=
dst_wrap
;
}
/* build palette */
pal
=
(
uint32_t
*
)
dst
->
data
[
1
];
i
=
0
;
for
(
r
=
0
;
r
<
6
;
r
++
)
{
for
(
g
=
0
;
g
<
6
;
g
++
)
{
for
(
b
=
0
;
b
<
6
;
b
++
)
{
pal
[
i
++
]
=
(
0xff
<<
24
)
|
(
pal_value
[
r
]
<<
16
)
|
(
pal_value
[
g
]
<<
8
)
|
pal_value
[
b
];
}
}
}
while
(
i
<
256
)
pal
[
i
++
]
=
0
;
}
typedef
struct
ConvertEntry
{
void
(
*
convert
)(
AVPicture
*
dst
,
AVPicture
*
src
,
int
width
,
int
height
);
}
ConvertEntry
;
...
...
@@ -1039,6 +1138,9 @@ static ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
[
PIX_FMT_GRAY8
]
=
{
.
convert
=
rgb24_to_gray
},
[
PIX_FMT_PAL8
]
=
{
.
convert
=
rgb24_to_pal8
},
},
[
PIX_FMT_RGBA32
]
=
{
[
PIX_FMT_YUV420P
]
=
{
...
...
@@ -1105,6 +1207,23 @@ static ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
.
convert
=
monoblack_to_gray
},
},
[
PIX_FMT_PAL8
]
=
{
[
PIX_FMT_RGB555
]
=
{
.
convert
=
pal8_to_rgb555
},
[
PIX_FMT_RGB565
]
=
{
.
convert
=
pal8_to_rgb565
},
[
PIX_FMT_BGR24
]
=
{
.
convert
=
pal8_to_bgr24
},
[
PIX_FMT_RGB24
]
=
{
.
convert
=
pal8_to_rgb24
},
[
PIX_FMT_RGBA32
]
=
{
.
convert
=
pal8_to_rgba32
},
},
};
static
int
avpicture_alloc
(
AVPicture
*
picture
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录