summaryrefslogtreecommitdiffstats
path: root/tools/vorbiscomm.pm
diff options
context:
space:
mode:
authorRyan Jackson <rdjackso@rockbox.org>2005-07-12 16:40:50 +0000
committerRyan Jackson <rdjackso@rockbox.org>2005-07-12 16:40:50 +0000
commit40a8401cd35cef71b0ffa017106ee156fb3239ed (patch)
tree03975c03d4df8247c020bd85dea181f6bd6f700e /tools/vorbiscomm.pm
parentb3437ecbfefcc819dc3fb859f2c1e1894dd6cca1 (diff)
downloadrockbox-40a8401cd35cef71b0ffa017106ee156fb3239ed.tar.gz
rockbox-40a8401cd35cef71b0ffa017106ee156fb3239ed.tar.bz2
rockbox-40a8401cd35cef71b0ffa017106ee156fb3239ed.zip
songdb.pl now calculates the checksum for Ogg Vorbis files by starting at the first page of audio data
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7124 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/vorbiscomm.pm')
-rw-r--r--tools/vorbiscomm.pm44
1 files changed, 44 insertions, 0 deletions
diff --git a/tools/vorbiscomm.pm b/tools/vorbiscomm.pm
index 4577a700a5..e2bae11276 100644
--- a/tools/vorbiscomm.pm
+++ b/tools/vorbiscomm.pm
@@ -415,6 +415,50 @@ sub _loadComments
$data->{'INFO'}{'offset'} = $byteCount;
$data->{'COMMENTS'} = \%comments;
+
+ # Now find the offset of the first page
+ # with audio data.
+ while(_findPage($fh))
+ {
+ $byteCount = tell($fh) - 4;
+
+ # version flag
+ read($fh, $buffer, 1);
+ if (ord($buffer) != 0x00)
+ {
+ warn "Invalid stream structure version: " .
+ sprintf("%x", ord($buffer));
+ return;
+ }
+
+ # header type flag
+ read($fh, $buffer, 1);
+ # Audio data starts as a fresh packet on a new page, so
+ # if header_type is odd it's not a fresh packet
+ next if ( ord($buffer) % 2 );
+
+ # skip past granule position, stream_serial_number,
+ # page_sequence_number, and crc
+ read($fh, $buffer, 20);
+
+ # page_segments
+ read($fh, $buffer, 1);
+ my $page_segments = ord($buffer);
+
+ # skip past the segment table
+ read($fh, $buffer, $page_segments);
+
+ # read packet_type byte
+ read($fh, $buffer, 1);
+
+ # Not an audio packet. All audio packet numbers are even
+ next if ( ord($buffer) % 2 );
+
+ # Found the first audio packet
+ last;
+ }
+
+ $data->{'INFO'}{'audio_offset'} = $byteCount;
}
sub _calculateTrackLength