| 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 |
maxl=$(( $m-1 )) # the max level numerical value |
| 15 |
# z: max number allowed by bits (numerical value) |
| 16 |
z=15 |
| 17 |
# a: iteration of valid array subscript (1-based) |
| 18 |
a=1 |
| 19 |
# iteration of pixels |
| 20 |
#i=0 |
| 21 |
j=0 |
| 22 |
k=0 |
| 23 |
l=0 |
| 24 |
|
| 25 |
echo "static const unsigned short Table5Level[] =" |
| 26 |
echo "{" |
| 27 |
|
| 28 |
#for (( i=0; i<=$z; i++ )) |
| 29 |
#do |
| 30 |
for (( j=0; j<=$z; j++ )) |
| 31 |
do |
| 32 |
for (( k=0; k<=$z; k++ )) |
| 33 |
do |
| 34 |
for (( l=0; l<=$z; l++ )) |
| 35 |
do |
| 36 |
if test $j -le ${maxl} -a $k -le ${maxl} -a $l -le ${maxl} |
| 37 |
then |
| 38 |
bj=$(echo "ibase=16;obase=2; $j" | bc | awk '{if ($0<10){print "000"$0} else if ($0<100){print "00"$0} else if ($0<1000){print "0"$0} else {print $0} }') |
| 39 |
bk=$(echo "ibase=16;obase=2; $k" | bc | awk '{if ($0<10){print "000"$0} else if ($0<100){print "00"$0} else if ($0<1000){print "0"$0} else {print $0} }') |
| 40 |
bl=$(echo "ibase=16;obase=2; $l" | bc | awk '{if ($0<10){print "000"$0} else if ($0<100){print "00"$0} else if ($0<1000){print "0"$0} else {print $0} }') |
| 41 |
binput="${bj}${bk}${bl}" |
| 42 |
#echo "test:" ${bj} ${bk} ${bl} ":" ${binput} ":" $(echo "ibase=2;obase=10000; ${binput}" | bc) |
| 43 |
array[$a]=$(echo "ibase=2;obase=10000; ${binput}" | bc) |
| 44 |
remainder=$(( $a % 16 )) |
| 45 |
a=$(( $a+1 )) |
| 46 |
#echo "test:" ${remainder} |
| 47 |
# print line of output |
| 48 |
if test ${remainder} -eq 0 |
| 49 |
then |
| 50 |
printf " " |
| 51 |
pstart=$(( $a-16 )) |
| 52 |
pfinal=$(( $a-1 )) |
| 53 |
#echo "array subscript: $a, pstart: $pstart, pfinal: $pfinal, iterators: $j $k $l" |
| 54 |
for (( p=$pstart; p<=$pfinal; p++ )) |
| 55 |
do |
| 56 |
printf "0x%x," 0x${array[$p]} |
| 57 |
done |
| 58 |
printf "\n" |
| 59 |
fi |
| 60 |
fi |
| 61 |
done |
| 62 |
done |
| 63 |
done |
| 64 |
#done |
| 65 |
|
| 66 |
# need to print out the last set of combinations |
| 67 |
dividend=$(( $a-1 )) |
| 68 |
divisor=${dividend}/16 # the number of completed rows already printed |
| 69 |
printf " " |
| 70 |
pstart=$(( ${divisor}*16+1 )) |
| 71 |
pfinal=${dividend} |
| 72 |
#echo "array subscript: $a, pstart: $pstart, pfinal: $pfinal, iterators: $j $k $l" |
| 73 |
for (( p=$pstart; p<=$pfinal; p++ )) |
| 74 |
do |
| 75 |
printf "0x%x," 0x${array[$p]} |
| 76 |
done |
| 77 |
printf "\n" |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
echo "};" |
| 82 |
echo "max number of valid combinations: $(( a-1 ))" |