angelu2001 / php-reader

Automatically exported from code.google.com/p/php-reader
0 stars 0 forks source link

Incorrect check for sync word marker causes “Invalid frame sync” #71

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
This issue is closely related to issue 60: 
http://code.google.com/p/php-reader/issues/detail?id=60. 

On my 64-bit Linux machine, I get an exception from Frame.php at line 236, 
stating “File does not contain a valid MPEG Audio Bit Stream (Invalid frame 
sync)”. All the MP3 files work flawlessly on my Windows 7 machine with the 
same php-reader version, i.e. the zipped one from the downloads page. 

When I use the latest svn sources, I basically get the same error: “File does 
not contain a valid MPEG Audio Bit Stream (Invalid frame sync and 
resynchronization failed)”

When I change 
  Zend_Bit_Twiddling::getValue($header, 21, 32)
to 
  Zend_Bit_Twiddling::getValue($header, 20, 31)
everthing works fine on the Linux machine. 

Linux machine info:
  PHP Version 5.3.10-1ubuntu3.2
  Linux 3.2.0-23-generic #36-Ubuntu SMP x86_64

Windows machine info:
  PHP Version 5.3.8
  Windows NT 6.1 build 7601 (Windows 7 Business Edition Service Pack 1) i586

You can get an example file from
  http://www.hochweber.ch/improvisation/E7-A7/E7-A7-bsp.mp3
Disclaimer: I just googled “mp3 test file”. 

Original issue reported on code.google.com by ideb...@googlemail.com on 19 Aug 2012 at 12:17

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Apparently, this bug comes down to the different values of PHP_INT_MAX on my 
machines. 

In the constructor of Abs/Frame.php the $header of the linked mp3 file is 
4294661184 or 0xfffb5440. On the Windows machine (64 bit as well), PHP_INT_MAX 
is 2147483647 which is smaller than the $header. On the Linux machine, 
PHP_INT_MAX is 9223372036854775807. 

Now comes the interesting part. The function return value of 
  Zend_Bit_Twiddling::getValue($header, 21, 32)
is -1 or 0xffffffff on Windows, but 2047 or 0x7ff on Linux. Thus, checking 
against 0xffe via testAllBits fails on Linux and throws the exception 'Invalid 
frame sync'.

Check out stackoverflow.com for more information, where I found a related 
question:

http://stackoverflow.com/questions/11402469/bitwise-operations-on-big-integers-i
n-php-5-2-and-php-5-3

Original comment by ideb...@googlemail.com on 19 Aug 2012 at 6:07

GoogleCodeExporter commented 8 years ago

Original comment by svollbehr on 21 Aug 2012 at 5:42