···260260 * seek to this byte position and check if there is another
261261 * valid MPEG frame header of the same type. */
262262 struct mp3info info;
263263-263263+264264 /* Gather frame size from given header and seek to next
265265 * frame header. */
266266- mp3headerinfo(&info, header);
266266+ if (!mp3headerinfo(&info, header)) continue;
267267 lseek(fd, info.frame_size-4, SEEK_CUR);
268268-268268+269269 /* Read possible next frame header and seek back to last frame
270270 * headers byte position. */
271271 reference_header = 0;
272272 read_uint32be_mp3data(fd, &reference_header);
273273- //
274274- lseek(fd, -info.frame_size, SEEK_CUR);
275275-276276- /* If the current header is of the same type as the previous
277277- * header we are finished. */
278278- if (headers_have_same_type(header, reference_header))
273273+274274+ /* If the current header is of the same type as the previous
275275+ * header we are finished. Rewind to frame data start. */
276276+ if (headers_have_same_type(header, reference_header)) {
277277+ lseek(fd, -info.frame_size, SEEK_CUR);
279278 break;
279279+ }
280280+ /* Otherwise keep going. Rewind to to start of "next" frame. */
281281+ lseek(fd, -4, SEEK_CUR);
282282+ pos += info.frame_size - 4;
280283 }
281284 }
282282-285285+283286 } while (true);
284287285288 *offset = pos - 4;
···511514{
512515 long tmp;
513516 unsigned long header = 0;
514514-515515- header = __find_next_frame(fd, &tmp, 0x20000, 0, fileread, single_header);
517517+518518+ header = __find_next_frame(fd, &tmp, 0x100000, 0, fileread, single_header);
516519 if(header == 0)
517520 return -1;
518521