// This source and compression method apply to GNU General Public License. // Copyright (C) 2011 and later by Jasenko Dzinleski // This program is free software; you can redistribute it // and/or modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 2 of the // License, or (at your option) any later version. // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // // written by Dzinleski Jasenko June , 28 , 2011 // to Dusica and Dzinleski Borce // // #include #include #include #define BuffL 128 #define BtM BuffL*8 #define TBEnd 3*8 char infn[256]="War_and_Peace_NT.txt"; char outfn[256]="t_.txt"; char out1fn[256]="1_.mar"; char out2fn[256]="2_.mar"; char out3fn[256]="3_.mar"; char out4fn[256]="4_.mar"; char fn_[256]; FILE *f1,*f2,*f3,*f4,*f5,*f6; long da[0xff][0xff][1+50]; int dai=0; int ca[BuffL][3]; int cai=0; int fb[BuffL][3]; int fbi=0; int ia[BuffL][2]; int iai=0; __int64 fc=0; bool br[BtM]; int bri=0; bool bt[BtM]; int bti=0; bool bt32_1[32]; int bt32i_1=0; bool bt32_2[32]; int bt32i_2=0; __int64 bitc=0,bc=0,fbc=0; int bytc=0,bytc1=0; bool df=false; bool nf=false; bool o_f=false; char c_l[256]="{[--]}{[hh][ee][cc][dd]}{[AZ][az][09][__][ ][..]}"; int c_p(char cl_a[256],int ci,bool tf,char r_a[256]) { int a,b,c,d=0; for(a=0;a<256;++a){r_a[a]='\0';} if(tf) { for(a=0;a>24)<<24)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0xff000000)>>24)<<25)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0xff000000)>>24)<<26)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0xff000000)>>24)<<27)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0xff000000)>>24)<<28)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0xff000000)>>24)<<29)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0xff000000)>>24)<<30)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0xff000000)>>24)<<31)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0x00ff0000)>>16)<<24)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0x00ff0000)>>16)<<25)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0x00ff0000)>>16)<<26)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0x00ff0000)>>16)<<27)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0x00ff0000)>>16)<<28)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0x00ff0000)>>16)<<29)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0x00ff0000)>>16)<<30)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0x00ff0000)>>16)<<31)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0x0000ff00)>>8)<<24)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0x0000ff00)>>8)<<25)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0x0000ff00)>>8)<<26)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0x0000ff00)>>8)<<27)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0x0000ff00)>>8)<<28)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0x0000ff00)>>8)<<29)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0x0000ff00)>>8)<<30)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if((((((d&0x0000ff00)>>8)<<31)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if(((((d&0x000000ff)<<24)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if(((((d&0x000000ff)<<25)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if(((((d&0x000000ff)<<26)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if(((((d&0x000000ff)<<27)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if(((((d&0x000000ff)<<28)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if(((((d&0x000000ff)<<29)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if(((((d&0x000000ff)<<30)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} if(((((d&0x000000ff)<<31)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;} } int mar79_2(char m_in1fn[256],char m_out1fn[256],char m_out2fn[256],char m_out3fn[256],char m_out4fn[256]) { int i,j,k,l,m,n,p,q; int a,b,c,d; int nB1,nB2,nB3,nB4,nB16_1,nB16_2,nB16_3,n1,n2,n3; int t1,t2,t3,t4; int t_1,t_2,t_3; int c_0,c_1,c_2; int mx,mxi; int bm; for(i=0;i<0xff;++i){for(j=0;j<0xff;++j){da[i][j][0]=-1;}}dai=0; f2=fopen(m_out1fn,"wb"); f1=fopen(m_in1fn,"rb"); while(!feof(f1)) { if(!feof(f1)){nB1=getc(f1);}else{nB1=0;} if(!feof(f1)){nB2=getc(f1);}else{nB2=0;} if(!feof(f1)){nB3=getc(f1);}else{nB3=0;} if(!feof(f1)){nB4=getc(f1);}else{nB4=0;} n1=(nB1<<8)|nB2; n2=(nB2<<8)|nB3; n3=(nB3<<8)|nB4; fbc+=32; fb[fbi][0]=n1;fb[fbi][1]=n2;fb[fbi][2]=n3; if(n1>=n2){ca[cai][0]=n1-n2;}else{ca[cai][0]=n2-n1;} if(n2>=n3){ca[cai][1]=n2-n3;}else{ca[cai][1]=n3-n2;} if(ca[cai][0]>=ca[cai][1]){ca[cai][2]=ca[cai][0]-ca[cai][1];}else{ca[cai][2]=ca[cai][1]-ca[cai][0];} //printf("!%d %d!",((ca[cai][2]&0xff00)>>8),(ca[cai][2]&0x00ff)); if(da[((ca[cai][2]&0xff00)>>8)][(ca[cai][2]&0x00ff)][0]==-1) { da[((ca[cai][2]&0xff00)>>8)][(ca[cai][2]&0x00ff)][0]=1;b=1; da[((ca[cai][2]&0xff00)>>8)][(ca[cai][2]&0x00ff)][da[((ca[cai][2]&0xff00)>>8)][(ca[cai][2]&0x00ff)][0]]=(fb[fbi][0]&0xff00)|(fb[fbi][2]&0x00ff); }else{ for(i=1;i<=da[((ca[cai][2]&0xff00)>>8)][(ca[cai][2]&0x00ff)][0];++i) { if ((fb[fbi][0]&0xff00)|(fb[fbi][2]&0x00ff)==da[((ca[cai][2]&0xff00)>>8)][(ca[cai][2]&0x00ff)][i]){break;} } if(i==1+da[((ca[cai][2]&0xff00)>>8)][(ca[cai][2]&0x00ff)][0]) { ++da[((ca[cai][2]&0xff00)>>8)][(ca[cai][2]&0x00ff)][0]; b=da[((ca[cai][2]&0xff00)>>8)][(ca[cai][2]&0x00ff)][0]; da[((ca[cai][2]&0xff00)>>8)][(ca[cai][2]&0x00ff)][da[((ca[cai][2]&0xff00)>>8)][(ca[cai][2]&0x00ff)][0]]=(fb[fbi][0]&0xff00)|(fb[fbi][2]&0x00ff); }else{b=i;} } a=ca[cai][2]; b=da[((ca[cai][2]&0xff00)>>8)][(ca[cai][2]&0x00ff)][0]; t1=(da[((a&0xff00)>>8)][(a&0x00ff)][b]&0xff00)>>8; t4=da[((a&0xff00)>>8)][(a&0x00ff)][b]&0x00ff; for(t2=0;t2<0xff;++t2) { for(t3=0;t3<0xff;++t3) { t_1=(t1<<8)|t2; t_2=(t2<<8)|t3; t_3=(t3<<8)|t4; if(((t_1&0x00ff)==((t_2&0xff00)>>8))&&((t_2&0x00ff)==((t_3&0xff00)>>8))) { if(t_1>=t_2){c_0=t_1-t_2;}else{c_0=t_2-t_1;} if(t_2>=t_3){c_1=t_2-t_3;}else{c_1=t_3-t_2;} if(c_0>=c_1) { c_2=c_0-c_1; if(c_2==a&&ca[cai][2]==a) { if ( da[((ca[cai][2]&0xff00)>>8)][(ca[cai][2]&0x00ff)][b]==(fb[fbi][0]&0xff00)|(fb[fbi][2]&0x00ff) ){break;} } }else{ c_2=c_1-c_0; if(c_2==a&&ca[cai][2]==a) { if ( da[((ca[cai][2]&0xff00)>>8)][(ca[cai][2]&0x00ff)][b]==(fb[fbi][0]&0xff00)|(fb[fbi][2]&0x00ff) ){break;} } } } } if(t3!=0xff){break;} } //if(t2!=0xff){printf("ok\n");}else{printf("?\n");} ++cai;++fbi; if(iai==0){ia[iai][0]=a;ia[iai][1]=b;c=iai;++iai;}else{ for(i=0;i=BuffL) { cai=0;fbi=0;iai=0; for(i=0;i<0xff;++i){for(j=0;j<0xff;++j){da[i][j][0]=-1;}}dai=0; } } fclose(f1); fclose(f2); printf("compressed bytes %d , file bytes %d (%d)\n\n\n", (long)((double)bitc/8.0), (long)((double)fbc/8.0), (long)((100*(double)((double)bitc/8.0))/(double)((double)fbc/8.0))); return(0); } int main(int argc,char *argv[]) { int a,b,c,ci,d; int i,j,k,l,m; char cmd[50][256]; char c_1[256]; char c_2[256]; char fn[10][2];int fi=0; int op=0; int ml=0; // 4 + 0,1,2,3 ... - to be determined // printf("\nText Complexity Routine written by Dzinleski Jasenko June , 28 , 2011\n"); printf("\n"); printf("\nOS Win32 VRM 1.0.0\n\n"); // for(i=0;i<50;++i){for(j=0;j<256;++j){cmd[i][j]='\0';}} for(i=0;i\n"); printf("mar79_xxx -d []\n"); printf("\n"); return(0); } if(op==2) { printf("\nText Complexity Routine written by Dzinleski Jasenko June , 28 , 2011\n"); printf("\n"); printf("\nOS Win32 VRM 1.0.0\n\n"); printf("\n"); printf("\tThis source and compression method apply to GNU General Public License.\n"); printf("\t Copyright (C) 2011 and later Jasenko Dzinleski \n"); printf("\n"); printf("\t This program is free software; you can redistribute it\n"); printf("\tand/or modify it under the terms of the GNU General Public License as\n"); printf("\tpublished by the Free Software Foundation; either version 2 of the\n"); printf("\tLicense, or (at your option) any later version.\n"); printf("\n"); printf("\tThis program is distributed in the hope that it will be useful, but\n"); printf("\tWITHOUT ANY WARRANTY; without even the implied warranty of\n"); printf("\tMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"); printf("\tGeneral Public License for more details.\n"); printf("\n"); printf("\tYou should have received a copy of the GNU General Public License along\n"); printf("\twith this program; if not, write to the Free Software Foundation, Inc.,\n"); printf("\t51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n"); printf("\n"); return(0); } if(op==3) { //| ci=3; for(i=0;i<256;++i){c_1[i]='\0';} c_p(c_l,ci,true,c_1); //for(i=0;i=fn[0][0]&&cmd[2][i]<=fn[0][1])|| (cmd[2][i]>=fn[1][0]&&cmd[2][i]<=fn[1][1])|| (cmd[2][i]>=fn[2][0]&&cmd[2][i]<=fn[2][1])|| (cmd[2][i]>=fn[3][0]&&cmd[2][i]<=fn[3][1])|| (cmd[2][i]>=fn[4][0]&&cmd[2][i]<=fn[4][1])|| (cmd[2][i]>=fn[5][0]&&cmd[2][i]<=fn[5][1]) ){}else{break;} } if(i==strlen(cmd[2])){/*printf("?");*/}else{return(0);} //| f1=fopen(cmd[2],"rb");if(f1==NULL){return(-1);}else{fclose(f1);} if(0==f_n(cmd[2],NULL)) { f1=fopen(cmd[2],"rb");if(f1==NULL){return(-1);}else{fclose(f1);} mar79_2(cmd[2],out1fn,out2fn,out3fn,out4fn); } } if(op==4) { //| ci=3; for(i=0;i<256;++i){c_1[i]='\0';} c_p(c_l,ci,true,c_1); //for(i=0;i=fn[0][0]&&cmd[2][i]<=fn[0][1])|| (cmd[2][i]>=fn[1][0]&&cmd[2][i]<=fn[1][1])|| (cmd[2][i]>=fn[2][0]&&cmd[2][i]<=fn[2][1])|| (cmd[2][i]>=fn[3][0]&&cmd[2][i]<=fn[3][1])|| (cmd[2][i]>=fn[4][0]&&cmd[2][i]<=fn[4][1])|| (cmd[2][i]>=fn[5][0]&&cmd[2][i]<=fn[5][1]) ){}else{break;} } if(i==strlen(cmd[2])){/*printf("?");*/}else{return(0);} //| if(strlen(cmd[3])!=0) { if(0==f_n(cmd[2],cmd[3])) { f1=fopen(out1fn,"rb");if(f1==NULL){return(-1);}else{fclose(f1);} } }else{ if(0==f_n(cmd[2],NULL)) { f1=fopen(out1fn,"rb");if(f1==NULL){return(-1);}else{fclose(f1);} } } } } //| return(0); }