Angerstein
Jun 22 2005, 02:16 PM
Hello,
I have just another issue fighting binaeries.
The mp3 format uses something (sick) called syncsave integer.
If you have a 4 Byte 32 Bit the very first bit of every Byte is used
as a syncsave bit. so you can only put a 28 Bit long Number in it.
Puting stuff in this format is the one thing and getting the right number
out of it is the other thing I dont know.
I tried the uucode format transformer "un"pack("u", $buffer) but this dont
work.
Thanks,
Bastian
Dave Gray
Jun 22 2005, 06:31 PM
On 6/22/05, Angerstein <[Email Removed]> wrote:
QUOTE |
The mp3 format uses something (sick) called syncsave integer.
If you have a 4 Byte 32 Bit the very first bit of every Byte is used as a syncsave bit. so you can only put a 28 Bit long Number in it.
Puting stuff in this format is the one thing and getting the right number out of it is the other thing I dont know.
I tried the uucode format transformer "un"pack("u", $buffer) but this dont work.
|
What you have to do is skip those ranges (between (2^7)+1 and 2^8, etc).
#!/usr/bin/perl
use strict;
use warnings;
my @data = ((2**8)-1, (2**16)-1, (2**24)-1, (2**32)-1);
my @ss = ();
my %gaps;
for (my $i = 7; $i <= 32; $i += 8) {
$gaps{$i} = (2**($i+1)) - (2**$i);
}
# normal to synchsafe
for my $n (@data) {
my $ss = $n;
for my $k (keys %gaps) {
$ss += $gaps{$k} if $ss > (2**$k);
}
print "$n -> $ssn";
push @ss, $ss;
}
# synchsafe to normal
for my $ss (@ss) {
my $n = $ss;
for my $k (keys %gaps) {
$n -= $gaps{$k} if $ss > (2**$k);
}
print "$ss -> $nn";
}
[1] <http://www.id3.org/id3v2.4.0-structure.txt> (section 6.2)