Mercurial > libavformat.hg
annotate id3v1.c @ 5286:3ce92654e943 libavformat
Skip padding bytes correctly in ID3 tags.
This fixes a regression introduced in r20170.
author | jai_menon |
---|---|
date | Thu, 15 Oct 2009 13:55:19 +0000 |
parents | eb33b7205b3c |
children | 1c7cdbafd33c |
rev | line source |
---|---|
885 | 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 | 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 | 8 * modify it under the terms of the GNU Lesser General Public |
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 | 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 | 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 | |
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 | 20 */ |
3286 | 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" |
234 | 24 |
5160 | 25 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
|
26 [0] = "Blues", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
27 [1] = "Classic Rock", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
28 [2] = "Country", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
29 [3] = "Dance", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
30 [4] = "Disco", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
31 [5] = "Funk", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
32 [6] = "Grunge", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
33 [7] = "Hip-Hop", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
34 [8] = "Jazz", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
35 [9] = "Metal", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
36 [10] = "New Age", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
37 [11] = "Oldies", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
38 [12] = "Other", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
39 [13] = "Pop", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
40 [14] = "R&B", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
41 [15] = "Rap", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
42 [16] = "Reggae", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
43 [17] = "Rock", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
44 [18] = "Techno", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
45 [19] = "Industrial", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
46 [20] = "Alternative", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
47 [21] = "Ska", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
48 [22] = "Death Metal", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
49 [23] = "Pranks", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
50 [24] = "Soundtrack", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
51 [25] = "Euro-Techno", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
52 [26] = "Ambient", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
53 [27] = "Trip-Hop", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
54 [28] = "Vocal", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
55 [29] = "Jazz+Funk", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
56 [30] = "Fusion", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
57 [31] = "Trance", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
58 [32] = "Classical", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
59 [33] = "Instrumental", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
60 [34] = "Acid", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
61 [35] = "House", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
62 [36] = "Game", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
63 [37] = "Sound Clip", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
64 [38] = "Gospel", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
65 [39] = "Noise", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
66 [40] = "AlternRock", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
67 [41] = "Bass", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
68 [42] = "Soul", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
69 [43] = "Punk", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
70 [44] = "Space", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
71 [45] = "Meditative", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
72 [46] = "Instrumental Pop", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
73 [47] = "Instrumental Rock", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
74 [48] = "Ethnic", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
75 [49] = "Gothic", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
76 [50] = "Darkwave", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
77 [51] = "Techno-Industrial", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
78 [52] = "Electronic", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
79 [53] = "Pop-Folk", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
80 [54] = "Eurodance", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
81 [55] = "Dream", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
82 [56] = "Southern Rock", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
83 [57] = "Comedy", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
84 [58] = "Cult", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
85 [59] = "Gangsta", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
86 [60] = "Top 40", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
87 [61] = "Christian Rap", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
88 [62] = "Pop/Funk", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
89 [63] = "Jungle", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
90 [64] = "Native American", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
91 [65] = "Cabaret", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
92 [66] = "New Wave", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
93 [67] = "Psychadelic", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
94 [68] = "Rave", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
95 [69] = "Showtunes", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
96 [70] = "Trailer", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
97 [71] = "Lo-Fi", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
98 [72] = "Tribal", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
99 [73] = "Acid Punk", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
100 [74] = "Acid Jazz", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
101 [75] = "Polka", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
102 [76] = "Retro", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
103 [77] = "Musical", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
104 [78] = "Rock & Roll", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
105 [79] = "Hard Rock", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
106 [80] = "Folk", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
107 [81] = "Folk-Rock", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
108 [82] = "National Folk", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
109 [83] = "Swing", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
110 [84] = "Fast Fusion", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
111 [85] = "Bebob", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
112 [86] = "Latin", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
113 [87] = "Revival", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
114 [88] = "Celtic", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
115 [89] = "Bluegrass", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
116 [90] = "Avantgarde", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
117 [91] = "Gothic Rock", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
118 [92] = "Progressive Rock", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
119 [93] = "Psychedelic Rock", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
120 [94] = "Symphonic Rock", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
121 [95] = "Slow Rock", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
122 [96] = "Big Band", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
123 [97] = "Chorus", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
124 [98] = "Easy Listening", |
1763f7d0d8d0
cosmetics: Reformat to K&R and prettyprint newly created files.
diego
parents:
5016
diff
changeset
|
125 [99] = "Acoustic", |
234 | 126 [100] = "Humour", |
127 [101] = "Speech", | |
128 [102] = "Chanson", | |
129 [103] = "Opera", | |
130 [104] = "Chamber Music", | |
131 [105] = "Sonata", | |
132 [106] = "Symphony", | |
133 [107] = "Booty Bass", | |
134 [108] = "Primus", | |
135 [109] = "Porn Groove", | |
136 [110] = "Satire", | |
137 [111] = "Slow Jam", | |
138 [112] = "Club", | |
139 [113] = "Tango", | |
140 [114] = "Samba", | |
141 [115] = "Folklore", | |
142 [116] = "Ballad", | |
143 [117] = "Power Ballad", | |
144 [118] = "Rhythmic Soul", | |
145 [119] = "Freestyle", | |
146 [120] = "Duet", | |
147 [121] = "Punk Rock", | |
148 [122] = "Drum Solo", | |
149 [123] = "A capella", | |
150 [124] = "Euro-House", | |
151 [125] = "Dance Hall", | |
152 }; | |
5045
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
153 |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
154 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
|
155 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
|
156 { |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
157 int i, c; |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
158 char *q, str[512]; |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
159 |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
160 q = str; |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
161 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
|
162 c = buf[i]; |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
163 if (c == '\0') |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
164 break; |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
165 if ((q - str) >= sizeof(str) - 1) |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
166 break; |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
167 *q++ = c; |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
168 } |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
169 *q = '\0'; |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
170 |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
171 if (*str) |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
172 av_metadata_set(&s->metadata, key, str); |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
173 } |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
174 |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
175 /** |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
176 * Parse an ID3v1 tag |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
177 * |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
178 * @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
|
179 */ |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
180 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
|
181 { |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
182 char str[5]; |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
183 int genre; |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
184 |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
185 if (!(buf[0] == 'T' && |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
186 buf[1] == 'A' && |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
187 buf[2] == 'G')) |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
188 return -1; |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
189 get_string(s, "title", buf + 3, 30); |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
190 get_string(s, "author", buf + 33, 30); |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
191 get_string(s, "album", buf + 63, 30); |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
192 get_string(s, "year", buf + 93, 4); |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
193 get_string(s, "comment", buf + 97, 30); |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
194 if (buf[125] == 0 && buf[126] != 0) { |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
195 snprintf(str, sizeof(str), "%d", buf[126]); |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
196 av_metadata_set(&s->metadata, "track", str); |
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 genre = buf[127]; |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
199 if (genre <= ID3v1_GENRE_MAX) |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
200 av_metadata_set(&s->metadata, "genre", ff_id3v1_genre_str[genre]); |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
201 return 0; |
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 |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
204 void ff_id3v1_read(AVFormatContext *s) |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
205 { |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
206 int ret, filesize; |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
207 uint8_t buf[ID3v1_TAG_SIZE]; |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
208 |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
209 if (!url_is_streamed(s->pb)) { |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
210 /* XXX: change that */ |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
211 filesize = url_fsize(s->pb); |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
212 if (filesize > 128) { |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
213 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
|
214 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
|
215 if (ret == ID3v1_TAG_SIZE) { |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
216 parse_tag(s, buf); |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
217 } |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
218 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
|
219 } |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
220 } |
9ed3c88ed9ba
Move id3v1/id3v2 handling code from mp3.c to id3v[12].c.
diego
parents:
5017
diff
changeset
|
221 } |