On Wed, May 27, 2009 at 01:14:04PM -0400, Jason Tackaberry wrote:
> On Wed, 2009-05-27 at 18:25 +0200, Matthias Reichl wrote:
> > I did some testing and it seems that r3821 (new find_header
> > function in audio/eyeD3/mp3.py) is causing this problems.
> > If I use the old function (__EYED3_ORIG_find_header) instead,
> > mminfo reports the correct length.
> 
> Thanks for the thorough bug report, Matthias.  I've committed a fix to
> svn.  I'd appreciate it if you could try the svn version of kaa.metadata
> and verify this fixes the problem for you?

Thanks, Jason, this fixed the problems!

But when looking at the find_header code I discovered two more
potential issues:

- A wrong start_pos is returned if no header could be found in
  the first 64k block
- It won't find a header if it crosses the 64k block boundary
  (for example when the header starts at byte 65535)

I've attached a patch that should fix these two issues. Please
have a look at it, I hope it's correct.

so long,

Hias
Index: metadata/src/audio/eyeD3/mp3.py
===================================================================
--- metadata/src/audio/eyeD3/mp3.py	(revision 4105)
+++ metadata/src/audio/eyeD3/mp3.py	(working copy)
@@ -112,8 +112,11 @@
 def find_header(fp, start_pos=0):
     import struct
     fp.seek(start_pos)
+    data = ''
     carry = ''
     while True:
+        # account for already consumed data
+        start_pos = start_pos + len(data) - len(carry)
         data, carry = carry + fp.read(64*1024), ''
         if not data:
             break
@@ -133,7 +136,10 @@
                 if is_valid_mp_header(header):
                     return pos + start_pos, header, header_bytes
             else:
-                carry = data[pos+1:]
+                # restart at current position to catch headers crossing
+                # a block boundary
+                carry = data[pos:]
+                break
 
     return None, None, None
 
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Freevo-devel mailing list
Freevo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to