Advertisement

MP3-Beating Compression

Started by April 06, 2000 01:58 PM
494 comments, last by kieren_j 24 years, 8 months ago
when the little folder has a X through it, doesn''t it mean it has been closed?

MENTAL
Lack, here are some bytes taken from a zip file:

10010010 00101010 00111111 01100100 10101111 11101010 11111100 00111010 01011001 10111110

3-bit: 000: 2
001: 4
010: 3
011: 3
100: 3
101: 4
110: 0
111: 7 -> "most common"

if you count 3-bit aligned
Ok, let''s compress it:
Header: 111 Body: 1 100 1 100 1 100 1 010 1 101 1 000 0 0 1 011 1 001 1 001 1 010 0 0 1 101 1 010
0 0 1 000 1 011 1 101 1 001 1 011 1 001 1 101 0 1 10

-> no compression with 3-bit pattern length

4 bit: 1001: 2
0010: 2
1010: 4 -> most common
0011: 2
1111: 3
0110: 1
0100: 1
1110: 2
1100: 1
0101: 1
1011: 1

Let''s try to compress ist again:
Header: 1010 Body: 1 1001 1 0010 1 0010 0 1 0011 1 1111 1 0110 1 0100 0 1 1111 1 1110 0 1 1111 1 1100 1 0011 0 1 0101 1 1001 1 1011 1 1110

-> no compression with 4 bit patterns

Try it with other pattern lengths and you''ll get the same results.
Now I''ll reorder the bits:
10010010 00101010 00111111 01100100 10101111 11101010 11111100 00111010 01011001 10111110
->
1000111001 0001011010 0111111101 1010001111 0110111111 0011101001 1110110101 0010100010

Now try to compress this....
or tell me an other "Byte" size to reorder the bits

Visit our homepage: www.rarebyte.de.st

GA
Visit our homepage: www.rarebyte.de.stGA
Advertisement
3dModelMan, there can't be efficient compression methods for every kind of data because then you could compress the compressed files again and again and again.....
And there is no good general bit swaping method for zip files. Maybe one of your 256 variations of reordering bits works for one specific zip file but then the description of the reordering method must be very large itself if it should work with random data

Visit our homepage: www.rarebyte.de.st

GA

Edited by - ga on 4/16/00 8:53:09 AM
Visit our homepage: www.rarebyte.de.stGA
Whoever the hell posted that as anonymous - please don''t.
As I said, I am going to upload a demo!
Damn it, just wait until after then to critisise it!

The guy who posted - sorry, I thought you were taking the piss outa me (everybody else does).....
If you have a lot more bytes, then there will be a lot more evident patterns - 5 bytes or whatever is not enough. And you don't specify the bit length yourself; my alogrithm (which you can look at once I've uploaded the demo) calculates the bit length that saves the most and uses that.
When you apply this to a file, it usually detects "16-bit", and makes the file about 10% bigger than it orignally was! Oh no! But, apply it again, and for some reason it detects "4-bit" data, and reduces it by a lot more than it increased it in the first place.
Do this lots of times, you've got great compressed data!
Add other pre-processing routines (like the bit-reorder) and you've got really great compressed data!
Watch out for the demo, should be here tomorrow. It's a Win32 console app, and has only been tested on my Win95B machine. It only shows of the bit-based huffman I've been talking about. Source code is 17.5kb now, and it still runs very slow!!
Can anybody think of a better name though?

Edited by - kieren_j on 4/16/00 3:42:49 PM
If anybody wants to speed up my routines:

struct "bitstream"
Note: I don''t want classes, thanks
typedef struct bitstream{	unsigned char *ptr;	unsigned long byte;	unsigned char bit;} bitstream;


function "read_bit"
Note: must return "1" or "0"
unsigned char inline read_bit(bitstream *bs){	unsigned char ret;	switch (bs->bit)	{	case 0:		ret = bs->ptr[bs->byte] & 1;		break;	case 1:		ret = bs->ptr[bs->byte] & 2;		break;	case 2:		ret = bs->ptr[bs->byte] & 4;		break;	case 3:		ret = bs->ptr[bs->byte] & 8;		break;	case 4:		ret = bs->ptr[bs->byte] & 16;		break;	case 5:		ret = bs->ptr[bs->byte] & 32;		break;	case 6:		ret = bs->ptr[bs->byte] & 64;		break;	case 7:		ret = bs->ptr[bs->byte] & 128;		break;	}	bs->bit++;	if (bs->bit == 8)	{		bs->bit = 0;		bs->byte++;	}	if (ret)		ret = 1;		return ret;}


function "write_bit"
void inline write_bit(bitstream *bs, unsigned char value){	if (value)	{		switch (bs->bit)		{		case 0:			bs->ptr[bs->byte] /= 1;			break;		case 1:			bs->ptr[bs->byte] /= 2;			break;		case 2:			bs->ptr[bs->byte] /= 4;			break;		case 3:			bs->ptr[bs->byte] /= 8;			break;		case 4:			bs->ptr[bs->byte] /= 16;			break;		case 5:			bs->ptr[bs->byte] /= 32;			break;		case 6:			bs->ptr[bs->byte] /= 64;			break;		case 7:			bs->ptr[bs->byte] /= 128;			break;		}	}	bs->bit++;	if (bs->bit == 8)	{		bs->bit = 0;		bs->byte++;	}}


To read / write multiple bits, the functions are called the required amount of times in functions read_bits and write_bits. A function, write_byte calls write_bit 8 times, once with BYTE AND 1, then BYTE AND 2, then BYTE AND 4, and so on.
At the moment it takes 3 minutes to compress about 1.5mb!
Advertisement
is anybody still taking this seriously?
In fact, have a sample output as well:
Primary Compression.............(PRI) Bits:16  New Size:    3961  Change:     233  Data:2020Secondary Compression.............(# 1) Bits: 4  New Size:    3475  Change:    -486  Data:   0..........(# 2) Bits:16  New Size:    3694  Change:     219  Data:6868..........(# 3) Bits: 4  New Size:    3350  Change:    -344  Data:   0..........(# 4) Bits:16  New Size:    3560  Change:     210  Data:8D8D..........(# 5) Bits: 4  New Size:    3227  Change:    -333  Data:   0..........(# 6) Bits:16  New Size:    3430  Change:     203  Data:4646..........(# 7) Bits: 4  New Size:    3104  Change:    -326  Data:   0..........(# 8) Bits:16  New Size:    3298  Change:     194  Data:A3A3..........(# 9) Bits: 4  New Size:    3000  Change:    -298  Data:   0..........(#10) Bits:16  New Size:    3188  Change:     188  Data:4646..........(#11) Bits: 4  New Size:    2886  Change:    -302  Data:   0........


It shows it in the process of compressing.
kieron_j,
Just some advice:
Most of the ppl here don''t believe you, and your attemps at convincing them you are right are terribly pointless. Go off and do your thing and fuck everyone else. If your right, then good luck to you, or else your find out the hard way. If they don''t believe you, thats there thing and you can''t change that. I hope you realize this. Just leave, and like i said: fuck everyone else.
quote: Original post by Zipster

kieron_j,
Just some advice:
Most of the ppl here don''t believe you, and your attemps at convincing them you are right are terribly pointless. Go off and do your thing and fuck everyone else.


Hey, hold on a second. He''s posting real code now! We''re getting somewhere

This topic is closed to new replies.

Advertisement