Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
7221579b
Commit
7221579b
authored
Apr 21, 2010
by
David Conrad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mov: Read QuickTime chapters
Originally committed as revision 22928 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
dc75e4e3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
0 deletions
+79
-0
isom.h
libavformat/isom.h
+1
-0
mov.c
libavformat/mov.c
+78
-0
No files found.
libavformat/isom.h
View file @
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
View file @
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
;
}
...
...
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