Originally committed as revision 19156 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diego Biurrun authored on 2009/06/12 00:35:23... | ... |
@@ -22,106 +22,106 @@ |
22 | 22 |
#include "id3v1.h" |
23 | 23 |
|
24 | 24 |
const char *ff_id3v1_genre_str[ID3v1_GENRE_MAX + 1] = { |
25 |
- [0] = "Blues", |
|
26 |
- [1] = "Classic Rock", |
|
27 |
- [2] = "Country", |
|
28 |
- [3] = "Dance", |
|
29 |
- [4] = "Disco", |
|
30 |
- [5] = "Funk", |
|
31 |
- [6] = "Grunge", |
|
32 |
- [7] = "Hip-Hop", |
|
33 |
- [8] = "Jazz", |
|
34 |
- [9] = "Metal", |
|
35 |
- [10] = "New Age", |
|
36 |
- [11] = "Oldies", |
|
37 |
- [12] = "Other", |
|
38 |
- [13] = "Pop", |
|
39 |
- [14] = "R&B", |
|
40 |
- [15] = "Rap", |
|
41 |
- [16] = "Reggae", |
|
42 |
- [17] = "Rock", |
|
43 |
- [18] = "Techno", |
|
44 |
- [19] = "Industrial", |
|
45 |
- [20] = "Alternative", |
|
46 |
- [21] = "Ska", |
|
47 |
- [22] = "Death Metal", |
|
48 |
- [23] = "Pranks", |
|
49 |
- [24] = "Soundtrack", |
|
50 |
- [25] = "Euro-Techno", |
|
51 |
- [26] = "Ambient", |
|
52 |
- [27] = "Trip-Hop", |
|
53 |
- [28] = "Vocal", |
|
54 |
- [29] = "Jazz+Funk", |
|
55 |
- [30] = "Fusion", |
|
56 |
- [31] = "Trance", |
|
57 |
- [32] = "Classical", |
|
58 |
- [33] = "Instrumental", |
|
59 |
- [34] = "Acid", |
|
60 |
- [35] = "House", |
|
61 |
- [36] = "Game", |
|
62 |
- [37] = "Sound Clip", |
|
63 |
- [38] = "Gospel", |
|
64 |
- [39] = "Noise", |
|
65 |
- [40] = "AlternRock", |
|
66 |
- [41] = "Bass", |
|
67 |
- [42] = "Soul", |
|
68 |
- [43] = "Punk", |
|
69 |
- [44] = "Space", |
|
70 |
- [45] = "Meditative", |
|
71 |
- [46] = "Instrumental Pop", |
|
72 |
- [47] = "Instrumental Rock", |
|
73 |
- [48] = "Ethnic", |
|
74 |
- [49] = "Gothic", |
|
75 |
- [50] = "Darkwave", |
|
76 |
- [51] = "Techno-Industrial", |
|
77 |
- [52] = "Electronic", |
|
78 |
- [53] = "Pop-Folk", |
|
79 |
- [54] = "Eurodance", |
|
80 |
- [55] = "Dream", |
|
81 |
- [56] = "Southern Rock", |
|
82 |
- [57] = "Comedy", |
|
83 |
- [58] = "Cult", |
|
84 |
- [59] = "Gangsta", |
|
85 |
- [60] = "Top 40", |
|
86 |
- [61] = "Christian Rap", |
|
87 |
- [62] = "Pop/Funk", |
|
88 |
- [63] = "Jungle", |
|
89 |
- [64] = "Native American", |
|
90 |
- [65] = "Cabaret", |
|
91 |
- [66] = "New Wave", |
|
92 |
- [67] = "Psychadelic", |
|
93 |
- [68] = "Rave", |
|
94 |
- [69] = "Showtunes", |
|
95 |
- [70] = "Trailer", |
|
96 |
- [71] = "Lo-Fi", |
|
97 |
- [72] = "Tribal", |
|
98 |
- [73] = "Acid Punk", |
|
99 |
- [74] = "Acid Jazz", |
|
100 |
- [75] = "Polka", |
|
101 |
- [76] = "Retro", |
|
102 |
- [77] = "Musical", |
|
103 |
- [78] = "Rock & Roll", |
|
104 |
- [79] = "Hard Rock", |
|
105 |
- [80] = "Folk", |
|
106 |
- [81] = "Folk-Rock", |
|
107 |
- [82] = "National Folk", |
|
108 |
- [83] = "Swing", |
|
109 |
- [84] = "Fast Fusion", |
|
110 |
- [85] = "Bebob", |
|
111 |
- [86] = "Latin", |
|
112 |
- [87] = "Revival", |
|
113 |
- [88] = "Celtic", |
|
114 |
- [89] = "Bluegrass", |
|
115 |
- [90] = "Avantgarde", |
|
116 |
- [91] = "Gothic Rock", |
|
117 |
- [92] = "Progressive Rock", |
|
118 |
- [93] = "Psychedelic Rock", |
|
119 |
- [94] = "Symphonic Rock", |
|
120 |
- [95] = "Slow Rock", |
|
121 |
- [96] = "Big Band", |
|
122 |
- [97] = "Chorus", |
|
123 |
- [98] = "Easy Listening", |
|
124 |
- [99] = "Acoustic", |
|
25 |
+ [0] = "Blues", |
|
26 |
+ [1] = "Classic Rock", |
|
27 |
+ [2] = "Country", |
|
28 |
+ [3] = "Dance", |
|
29 |
+ [4] = "Disco", |
|
30 |
+ [5] = "Funk", |
|
31 |
+ [6] = "Grunge", |
|
32 |
+ [7] = "Hip-Hop", |
|
33 |
+ [8] = "Jazz", |
|
34 |
+ [9] = "Metal", |
|
35 |
+ [10] = "New Age", |
|
36 |
+ [11] = "Oldies", |
|
37 |
+ [12] = "Other", |
|
38 |
+ [13] = "Pop", |
|
39 |
+ [14] = "R&B", |
|
40 |
+ [15] = "Rap", |
|
41 |
+ [16] = "Reggae", |
|
42 |
+ [17] = "Rock", |
|
43 |
+ [18] = "Techno", |
|
44 |
+ [19] = "Industrial", |
|
45 |
+ [20] = "Alternative", |
|
46 |
+ [21] = "Ska", |
|
47 |
+ [22] = "Death Metal", |
|
48 |
+ [23] = "Pranks", |
|
49 |
+ [24] = "Soundtrack", |
|
50 |
+ [25] = "Euro-Techno", |
|
51 |
+ [26] = "Ambient", |
|
52 |
+ [27] = "Trip-Hop", |
|
53 |
+ [28] = "Vocal", |
|
54 |
+ [29] = "Jazz+Funk", |
|
55 |
+ [30] = "Fusion", |
|
56 |
+ [31] = "Trance", |
|
57 |
+ [32] = "Classical", |
|
58 |
+ [33] = "Instrumental", |
|
59 |
+ [34] = "Acid", |
|
60 |
+ [35] = "House", |
|
61 |
+ [36] = "Game", |
|
62 |
+ [37] = "Sound Clip", |
|
63 |
+ [38] = "Gospel", |
|
64 |
+ [39] = "Noise", |
|
65 |
+ [40] = "AlternRock", |
|
66 |
+ [41] = "Bass", |
|
67 |
+ [42] = "Soul", |
|
68 |
+ [43] = "Punk", |
|
69 |
+ [44] = "Space", |
|
70 |
+ [45] = "Meditative", |
|
71 |
+ [46] = "Instrumental Pop", |
|
72 |
+ [47] = "Instrumental Rock", |
|
73 |
+ [48] = "Ethnic", |
|
74 |
+ [49] = "Gothic", |
|
75 |
+ [50] = "Darkwave", |
|
76 |
+ [51] = "Techno-Industrial", |
|
77 |
+ [52] = "Electronic", |
|
78 |
+ [53] = "Pop-Folk", |
|
79 |
+ [54] = "Eurodance", |
|
80 |
+ [55] = "Dream", |
|
81 |
+ [56] = "Southern Rock", |
|
82 |
+ [57] = "Comedy", |
|
83 |
+ [58] = "Cult", |
|
84 |
+ [59] = "Gangsta", |
|
85 |
+ [60] = "Top 40", |
|
86 |
+ [61] = "Christian Rap", |
|
87 |
+ [62] = "Pop/Funk", |
|
88 |
+ [63] = "Jungle", |
|
89 |
+ [64] = "Native American", |
|
90 |
+ [65] = "Cabaret", |
|
91 |
+ [66] = "New Wave", |
|
92 |
+ [67] = "Psychadelic", |
|
93 |
+ [68] = "Rave", |
|
94 |
+ [69] = "Showtunes", |
|
95 |
+ [70] = "Trailer", |
|
96 |
+ [71] = "Lo-Fi", |
|
97 |
+ [72] = "Tribal", |
|
98 |
+ [73] = "Acid Punk", |
|
99 |
+ [74] = "Acid Jazz", |
|
100 |
+ [75] = "Polka", |
|
101 |
+ [76] = "Retro", |
|
102 |
+ [77] = "Musical", |
|
103 |
+ [78] = "Rock & Roll", |
|
104 |
+ [79] = "Hard Rock", |
|
105 |
+ [80] = "Folk", |
|
106 |
+ [81] = "Folk-Rock", |
|
107 |
+ [82] = "National Folk", |
|
108 |
+ [83] = "Swing", |
|
109 |
+ [84] = "Fast Fusion", |
|
110 |
+ [85] = "Bebob", |
|
111 |
+ [86] = "Latin", |
|
112 |
+ [87] = "Revival", |
|
113 |
+ [88] = "Celtic", |
|
114 |
+ [89] = "Bluegrass", |
|
115 |
+ [90] = "Avantgarde", |
|
116 |
+ [91] = "Gothic Rock", |
|
117 |
+ [92] = "Progressive Rock", |
|
118 |
+ [93] = "Psychedelic Rock", |
|
119 |
+ [94] = "Symphonic Rock", |
|
120 |
+ [95] = "Slow Rock", |
|
121 |
+ [96] = "Big Band", |
|
122 |
+ [97] = "Chorus", |
|
123 |
+ [98] = "Easy Listening", |
|
124 |
+ [99] = "Acoustic", |
|
125 | 125 |
[100] = "Humour", |
126 | 126 |
[101] = "Speech", |
127 | 127 |
[102] = "Chanson", |
... | ... |
@@ -25,24 +25,24 @@ |
25 | 25 |
|
26 | 26 |
int ff_id3v2_match(const uint8_t *buf) |
27 | 27 |
{ |
28 |
- return buf[0] == 'I' && |
|
29 |
- buf[1] == 'D' && |
|
30 |
- buf[2] == '3' && |
|
31 |
- buf[3] != 0xff && |
|
32 |
- buf[4] != 0xff && |
|
33 |
- (buf[6] & 0x80) == 0 && |
|
34 |
- (buf[7] & 0x80) == 0 && |
|
35 |
- (buf[8] & 0x80) == 0 && |
|
36 |
- (buf[9] & 0x80) == 0; |
|
28 |
+ return buf[0] == 'I' && |
|
29 |
+ buf[1] == 'D' && |
|
30 |
+ buf[2] == '3' && |
|
31 |
+ buf[3] != 0xff && |
|
32 |
+ buf[4] != 0xff && |
|
33 |
+ (buf[6] & 0x80) == 0 && |
|
34 |
+ (buf[7] & 0x80) == 0 && |
|
35 |
+ (buf[8] & 0x80) == 0 && |
|
36 |
+ (buf[9] & 0x80) == 0; |
|
37 | 37 |
} |
38 | 38 |
|
39 | 39 |
int ff_id3v2_tag_len(const uint8_t * buf) |
40 | 40 |
{ |
41 | 41 |
int len = ((buf[6] & 0x7f) << 21) + |
42 |
- ((buf[7] & 0x7f) << 14) + |
|
43 |
- ((buf[8] & 0x7f) << 7) + |
|
44 |
- (buf[9] & 0x7f) + |
|
45 |
- ID3v2_HEADER_SIZE; |
|
42 |
+ ((buf[7] & 0x7f) << 14) + |
|
43 |
+ ((buf[8] & 0x7f) << 7) + |
|
44 |
+ (buf[9] & 0x7f) + |
|
45 |
+ ID3v2_HEADER_SIZE; |
|
46 | 46 |
if (buf[5] & 0x10) |
47 | 47 |
len += ID3v2_HEADER_SIZE; |
48 | 48 |
return len; |
... | ... |
@@ -50,9 +50,9 @@ int ff_id3v2_tag_len(const uint8_t * buf) |
50 | 50 |
|
51 | 51 |
static unsigned int get_size(ByteIOContext *s, int len) |
52 | 52 |
{ |
53 |
- int v=0; |
|
54 |
- while(len--) |
|
55 |
- v= (v<<7) + (get_byte(s)&0x7F); |
|
53 |
+ int v = 0; |
|
54 |
+ while (len--) |
|
55 |
+ v = (v << 7) + (get_byte(s) & 0x7F); |
|
56 | 56 |
return v; |
57 | 57 |
} |
58 | 58 |
|
... | ... |
@@ -62,17 +62,17 @@ static void read_ttag(AVFormatContext *s, int taglen, const char *key) |
62 | 62 |
int len, dstlen = sizeof(dst) - 1; |
63 | 63 |
unsigned genre; |
64 | 64 |
|
65 |
- dst[0]= 0; |
|
66 |
- if(taglen < 1) |
|
65 |
+ dst[0] = 0; |
|
66 |
+ if (taglen < 1) |
|
67 | 67 |
return; |
68 | 68 |
|
69 | 69 |
taglen--; /* account for encoding type byte */ |
70 | 70 |
|
71 |
- switch(get_byte(s->pb)) { /* encoding type */ |
|
71 |
+ switch (get_byte(s->pb)) { /* encoding type */ |
|
72 | 72 |
|
73 | 73 |
case 0: /* ISO-8859-1 (0 - 255 maps directly into unicode) */ |
74 | 74 |
q = dst; |
75 |
- while(taglen--) { |
|
75 |
+ while (taglen--) { |
|
76 | 76 |
uint8_t tmp; |
77 | 77 |
PUT_UTF8(get_byte(s->pb), tmp, if (q - dst < dstlen - 1) *q++ = tmp;) |
78 | 78 |
} |
... | ... |
@@ -80,7 +80,7 @@ static void read_ttag(AVFormatContext *s, int taglen, const char *key) |
80 | 80 |
break; |
81 | 81 |
|
82 | 82 |
case 3: /* UTF-8 */ |
83 |
- len = FFMIN(taglen, dstlen-1); |
|
83 |
+ len = FFMIN(taglen, dstlen - 1); |
|
84 | 84 |
get_buffer(s->pb, dst, len); |
85 | 85 |
dst[len] = 0; |
86 | 86 |
break; |
... | ... |
@@ -103,9 +103,9 @@ void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags) |
103 | 103 |
int taghdrlen; |
104 | 104 |
const char *reason; |
105 | 105 |
|
106 |
- switch(version) { |
|
106 |
+ switch (version) { |
|
107 | 107 |
case 2: |
108 |
- if(flags & 0x40) { |
|
108 |
+ if (flags & 0x40) { |
|
109 | 109 |
reason = "compression"; |
110 | 110 |
goto error; |
111 | 111 |
} |
... | ... |
@@ -124,16 +124,16 @@ void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags) |
124 | 124 |
goto error; |
125 | 125 |
} |
126 | 126 |
|
127 |
- if(flags & 0x80) { |
|
127 |
+ if (flags & 0x80) { |
|
128 | 128 |
reason = "unsynchronization"; |
129 | 129 |
goto error; |
130 | 130 |
} |
131 | 131 |
|
132 |
- if(isv34 && flags & 0x40) /* Extended header present, just skip over it */ |
|
132 |
+ if (isv34 && flags & 0x40) /* Extended header present, just skip over it */ |
|
133 | 133 |
url_fskip(s->pb, get_size(s->pb, 4)); |
134 | 134 |
|
135 |
- while(len >= taghdrlen) { |
|
136 |
- if(isv34) { |
|
135 |
+ while (len >= taghdrlen) { |
|
136 |
+ if (isv34) { |
|
137 | 137 |
tag = get_be32(s->pb); |
138 | 138 |
tlen = get_size(s->pb, 4); |
139 | 139 |
get_be16(s->pb); /* flags */ |
... | ... |
@@ -143,12 +143,12 @@ void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags) |
143 | 143 |
} |
144 | 144 |
len -= taghdrlen + tlen; |
145 | 145 |
|
146 |
- if(len < 0) |
|
146 |
+ if (len < 0) |
|
147 | 147 |
break; |
148 | 148 |
|
149 | 149 |
next = url_ftell(s->pb) + tlen; |
150 | 150 |
|
151 |
- switch(tag) { |
|
151 |
+ switch (tag) { |
|
152 | 152 |
case MKBETAG('T', 'I', 'T', '2'): |
153 | 153 |
case MKBETAG(0, 'T', 'T', '2'): |
154 | 154 |
read_ttag(s, tlen, "title"); |
... | ... |
@@ -183,7 +183,7 @@ void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags) |
183 | 183 |
url_fseek(s->pb, next, SEEK_SET); |
184 | 184 |
} |
185 | 185 |
|
186 |
- if(version == 4 && flags & 0x10) /* Footer preset, always 10 bytes, skip over it */ |
|
186 |
+ if (version == 4 && flags & 0x10) /* Footer preset, always 10 bytes, skip over it */ |
|
187 | 187 |
url_fskip(s->pb, 10); |
188 | 188 |
return; |
189 | 189 |
|
... | ... |
@@ -191,4 +191,3 @@ void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags) |
191 | 191 |
av_log(s, AV_LOG_INFO, "ID3v2.%d tag skipped, cannot handle %s\n", version, reason); |
192 | 192 |
url_fskip(s->pb, len); |
193 | 193 |
} |
194 |
- |