can someone help me ? about the unlimited compression without data loss

Post/Author/DateTimePost
#1

uglyvan

Jun 05, 2013 8:14:42

written in justbasic 1.01
I'm a poor programmer, so I hope the following code is not too badly written
this is the compression program; I just can't handle uncompression

  
  dim s(1000000)
dim t(1000000)


dim u(255)
dim v(255)
dim w(255)


open "puckupazipfile.zip" for input as #f


open "report.raw" for output as #g


lf=lof(#f)


for i=1 to lf


a=asc(input$(#f,1))


u(a)=u(a)+1


t(i)=a


next i
close #f


for i=0 to 255


zz=0 for j=0 to 255


if u(j)>zz then
zz=u(j)
aa=j


end if


next j
v(aa)=zz
u(aa)=0
w(i)=aa
print w(i);"   ";aa;" ";zz;"  ";v(aa)


next i


for j=0 to 255


print #g, chr$(w(j));


'print #g, str$(v(w(j)));


print j


z=0
zztop=0
for i=1 to lf


if s(i)=1 then
zztop=zztop+1
end if


if t(i)=w(j) then


if t(i-z-zztop)>255 then


do
print #g,chr$(0);
z=z+255
loop until t(i-z-zztop)<256


end if
s(i)=1
print #g,chr$(t(i-z-zztop));


z=i
zztop=0
end if


next i


next j


close #g


end


 

#2

uglyvan

Jun 05, 2013 8:18:48

written in justbasic 1.01
I'm a poor programmer, so I hope the following code is not too badly written
this is the compression program; I just can't handle uncompression

  
  dim s(1000000)
dim t(1000000)


dim u(255)
dim v(255)
dim w(255)


open "puckupazipfile.zip" for input as #f


open "report.raw" for output as #g


lf=lof(#f)


for i=1 to lf


a=asc(input$(#f,1))


u(a)=u(a)+1


t(i)=a


next i
close #f


for i=0 to 255


zz=0 for j=0 to 255


if u(j)>zz then
zz=u(j)
aa=j


end if


next j
v(aa)=zz
u(aa)=0
w(i)=aa
print w(i);"   ";aa;" ";zz;"  ";v(aa)


next i
  




first, we create a total for each number (from 0 to 255)
then we sort for the most frequent number

#3

uglyvan

Jun 05, 2013 8:24:28

for j=0 to 255


print #g, chr$(w(j));


'print #g, str$(v(w(j)));


print j


z=0
zztop=0
for i=1 to lf


if s(i)=1 then
zztop=zztop+1
end if


if t(i)=w(j) then


if t(i-z-zztop)>255 then


do
print #g,chr$(0);
z=z+255
loop until t(i-z-zztop)<256


end if
s(i)=1
print #g,chr$(t(i-z-zztop));


z=i
zztop=0
end if


next i


next j


close #g


end


 




then we use distance between two occurences of the same number;

the idea then is to say when you have read your file one time and found say a 237 at occurence 22 , then if there is a 40 at occurence 24 you can substract 1 (the occurence 22) so you put a 23 for the occurence of the number 40.
#4

uglyvan

Jun 05, 2013 8:45:53
then, subject "report.raw" to Winzip

the new size of  "puckupazipfile.zip" is shorter than before

#5

mellored

Jun 05, 2013 8:46:39
What's the pont of compressing something that you can't uncompress?

And you really want better variable names.  This is zztop.