MCPcopy Create free account
hub / github.com/DentonW/DevIL / iFindMp3Pic

Function iFindMp3Pic

DevIL/src-IL/src/il_mp3.cpp:137–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135
136
137ILuint iFindMp3Pic(MP3HEAD *Header)
138{
139 char ID[4];
140 ILuint FrameSize;
141 ILubyte TextEncoding;
142 ILubyte MimeType[65], Description[65];
143 ILubyte PicType;
144 ILuint i;
145 ILuint Type = MP3_NONE;
146
147 do {
148 if (iread(ID, 4, 1) != 1)
149 return MP3_NONE;
150 if (Header->VersionMajor == 3)
151 FrameSize = GetBigUInt();
152 else
153 FrameSize = GetSynchInt();
154
155 GetBigUShort(); // Skip the flags.
156
157 //@TODO: Support multiple APIC entries in an mp3 file.
158 if (!strncmp(ID, "APIC", 4)) {
159 //@TODO: Use TextEncoding properly - UTF16 strings starting with FFFE or FEFF.
160 TextEncoding = igetc();
161 // Get the MimeType (read until we hit 0).
162 for (i = 0; i < 65; i++) {
163 MimeType[i] = igetc();
164 if (MimeType[i] == 0)
165 break;
166 }
167 // The MimeType must be terminated by 0 in the file by the specs.
168 if (MimeType[i] != 0)
169 return MP3_NONE;
170 if (!strcmp((char*)MimeType, "image/jpeg"))
171 Type = MP3_JPG;
172 else if (!strcmp((char*)MimeType, "image/png"))
173 Type = MP3_PNG;
174 else
175 Type = MP3_NONE;
176
177 PicType = igetc(); // Whether this is a cover, band logo, etc.
178
179 // Skip the description.
180 for (i = 0; i < 65; i++) {
181 Description[i] = igetc();
182 if (Description[i] == 0)
183 break;
184 }
185 if (Description[i] != 0)
186 return MP3_NONE;
187 return Type;
188 }
189 else {
190 iseek(FrameSize, IL_SEEK_CUR);
191 }
192
193 //if (!strncmp(MimeType, "
194 } while (!ieof() && itell() < Header->Length);

Callers 1

iLoadMp3InternalFunction · 0.85

Calls 3

GetBigUIntFunction · 0.85
GetSynchIntFunction · 0.85
GetBigUShortFunction · 0.85

Tested by

no test coverage detected