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
47ac3449
Commit
47ac3449
authored
May 06, 2013
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
id3v2enc: chapter support
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
d26f637b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
13 deletions
+69
-13
id3v2enc.c
libavformat/id3v2enc.c
+69
-13
No files found.
libavformat/id3v2enc.c
View file @
47ac3449
...
...
@@ -162,33 +162,31 @@ void ff_id3v2_start(ID3v2EncContext *id3, AVIOContext *pb, int id3v2_version,
avio_wb32
(
pb
,
0
);
}
int
ff_id3v2_write_metadata
(
AVFormatContext
*
s
,
ID3v2EncContext
*
id3
)
static
int
write_metadata
(
AVIOContext
*
pb
,
AVDictionary
**
metadata
,
ID3v2EncContext
*
id3
,
int
enc
)
{
AVDictionaryEntry
*
t
=
NULL
;
int
enc
=
id3
->
version
==
3
?
ID3v2_ENCODING_UTF16BOM
:
ID3v2_ENCODING_UTF8
;
int
ret
;
ff_metadata_conv
(
&
s
->
metadata
,
ff_id3v2_34_metadata_conv
,
NULL
);
ff_metadata_conv
(
metadata
,
ff_id3v2_34_metadata_conv
,
NULL
);
if
(
id3
->
version
==
3
)
id3v2_3_metadata_split_date
(
&
s
->
metadata
);
id3v2_3_metadata_split_date
(
metadata
);
else
if
(
id3
->
version
==
4
)
ff_metadata_conv
(
&
s
->
metadata
,
ff_id3v2_4_metadata_conv
,
NULL
);
while
((
t
=
av_dict_get
(
s
->
metadata
,
""
,
t
,
AV_DICT_IGNORE_SUFFIX
)))
{
int
ret
;
ff_metadata_conv
(
metadata
,
ff_id3v2_4_metadata_conv
,
NULL
);
if
((
ret
=
id3v2_check_write_tag
(
id3
,
s
->
pb
,
t
,
ff_id3v2_tags
,
enc
))
>
0
)
{
while
((
t
=
av_dict_get
(
*
metadata
,
""
,
t
,
AV_DICT_IGNORE_SUFFIX
)))
{
if
((
ret
=
id3v2_check_write_tag
(
id3
,
pb
,
t
,
ff_id3v2_tags
,
enc
))
>
0
)
{
id3
->
len
+=
ret
;
continue
;
}
if
((
ret
=
id3v2_check_write_tag
(
id3
,
s
->
pb
,
t
,
id3
->
version
==
3
?
ff_id3v2_3_tags
:
ff_id3v2_4_tags
,
enc
))
>
0
)
{
if
((
ret
=
id3v2_check_write_tag
(
id3
,
pb
,
t
,
id3
->
version
==
3
?
ff_id3v2_3_tags
:
ff_id3v2_4_tags
,
enc
))
>
0
)
{
id3
->
len
+=
ret
;
continue
;
}
/* unknown tag, write as TXXX frame */
if
((
ret
=
id3v2_put_ttag
(
id3
,
s
->
pb
,
t
->
key
,
t
->
value
,
MKBETAG
(
'T'
,
'X'
,
'X'
,
'X'
),
enc
))
<
0
)
if
((
ret
=
id3v2_put_ttag
(
id3
,
pb
,
t
->
key
,
t
->
value
,
MKBETAG
(
'T'
,
'X'
,
'X'
,
'X'
),
enc
))
<
0
)
return
ret
;
id3
->
len
+=
ret
;
}
...
...
@@ -196,6 +194,64 @@ int ff_id3v2_write_metadata(AVFormatContext *s, ID3v2EncContext *id3)
return
0
;
}
static
int
write_chapter
(
AVFormatContext
*
s
,
ID3v2EncContext
*
id3
,
int
id
,
int
enc
)
{
const
AVRational
time_base
=
{
1
,
1000
};
AVChapter
*
ch
=
s
->
chapters
[
id
];
uint8_t
*
dyn_buf
=
NULL
;
AVIOContext
*
dyn_bc
=
NULL
;
char
name
[
123
];
int
len
,
start
,
end
,
ret
;
if
((
ret
=
avio_open_dyn_buf
(
&
dyn_bc
))
<
0
)
goto
fail
;
start
=
av_rescale_q
(
ch
->
start
,
ch
->
time_base
,
time_base
);
end
=
av_rescale_q
(
ch
->
end
,
ch
->
time_base
,
time_base
);
snprintf
(
name
,
122
,
"ch%d"
,
id
);
id3
->
len
+=
avio_put_str
(
dyn_bc
,
name
);
avio_wb32
(
dyn_bc
,
start
);
avio_wb32
(
dyn_bc
,
end
);
avio_wb32
(
dyn_bc
,
0xFFFFFFFFu
);
avio_wb32
(
dyn_bc
,
0xFFFFFFFFu
);
if
((
ret
=
write_metadata
(
dyn_bc
,
&
ch
->
metadata
,
id3
,
enc
))
<
0
)
goto
fail
;
len
=
avio_close_dyn_buf
(
dyn_bc
,
&
dyn_buf
);
id3
->
len
+=
16
+
ID3v2_HEADER_SIZE
;
avio_wb32
(
s
->
pb
,
MKBETAG
(
'C'
,
'H'
,
'A'
,
'P'
));
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
;
}
int
ff_id3v2_write_metadata
(
AVFormatContext
*
s
,
ID3v2EncContext
*
id3
)
{
int
enc
=
id3
->
version
==
3
?
ID3v2_ENCODING_UTF16BOM
:
ID3v2_ENCODING_UTF8
;
int
i
,
ret
;
if
((
ret
=
write_metadata
(
s
->
pb
,
&
s
->
metadata
,
id3
,
enc
))
<
0
)
return
ret
;
for
(
i
=
0
;
i
<
s
->
nb_chapters
;
i
++
)
{
if
((
ret
=
write_chapter
(
s
,
id3
,
i
,
enc
))
<
0
)
return
ret
;
}
return
0
;
}
int
ff_id3v2_write_apic
(
AVFormatContext
*
s
,
ID3v2EncContext
*
id3
,
AVPacket
*
pkt
)
{
AVStream
*
st
=
s
->
streams
[
pkt
->
stream_index
];
...
...
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