1 | SUBROUTINE UNPACK_CBF(N,CMPR,MXY,IMG) |
---|
2 | |
---|
3 | Cf2py intent(in) N |
---|
4 | Cf2py intent(in) CMPR |
---|
5 | Cf2py depend(N) CMPR |
---|
6 | Cf2py intent(in) MXY |
---|
7 | Cf2py intent(in,out) IMG |
---|
8 | Cf2py depend(MXY) IMG |
---|
9 | |
---|
10 | IMPLICIT NONE |
---|
11 | INTEGER*4 N,MXY |
---|
12 | CHARACTER*1 CMPR(0:N-1) |
---|
13 | INTEGER*4 IMG(0:MXY-1),BASEPIXEL |
---|
14 | INTEGER*4 I,J,ISIZE |
---|
15 | CHARACTER*1 C1,E1 |
---|
16 | CHARACTER*2 C2,E2 |
---|
17 | CHARACTER*4 C4,E4 |
---|
18 | INTEGER*1 IONEBYTE |
---|
19 | INTEGER*2 ITWOBYTES |
---|
20 | INTEGER*4 IFOURBYTES |
---|
21 | |
---|
22 | E1 = CHAR(128) |
---|
23 | E2 = CHAR(0)//CHAR(128) |
---|
24 | E4 = CHAR(0)//CHAR(0)//CHAR(0)//CHAR(128) |
---|
25 | |
---|
26 | I = 0 |
---|
27 | J = 0 |
---|
28 | BASEPIXEL = 0 |
---|
29 | DO WHILE ( I.LT.N ) |
---|
30 | C1 = CMPR(I) |
---|
31 | ISIZE = 1 |
---|
32 | IF ( C1.EQ.E1 ) THEN |
---|
33 | ISIZE = 2 |
---|
34 | I = I+1 |
---|
35 | C2 = CMPR(I)//CMPR(I+1) |
---|
36 | IF ( C2.EQ.E2 ) THEN |
---|
37 | ISIZE = 4 |
---|
38 | I = I+2 |
---|
39 | C4 = CMPR(I)//CMPR(I+1)//CMPR(I+2)//CMPR(I+3) |
---|
40 | IF ( C4.EQ.E4 ) THEN |
---|
41 | ISIZE = 8 |
---|
42 | I = I+4 |
---|
43 | END IF |
---|
44 | END IF |
---|
45 | END IF |
---|
46 | IF ( ISIZE .EQ. 1 ) THEN |
---|
47 | IONEBYTE = ICHAR(CMPR(I)) |
---|
48 | I = I+1 |
---|
49 | BASEPIXEL = BASEPIXEL+IONEBYTE |
---|
50 | ELSE IF ( ISIZE .EQ. 2 ) THEN |
---|
51 | ITWOBYTES = ICHAR(CMPR(I)) |
---|
52 | ITWOBYTES = ITWOBYTES+ISHFT(ICHAR(CMPR(I+1)),8) |
---|
53 | I = I+2 |
---|
54 | BASEPIXEL = BASEPIXEL+ITWOBYTES |
---|
55 | ELSE IF ( ISIZE.EQ.4 ) THEN |
---|
56 | IFOURBYTES = ICHAR(CMPR(I)) |
---|
57 | IFOURBYTES = IFOURBYTES+ISHFT(ICHAR(CMPR(I+1)),8) |
---|
58 | IFOURBYTES = IFOURBYTES+ISHFT(ICHAR(CMPR(I+2)),16) |
---|
59 | IFOURBYTES = IFOURBYTES+ISHFT(ICHAR(CMPR(I+3)),24) |
---|
60 | I = I+4 |
---|
61 | BASEPIXEL = BASEPIXEL+IFOURBYTES |
---|
62 | END IF |
---|
63 | c IF ( MOD(J,100000).EQ.0 ) PRINT *,I,J,BASEPIXEL |
---|
64 | IMG(J) = BASEPIXEL |
---|
65 | J = J+1 |
---|
66 | END DO |
---|
67 | RETURN |
---|
68 | END |
---|
69 | |
---|
70 | SUBROUTINE UNPACK_CBF3(N,CMPR,MXY,IMG) |
---|
71 | |
---|
72 | Cf2py intent(in) N |
---|
73 | Cf2py intent(in) CMPR |
---|
74 | Cf2py depend(N) CMPR |
---|
75 | Cf2py intent(in) MXY |
---|
76 | Cf2py intent(in,out) IMG |
---|
77 | Cf2py depend(MXY) IMG |
---|
78 | |
---|
79 | IMPLICIT NONE |
---|
80 | INTEGER*4 N,MXY |
---|
81 | INTEGER*1 CMPR(0:N-1) |
---|
82 | INTEGER*4 IMG(0:MXY-1),BASEPIXEL |
---|
83 | INTEGER*4 I,J,ISIZE |
---|
84 | CHARACTER*1 C1,E1 |
---|
85 | CHARACTER*2 C2,E2 |
---|
86 | CHARACTER*4 C4,E4 |
---|
87 | INTEGER*1 IONEBYTE |
---|
88 | INTEGER*2 ITWOBYTES |
---|
89 | INTEGER*4 IFOURBYTES |
---|
90 | |
---|
91 | E1 = CHAR(128) |
---|
92 | E2 = CHAR(0)//CHAR(128) |
---|
93 | E4 = CHAR(0)//CHAR(0)//CHAR(0)//CHAR(128) |
---|
94 | |
---|
95 | I = 0 |
---|
96 | J = 0 |
---|
97 | BASEPIXEL = 0 |
---|
98 | DO WHILE ( I.LT.N ) |
---|
99 | C1 = CHAR(CMPR(I)) |
---|
100 | ISIZE = 1 |
---|
101 | IF ( C1.EQ.E1 ) THEN |
---|
102 | ISIZE = 2 |
---|
103 | I = I+1 |
---|
104 | C2 = CHAR(CMPR(I))//CHAR(CMPR(I+1)) |
---|
105 | IF ( C2.EQ.E2 ) THEN |
---|
106 | ISIZE = 4 |
---|
107 | I = I+2 |
---|
108 | C4 = CHAR(CMPR(I))//CHAR(CMPR(I+1))// |
---|
109 | 1 CHAR(CMPR(I+2))//CHAR(CMPR(I+3)) |
---|
110 | IF ( C4.EQ.E4 ) THEN |
---|
111 | ISIZE = 8 |
---|
112 | I = I+4 |
---|
113 | END IF |
---|
114 | END IF |
---|
115 | END IF |
---|
116 | IF ( ISIZE .EQ. 1 ) THEN |
---|
117 | IONEBYTE = ICHAR(CHAR(CMPR(I))) |
---|
118 | I = I+1 |
---|
119 | BASEPIXEL = BASEPIXEL+IONEBYTE |
---|
120 | ELSE IF ( ISIZE .EQ. 2 ) THEN |
---|
121 | ITWOBYTES = ICHAR(CHAR(CMPR(I))) |
---|
122 | ITWOBYTES = ITWOBYTES+ISHFT(ICHAR(CHAR(CMPR(I+1))),8) |
---|
123 | I = I+2 |
---|
124 | BASEPIXEL = BASEPIXEL+ITWOBYTES |
---|
125 | ELSE IF ( ISIZE.EQ.4 ) THEN |
---|
126 | IFOURBYTES = ICHAR(CHAR(CMPR(I))) |
---|
127 | IFOURBYTES = IFOURBYTES+ISHFT(ICHAR(CHAR(CMPR(I+1))),8) |
---|
128 | IFOURBYTES = IFOURBYTES+ISHFT(ICHAR(CHAR(CMPR(I+2))),16) |
---|
129 | IFOURBYTES = IFOURBYTES+ISHFT(ICHAR(CHAR(CMPR(I+3))),24) |
---|
130 | I = I+4 |
---|
131 | BASEPIXEL = BASEPIXEL+IFOURBYTES |
---|
132 | END IF |
---|
133 | c IF ( MOD(J,100000).EQ.0 ) PRINT *,I,J,BASEPIXEL |
---|
134 | IMG(J) = BASEPIXEL |
---|
135 | J = J+1 |
---|
136 | END DO |
---|
137 | RETURN |
---|
138 | END |
---|