[Slim-Checkins] r10102 - /branches/6.5/server/CPAN/MP4/Info.pm

dsully at svn.slimdevices.com dsully at svn.slimdevices.com
Fri Sep 29 13:51:04 PDT 2006


Author: dsully
Date: Fri Sep 29 13:51:04 2006
New Revision: 10102

URL: http://svn.slimdevices.com?rev=10102&view=rev
Log:
Bug: N/A
Description: Merge from trunk -r 10100:10101

Modified:
    branches/6.5/server/CPAN/MP4/Info.pm

Modified: branches/6.5/server/CPAN/MP4/Info.pm
URL: http://svn.slimdevices.com/branches/6.5/server/CPAN/MP4/Info.pm?rev=10102&r1=10101&r2=10102&view=diff
==============================================================================
--- branches/6.5/server/CPAN/MP4/Info.pm (original)
+++ branches/6.5/server/CPAN/MP4/Info.pm Fri Sep 29 13:51:04 2006
@@ -27,7 +27,7 @@
 		all	=> [@EXPORT, @EXPORT_OK]
 	       );
 
-$VERSION = '1.10';
+$VERSION = '1.11';
 
 my $debug = 0;
 
@@ -156,7 +156,7 @@
 	APID	Apple Store ID
 	ART	Artist
 	CMT	Comment
-	COVR	Album art (typically jpeg data)
+	COVR	Album art (typically JPEG or PNG data)
 	CPIL	Compilation (boolean)
 	CPRT	Copyright statement
 	DAY	Year
@@ -377,6 +377,9 @@
     close ($fh);
     return $err if $err;
 
+    # remaining get_mp4tag() stuff
+    $tags->{CPIL}     = 0                unless defined ($tags->{CPIL});
+
     # MP3::Info compatibility
     $tags->{TITLE}    = $tags->{NAM}     if defined ($tags->{NAM});
     $tags->{ARTIST}   = $tags->{ART}     if defined ($tags->{ART});
@@ -389,10 +392,14 @@
     # remaining get_mp4info() stuff
     $tags->{VERSION}  = 4;
     $tags->{LAYER}    = 1                if defined ($tags->{FREQUENCY});
-    $tags->{BITRATE}  = int (0.5 + $tags->{SIZE} / (($tags->{MM}*60+$tags->{SS}+$tags->{MS}/1000)*128))
-	if (defined($tags->{SIZE}) && defined($tags->{MS}));	# A bit bogus
-    $tags->{COPYRIGHT}= 1                if defined ($tags->{CPRT});
+    $tags->{COPYRIGHT}= (defined ($tags->{CPRT}) ? 1 : 0);
     $tags->{ENCRYPTED}= 0                unless defined ($tags->{ENCRYPTED});
+
+    # Returns actual (not requested) bitrate
+    if (defined($tags->{SIZE}) && $tags->{SIZE} && defined($tags->{SECS}) && ($tags->{MM}+$tags->{SS}+$tags->{MS}))
+    {
+	$tags->{BITRATE}  = int (0.5 + $tags->{SIZE} / (($tags->{MM}*60+$tags->{SS}+$tags->{MS}/1000)*128))
+    }
 
     # Post process '---' container
     if ($tags->{MEAN} && ref($tags->{MEAN}) eq 'ARRAY')
@@ -445,15 +452,9 @@
 sub parse_atom
 {
     my ($fh, $level, $parentsize, $tags) = @_;
-    my ($header, $size, $id, $err);
+    my ($header, $size, $id, $err, $pos);
     if (read ($fh, $header, 8) != 8)
     {
-	# XXXX - temporary fix for bug 4151
-	# AAC & ALAC files with artwork have changed.
-	if ($header =~ /^\000+$/) {
-		return 0;
-	}
-
 	$@ = 'Premature eof';
 	return -1;
     }
@@ -461,10 +462,11 @@
     ($size,$id) = unpack 'Na4', $header;
     if ($size==0)
     {
-	# Special zero-sized atom at top-level means we're done (14496-12 S4.2)
-	return 0 if $level==1;
-	$@ = 'Parse error';
-	return -1;
+	# Zero-sized atom extends to eof (14496-12:2004 S4.2)
+	$pos=tell($fh);
+	seek $fh, 0, 2;
+	$size = tell($fh) - $pos;	# Error if parent size doesn't match
+	seek $fh, $pos, 0;
     }
     elsif ($size == 1)
     {
@@ -849,7 +851,7 @@
 
 Chris Nandor E<lt>pudge at pobox.comE<gt> for writing L<MP3::Info|MP3::Info>
 
-Dan Sully for cover art and iTunes/aacgain metadata patches.
+Dan Sully at Slim Devices for cover art and iTunes/aacgain metadata patches.
 
 =head1 SEE ALSO
 
@@ -888,7 +890,7 @@
 
 =head1 COPYRIGHT and LICENSE
 
-Copyright (c) 2004, 2005, Jonathan Harris E<lt>jhar at cpan.orgE<gt>
+Copyright (c) 2004, 2005, 2006, Jonathan Harris E<lt>jhar at cpan.orgE<gt>
 
 This program is free software; you can redistribute it and/or modify it
 under the the same terms as Perl itself.



More information about the checkins mailing list