comparison oggparsevorbis.c @ 2197:94d11eaef9bf libavformat

whitespace cosmetics
author mru
date Sun, 24 Jun 2007 12:20:17 +0000
parents 5864dc9a9741
children 7c13baaa4f87
comparison
equal deleted inserted replaced
2196:5864dc9a9741 2197:94d11eaef9bf
28 #include "bswap.h" 28 #include "bswap.h"
29 #include "ogg2.h" 29 #include "ogg2.h"
30 #include "avstring.h" 30 #include "avstring.h"
31 31
32 extern int 32 extern int
33 vorbis_comment (AVFormatContext * as, uint8_t *buf, int size) 33 vorbis_comment(AVFormatContext * as, uint8_t *buf, int size)
34 { 34 {
35 char *p = buf; 35 char *p = buf;
36 int s, n, j; 36 int s, n, j;
37 37
38 if (size < 4) 38 if (size < 4)
50 50
51 n = AV_RL32(p); 51 n = AV_RL32(p);
52 p += 4; 52 p += 4;
53 size -= 4; 53 size -= 4;
54 54
55 while (size >= 4){ 55 while (size >= 4) {
56 char *t, *v; 56 char *t, *v;
57 int tl, vl; 57 int tl, vl;
58 58
59 s = AV_RL32(p); 59 s = AV_RL32(p);
60 p += 4; 60 p += 4;
66 t = p; 66 t = p;
67 p += s; 67 p += s;
68 size -= s; 68 size -= s;
69 n--; 69 n--;
70 70
71 v = memchr (t, '=', s); 71 v = memchr(t, '=', s);
72 if (!v) 72 if (!v)
73 continue; 73 continue;
74 74
75 tl = v - t; 75 tl = v - t;
76 vl = s - tl - 1; 76 vl = s - tl - 1;
77 v++; 77 v++;
78 78
79 if (tl && vl){ 79 if (tl && vl) {
80 char tt[tl + 1]; 80 char tt[tl + 1];
81 char ct[vl + 1]; 81 char ct[vl + 1];
82 82
83 for (j = 0; j < tl; j++) 83 for (j = 0; j < tl; j++)
84 tt[j] = toupper (t[j]); 84 tt[j] = toupper(t[j]);
85 tt[tl] = 0; 85 tt[tl] = 0;
86 86
87 memcpy (ct, v, vl); 87 memcpy(ct, v, vl);
88 ct[vl] = 0; 88 ct[vl] = 0;
89 89
90 // took from Vorbis_I_spec 90 // took from Vorbis_I_spec
91 if (!strcmp (tt, "AUTHOR") || !strcmp(tt, "ARTIST")) 91 if (!strcmp(tt, "AUTHOR") || !strcmp(tt, "ARTIST"))
92 av_strlcpy (as->author, ct, sizeof (as->author)); 92 av_strlcpy(as->author, ct, sizeof(as->author));
93 else if (!strcmp (tt, "TITLE")) 93 else if (!strcmp(tt, "TITLE"))
94 av_strlcpy (as->title, ct, sizeof (as->title)); 94 av_strlcpy(as->title, ct, sizeof(as->title));
95 else if (!strcmp (tt, "COPYRIGHT")) 95 else if (!strcmp(tt, "COPYRIGHT"))
96 av_strlcpy (as->copyright, ct, sizeof (as->copyright)); 96 av_strlcpy(as->copyright, ct, sizeof(as->copyright));
97 else if (!strcmp (tt, "DESCRIPTION")) 97 else if (!strcmp(tt, "DESCRIPTION"))
98 av_strlcpy (as->comment, ct, sizeof (as->comment)); 98 av_strlcpy(as->comment, ct, sizeof(as->comment));
99 else if (!strcmp (tt, "GENRE")) 99 else if (!strcmp(tt, "GENRE"))
100 av_strlcpy (as->genre, ct, sizeof (as->genre)); 100 av_strlcpy(as->genre, ct, sizeof(as->genre));
101 else if (!strcmp (tt, "TRACKNUMBER")) 101 else if (!strcmp(tt, "TRACKNUMBER"))
102 as->track = atoi (ct); 102 as->track = atoi(ct);
103 else if (!strcmp(tt, "ALBUM")) 103 else if (!strcmp(tt, "ALBUM"))
104 av_strlcpy(as->album, ct, sizeof(as->album)); 104 av_strlcpy(as->album, ct, sizeof(as->album));
105 else if (!strcmp(tt, "GENRE")) 105 else if (!strcmp(tt, "GENRE"))
106 av_strlcpy(as->genre, ct, sizeof(as->genre)); 106 av_strlcpy(as->genre, ct, sizeof(as->genre));
107 else if (!strcmp(tt, "DESCRIPTION")) 107 else if (!strcmp(tt, "DESCRIPTION"))
108 av_strlcpy(as->comment, ct, sizeof(as->comment)); 108 av_strlcpy(as->comment, ct, sizeof(as->comment));
109 } 109 }
110 } 110 }
111 111
112 if (size > 0) 112 if (size > 0)
113 av_log (as, AV_LOG_INFO, "%i bytes of comment header remain\n", size); 113 av_log(as, AV_LOG_INFO, "%i bytes of comment header remain\n", size);
114 if (n > 0) 114 if (n > 0)
115 av_log (as, AV_LOG_INFO, 115 av_log(as, AV_LOG_INFO,
116 "truncated comment header, %i comments not found\n", n); 116 "truncated comment header, %i comments not found\n", n);
117 117
118 return 0; 118 return 0;
119 } 119 }
120 120
121 121
150 150
151 ptr[0] = 2; 151 ptr[0] = 2;
152 offset = 1; 152 offset = 1;
153 offset += av_xiphlacing(&ptr[offset], priv->len[0]); 153 offset += av_xiphlacing(&ptr[offset], priv->len[0]);
154 offset += av_xiphlacing(&ptr[offset], priv->len[1]); 154 offset += av_xiphlacing(&ptr[offset], priv->len[1]);
155 for(i = 0; i < 3; i++) { 155 for (i = 0; i < 3; i++) {
156 memcpy(&ptr[offset], priv->packet[i], priv->len[i]); 156 memcpy(&ptr[offset], priv->packet[i], priv->len[i]);
157 offset += priv->len[i]; 157 offset += priv->len[i];
158 } 158 }
159 *buf = av_realloc(*buf, offset); 159 *buf = av_realloc(*buf, offset);
160 return offset; 160 return offset;
170 oggvorbis_private_t *priv; 170 oggvorbis_private_t *priv;
171 171
172 if (os->seq > 2) 172 if (os->seq > 2)
173 return 0; 173 return 0;
174 174
175 if(os->seq == 0) { 175 if (os->seq == 0) {
176 os->private = av_mallocz(sizeof(oggvorbis_private_t)); 176 os->private = av_mallocz(sizeof(oggvorbis_private_t));
177 if(!os->private) 177 if (!os->private)
178 return 0; 178 return 0;
179 } 179 }
180 180
181 priv = os->private; 181 priv = os->private;
182 priv->len[os->seq] = os->psize; 182 priv->len[os->seq] = os->psize;