Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
7221579b
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,发现更多精彩内容 >>
提交
7221579b
编写于
4月 21, 2010
作者:
D
David Conrad
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mov: Read QuickTime chapters
Originally committed as revision 22928 to
svn://svn.ffmpeg.org/ffmpeg/trunk
上级
dc75e4e3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
79 addition
and
0 deletion
+79
-0
libavformat/isom.h
libavformat/isom.h
+1
-0
libavformat/mov.c
libavformat/mov.c
+78
-0
未找到文件。
libavformat/isom.h
浏览文件 @
7221579b
...
...
@@ -138,6 +138,7 @@ typedef struct MOVContext {
MOVTrackExt
*
trex_data
;
unsigned
trex_count
;
int
itunes_metadata
;
///< metadata are itunes style
int
chapter_track
;
}
MOVContext
;
int
ff_mp4_read_descr_len
(
ByteIOContext
*
pb
);
...
...
libavformat/mov.c
浏览文件 @
7221579b
...
...
@@ -1953,6 +1953,12 @@ static int mov_read_tfhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return
0
;
}
static
int
mov_read_chap
(
MOVContext
*
c
,
ByteIOContext
*
pb
,
MOVAtom
atom
)
{
c
->
chapter_track
=
get_be32
(
pb
);
return
0
;
}
static
int
mov_read_trex
(
MOVContext
*
c
,
ByteIOContext
*
pb
,
MOVAtom
atom
)
{
MOVTrackExt
*
trex
;
...
...
@@ -2200,6 +2206,8 @@ static const MOVParseTableEntry mov_default_parse_table[] = {
{
MKTAG
(
't'
,
'f'
,
'h'
,
'd'
),
mov_read_tfhd
},
/* track fragment header */
{
MKTAG
(
't'
,
'r'
,
'a'
,
'k'
),
mov_read_trak
},
{
MKTAG
(
't'
,
'r'
,
'a'
,
'f'
),
mov_read_default
},
{
MKTAG
(
't'
,
'r'
,
'e'
,
'f'
),
mov_read_default
},
{
MKTAG
(
'c'
,
'h'
,
'a'
,
'p'
),
mov_read_chap
},
{
MKTAG
(
't'
,
'r'
,
'e'
,
'x'
),
mov_read_trex
},
{
MKTAG
(
't'
,
'r'
,
'u'
,
'n'
),
mov_read_trun
},
{
MKTAG
(
'u'
,
'd'
,
't'
,
'a'
),
mov_read_default
},
...
...
@@ -2255,6 +2263,73 @@ static int mov_probe(AVProbeData *p)
return
score
;
}
// must be done after parsing all trak because there's no order requirement
static
void
mov_read_chapters
(
AVFormatContext
*
s
)
{
MOVContext
*
mov
=
s
->
priv_data
;
AVStream
*
st
=
NULL
;
MOVStreamContext
*
sc
;
int64_t
cur_pos
;
uint8_t
*
title
=
NULL
;
int
i
,
len
,
i8
,
i16
;
for
(
i
=
0
;
i
<
s
->
nb_streams
;
i
++
)
if
(
s
->
streams
[
i
]
->
id
==
mov
->
chapter_track
)
{
st
=
s
->
streams
[
i
];
break
;
}
if
(
!
st
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Referenced QT chapter track not found
\n
"
);
return
;
}
st
->
discard
=
AVDISCARD_ALL
;
sc
=
st
->
priv_data
;
cur_pos
=
url_ftell
(
sc
->
pb
);
for
(
i
=
0
;
i
<
st
->
nb_index_entries
;
i
++
)
{
AVIndexEntry
*
sample
=
&
st
->
index_entries
[
i
];
int64_t
end
=
i
+
1
<
st
->
nb_index_entries
?
st
->
index_entries
[
i
+
1
].
timestamp
:
st
->
duration
;
if
(
url_fseek
(
sc
->
pb
,
sample
->
pos
,
SEEK_SET
)
!=
sample
->
pos
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Chapter %d not found in file
\n
"
,
i
);
goto
finish
;
}
title
=
av_malloc
(
sample
->
size
+
2
);
get_buffer
(
sc
->
pb
,
title
,
sample
->
size
);
// the first two bytes are the length of the title
len
=
AV_RB16
(
title
);
if
(
len
>
sample
->
size
-
2
)
continue
;
// The samples could theoretically be in any encoding if there's an encd
// atom following, but in practice are only utf-8 or utf-16, distinguished
// instead by the presence of a BOM
if
(
AV_RB16
(
title
+
2
)
==
0xfeff
)
{
uint8_t
*
utf8
=
av_malloc
(
2
*
len
+
3
);
i8
=
i16
=
0
;
while
(
i16
<
len
)
{
uint32_t
ch
;
uint8_t
tmp
;
GET_UTF16
(
ch
,
i16
<
len
?
AV_RB16
(
title
+
(
i16
+=
2
))
:
0
,
break
;)
PUT_UTF8
(
ch
,
tmp
,
if
(
i8
<
2
*
len
)
utf8
[
2
+
i8
++
]
=
tmp
;)
}
utf8
[
2
+
i8
]
=
0
;
av_freep
(
&
title
);
title
=
utf8
;
}
ff_new_chapter
(
s
,
i
,
st
->
time_base
,
sample
->
timestamp
,
end
,
title
+
2
);
av_freep
(
&
title
);
}
finish:
av_free
(
title
);
url_fseek
(
sc
->
pb
,
cur_pos
,
SEEK_SET
);
}
static
int
mov_read_header
(
AVFormatContext
*
s
,
AVFormatParameters
*
ap
)
{
MOVContext
*
mov
=
s
->
priv_data
;
...
...
@@ -2280,6 +2355,9 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
dprintf
(
mov
->
fc
,
"on_parse_exit_offset=%lld
\n
"
,
url_ftell
(
pb
));
if
(
!
url_is_streamed
(
pb
)
&&
mov
->
chapter_track
>
0
)
mov_read_chapters
(
s
);
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录