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
79aa91d5
Commit
79aa91d5
authored
Jun 04, 2019
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/id3v2enc: write CTOC too
parent
1e7a8b92
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
+39
-0
id3v2enc.c
libavformat/id3v2enc.c
+39
-0
No files found.
libavformat/id3v2enc.c
View file @
79aa91d5
...
...
@@ -255,6 +255,42 @@ static int write_metadata(AVIOContext *pb, AVDictionary **metadata,
return
0
;
}
static
int
write_ctoc
(
AVFormatContext
*
s
,
ID3v2EncContext
*
id3
,
int
enc
)
{
uint8_t
*
dyn_buf
=
NULL
;
AVIOContext
*
dyn_bc
=
NULL
;
char
name
[
123
];
int
len
,
ret
;
if
(
s
->
nb_chapters
==
0
)
return
0
;
if
((
ret
=
avio_open_dyn_buf
(
&
dyn_bc
))
<
0
)
goto
fail
;
id3
->
len
+=
avio_put_str
(
dyn_bc
,
"toc"
);
avio_wb16
(
dyn_bc
,
0x03
);
avio_w8
(
dyn_bc
,
s
->
nb_chapters
);
for
(
int
i
=
0
;
i
<
s
->
nb_chapters
;
i
++
)
{
snprintf
(
name
,
122
,
"ch%d"
,
i
);
id3
->
len
+=
avio_put_str
(
dyn_bc
,
name
);
}
len
=
avio_close_dyn_buf
(
dyn_bc
,
&
dyn_buf
);
id3
->
len
+=
16
+
ID3v2_HEADER_SIZE
;
avio_wb32
(
s
->
pb
,
MKBETAG
(
'C'
,
'T'
,
'O'
,
'C'
));
avio_wb32
(
s
->
pb
,
len
);
avio_wb16
(
s
->
pb
,
0
);
avio_write
(
s
->
pb
,
dyn_buf
,
len
);
fail:
if
(
dyn_bc
&&
!
dyn_buf
)
avio_close_dyn_buf
(
dyn_bc
,
&
dyn_buf
);
av_freep
(
&
dyn_buf
);
return
ret
;
}
static
int
write_chapter
(
AVFormatContext
*
s
,
ID3v2EncContext
*
id3
,
int
id
,
int
enc
)
{
const
AVRational
time_base
=
{
1
,
1000
};
...
...
@@ -306,6 +342,9 @@ int ff_id3v2_write_metadata(AVFormatContext *s, ID3v2EncContext *id3)
if
((
ret
=
write_metadata
(
s
->
pb
,
&
s
->
metadata
,
id3
,
enc
))
<
0
)
return
ret
;
if
((
ret
=
write_ctoc
(
s
,
id3
,
enc
))
<
0
)
return
ret
;
for
(
i
=
0
;
i
<
s
->
nb_chapters
;
i
++
)
{
if
((
ret
=
write_chapter
(
s
,
id3
,
i
,
enc
))
<
0
)
return
ret
;
...
...
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