annotate id3v1.c @ 6455:3f50c7effad1 libavformat

rtsp: 10l, try to update the correct rtp stream This fixes a bug from rev 22917. Now RTSP streams where the individual RTCP sender reports aren't sent at the same time actually are synced properly.
author mstorsjo
date Fri, 03 Sep 2010 07:10:21 +0000
parents f74198942337
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 858
diff changeset
1 /*
5016
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4900
diff changeset
2 * ID3v1 header parser
4251
77e0c7511d41 cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents: 4221
diff changeset
3 * Copyright (c) 2003 Fabrice Bellard
234
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
4 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1321
diff changeset
5 * This file is part of FFmpeg.
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1321
diff changeset
6 *
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1321
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
234
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1321
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
234
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
11 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1321
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
234
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
15 * Lesser General Public License for more details.
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
16 *
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1321
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
896
edbe5c3717f9 Update licensing information: The FSF changed postal address.
diego
parents: 885
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
234
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
20 */
3286
6f61c3b36632 Use full path for #includes from another directory.
diego
parents: 3278
diff changeset
21
5016
eb6dd7717805 Move id3v2 parsing code from mp3.c to id3v2.h and id3v2.c.
diego
parents: 4900
diff changeset
22 #include "id3v1.h"
5045
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
23 #include "libavcodec/avcodec.h"
5450
daea7c5405ac Simplify code by using av_metadata_set2().
michael
parents: 5448
diff changeset
24 #include "libavutil/avstring.h"
234
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
25
5160
eb33b7205b3c ff_id3v1_genre_str table should be const.
reimar
parents: 5045
diff changeset
26 const char * const ff_id3v1_genre_str[ID3v1_GENRE_MAX + 1] = {
5017
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
27 [0] = "Blues",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
28 [1] = "Classic Rock",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
29 [2] = "Country",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
30 [3] = "Dance",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
31 [4] = "Disco",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
32 [5] = "Funk",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
33 [6] = "Grunge",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
34 [7] = "Hip-Hop",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
35 [8] = "Jazz",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
36 [9] = "Metal",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
37 [10] = "New Age",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
38 [11] = "Oldies",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
39 [12] = "Other",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
40 [13] = "Pop",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
41 [14] = "R&B",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
42 [15] = "Rap",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
43 [16] = "Reggae",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
44 [17] = "Rock",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
45 [18] = "Techno",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
46 [19] = "Industrial",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
47 [20] = "Alternative",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
48 [21] = "Ska",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
49 [22] = "Death Metal",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
50 [23] = "Pranks",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
51 [24] = "Soundtrack",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
52 [25] = "Euro-Techno",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
53 [26] = "Ambient",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
54 [27] = "Trip-Hop",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
55 [28] = "Vocal",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
56 [29] = "Jazz+Funk",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
57 [30] = "Fusion",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
58 [31] = "Trance",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
59 [32] = "Classical",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
60 [33] = "Instrumental",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
61 [34] = "Acid",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
62 [35] = "House",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
63 [36] = "Game",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
64 [37] = "Sound Clip",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
65 [38] = "Gospel",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
66 [39] = "Noise",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
67 [40] = "AlternRock",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
68 [41] = "Bass",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
69 [42] = "Soul",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
70 [43] = "Punk",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
71 [44] = "Space",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
72 [45] = "Meditative",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
73 [46] = "Instrumental Pop",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
74 [47] = "Instrumental Rock",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
75 [48] = "Ethnic",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
76 [49] = "Gothic",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
77 [50] = "Darkwave",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
78 [51] = "Techno-Industrial",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
79 [52] = "Electronic",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
80 [53] = "Pop-Folk",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
81 [54] = "Eurodance",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
82 [55] = "Dream",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
83 [56] = "Southern Rock",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
84 [57] = "Comedy",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
85 [58] = "Cult",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
86 [59] = "Gangsta",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
87 [60] = "Top 40",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
88 [61] = "Christian Rap",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
89 [62] = "Pop/Funk",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
90 [63] = "Jungle",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
91 [64] = "Native American",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
92 [65] = "Cabaret",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
93 [66] = "New Wave",
5592
8d7341df7f4c Revert Revision: 21473
michael
parents: 5591
diff changeset
94 [67] = "Psychadelic",
5017
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
95 [68] = "Rave",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
96 [69] = "Showtunes",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
97 [70] = "Trailer",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
98 [71] = "Lo-Fi",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
99 [72] = "Tribal",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
100 [73] = "Acid Punk",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
101 [74] = "Acid Jazz",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
102 [75] = "Polka",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
103 [76] = "Retro",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
104 [77] = "Musical",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
105 [78] = "Rock & Roll",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
106 [79] = "Hard Rock",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
107 [80] = "Folk",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
108 [81] = "Folk-Rock",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
109 [82] = "National Folk",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
110 [83] = "Swing",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
111 [84] = "Fast Fusion",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
112 [85] = "Bebob",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
113 [86] = "Latin",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
114 [87] = "Revival",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
115 [88] = "Celtic",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
116 [89] = "Bluegrass",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
117 [90] = "Avantgarde",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
118 [91] = "Gothic Rock",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
119 [92] = "Progressive Rock",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
120 [93] = "Psychedelic Rock",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
121 [94] = "Symphonic Rock",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
122 [95] = "Slow Rock",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
123 [96] = "Big Band",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
124 [97] = "Chorus",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
125 [98] = "Easy Listening",
1763f7d0d8d0 cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents: 5016
diff changeset
126 [99] = "Acoustic",
234
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
127 [100] = "Humour",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
128 [101] = "Speech",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
129 [102] = "Chanson",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
130 [103] = "Opera",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
131 [104] = "Chamber Music",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
132 [105] = "Sonata",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
133 [106] = "Symphony",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
134 [107] = "Booty Bass",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
135 [108] = "Primus",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
136 [109] = "Porn Groove",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
137 [110] = "Satire",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
138 [111] = "Slow Jam",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
139 [112] = "Club",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
140 [113] = "Tango",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
141 [114] = "Samba",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
142 [115] = "Folklore",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
143 [116] = "Ballad",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
144 [117] = "Power Ballad",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
145 [118] = "Rhythmic Soul",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
146 [119] = "Freestyle",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
147 [120] = "Duet",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
148 [121] = "Punk Rock",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
149 [122] = "Drum Solo",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
150 [123] = "A capella",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
151 [124] = "Euro-House",
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
152 [125] = "Dance Hall",
5447
1c7cdbafd33c More ID3v1 genres from ffmbc.
michael
parents: 5160
diff changeset
153 [126] = "Goa",
1c7cdbafd33c More ID3v1 genres from ffmbc.
michael
parents: 5160
diff changeset
154 [127] = "Drum & Bass",
1c7cdbafd33c More ID3v1 genres from ffmbc.
michael
parents: 5160
diff changeset
155 [128] = "Club-House",
1c7cdbafd33c More ID3v1 genres from ffmbc.
michael
parents: 5160
diff changeset
156 [129] = "Hardcore",
1c7cdbafd33c More ID3v1 genres from ffmbc.
michael
parents: 5160
diff changeset
157 [130] = "Terror",
1c7cdbafd33c More ID3v1 genres from ffmbc.
michael
parents: 5160
diff changeset
158 [131] = "Indie",
1c7cdbafd33c More ID3v1 genres from ffmbc.
michael
parents: 5160
diff changeset
159 [132] = "BritPop",
1c7cdbafd33c More ID3v1 genres from ffmbc.
michael
parents: 5160
diff changeset
160 [133] = "Negerpunk",
1c7cdbafd33c More ID3v1 genres from ffmbc.
michael
parents: 5160
diff changeset
161 [134] = "Polsk Punk",
1c7cdbafd33c More ID3v1 genres from ffmbc.
michael
parents: 5160
diff changeset
162 [135] = "Beat",
1c7cdbafd33c More ID3v1 genres from ffmbc.
michael
parents: 5160
diff changeset
163 [136] = "Christian Gangsta",
1c7cdbafd33c More ID3v1 genres from ffmbc.
michael
parents: 5160
diff changeset
164 [137] = "Heavy Metal",
1c7cdbafd33c More ID3v1 genres from ffmbc.
michael
parents: 5160
diff changeset
165 [138] = "Black Metal",
1c7cdbafd33c More ID3v1 genres from ffmbc.
michael
parents: 5160
diff changeset
166 [139] = "Crossover",
5453
39e5af193378 Correct truncated ID3v1 genre name.
astrange
parents: 5450
diff changeset
167 [140] = "Contemporary Christian",
5447
1c7cdbafd33c More ID3v1 genres from ffmbc.
michael
parents: 5160
diff changeset
168 [141] = "Christian Rock",
1c7cdbafd33c More ID3v1 genres from ffmbc.
michael
parents: 5160
diff changeset
169 [142] = "Merengue",
1c7cdbafd33c More ID3v1 genres from ffmbc.
michael
parents: 5160
diff changeset
170 [143] = "Salsa",
1c7cdbafd33c More ID3v1 genres from ffmbc.
michael
parents: 5160
diff changeset
171 [144] = "Thrash Metal",
1c7cdbafd33c More ID3v1 genres from ffmbc.
michael
parents: 5160
diff changeset
172 [145] = "Anime",
1c7cdbafd33c More ID3v1 genres from ffmbc.
michael
parents: 5160
diff changeset
173 [146] = "JPop",
1c7cdbafd33c More ID3v1 genres from ffmbc.
michael
parents: 5160
diff changeset
174 [147] = "SynthPop",
234
b99548e3ab84 ID3 parsing and generation in MP3 format
bellard
parents:
diff changeset
175 };
5045
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
176
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
177 static void get_string(AVFormatContext *s, const char *key,
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
178 const uint8_t *buf, int buf_size)
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
179 {
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
180 int i, c;
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
181 char *q, str[512];
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
182
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
183 q = str;
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
184 for(i = 0; i < buf_size; i++) {
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
185 c = buf[i];
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
186 if (c == '\0')
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
187 break;
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
188 if ((q - str) >= sizeof(str) - 1)
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
189 break;
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
190 *q++ = c;
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
191 }
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
192 *q = '\0';
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
193
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
194 if (*str)
5982
f74198942337 Mark av_metadata_set() as deprecated, and use av_metadata_set2()
stefano
parents: 5618
diff changeset
195 av_metadata_set2(&s->metadata, key, str, 0);
5045
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
196 }
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
197
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
198 /**
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
199 * Parse an ID3v1 tag
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
200 *
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
201 * @param buf ID3v1_TAG_SIZE long buffer containing the tag
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
202 */
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
203 static int parse_tag(AVFormatContext *s, const uint8_t *buf)
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
204 {
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
205 int genre;
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
206
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
207 if (!(buf[0] == 'T' &&
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
208 buf[1] == 'A' &&
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
209 buf[2] == 'G'))
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
210 return -1;
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
211 get_string(s, "title", buf + 3, 30);
5448
97b8e17cfbd4 s/author/artist/ for ID3
michael
parents: 5447
diff changeset
212 get_string(s, "artist", buf + 33, 30);
5045
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
213 get_string(s, "album", buf + 63, 30);
5618
27fd77f20a89 Add a list of generic tags and change demuxers to follow it.
pross
parents: 5592
diff changeset
214 get_string(s, "date", buf + 93, 4);
5045
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
215 get_string(s, "comment", buf + 97, 30);
5450
daea7c5405ac Simplify code by using av_metadata_set2().
michael
parents: 5448
diff changeset
216 if (buf[125] == 0 && buf[126] != 0)
daea7c5405ac Simplify code by using av_metadata_set2().
michael
parents: 5448
diff changeset
217 av_metadata_set2(&s->metadata, "track", av_d2str(buf[126]), AV_METADATA_DONT_STRDUP_VAL);
5045
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
218 genre = buf[127];
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
219 if (genre <= ID3v1_GENRE_MAX)
5982
f74198942337 Mark av_metadata_set() as deprecated, and use av_metadata_set2()
stefano
parents: 5618
diff changeset
220 av_metadata_set2(&s->metadata, "genre", ff_id3v1_genre_str[genre], 0);
5045
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
221 return 0;
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
222 }
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
223
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
224 void ff_id3v1_read(AVFormatContext *s)
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
225 {
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
226 int ret, filesize;
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
227 uint8_t buf[ID3v1_TAG_SIZE];
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
228
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
229 if (!url_is_streamed(s->pb)) {
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
230 /* XXX: change that */
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
231 filesize = url_fsize(s->pb);
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
232 if (filesize > 128) {
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
233 url_fseek(s->pb, filesize - 128, SEEK_SET);
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
234 ret = get_buffer(s->pb, buf, ID3v1_TAG_SIZE);
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
235 if (ret == ID3v1_TAG_SIZE) {
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
236 parse_tag(s, buf);
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
237 }
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
238 url_fseek(s->pb, 0, SEEK_SET);
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
239 }
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
240 }
9ed3c88ed9ba Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents: 5017
diff changeset
241 }