summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2002-09-16 13:32:12 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2002-09-16 13:32:12 +0000
commit842d5a99d0885f15d5e28cf8661e6ba5529e4b15 (patch)
treef65b2b2472e057774a7f89ddc321f7ad02c6650d
parent2bd519d7b7f64e60be07063df0305d9f06382642 (diff)
downloadrockbox-842d5a99d0885f15d5e28cf8661e6ba5529e4b15.tar.gz
rockbox-842d5a99d0885f15d5e28cf8661e6ba5529e4b15.zip
Now skips garbage padding after the ID3V2 tag, along with Xing and LAME headers
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2300 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/id3.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/firmware/id3.c b/firmware/id3.c
index 4a803e7d2b..b6d9852175 100644
--- a/firmware/id3.c
+++ b/firmware/id3.c
@@ -419,7 +419,7 @@ static int getsonglength(int fd, struct mp3entry *entry)
419 } 419 }
420 420
421 /* Loop trough file until we find a frame header */ 421 /* Loop trough file until we find a frame header */
422 bytecount = 0; 422 bytecount = entry->id3v2len - 1;
423 restart: 423 restart:
424 do { 424 do {
425 header <<= 8; 425 header <<= 8;
@@ -557,29 +557,46 @@ static int getsonglength(int fd, struct mp3entry *entry)
557 /* Yes, it is a VBR file */ 557 /* Yes, it is a VBR file */
558 entry->vbr = true; 558 entry->vbr = true;
559 entry->vbrflags = xing[7]; 559 entry->vbrflags = xing[7];
560 int i = 8; /* Where to start parsing info */
560 561
561 if (entry->vbrflags & VBR_FRAMES_FLAG) /* Is the frame count there? */ 562 if (entry->vbrflags & VBR_FRAMES_FLAG) /* Is the frame count there? */
562 { 563 {
563 int framecount = (xing[8] << 24) | (xing[9] << 16) | 564 int framecount = (xing[i] << 24) | (xing[i+1] << 16) |
564 (xing[10] << 8) | xing[11]; 565 (xing[i+2] << 8) | xing[i+3];
565 566
566 filetime = framecount * tpf; 567 filetime = framecount * tpf;
568 i += 4;
567 } 569 }
568 570
569 if (entry->vbrflags & VBR_BYTES_FLAG) /* is byte count there? */ 571 if (entry->vbrflags & VBR_BYTES_FLAG) /* is byte count there? */
570 { 572 {
571 int bytecount = (xing[12] << 24) | (xing[13] << 16) | 573 int bytecount = (xing[i] << 24) | (xing[i+1] << 16) |
572 (xing[14] << 8) | xing[15]; 574 (xing[i+2] << 8) | xing[i+3];
573 575
574 bitrate = bytecount * 8 / filetime; 576 bitrate = bytecount * 8 / filetime;
577 i += 4;
575 } 578 }
576 579
577 if (entry->vbrflags & VBR_TOC_FLAG) /* is table-of-contents there? */ 580 if (entry->vbrflags & VBR_TOC_FLAG) /* is table-of-contents there? */
578 { 581 {
579 memcpy( entry->toc, xing+16, 100 ); 582 memcpy( entry->toc, xing+i, 100 );
580 } 583 }
584
585 /* Make sure we skip this frame in playback */
586 bytecount += bpf;
587 }
588
589 /* Is it a LAME Info frame? */
590 if (xing[0] == 'I' &&
591 xing[1] == 'n' &&
592 xing[2] == 'f' &&
593 xing[3] == 'o')
594 {
595 /* Make sure we skip this frame in playback */
596 bytecount += bpf;
581 } 597 }
582 598
599
583 entry->bitrate = bitrate; 600 entry->bitrate = bitrate;
584 601
585 /* If the file time hasn't been established, this may be a fixed 602 /* If the file time hasn't been established, this may be a fixed
@@ -593,6 +610,10 @@ static int getsonglength(int fd, struct mp3entry *entry)
593 filetime = entry->filesize/bpf*tpf; 610 filetime = entry->filesize/bpf*tpf;
594 } 611 }
595 612
613 DEBUGF("Old ID3V2 length: %x\n", entry->id3v2len);
614 entry->id3v2len = bytecount;
615 DEBUGF("New ID3V2 length: %x\n", bytecount);
616
596 return filetime; 617 return filetime;
597} 618}
598 619