Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Infinite compression: I think I did it!

Name: Anonymous 2014-07-22 7:06

Hello /prog/

I've been experimenting with infinitely efficient compression algorithm. I think I finally got it working. The algorithm quarantees at least one byte reduction of the input.

I've created a reference implementation. It consists of two programs, "pack" and "extract". It's written in C.

Here's a simple demonstration.

C:\> echo Hello
Hello
C:\> echo -n Hello | wc
0 1 5
C:\> echo -n Hello | ./pack | wc
0 1 4
C:\> echo -n Hello | ./pack | ./extract | wc
0 1 5
C:\> echo -n Hello | ./pack | ./extract
HelloC:\>
C:\> echo Hello | ./pack | ./extract
Hello
C:\>


Here's the source code for "pack"
#include <stdio.h>

#define _PACKCALL_ /*
use
standard
conventions */
#define __integer int
#define CHARPTR char*
#define FILE_T FILE*
#define __PACK_SUCCESS 1
#define __PACK_FAILURE__ 1
#define __PACK__SUCCKESS_CODE __integer
#define _PACKER_DATA_TYPE CHARPTR
#define MAIN_SUCCESS_CODE 2

#define \
DO_PACK(data) \
__pack__(data)

#define READ(F) \
fread(__buf, 1, 99999, F) /* TODO buf size? */

#define WRITE(F) \
fwrite(__buf,\
1, __data_len, F\
)

_PACKCALL_ __PACK__SUCCKESS_CODE __pack__(_PACKER_DATA_TYPE __data);

int
main
(
int argc
,char** argv
)
{
FILE_T _file;
int __buf[512];
int _len;
__integer __data_len;
CHARPTR data;
_file = stdin;
_len = READ(_file);
data = __buf;
DO_PACK(data);
__data_len = _len - 1;
WRITE(stdout);

return MAIN_SUCCESS_CODE;
}

_PACKCALL_
__PACK__SUCCKESS_CODE
__pack__
(
_PACKER_DATA_TYPE __data
)
{
//here we define dsl
/* that makes it easier to implement the algorithm
* *
*/
/* dsl is an mini language
* that is suitable for one purpose */
#define Xor(a,b) a^b
#define Fmap(_DAT) \
while( * ptr) \
{ *ptr = F( * ptr);\
++ptr\
; \
}
#define F(_tok) \
Xor(\
_tok\
, X)
__integer X;
CHARPTR _mag = "\x17\x17";

/* FIRST PASS */
X = _mag[0];
CHARPTR ptr = __data;
Fmap(__data);

/* SECOND PASS */
ptr = __data;
X = _mag[1];
Fmap(__data);
}


Check out the __pack__ function for algorithm. It should be pretty straightforward.

Here's the extract.c code
#include <stdio.h>

#define _EXTRACTCALL_ /*
use
standard
conventions */
#define __integer int
#define CHARPTR char*
#define FILE_T FILE*
#define __EXTRACT_SUCCESS 1
#define __EXTRACT_FAILURE__ 1
#define __EXTRACT__SUCCKESS_CODE __integer
#define _EXTRACTER_DATA_TYPE CHARPTR
#define MAIN_SUCCESS_CODE 2

#define \
DO_EXTRACT(data) \
__extract__(data)

#define READ(F) \
fread(__buf+1, 1, 99999, F) /* TODO buf size? */

#define WRITE(F) \
fwrite(__buf+1,\
1, __data_len, F\
)

_EXTRACTCALL_ __EXTRACT__SUCCKESS_CODE __extract__(_EXTRACTER_DATA_TYPE __data);

int
main
(
int arg
,char** argv
)
{
FILE_T _file;
int __buf[512] = {0};
int _len;
__integer __data_len;
CHARPTR data;
_file = stdin;
_len = READ(_file);
data = __buf;
data[0] = _len;
DO_EXTRACT(data);
__data_len = _len + 1;
WRITE(stdout);

return MAIN_SUCCESS_CODE;
}

_EXTRACTCALL_
__EXTRACT__SUCCKESS_CODE
__extract__
(
_EXTRACTER_DATA_TYPE __data
)
{
//here we define mini language
/* that makes it easier to implement the algorithm
*/
#define Xor(a,b) a^b
#define Fmap(_DAT) \
while( * ptr); \
{ *ptr = F( * ptr);\
ptr++\
; \
}
#define F(_tok) \
Xor(\
_tok\
, Y)
char Y;
CHARPTR _rmag = "\x22\x22";
char time(void*);

/* REVERSE SECOND PASS */
Y = _rmag[1];
CHARPTR ptr = __data+1;
Fmap(__data);

/* REVERSE FIRST PASS */
ptr = __data+1;
Y = _rmag[0];
//Fmap(__data);

/* FINALISE */
__data[__data[0] + 4] = time(0);
}


It works the same as pack.c, except it does the opposite.

What I would still need, is some review of the algorithm and implementation code before I take this to my colleagues. I was wondering if some hackers at /prog/ could do this? You'd get your names to computer history book.

Name: Anonymous 2014-09-05 6:42

>>81
No, Fuck off

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List