Debian Codegraph @

test/compress-5level.sh.in

raw
1 #!@SHELL@
2
3 # compression of 5-level inks (irrespective of bits per level)
4 # 3-level, 5 pixels = 1024 combinations: 10 bits long
5 # but since not all levels used: unique are 242, or 1 byte
6 # 4-level, 4 pixels = 65536 combinations: 16 bits long
7 # but since only 2 bits per pixel used there are 256 combinations, or 1 byte
8 # 5-level, 3 pixels: 15 bits long
9 # but since only 3 bits per pixel used there are 125 unique combinations, or 1 byte
10
11
12 # m: max number of levels used
13 m=5
14 # z: max number allowed by bits
15 z=16
16 # a: iteration of array subscript
17 a=1
18 # n: iteration of valid combinations
19 n=0
20 # iteration of pixels
21 #i=0
22 j=0
23 k=0
24 l=0
25
26 echo "static const unsigned char ninetoeight[] ="
27 echo "{"
28
29 #for (( i=1; i<=$z; i++ ))
30 #do
31 for (( j=1; j<=$z; j++ ))
32 do
33 for (( k=1; k<=$z; k++ ))
34 do
35 for (( l=1; l<=$z; l++ ))
36 do
37 # if test $i -gt $m -o $j -gt $m -o $k -gt $m -o $l -gt $m
38 if test $j -gt $m -o $k -gt $m -o $l -gt $m
39 then
40 array[$a]=0
41 else
42 array[$a]=$n
43 n=$(( $n+1 ))
44 fi
45 # print line of output
46 remainder=$(( $a % 16 ))
47 a=$(( $a+1 ))
48 if test $remainder -eq 0
49 then
50 printf " "
51 pstart=$(( 256*($j-1)+16*($k-1)+1 ))
52 pfinal=$(( 256*($j-1)+16*$k ))
53 #echo "array subscript: $a, pstart: $pstart, pfinal: $pfinal, iterators: $j $k $l"
54 for (( p=$pstart; p<=$pfinal; p++ ))
55 do
56 printf "%3d," ${array[$p]}
57 done
58 printf "\n"
59 fi
60 done
61 done
62 done
63 #done
64
65 echo "};"
66 echo "max number of valid combinations: $n"