1 /*
2 * VorbisComment writer
3 * Copyright (c) 2009 James Darnley
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
27
28 /**
29 * VorbisComment metadata conversion mapping.
30 * from Ogg Vorbis I format specification: comment field and header specification
31 * http://xiph.org/vorbis/doc/v-comment.html
32 */
34 { "ALBUMARTIST", "album_artist"},
35 { "TRACKNUMBER", "track" },
36 { "DISCNUMBER", "disc" },
37 { "DESCRIPTION", "comment" },
38 { 0 }
39 };
40
42 AVChapter **chapters,
unsigned int nb_chapters)
43 {
45 len += strlen(vendor_string);
46 if (chapters && nb_chapters) {
47 for (
int i = 0;
i < nb_chapters;
i++) {
49 len += 4 + 12 + 1 + 10;
51 int64_t len1 = !strcmp(
tag->key,
"title") ? 4 : strlen(
tag->key);
52 len += 4 + 10 + len1 + 1 + strlen(
tag->value);
53 }
54 }
55 }
56 if (m) {
59 len += 4 +strlen(
tag->key) + 1 + strlen(
tag->value);
60 }
61 }
63 }
64
66 const char *vendor_string,
67 AVChapter **chapters,
unsigned int nb_chapters)
68 {
69 size_t vendor_string_length = strlen(vendor_string);
70 int cm_count = 0;
72 avio_write(pb, vendor_string, vendor_string_length);
73 if (chapters && nb_chapters) {
74 for (
int i = 0;
i < nb_chapters;
i++) {
76 }
77 }
78 if (m) {
83 int64_t len1 = strlen(
tag->key);
84 int64_t len2 = strlen(
tag->value);
85 if (len1+1+len2 > UINT32_MAX)
91 }
92 for (
int i = 0;
i < nb_chapters;
i++) {
94 char chapter_time[13];
95 char chapter_number[4];
97
103 snprintf(chapter_number,
sizeof(chapter_number),
"%03d",
i);
104 snprintf(chapter_time,
sizeof(chapter_time),
"%02d:%02d:%02d.%03d",
h, m,
s, ms);
110
113 int64_t len1 = !strcmp(
tag->key,
"title") ? 4 : strlen(
tag->key);
114 int64_t len2 = strlen(
tag->value);
115 if (len1+1+len2+10 > UINT32_MAX)
120 if (!strcmp(
tag->key,
"title"))
122 else
126 }
127 }
128 } else
130 return 0;
131 }