Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
a3b53ff0
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,发现更多精彩内容 >>
提交
a3b53ff0
编写于
8月 22, 2013
作者:
L
Luca Barbato
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mov: Refactor video specific parsing in mov_parse_stsd_video
上级
bf985625
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
108 addition
and
107 deletion
+108
-107
libavformat/mov.c
libavformat/mov.c
+108
-107
未找到文件。
libavformat/mov.c
浏览文件 @
a3b53ff0
...
...
@@ -1100,11 +1100,117 @@ static int mov_codec_id(AVStream *st, uint32_t format)
return
id
;
}
static
void
mov_parse_stsd_video
(
MOVContext
*
c
,
AVIOContext
*
pb
,
AVStream
*
st
,
MOVStreamContext
*
sc
)
{
unsigned
int
color_depth
,
len
,
j
;
int
color_greyscale
;
int
color_table_id
;
avio_rb16
(
pb
);
/* version */
avio_rb16
(
pb
);
/* revision level */
avio_rb32
(
pb
);
/* vendor */
avio_rb32
(
pb
);
/* temporal quality */
avio_rb32
(
pb
);
/* spatial quality */
st
->
codec
->
width
=
avio_rb16
(
pb
);
/* width */
st
->
codec
->
height
=
avio_rb16
(
pb
);
/* height */
avio_rb32
(
pb
);
/* horiz resolution */
avio_rb32
(
pb
);
/* vert resolution */
avio_rb32
(
pb
);
/* data size, always 0 */
avio_rb16
(
pb
);
/* frames per samples */
len
=
avio_r8
(
pb
);
/* codec name, pascal string */
if
(
len
>
31
)
len
=
31
;
mov_read_mac_string
(
c
,
pb
,
len
,
st
->
codec
->
codec_name
,
32
);
if
(
len
<
31
)
avio_skip
(
pb
,
31
-
len
);
/* codec_tag YV12 triggers an UV swap in rawdec.c */
if
(
!
memcmp
(
st
->
codec
->
codec_name
,
"Planar Y'CbCr 8-bit 4:2:0"
,
25
))
st
->
codec
->
codec_tag
=
MKTAG
(
'I'
,
'4'
,
'2'
,
'0'
);
/* Flash Media Server uses tag H263 with Sorenson Spark */
if
(
st
->
codec
->
codec_tag
==
MKTAG
(
'H'
,
'2'
,
'6'
,
'3'
)
&&
!
memcmp
(
st
->
codec
->
codec_name
,
"Sorenson H263"
,
13
))
st
->
codec
->
codec_id
=
AV_CODEC_ID_FLV1
;
st
->
codec
->
bits_per_coded_sample
=
avio_rb16
(
pb
);
/* depth */
color_table_id
=
avio_rb16
(
pb
);
/* colortable id */
av_dlog
(
c
->
fc
,
"depth %d, ctab id %d
\n
"
,
st
->
codec
->
bits_per_coded_sample
,
color_table_id
);
/* figure out the palette situation */
color_depth
=
st
->
codec
->
bits_per_coded_sample
&
0x1F
;
color_greyscale
=
st
->
codec
->
bits_per_coded_sample
&
0x20
;
/* if the depth is 2, 4, or 8 bpp, file is palettized */
if
((
color_depth
==
2
)
||
(
color_depth
==
4
)
||
(
color_depth
==
8
))
{
/* for palette traversal */
unsigned
int
color_start
,
color_count
,
color_end
;
unsigned
char
r
,
g
,
b
;
if
(
color_greyscale
)
{
int
color_index
,
color_dec
;
/* compute the greyscale palette */
st
->
codec
->
bits_per_coded_sample
=
color_depth
;
color_count
=
1
<<
color_depth
;
color_index
=
255
;
color_dec
=
256
/
(
color_count
-
1
);
for
(
j
=
0
;
j
<
color_count
;
j
++
)
{
r
=
g
=
b
=
color_index
;
sc
->
palette
[
j
]
=
(
r
<<
16
)
|
(
g
<<
8
)
|
(
b
);
color_index
-=
color_dec
;
if
(
color_index
<
0
)
color_index
=
0
;
}
}
else
if
(
color_table_id
)
{
const
uint8_t
*
color_table
;
/* if flag bit 3 is set, use the default palette */
color_count
=
1
<<
color_depth
;
if
(
color_depth
==
2
)
color_table
=
ff_qt_default_palette_4
;
else
if
(
color_depth
==
4
)
color_table
=
ff_qt_default_palette_16
;
else
color_table
=
ff_qt_default_palette_256
;
for
(
j
=
0
;
j
<
color_count
;
j
++
)
{
r
=
color_table
[
j
*
3
+
0
];
g
=
color_table
[
j
*
3
+
1
];
b
=
color_table
[
j
*
3
+
2
];
sc
->
palette
[
j
]
=
(
r
<<
16
)
|
(
g
<<
8
)
|
(
b
);
}
}
else
{
/* load the palette from the file */
color_start
=
avio_rb32
(
pb
);
color_count
=
avio_rb16
(
pb
);
color_end
=
avio_rb16
(
pb
);
if
((
color_start
<=
255
)
&&
(
color_end
<=
255
))
{
for
(
j
=
color_start
;
j
<=
color_end
;
j
++
)
{
/* each R, G, or B component is 16 bits;
* only use the top 8 bits; skip alpha bytes
* up front */
avio_r8
(
pb
);
avio_r8
(
pb
);
r
=
avio_r8
(
pb
);
avio_r8
(
pb
);
g
=
avio_r8
(
pb
);
avio_r8
(
pb
);
b
=
avio_r8
(
pb
);
avio_r8
(
pb
);
sc
->
palette
[
j
]
=
(
r
<<
16
)
|
(
g
<<
8
)
|
(
b
);
}
}
}
sc
->
has_palette
=
1
;
}
}
int
ff_mov_read_stsd_entries
(
MOVContext
*
c
,
AVIOContext
*
pb
,
int
entries
)
{
AVStream
*
st
;
MOVStreamContext
*
sc
;
int
j
,
pseudo_stream_id
;
int
pseudo_stream_id
;
if
(
c
->
fc
->
nb_streams
<
1
)
return
0
;
...
...
@@ -1157,113 +1263,8 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
(
format
>>
24
)
&
0xff
,
st
->
codec
->
codec_type
);
if
(
st
->
codec
->
codec_type
==
AVMEDIA_TYPE_VIDEO
)
{
unsigned
int
color_depth
,
len
;
int
color_greyscale
;
int
color_table_id
;
st
->
codec
->
codec_id
=
id
;
avio_rb16
(
pb
);
/* version */
avio_rb16
(
pb
);
/* revision level */
avio_rb32
(
pb
);
/* vendor */
avio_rb32
(
pb
);
/* temporal quality */
avio_rb32
(
pb
);
/* spatial quality */
st
->
codec
->
width
=
avio_rb16
(
pb
);
/* width */
st
->
codec
->
height
=
avio_rb16
(
pb
);
/* height */
avio_rb32
(
pb
);
/* horiz resolution */
avio_rb32
(
pb
);
/* vert resolution */
avio_rb32
(
pb
);
/* data size, always 0 */
avio_rb16
(
pb
);
/* frames per samples */
len
=
avio_r8
(
pb
);
/* codec name, pascal string */
if
(
len
>
31
)
len
=
31
;
mov_read_mac_string
(
c
,
pb
,
len
,
st
->
codec
->
codec_name
,
32
);
if
(
len
<
31
)
avio_skip
(
pb
,
31
-
len
);
/* codec_tag YV12 triggers an UV swap in rawdec.c */
if
(
!
memcmp
(
st
->
codec
->
codec_name
,
"Planar Y'CbCr 8-bit 4:2:0"
,
25
))
st
->
codec
->
codec_tag
=
MKTAG
(
'I'
,
'4'
,
'2'
,
'0'
);
/* Flash Media Server uses tag H263 with Sorenson Spark */
if
(
format
==
MKTAG
(
'H'
,
'2'
,
'6'
,
'3'
)
&&
!
memcmp
(
st
->
codec
->
codec_name
,
"Sorenson H263"
,
13
))
st
->
codec
->
codec_id
=
AV_CODEC_ID_FLV1
;
st
->
codec
->
bits_per_coded_sample
=
avio_rb16
(
pb
);
/* depth */
color_table_id
=
avio_rb16
(
pb
);
/* colortable id */
av_dlog
(
c
->
fc
,
"depth %d, ctab id %d
\n
"
,
st
->
codec
->
bits_per_coded_sample
,
color_table_id
);
/* figure out the palette situation */
color_depth
=
st
->
codec
->
bits_per_coded_sample
&
0x1F
;
color_greyscale
=
st
->
codec
->
bits_per_coded_sample
&
0x20
;
/* if the depth is 2, 4, or 8 bpp, file is palettized */
if
((
color_depth
==
2
)
||
(
color_depth
==
4
)
||
(
color_depth
==
8
))
{
/* for palette traversal */
unsigned
int
color_start
,
color_count
,
color_end
;
unsigned
char
r
,
g
,
b
;
if
(
color_greyscale
)
{
int
color_index
,
color_dec
;
/* compute the greyscale palette */
st
->
codec
->
bits_per_coded_sample
=
color_depth
;
color_count
=
1
<<
color_depth
;
color_index
=
255
;
color_dec
=
256
/
(
color_count
-
1
);
for
(
j
=
0
;
j
<
color_count
;
j
++
)
{
r
=
g
=
b
=
color_index
;
sc
->
palette
[
j
]
=
(
r
<<
16
)
|
(
g
<<
8
)
|
(
b
);
color_index
-=
color_dec
;
if
(
color_index
<
0
)
color_index
=
0
;
}
}
else
if
(
color_table_id
)
{
const
uint8_t
*
color_table
;
/* if flag bit 3 is set, use the default palette */
color_count
=
1
<<
color_depth
;
if
(
color_depth
==
2
)
color_table
=
ff_qt_default_palette_4
;
else
if
(
color_depth
==
4
)
color_table
=
ff_qt_default_palette_16
;
else
color_table
=
ff_qt_default_palette_256
;
for
(
j
=
0
;
j
<
color_count
;
j
++
)
{
r
=
color_table
[
j
*
3
+
0
];
g
=
color_table
[
j
*
3
+
1
];
b
=
color_table
[
j
*
3
+
2
];
sc
->
palette
[
j
]
=
(
r
<<
16
)
|
(
g
<<
8
)
|
(
b
);
}
}
else
{
/* load the palette from the file */
color_start
=
avio_rb32
(
pb
);
color_count
=
avio_rb16
(
pb
);
color_end
=
avio_rb16
(
pb
);
if
((
color_start
<=
255
)
&&
(
color_end
<=
255
))
{
for
(
j
=
color_start
;
j
<=
color_end
;
j
++
)
{
/* each R, G, or B component is 16 bits;
* only use the top 8 bits; skip alpha bytes
* up front */
avio_r8
(
pb
);
avio_r8
(
pb
);
r
=
avio_r8
(
pb
);
avio_r8
(
pb
);
g
=
avio_r8
(
pb
);
avio_r8
(
pb
);
b
=
avio_r8
(
pb
);
avio_r8
(
pb
);
sc
->
palette
[
j
]
=
(
r
<<
16
)
|
(
g
<<
8
)
|
(
b
);
}
}
}
sc
->
has_palette
=
1
;
}
mov_parse_stsd_video
(
c
,
pb
,
st
,
sc
);
}
else
if
(
st
->
codec
->
codec_type
==
AVMEDIA_TYPE_AUDIO
)
{
int
bits_per_sample
,
flags
;
uint16_t
version
=
avio_rb16
(
pb
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录