Very strange. I'll take a look. (and see if I still remember what I was thinking when I wrote that )
[edit]
HA! That's hilarious! It looks like it's all ID3v2's fault... again. Whoever tagged this shoulda used the "unsynchronization" feature...
Short answer: delete (or otherwise mangle) the tag!
Long answer:
The MP3 header sync pattern is 0xFFF. (normally doesn't occur in text)
There is an ID3v2 tag at the beginning of the file. (so far, so good)
That tag uses UTF-16 encoding. (still good)
The Unicode strings all have a 16-bit Unicode "byte order mark" ("BOM", Unicode character U+FEFF)
However, it's little-endian UTF-16 so the character U+FEFF is encoded to the bytes 0xFFFE. (BIG problem)
Now, since the ID3 tag is before everything else in the file, my program scans it for the first sync header. It sees the 0xFFF from the Unicode BOM and parses it as a frame header.
The tag was parsed as an MP1 frame, and since I couldn't find anything on how MP1 or MP2 files store the data I just kill the program when one is encountered. (Nobody here uses MP1 anyway...)
This whole problem could have been avoided if whoever tagged the file used the ID3 unsynchronization scheme. That outputs a 0x00 byte after all 0xFF bytes to break up any false sync headers PRECISELY because of this problem.
Most other programs at least know how to skip over ID3 data, which is why no other programs fail on this. mp3repacker, however, has the attitude that if it ain't an MP3 frame it's junk (and I don't plan on changing that)
So the problem came from a combination of things:
* The file uses an ID3v2 tag
* The tag does not use the feature that breaks up confusing bytes
* The tag uses the EXACT Unicode encoding that results in lots of 0xFFFE strings
* My program has no idea what a "tag" is, or how to skip one when it sees one
My debugger program gives this as output:
Get a bunch of data from the file
Begin reading at 0 - 4096
Found a possible header at 21 (21)
MPEG1 Layer 1
160 kbps
48000 Hz
Stereo
CRC present
Padded frame
Frame length: 481
Found a possible header at 962 (962)
MPEG1 Layer 3
192 kbps
44100 Hz
Stereo
CRC present
Frame length: 626
Found a possible header at 1588 (1588)
MPEG1 Layer 3
192 kbps
44100 Hz
Stereo
CRC present
Padded frame
Frame length: 627
Found a possible header at 2215 (2215)
MPEG1 Layer 3
192 kbps
44100 Hz
Stereo
CRC present
Padded frame
Frame length: 627
Found a possible header at 2842 (2842)
MPEG1 Layer 3
192 kbps
44100 Hz
Stereo
CRC present
Padded frame
Frame length: 627
Found a possible header at 3469 (3469)
MPEG1 Layer 3
192 kbps
44100 Hz
Stereo
CRC present
Padded frame
Frame length: 627
No possible headers found
And the end of the file has been reached!
bitrate={160,192,192,192,192,192};
bpf={3848,5008,5016,5016,5016,5016};
bitsused={,4142,4998,4716,4446,4328};
reservoir={,0,70,34,33,66};
The first frame is the one from the header, and you can see that it is different from all the rest.