author | HG Automerge |
Thu, 19 Jan 2017 12:00:14 +0000 | |
branch | jv |
changeset 3854 | 4afd107bc911 |
parent 1848 | 864ca2cd4e71 |
child 3855 | 1db7742d33ad |
child 4148 | d81244401c19 |
permissions | -rw-r--r-- |
540 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
525 | 12 |
|
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
13 |
"{ Package: 'stx:libview2' }" |
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
14 |
|
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
15 |
ImageReader subclass:#AVIReader |
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
16 |
instanceVariableNames:'riffReader frames nframes frameBuffer frameBufferSize imageBuffer |
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
17 |
redPalette greenPalette bluePalette flags frameDelay streamType |
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
18 |
depth compression colorTable numColors deltaMethod' |
525 | 19 |
classVariableNames:'MAXCOLORS UnsupportedFormatErrorSignal' |
20 |
poolDictionaries:'' |
|
1745
4fa0fad2a463
code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents:
1437
diff
changeset
|
21 |
category:'Graphics-Images-Readers' |
525 | 22 |
! |
23 |
||
24 |
!AVIReader class methodsFor:'documentation'! |
|
25 |
||
526 | 26 |
copyright |
27 |
" |
|
28 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
29 |
All Rights Reserved |
|
30 |
||
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
! |
|
39 |
||
525 | 40 |
documentation |
41 |
" |
|
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
42 |
This is not yet completed, untested and highly experimental. |
540 | 43 |
|
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
44 |
This reader read frames from an AVI file; however, only a tiny subset of AVI is supported. |
616 | 45 |
|
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
46 |
This is a very first attempt in reading AVI files; |
616 | 47 |
Its very experimental, preliminary and will certainly change. |
48 |
(will introduce a new class hierarchy based upon some MovieReader ...). |
|
525 | 49 |
|
50 |
When used like an imageReader, #fromFile: will return |
|
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
51 |
the very first frame and the rest as imageFrameSequence. |
525 | 52 |
|
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
53 |
Warning: |
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
54 |
right now, the complete movie is read and huge |
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
55 |
amounts of memory are allocated. |
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
56 |
The interface will be changed to allow stream operation ... |
525 | 57 |
|
58 |
[author:] |
|
59 |
Claus Gittinger |
|
60 |
||
61 |
[see also:] |
|
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
62 |
ImageReader RIFFReader |
525 | 63 |
" |
64 |
! |
|
65 |
||
66 |
examples |
|
67 |
" |
|
68 |
|reader film view tNext| |
|
69 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
70 |
reader := AVIReader readFile:'/phys/exept/home/pd_stuff/movies/avi/drlair.avi'. |
525 | 71 |
reader isNil ifTrue:[^ nil]. |
72 |
film := reader images. |
|
73 |
view := StandardSystemView extent:(film first extent). |
|
74 |
view openAndWait. |
|
75 |
||
76 |
tNext := Time millisecondClockValue + (reader frameDelay). |
|
77 |
film do:[:frame | |
|
78 |
frame displayOn:view x:0 y:0. |
|
79 |
(Delay untilMilliseconds:tNext) wait. |
|
80 |
tNext := tNext + (reader frameDelay). |
|
81 |
]. |
|
82 |
" |
|
83 |
! ! |
|
84 |
||
85 |
!AVIReader class methodsFor:'class initialization'! |
|
86 |
||
87 |
initialize |
|
88 |
MAXCOLORS := 256. |
|
89 |
||
90 |
UnsupportedFormatErrorSignal isNil ifTrue:[ |
|
91 |
UnsupportedFormatErrorSignal := ErrorSignal newSignalMayProceed:true. |
|
92 |
UnsupportedFormatErrorSignal nameClass:self message:#unsupportedFormatErrorSignal. |
|
93 |
]. |
|
94 |
||
95 |
" |
|
96 |
AVIReader initialize |
|
97 |
" |
|
98 |
||
99 |
"Created: 4.4.1997 / 22:35:52 / cg" |
|
100 |
"Modified: 5.4.1997 / 14:37:08 / cg" |
|
101 |
! ! |
|
102 |
||
103 |
!AVIReader class methodsFor:'testing'! |
|
104 |
||
105 |
isValidImageFile:aFileName |
|
106 |
"return true, if aFileName contains an AVI-movie" |
|
107 |
||
1437 | 108 |
^ RIFFReader isRIFFFile:aFileName withType:'AVI' |
525 | 109 |
|
110 |
" |
|
1437 | 111 |
AVIReader isValidImageFile:'bitmaps/magtape.xpm' |
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
112 |
AVIReader isValidImageFile:'/phys/exept/home/pd_stuff/movies/avi/drlair.avi' |
525 | 113 |
" |
114 |
||
115 |
"Created: 4.4.1997 / 22:35:52 / cg" |
|
116 |
"Modified: 4.4.1997 / 23:15:39 / cg" |
|
117 |
! ! |
|
118 |
||
119 |
!AVIReader methodsFor:'accessing'! |
|
120 |
||
121 |
frameDelay |
|
122 |
"return the value of the instance variable 'frameDelay' (automatically generated)" |
|
123 |
||
124 |
^ frameDelay |
|
125 |
||
126 |
"Created: 4.4.1997 / 22:35:52 / cg" |
|
127 |
! |
|
128 |
||
129 |
images |
|
130 |
"return a collection of all images as represented by myself" |
|
131 |
||
622 | 132 |
|image depth| |
525 | 133 |
|
134 |
depth := self bitsPerPixel. |
|
622 | 135 |
1 to:imageSequence size do:[:i | |
136 |
|frame| |
|
525 | 137 |
|
622 | 138 |
frame := imageSequence at:i. |
139 |
||
140 |
frame isImage ifFalse:[ |
|
141 |
image := (Image implementorForDepth:depth) new. |
|
142 |
image |
|
143 |
width:width |
|
144 |
height:height |
|
145 |
photometric:photometric |
|
146 |
samplesPerPixel:samplesPerPixel |
|
147 |
bitsPerSample:bitsPerSample |
|
148 |
colorMap:colorMap |
|
149 |
bits:frame |
|
150 |
mask:mask. |
|
151 |
imageSequence at:i put:image. |
|
152 |
]. |
|
525 | 153 |
]. |
622 | 154 |
^ imageSequence |
525 | 155 |
|
156 |
"Created: 4.4.1997 / 22:35:52 / cg" |
|
622 | 157 |
"Modified: 24.6.1997 / 15:57:17 / cg" |
525 | 158 |
! ! |
159 |
||
160 |
!AVIReader methodsFor:'decoders'! |
|
161 |
||
162 |
AVI_Decode_CRAM:data |
|
163 |
" |
|
164 |
||
165 |
/* |
|
166 |
* Routine to Decode an AVI CRAM chunk |
|
167 |
*/ |
|
168 |
||
169 |
#define AVI_CRAM_C1(ip,clr,rdec) { \ |
|
170 |
*ip++ = clr; *ip++ = clr; *ip++ = clr; *ip = clr; ip -= rdec; \ |
|
171 |
*ip++ = clr; *ip++ = clr; *ip++ = clr; *ip = clr; ip -= rdec; \ |
|
172 |
*ip++ = clr; *ip++ = clr; *ip++ = clr; *ip = clr; ip -= rdec; \ |
|
173 |
*ip++ = clr; *ip++ = clr; *ip++ = clr; *ip = clr; } |
|
174 |
||
175 |
#define AVI_CRAM_C2(ip,flag,cA,cB,rdec) { \ |
|
176 |
*ip++ =(flag&0x01)?(cB):(cA); *ip++ =(flag&0x02)?(cB):(cA); \ |
|
177 |
*ip++ =(flag&0x04)?(cB):(cA); *ip =(flag&0x08)?(cB):(cA); ip-=rdec; \ |
|
178 |
*ip++ =(flag&0x10)?(cB):(cA); *ip++ =(flag&0x20)?(cB):(cA); \ |
|
179 |
*ip++ =(flag&0x40)?(cB):(cA); *ip =(flag&0x80)?(cB):(cA); } |
|
180 |
||
181 |
#define AVI_CRAM_C4(ip,flag,cA0,cA1,cB0,cB1,rdec) { \ |
|
182 |
*ip++ =(flag&0x01)?(cB0):(cA0); *ip++ =(flag&0x02)?(cB0):(cA0); \ |
|
183 |
*ip++ =(flag&0x04)?(cB1):(cA1); *ip =(flag&0x08)?(cB1):(cA1); ip-=rdec; \ |
|
184 |
*ip++ =(flag&0x10)?(cB0):(cA0); *ip++ =(flag&0x20)?(cB0):(cA0); \ |
|
185 |
*ip++ =(flag&0x40)?(cB1):(cA1); *ip =(flag&0x80)?(cB1):(cA1); } |
|
186 |
||
187 |
#define AVI_MIN_MAX_CHECK(x,y,min_x,max_x,min_y,max_y) { \ |
|
188 |
if (x < min_x) min_x = x; if (y > max_y) max_y = y; \ |
|
189 |
if (x > max_x) max_x = x; if (y < min_y) min_y = y; } |
|
190 |
||
191 |
#define AVI_BLOCK_INC(x,y,imagex) { x += 4; if (x>=imagex) { x=0; y -= 4; } } |
|
192 |
||
193 |
#define AVI_GET_16(data,dptr) { data = *dptr++; data |= (*dptr++) << 8; } |
|
194 |
||
195 |
#define AVI_CRAM_rgbC1(ip,r,g,b) { \ |
|
196 |
*ip++=r; *ip++=g; *ip++=b; *ip++=r; *ip++=g; *ip++=b; \ |
|
197 |
*ip++=r; *ip++=g; *ip++=b; *ip++=r; *ip++=g; *ip =b; } |
|
198 |
||
199 |
#define AVI_CRAM_rgbC2(ip,flag,rA,gA,bA,rB,gB,bB) { \ |
|
200 |
if (flag&0x01) {*ip++=rB; *ip++=gB; *ip++=bB;} \ |
|
201 |
else {*ip++=rA; *ip++=gA; *ip++=bA;} \ |
|
202 |
if (flag&0x02) {*ip++=rB; *ip++=gB; *ip++=bB;} \ |
|
203 |
else {*ip++=rA; *ip++=gA; *ip++=bA;} \ |
|
204 |
if (flag&0x04) {*ip++=rB; *ip++=gB; *ip++=bB;} \ |
|
205 |
else {*ip++=rA; *ip++=gA; *ip++=bA;} \ |
|
206 |
if (flag&0x08) {*ip++=rB; *ip++=gB; *ip =bB;} \ |
|
207 |
else {*ip++=rA; *ip++=gA; *ip =bA;} } |
|
208 |
||
209 |
#define AVI_CRAM_rgbC4(ip,flag,rA,gA,bA,rB,gB,bB) { \ |
|
210 |
if (flag&0x01) {*ip++=rB; *ip++=gB; *ip++=bB;} \ |
|
211 |
else {*ip++=rA; *ip++=gA; *ip++=bA;} \ |
|
212 |
if (flag&0x02) {*ip++=rB; *ip++=gB; *ip =bB;} \ |
|
213 |
else {*ip++=rA; *ip++=gA; *ip =bA;} } |
|
214 |
||
215 |
#define AVI_Get_RGBColor(r,g,b,color) \ |
|
216 |
{ register ULONG _r,_g,_b; \ |
|
217 |
_r = (color >> 10) & 0x1f; r = (_r << 3) | (_r >> 2); \ |
|
218 |
_g = (color >> 5) & 0x1f; g = (_g << 3) | (_g >> 2); \ |
|
219 |
_b = color & 0x1f; b = (_b << 3) | (_b >> 2); \ |
|
220 |
if (xa_gamma_flag==TRUE) { r = xa_gamma_adj[r]>>8; \ |
|
221 |
g = xa_gamma_adj[g]>>8; b = xa_gamma_adj[b]>>8; } } |
|
222 |
||
223 |
||
224 |
ULONG |
|
225 |
AVI_Decode_CRAM(image,delta,dsize,chdr,map,map_flag,imagex,imagey,imaged, |
|
226 |
xs,ys,xe,ye,special,extra) |
|
227 |
UBYTE *image; /* Image Buffer. */ |
|
228 |
UBYTE *delta; /* delta data. */ |
|
229 |
ULONG dsize; /* delta size */ |
|
230 |
XA_CHDR *chdr; /* color map info */ |
|
231 |
ULONG *map; /* used if it's going to be remapped. */ |
|
232 |
ULONG map_flag; /* whether or not to use remap_map info. */ |
|
233 |
ULONG imagex,imagey; /* Size of image buffer. */ |
|
234 |
ULONG imaged; /* Depth of Image. (IFF specific) */ |
|
235 |
ULONG *xs,*ys; /* pos of changed area. */ |
|
236 |
ULONG *xe,*ye; /* size of changed area. */ |
|
237 |
ULONG special; /* Special Info. */ |
|
238 |
void *extra; /* extra info needed to decode delta */ |
|
239 |
{ |
|
240 |
ULONG row_dec,exitflag,changed,block_cnt; |
|
241 |
ULONG code0,code1; |
|
242 |
LONG x,y,min_x,max_x,min_y,max_y; |
|
243 |
UBYTE *dptr; |
|
244 |
||
245 |
changed = 0; |
|
246 |
max_x = max_y = 0; min_x = imagex; min_y = imagey; |
|
247 |
dptr = delta; |
|
248 |
row_dec = imagex + 3; |
|
249 |
x = 0; |
|
250 |
y = imagey - 1; |
|
251 |
exitflag = 0; |
|
252 |
block_cnt = ((imagex * imagey) >> 4) + 1; |
|
253 |
||
254 |
if (map_flag == TRUE) |
|
255 |
{ |
|
256 |
if (x11_bytes_pixel == 4) |
|
257 |
{ |
|
258 |
while(!!exitflag) |
|
259 |
{ |
|
260 |
code0 = *dptr++; code1 = *dptr++; block_cnt--; |
|
261 |
if ( ((code1==0) && (code0==0) && !!block_cnt) || (y<0)) exitflag = 1; |
|
262 |
else |
|
263 |
{ |
|
264 |
if ((code1 >= 0x84) && (code1 <= 0x87)) /* skip */ |
|
265 |
{ ULONG skip = ((code1 - 0x84) << 8) + code0; |
|
266 |
block_cnt -= (skip-1); while(skip--) AVI_BLOCK_INC(x,y,imagex); |
|
267 |
} |
|
268 |
else /* single block encoded */ |
|
269 |
{ |
|
270 |
if (code1 >= 0x90) /* 8 color quadrant encoding */ |
|
271 |
{ ULONG cA0,cA1,cB0,cB1; |
|
272 |
ULONG *i_ptr = (ULONG *)(image + ((y * imagex + x) << 2) ); |
|
273 |
cB0 = (ULONG)map[*dptr++]; cA0 = (ULONG)map[*dptr++]; |
|
274 |
cB1 = (ULONG)map[*dptr++]; cA1 = (ULONG)map[*dptr++]; |
|
275 |
AVI_CRAM_C4(i_ptr,code0,cA0,cA1,cB0,cB1,row_dec); i_ptr -=row_dec; |
|
276 |
cB0 = (ULONG)map[*dptr++]; cA0 = (ULONG)map[*dptr++]; |
|
277 |
cB1 = (ULONG)map[*dptr++]; cA1 = (ULONG)map[*dptr++]; |
|
278 |
AVI_CRAM_C4(i_ptr,code1,cA0,cA1,cB0,cB1,row_dec); |
|
279 |
} else if (code1 < 0x80) /* 2 color encoding */ |
|
280 |
{ register ULONG clr_A,clr_B; |
|
281 |
ULONG *i_ptr = (ULONG *)(image + ((y * imagex + x) << 2) ); |
|
282 |
clr_B = (ULONG)map[*dptr++]; clr_A = (ULONG)map[*dptr++]; |
|
283 |
AVI_CRAM_C2(i_ptr,code0,clr_A,clr_B,row_dec); i_ptr -= row_dec; |
|
284 |
AVI_CRAM_C2(i_ptr,code1,clr_A,clr_B,row_dec); |
|
285 |
} |
|
286 |
else /* 1 color encoding */ |
|
287 |
{ ULONG clr = (ULONG)map[code0]; |
|
288 |
ULONG *i_ptr = (ULONG *)(image + ((y * imagex + x) << 2) ); |
|
289 |
AVI_CRAM_C1(i_ptr,clr,row_dec); |
|
290 |
} |
|
291 |
AVI_MIN_MAX_CHECK(x,y,min_x,max_x,min_y,max_y); |
|
292 |
changed = 1; AVI_BLOCK_INC(x,y,imagex); |
|
293 |
} /* end of single block */ |
|
294 |
} /* end of not term code */ |
|
295 |
} /* end of not while exit */ |
|
296 |
} /* end of 4 bytes pixel */ |
|
297 |
else if (x11_bytes_pixel == 2) |
|
298 |
{ |
|
299 |
while(!!exitflag) |
|
300 |
{ |
|
301 |
code0 = *dptr++; code1 = *dptr++; block_cnt--; |
|
302 |
if ( ((code1==0) && (code0==0) && !!block_cnt) || (y<0)) exitflag = 1; |
|
303 |
else |
|
304 |
{ |
|
305 |
if ((code1 >= 0x84) && (code1 <= 0x87)) /* skip */ |
|
306 |
{ ULONG skip = ((code1 - 0x84) << 8) + code0; |
|
307 |
block_cnt -= (skip-1); while(skip--) AVI_BLOCK_INC(x,y,imagex); |
|
308 |
} else /* single block encoded */ |
|
309 |
{ |
|
310 |
if (code1 >= 0x90) /* 8 color quadrant encoding */ |
|
311 |
{ |
|
312 |
USHORT cA0,cA1,cB0,cB1; |
|
313 |
USHORT *i_ptr = (USHORT *)(image + ((y * imagex + x) << 1) ); |
|
314 |
cB0 = map[*dptr++]; cA0 = map[*dptr++]; |
|
315 |
cB1 = map[*dptr++]; cA1 = map[*dptr++]; |
|
316 |
AVI_CRAM_C4(i_ptr,code0,cA0,cA1,cB0,cB1,row_dec); i_ptr -=row_dec; |
|
317 |
cB0 = map[*dptr++]; cA0 = map[*dptr++]; |
|
318 |
cB1 = map[*dptr++]; cA1 = map[*dptr++]; |
|
319 |
AVI_CRAM_C4(i_ptr,code1,cA0,cA1,cB0,cB1,row_dec); |
|
320 |
} /* end of 8 color quadrant encoding */ |
|
321 |
else if (code1 < 0x80) /* 2 color encoding */ |
|
322 |
{ USHORT clr_A,clr_B; |
|
323 |
USHORT *i_ptr = (USHORT *)(image + ((y * imagex + x) << 1) ); |
|
324 |
clr_B = (USHORT)map[*dptr++]; clr_A = (USHORT)map[*dptr++]; |
|
325 |
AVI_CRAM_C2(i_ptr,code0,clr_A,clr_B,row_dec); i_ptr -= row_dec; |
|
326 |
AVI_CRAM_C2(i_ptr,code1,clr_A,clr_B,row_dec); |
|
327 |
} /* end of 2 color */ |
|
328 |
else /* 1 color encoding */ |
|
329 |
{ USHORT clr = (USHORT)map[code0]; |
|
330 |
USHORT *i_ptr = (USHORT *)(image + ((y * imagex + x) << 1) ); |
|
331 |
AVI_CRAM_C1(i_ptr,clr,row_dec); |
|
332 |
} |
|
333 |
AVI_MIN_MAX_CHECK(x,y,min_x,max_x,min_y,max_y); |
|
334 |
changed = 1; AVI_BLOCK_INC(x,y,imagex); |
|
335 |
} /* end of single block */ |
|
336 |
} /* end of not term code */ |
|
337 |
} /* end of not while exit */ |
|
338 |
} /* end of 2 bytes pixel */ |
|
339 |
else /* (x11_bytes_pixel == 1) */ |
|
340 |
{ |
|
341 |
while(!!exitflag) |
|
342 |
{ |
|
343 |
code0 = *dptr++; code1 = *dptr++; block_cnt--; |
|
344 |
if ( ((code1==0) && (code0==0) && !!block_cnt) || (y<0)) exitflag = 1; |
|
345 |
else |
|
346 |
{ |
|
347 |
if ((code1 >= 0x84) && (code1 <= 0x87)) /* skip */ |
|
348 |
{ ULONG skip = ((code1 - 0x84) << 8) + code0; |
|
349 |
block_cnt -= (skip-1); while(skip--) AVI_BLOCK_INC(x,y,imagex); |
|
350 |
} else /* single block encoded */ |
|
351 |
{ |
|
352 |
if (code1 >= 0x90) /* 8 color quadrant encoding */ |
|
353 |
{ UBYTE cA0,cA1,cB0,cB1; |
|
354 |
UBYTE *i_ptr = (UBYTE *)(image + y * imagex + x); |
|
355 |
cB0 = (UBYTE)map[*dptr++]; cA0 = (UBYTE)map[*dptr++]; |
|
356 |
cB1 = (UBYTE)map[*dptr++]; cA1 = (UBYTE)map[*dptr++]; |
|
357 |
AVI_CRAM_C4(i_ptr,code0,cA0,cA1,cB0,cB1,row_dec); i_ptr -=row_dec; |
|
358 |
cB0 = (UBYTE)map[*dptr++]; cA0 = (UBYTE)map[*dptr++]; |
|
359 |
cB1 = (UBYTE)map[*dptr++]; cA1 = (UBYTE)map[*dptr++]; |
|
360 |
AVI_CRAM_C4(i_ptr,code1,cA0,cA1,cB0,cB1,row_dec); |
|
361 |
} |
|
362 |
else if (code1 < 0x80) /* 2 color encoding */ |
|
363 |
{ UBYTE clr_A,clr_B; |
|
364 |
UBYTE *i_ptr = (UBYTE *)(image + y * imagex + x); |
|
365 |
clr_B = (UBYTE)map[*dptr++]; clr_A = (UBYTE)map[*dptr++]; |
|
366 |
AVI_CRAM_C2(i_ptr,code0,clr_A,clr_B,row_dec); i_ptr -= row_dec; |
|
367 |
AVI_CRAM_C2(i_ptr,code1,clr_A,clr_B,row_dec); |
|
368 |
} |
|
369 |
else /* 1 color encoding */ |
|
370 |
{ UBYTE clr = (UBYTE)map[code0]; |
|
371 |
UBYTE *i_ptr = (UBYTE *)(image + y * imagex + x); |
|
372 |
AVI_CRAM_C1(i_ptr,clr,row_dec); |
|
373 |
} |
|
374 |
AVI_MIN_MAX_CHECK(x,y,min_x,max_x,min_y,max_y); |
|
375 |
changed = 1; AVI_BLOCK_INC(x,y,imagex); |
|
376 |
} /* end of single block */ |
|
377 |
} /* end of not term code */ |
|
378 |
} /* end of not while exit */ |
|
379 |
} /* end of 1 bytes pixel */ |
|
380 |
} /* end of map is TRUE */ |
|
381 |
else |
|
382 |
{ |
|
383 |
while(!!exitflag) |
|
384 |
{ |
|
385 |
code0 = *dptr++; code1 = *dptr++; block_cnt--; |
|
386 |
if ( ((code1==0) && (code0==0) && !!block_cnt) || (y<0)) exitflag = 1; |
|
387 |
else |
|
388 |
{ |
|
389 |
if ((code1 >= 0x84) && (code1 <= 0x87)) /* skip */ |
|
390 |
{ ULONG skip = ((code1 - 0x84) << 8) + code0; |
|
391 |
block_cnt -= (skip-1); while(skip--) AVI_BLOCK_INC(x,y,imagex); |
|
392 |
} else /* single block encoded */ |
|
393 |
{ |
|
394 |
if (code1 >= 0x90) /* 8 color quadrant encoding */ |
|
395 |
{ |
|
396 |
UBYTE cA0,cA1,cB0,cB1; |
|
397 |
UBYTE *i_ptr = (UBYTE *)(image + y * imagex + x); |
|
398 |
cB0 = (UBYTE)*dptr++; cA0 = (UBYTE)*dptr++; |
|
399 |
cB1 = (UBYTE)*dptr++; cA1 = (UBYTE)*dptr++; |
|
400 |
AVI_CRAM_C4(i_ptr,code0,cA0,cA1,cB0,cB1,row_dec); i_ptr -=row_dec; |
|
401 |
cB0 = (UBYTE)*dptr++; cA0 = (UBYTE)*dptr++; |
|
402 |
cB1 = (UBYTE)*dptr++; cA1 = (UBYTE)*dptr++; |
|
403 |
AVI_CRAM_C4(i_ptr,code1,cA0,cA1,cB0,cB1,row_dec); |
|
404 |
} |
|
405 |
else if (code1 < 0x80) /* 2 color encoding */ |
|
406 |
{ UBYTE clr_A,clr_B; |
|
407 |
UBYTE *i_ptr = (UBYTE *)(image + y * imagex + x); |
|
408 |
clr_B = (UBYTE)*dptr++; clr_A = (UBYTE)*dptr++; |
|
409 |
AVI_CRAM_C2(i_ptr,code0,clr_A,clr_B,row_dec); i_ptr -= row_dec; |
|
410 |
AVI_CRAM_C2(i_ptr,code1,clr_A,clr_B,row_dec); |
|
411 |
} /* end of 2 color */ |
|
412 |
else /* 1 color encoding */ |
|
413 |
{ |
|
414 |
UBYTE clr = (UBYTE)code0; |
|
415 |
UBYTE *i_ptr = (UBYTE *)(image + y * imagex + x); |
|
416 |
AVI_CRAM_C1(i_ptr,clr,row_dec); |
|
417 |
} |
|
418 |
AVI_MIN_MAX_CHECK(x,y,min_x,max_x,min_y,max_y); |
|
419 |
changed = 1; AVI_BLOCK_INC(x,y,imagex); |
|
420 |
} /* end of single block */ |
|
421 |
} /* end of not term code */ |
|
422 |
} /* end of not while exit */ |
|
423 |
} |
|
424 |
if (xa_optimize_flag == TRUE) |
|
425 |
{ |
|
426 |
if (changed) { *xs=min_x; *ys=min_y - 3; *xe=max_x + 4; *ye=max_y + 1; } |
|
427 |
else { *xs = *ys = *xe = *ye = 0; return(ACT_DLTA_NOP); } |
|
428 |
} |
|
429 |
else { *xs = *ys = 0; *xe = imagex; *ye = imagey; } |
|
430 |
if (map_flag) return(ACT_DLTA_MAPD); |
|
431 |
else return(ACT_DLTA_NORM); |
|
432 |
} |
|
433 |
||
434 |
" |
|
435 |
||
436 |
'AVI_Decode_CRAM' infoPrint. |
|
437 |
||
438 |
" |
|
439 |
AVIReader fromFile:'/home2/pd_stuff/movies/avi/hangldm.avi' |
|
440 |
" |
|
441 |
||
442 |
"Created: 5.4.1997 / 16:06:10 / cg" |
|
443 |
"Modified: 11.4.1997 / 14:03:32 / cg" |
|
444 |
! ! |
|
445 |
||
446 |
!AVIReader methodsFor:'helpers'! |
|
447 |
||
448 |
alignHeightTo:multiple |
|
449 |
"make height a multiple of the argument" |
|
450 |
||
451 |
height := multiple * ((height + multiple - 1) // multiple). |
|
452 |
||
453 |
"Modified: 5.4.1997 / 14:47:36 / cg" |
|
454 |
! |
|
455 |
||
456 |
alignTo:multiple |
|
457 |
"make width & height a multiple of the argument" |
|
458 |
||
459 |
width := multiple * ((width + multiple - 1) // multiple). |
|
460 |
height := multiple * ((height + multiple - 1) // multiple). |
|
461 |
||
462 |
"Created: 5.4.1997 / 14:47:54 / cg" |
|
463 |
! |
|
464 |
||
465 |
alignWidthTo:multiple |
|
466 |
"make height a multiple of the argument" |
|
467 |
||
468 |
width := multiple * ((width + multiple - 1) // multiple). |
|
469 |
||
470 |
"Created: 5.4.1997 / 14:47:16 / cg" |
|
471 |
"Modified: 5.4.1997 / 14:47:41 / cg" |
|
472 |
! ! |
|
473 |
||
1848 | 474 |
!AVIReader methodsFor:'private-reading'! |
525 | 475 |
|
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
476 |
getChunk_ISBJ:chunkSize |
525 | 477 |
"process (ignore) a ISBJ chunk" |
478 |
||
479 |
'getChunk_ISBJ -> ' infoPrint. |
|
480 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
481 |
self skipChunk:chunkSize |
525 | 482 |
|
483 |
"Created: 5.4.1997 / 15:19:17 / cg" |
|
484 |
! |
|
485 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
486 |
getChunk_auds:chunkSize |
525 | 487 |
"process an auds chunk" |
488 |
||
489 |
|format channels rate av_bps align size| |
|
490 |
||
491 |
'getChunk_auds' infoPrint. |
|
492 |
||
493 |
format := inStream nextShortMSB:false. |
|
494 |
channels := inStream nextShortMSB:false. |
|
495 |
rate := inStream nextLongMSB:false. |
|
496 |
av_bps := inStream nextLongMSB:false. |
|
497 |
align := inStream nextShortMSB:false. |
|
498 |
size := inStream nextShortMSB:false. |
|
499 |
||
500 |
inStream skip:(chunkSize - 16). |
|
501 |
||
502 |
" |
|
503 |
AVIReader fromFile:'/home2/pd_stuff/movies/avi/hangldm.avi' |
|
504 |
" |
|
505 |
||
506 |
"Created: 5.4.1997 / 00:01:15 / cg" |
|
507 |
"Modified: 5.4.1997 / 14:34:36 / cg" |
|
508 |
! |
|
509 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
510 |
getChunk_auds_wb:chunkSize |
525 | 511 |
"process (ignore for now) an auds chunk" |
512 |
||
513 |
'getChunk_auds_wb -> ' infoPrint. |
|
514 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
515 |
self skipChunk:chunkSize |
525 | 516 |
|
517 |
" |
|
518 |
AVIReader fromFile:'/home2/pd_stuff/movies/avi/hangldm.avi' |
|
519 |
" |
|
520 |
||
521 |
"Created: 5.4.1997 / 13:57:56 / cg" |
|
522 |
"Modified: 5.4.1997 / 14:34:33 / cg" |
|
523 |
! |
|
524 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
525 |
getChunk_avih:chunkSize |
525 | 526 |
"process an avih chunk" |
527 |
||
528 |
|us_frame max_bps pad_gram flags tot_frames init_frames nstreams |
|
529 |
sug_bsize scale rate start length| |
|
530 |
||
531 |
'getChunk_avih' infoPrint. |
|
532 |
||
533 |
chunkSize ~~ 56 ifTrue:[ |
|
534 |
self halt:'bad chunk size'. |
|
535 |
]. |
|
536 |
||
537 |
us_frame := inStream nextLongMSB:false. |
|
538 |
max_bps := inStream nextLongMSB:false. |
|
539 |
pad_gram := inStream nextLongMSB:false. |
|
540 |
flags := inStream nextLongMSB:false. |
|
541 |
tot_frames := inStream nextLongMSB:false. |
|
542 |
init_frames := inStream nextLongMSB:false. |
|
543 |
nstreams := inStream nextLongMSB:false. |
|
544 |
sug_bsize := inStream nextLongMSB:false. |
|
545 |
width := inStream nextLongMSB:false. |
|
546 |
height := inStream nextLongMSB:false. |
|
547 |
scale := inStream nextLongMSB:false. |
|
548 |
rate := inStream nextLongMSB:false. |
|
549 |
start := inStream nextLongMSB:false. |
|
550 |
length := inStream nextLongMSB:false. |
|
551 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
552 |
riffReader streamTypes:(OrderedCollection new:nstreams). |
525 | 553 |
|
554 |
" |
|
555 |
AVIReader fromFile:'/home2/pd_stuff/movies/avi/hangldm.avi' |
|
556 |
" |
|
557 |
||
558 |
"Created: 4.4.1997 / 23:19:37 / cg" |
|
559 |
"Modified: 5.4.1997 / 14:34:30 / cg" |
|
560 |
! |
|
561 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
562 |
getChunk_hdrl:chunkSize |
525 | 563 |
"process (ignore) a hdrl chunk" |
564 |
||
565 |
'getChunk_hdrl -> ' infoPrint. |
|
566 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
567 |
self skipChunk:chunkSize |
525 | 568 |
|
569 |
"Created: 5.4.1997 / 15:18:07 / cg" |
|
570 |
! |
|
571 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
572 |
getChunk_idx1:chunkSize |
525 | 573 |
"process (ignore) a idx1 chunk" |
574 |
||
575 |
'getChunk_idx1 -> ' infoPrint. |
|
576 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
577 |
self skipChunk:chunkSize |
525 | 578 |
|
579 |
"Created: 5.4.1997 / 15:17:53 / cg" |
|
580 |
! |
|
581 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
582 |
getChunk_strf:chunkSize |
525 | 583 |
"process a strf chunk" |
584 |
||
585 |
|sel| |
|
586 |
||
587 |
'getChunk_strf -> ' infoPrint. |
|
588 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
589 |
sel := ('getChunk_' , streamType, ':') asSymbolIfInterned. |
525 | 590 |
(sel isNil or:[(self respondsTo:sel) not]) ifTrue:[ |
591 |
'[' infoPrint. ('getChunk_' , streamType) infoPrint. '] ' infoPrint. |
|
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
592 |
sel := #'getChunk_Unknown:' |
525 | 593 |
]. |
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
594 |
self perform:sel with:chunkSize. |
525 | 595 |
|
596 |
" |
|
597 |
AVIReader fromFile:'/home2/pd_stuff/movies/avi/hangldm.avi' |
|
598 |
" |
|
599 |
||
600 |
"Created: 4.4.1997 / 23:41:09 / cg" |
|
601 |
"Modified: 5.4.1997 / 15:05:00 / cg" |
|
602 |
! |
|
603 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
604 |
getChunk_strh:chunkSize |
525 | 605 |
"process a strh chunk" |
606 |
||
607 |
|fcc_type fcc_handler priority flags rate init_frames streams |
|
608 |
sug_bsize scale start length quality samp_size size| |
|
609 |
||
610 |
'getChunk_strh' infoPrint. |
|
611 |
||
612 |
chunkSize < 48 ifTrue:[ |
|
613 |
self halt:'bad chunk size'. |
|
614 |
]. |
|
615 |
||
616 |
fcc_type := String new:4. |
|
617 |
inStream nextBytes:4 into:fcc_type. |
|
618 |
fcc_handler := inStream nextLongMSB:true. |
|
619 |
flags := inStream nextLongMSB:false. |
|
620 |
priority := inStream nextLongMSB:false. |
|
621 |
init_frames := inStream nextLongMSB:false. |
|
622 |
scale := inStream nextLongMSB:false. |
|
623 |
rate := inStream nextLongMSB:false. |
|
624 |
start := inStream nextLongMSB:false. |
|
625 |
length := inStream nextLongMSB:false. |
|
626 |
sug_bsize := inStream nextLongMSB:false. |
|
627 |
quality := inStream nextLongMSB:false. |
|
628 |
samp_size := inStream nextLongMSB:false. |
|
629 |
||
630 |
size := chunkSize. |
|
631 |
(size bitTest:1) ifTrue:[ |
|
632 |
size := size + 1 |
|
633 |
]. |
|
634 |
inStream skip:(size - 48). |
|
635 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
636 |
riffReader addStream:fcc_type. |
525 | 637 |
streamType := fcc_type. |
638 |
||
639 |
" |
|
640 |
AVIReader fromFile:'/home2/pd_stuff/movies/avi/hangldm.avi' |
|
641 |
" |
|
642 |
||
643 |
"Created: 4.4.1997 / 23:25:54 / cg" |
|
644 |
"Modified: 5.4.1997 / 14:34:23 / cg" |
|
645 |
! |
|
646 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
647 |
getChunk_strl:chunkSize |
525 | 648 |
"process (ignore) a strl chunk" |
649 |
||
650 |
'getChunk_strl -> ' infoPrint. |
|
651 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
652 |
self skipChunk:chunkSize |
525 | 653 |
|
654 |
"Created: 5.4.1997 / 15:18:01 / cg" |
|
655 |
! |
|
656 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
657 |
getChunk_vedt:chunkSize |
525 | 658 |
"process (ignore) a vedt chunk" |
659 |
||
660 |
'getChunk_vedt -> ' infoPrint. |
|
661 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
662 |
self skipChunk:chunkSize |
525 | 663 |
|
664 |
"Created: 5.4.1997 / 15:17:43 / cg" |
|
665 |
! |
|
666 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
667 |
getChunk_vids:chunkSize |
525 | 668 |
"process a vids chunk" |
669 |
||
670 |
|size sz |
|
671 |
width height planes image_size |
|
672 |
xpels_meter ypels_meter num_colors imp_colors |
|
673 |
sel nMore| |
|
674 |
||
675 |
'getChunk_vids -> ' infoPrint. |
|
676 |
||
677 |
sz := chunkSize. |
|
678 |
(sz bitTest:1) ifTrue:[ |
|
679 |
sz := sz + 1 |
|
680 |
]. |
|
681 |
colorTable := true. |
|
682 |
||
683 |
size := inStream nextLongMSB:false. |
|
684 |
width := inStream nextLongMSB:false. |
|
685 |
height := inStream nextLongMSB:false. |
|
686 |
planes := inStream nextShortMSB:false. |
|
687 |
depth := inStream nextShortMSB:false. |
|
688 |
compression := String new:4. |
|
689 |
inStream nextBytes:4 into:compression. |
|
690 |
image_size := inStream nextLongMSB:false. |
|
691 |
xpels_meter := inStream nextLongMSB:false. |
|
692 |
ypels_meter := inStream nextLongMSB:false. |
|
693 |
num_colors := inStream nextLongMSB:false. |
|
694 |
imp_colors := inStream nextLongMSB:false. |
|
695 |
sz := sz - 40. |
|
696 |
||
697 |
numColors := num_colors. |
|
698 |
(numColors == 0 and:[depth <= 8]) ifTrue:[ |
|
699 |
numColors := 1 bitShift:depth. |
|
700 |
]. |
|
701 |
||
702 |
sel := ('setupData_vids_' , compression) asSymbolIfInterned. |
|
703 |
(sel isNil or:[(self respondsTo:sel) not]) ifTrue:[ |
|
704 |
'[' infoPrint. ('setupData_vids_' , compression) infoPrint. '] ' infoPrint. |
|
705 |
sel := #'setupData_vids_Unknown' |
|
706 |
]. |
|
707 |
||
708 |
"/ setup compression-specific data |
|
709 |
self perform:sel. |
|
710 |
||
711 |
"/ read a colorTable - if any |
|
712 |
((depth <= 8) and:[colorTable]) ifTrue:[ |
|
713 |
redPalette := ByteArray new:256. |
|
714 |
greenPalette := ByteArray new:256. |
|
715 |
bluePalette := ByteArray new:256. |
|
716 |
||
717 |
1 to:numColors do:[:i | |
|
718 |
sz > 0 ifTrue:[ |
|
719 |
bluePalette at:i put:(inStream nextByte). |
|
720 |
greenPalette at:i put:(inStream nextByte). |
|
721 |
redPalette at:i put:(inStream nextByte). |
|
722 |
inStream nextByte. "/ padding |
|
723 |
sz := sz - 4. |
|
724 |
]. |
|
725 |
] |
|
726 |
]. |
|
727 |
||
728 |
"/ read more compression-specific data |
|
729 |
sel := ('readData_vids2_' , compression) asSymbolIfInterned. |
|
730 |
(sel isNil or:[(self respondsTo:sel) not]) ifTrue:[ |
|
731 |
] ifFalse:[ |
|
732 |
nMore := self perform:sel. |
|
733 |
sz := sz - nMore. |
|
734 |
]. |
|
735 |
||
736 |
inStream skip:sz. |
|
737 |
||
738 |
" |
|
739 |
AVIReader fromFile:'/home2/pd_stuff/movies/avi/hangldm.avi' |
|
740 |
" |
|
741 |
||
742 |
"Created: 4.4.1997 / 23:25:54 / cg" |
|
743 |
"Modified: 5.4.1997 / 15:32:10 / cg" |
|
744 |
! |
|
745 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
746 |
getChunk_vids_dc:chunkSize |
525 | 747 |
"process a vids chunk" |
748 |
||
749 |
|sz data sel| |
|
750 |
||
751 |
'getChunk_vids_dc -> ' infoPrint. |
|
752 |
||
753 |
sz := chunkSize. |
|
754 |
(sz bitTest:1) ifTrue:[ |
|
755 |
sz := sz + 1 |
|
756 |
]. |
|
757 |
||
758 |
sz == 0 ifTrue:[ |
|
759 |
"/ NOP wait frame |
|
760 |
^ self |
|
761 |
]. |
|
762 |
||
763 |
data := ByteArray new:sz. |
|
764 |
inStream nextBytes:sz into:data startingAt:1. |
|
765 |
||
766 |
sel := deltaMethod. |
|
767 |
(self respondsTo:sel) not ifTrue:[ |
|
768 |
'[' infoPrint. deltaMethod infoPrint. '] ' infoPrint. |
|
769 |
^ self |
|
770 |
]. |
|
771 |
||
772 |
self perform:deltaMethod with:data. |
|
773 |
||
774 |
" |
|
775 |
AVIReader fromFile:'/home2/pd_stuff/movies/avi/hangldm.avi' |
|
776 |
" |
|
777 |
||
778 |
"Created: 5.4.1997 / 01:01:37 / cg" |
|
779 |
"Modified: 5.4.1997 / 15:44:46 / cg" |
|
780 |
! |
|
781 |
||
782 |
readData_vids2_IJPG |
|
783 |
"more extra data here" |
|
784 |
||
785 |
|offset jsize format cspace| |
|
786 |
||
787 |
'readData_vids2_IJPG' infoPrint. |
|
788 |
||
789 |
offset := inStream nextLongMSB:false. |
|
790 |
jsize := inStream nextLongMSB:false. |
|
791 |
format := inStream nextLongMSB:false. |
|
792 |
cspace := inStream nextLongMSB:false. |
|
793 |
||
794 |
self JFIF_Read_IJPG_Tables. |
|
795 |
||
796 |
^ 16 + 128. |
|
797 |
||
798 |
"Created: 5.4.1997 / 15:08:04 / cg" |
|
799 |
! |
|
800 |
||
801 |
readData_vids2_JPEG |
|
802 |
"more extra data here" |
|
803 |
||
804 |
|offset jsize format cspace bits hsubsamp vsubsamp| |
|
805 |
||
806 |
'readData_vids2_IJPG' infoPrint. |
|
807 |
||
808 |
offset := inStream nextLongMSB:false. |
|
809 |
jsize := inStream nextLongMSB:false. |
|
810 |
format := inStream nextLongMSB:false. |
|
811 |
cspace := inStream nextLongMSB:false. |
|
812 |
bits := inStream nextLongMSB:false. |
|
813 |
hsubsamp := inStream nextLongMSB:false. |
|
814 |
vsubsamp := inStream nextLongMSB:false. |
|
815 |
||
816 |
^ 28. |
|
817 |
||
818 |
"Created: 5.4.1997 / 15:08:43 / cg" |
|
819 |
! |
|
820 |
||
821 |
setupData_vids_CRAM |
|
822 |
"CRAM specific setup" |
|
823 |
||
824 |
'setupData_vids_CRAM' infoPrint. |
|
825 |
||
826 |
"/ need to be multiple of 4 |
|
827 |
self alignTo:4. |
|
828 |
||
829 |
depth == 8 ifTrue:[ |
|
830 |
deltaMethod := #AVI_Decode_CRAM: |
|
831 |
] ifFalse:[ |
|
832 |
depth == 16 ifTrue:[ |
|
833 |
deltaMethod := #AVI_Decode_CRAM16: |
|
834 |
] ifFalse:[ |
|
835 |
"/ 'AVI [info]: CRAM but depth ~~ 8/16 format not supported' errorPrintCR. |
|
836 |
UnsupportedFormatErrorSignal raiseErrorString:'CRAM but depth ~~ 8/16'. |
|
837 |
] |
|
838 |
] |
|
839 |
||
840 |
"Modified: 5.4.1997 / 15:42:12 / cg" |
|
841 |
! |
|
842 |
||
843 |
setupData_vids_CVID |
|
844 |
"CVID specific setup" |
|
845 |
||
846 |
'setupData_vids_CVID' infoPrint. |
|
847 |
||
848 |
"/ 'AVI [info]: Radius Cinepak format not supported' errorPrintCR. |
|
849 |
UnsupportedFormatErrorSignal raiseErrorString:'Radius Cinepak format not supported'. |
|
850 |
||
851 |
"Modified: 5.4.1997 / 15:42:38 / cg" |
|
852 |
! |
|
853 |
||
854 |
setupData_vids_IJPG |
|
855 |
"IJPG specific setup" |
|
856 |
||
857 |
'setupData_vids_IJPG' infoPrint. |
|
858 |
||
859 |
"/ need to be multiple of 4@2 |
|
860 |
self alignWidthTo:4. |
|
861 |
self alignHeightTo:2. |
|
862 |
||
863 |
depth > 8 ifTrue:[ |
|
864 |
self QT_Gen_YUV_Tabs. |
|
865 |
] ifFalse:[ |
|
866 |
colorTable := false |
|
867 |
]. |
|
868 |
self jpg_alloc_MCU_bufs:width. |
|
869 |
||
870 |
depth ~~ 24 ifTrue:[ |
|
871 |
"/ 'AVI [info]: IJPG but depth ~~ 24' errorPrintCR. |
|
872 |
UnsupportedFormatErrorSignal raiseErrorString:'IJPG but depth ~~ 24'. |
|
873 |
^ self |
|
874 |
]. |
|
875 |
deltaMethod := #JFIF_Decode_JPEG: |
|
876 |
||
877 |
"Modified: 5.4.1997 / 15:55:55 / cg" |
|
878 |
! |
|
879 |
||
880 |
setupData_vids_IV31 |
|
881 |
"IV31 specific setup" |
|
882 |
||
883 |
'setupData_vids_IV31' infoPrint. |
|
884 |
||
885 |
"/ 'AVI [info]: AVI: Intel Indeo Video Codec Not Supported' errorPrintCR. |
|
886 |
UnsupportedFormatErrorSignal raiseErrorString:'AVI: Intel Indeo Video Codec Not Supported'. |
|
887 |
||
888 |
"Created: 5.4.1997 / 15:56:43 / cg" |
|
889 |
! |
|
890 |
||
891 |
setupData_vids_IV32 |
|
892 |
"IV32 specific setup" |
|
893 |
||
894 |
'setupData_vids_IV32' infoPrint. |
|
895 |
||
896 |
"/ 'AVI [info]: AVI: Intel Indeo Video Codec Not Supported' errorPrintCR. |
|
897 |
UnsupportedFormatErrorSignal raiseErrorString:'AVI: Intel Indeo Video Codec Not Supported'. |
|
898 |
||
899 |
"Created: 5.4.1997 / 15:56:49 / cg" |
|
900 |
! |
|
901 |
||
902 |
setupData_vids_JPEG |
|
903 |
"JPEG specific setup" |
|
904 |
||
905 |
'setupData_vids_JPEG' infoPrint. |
|
906 |
||
907 |
"/ need to be multiple of 4@2 |
|
908 |
self alignWidthTo:4. |
|
909 |
self alignHeightTo:2. |
|
910 |
||
911 |
depth > 8 ifTrue:[ |
|
912 |
self QT_Gen_YUV_Tabs. |
|
913 |
] ifFalse:[ |
|
914 |
colorTable := false |
|
915 |
]. |
|
916 |
self jpg_alloc_MCU_bufs:width. |
|
917 |
||
918 |
depth ~~ 8 ifTrue:[ |
|
919 |
depth ~~ 24 ifTrue:[ |
|
920 |
"/ 'AVI [info]: JPEG but depth ~~ 8/24' errorPrintCR. |
|
921 |
UnsupportedFormatErrorSignal raiseErrorString:'JPEG but depth ~~ 8/24'. |
|
922 |
^ self |
|
923 |
] |
|
924 |
]. |
|
925 |
deltaMethod := #JFIF_Decode_JPEG: |
|
926 |
||
927 |
"Created: 5.4.1997 / 15:29:54 / cg" |
|
928 |
"Modified: 5.4.1997 / 15:55:05 / cg" |
|
929 |
! |
|
930 |
||
931 |
setupData_vids_MJPG |
|
932 |
"MJPG specific setup" |
|
933 |
||
934 |
'setupData_vids_MJPG' infoPrint. |
|
935 |
||
936 |
UnsupportedFormatErrorSignal raiseErrorString:'MJPG not yet supported'. |
|
937 |
||
938 |
"/ need to be multiple of 4@2 |
|
939 |
self alignWidthTo:4. |
|
940 |
self alignHeightTo:2. |
|
941 |
||
942 |
depth > 8 ifTrue:[ |
|
943 |
self QT_Gen_YUV_Tabs. |
|
944 |
] ifFalse:[ |
|
945 |
colorTable := false |
|
946 |
]. |
|
947 |
self jpg_alloc_MCU_bufs:width. |
|
948 |
||
949 |
"Created: 5.4.1997 / 15:29:54 / cg" |
|
950 |
"Modified: 5.4.1997 / 15:53:08 / cg" |
|
951 |
! |
|
952 |
||
953 |
setupData_vids_MSVC |
|
954 |
"MSVC specific setup" |
|
955 |
||
956 |
'setupData_vids_MSVC' infoPrint. |
|
957 |
||
958 |
"/ need to be multiple of 4 |
|
959 |
self alignTo:4. |
|
960 |
||
961 |
depth == 8 ifTrue:[ |
|
962 |
deltaMethod := #AVI_Decode_CRAM: |
|
963 |
] ifFalse:[ |
|
964 |
depth == 16 ifTrue:[ |
|
965 |
deltaMethod := #AVI_Decode_CRAM16: |
|
966 |
] ifFalse:[ |
|
967 |
"/ 'AVI [info]: MSVC but depth ~~ 8/16 format not supported' errorPrintCR. |
|
968 |
UnsupportedFormatErrorSignal raiseErrorString:'MSVC but depth ~~ 8/16'. |
|
969 |
] |
|
970 |
] |
|
971 |
||
972 |
"Created: 5.4.1997 / 15:29:54 / cg" |
|
973 |
"Modified: 5.4.1997 / 15:41:56 / cg" |
|
974 |
! |
|
975 |
||
976 |
setupData_vids_NONE |
|
977 |
"NONE specific setup" |
|
978 |
||
979 |
'setupData_vids_NONE' infoPrint. |
|
980 |
||
981 |
"Created: 5.4.1997 / 15:29:54 / cg" |
|
982 |
"Modified: 5.4.1997 / 15:34:25 / cg" |
|
983 |
! |
|
984 |
||
985 |
setupData_vids_PACK |
|
986 |
"PACK specific setup" |
|
987 |
||
988 |
'setupData_vids_PACK' infoPrint. |
|
989 |
||
990 |
"Created: 5.4.1997 / 15:29:54 / cg" |
|
991 |
"Modified: 5.4.1997 / 15:34:31 / cg" |
|
992 |
! |
|
993 |
||
994 |
setupData_vids_RGB |
|
995 |
"RGB specific setup" |
|
996 |
||
997 |
'setupData_vids_RGB' infoPrint. |
|
998 |
||
999 |
depth == 8 ifTrue:[ |
|
1000 |
deltaMethod := #AVI_Decode_RGB: |
|
1001 |
] ifFalse:[ |
|
1002 |
depth == 24 ifTrue:[ |
|
1003 |
deltaMethod := #AVI_Decode_RGB24: |
|
1004 |
] ifFalse:[ |
|
1005 |
"/ 'AVI [info]: RGB but depth ~~ 8/24 format not supported' errorPrintCR. |
|
1006 |
UnsupportedFormatErrorSignal raiseErrorString:'RGB but depth ~~ 8/24'. |
|
1007 |
] |
|
1008 |
] |
|
1009 |
||
1010 |
"Modified: 5.4.1997 / 15:41:56 / cg" |
|
1011 |
"Created: 5.4.1997 / 15:48:47 / cg" |
|
1012 |
! |
|
1013 |
||
1014 |
setupData_vids_RLE4 |
|
1015 |
"RLE4 specific setup" |
|
1016 |
||
1017 |
'setupData_vids_RLE4' infoPrint. |
|
1018 |
||
1019 |
"Created: 5.4.1997 / 15:29:54 / cg" |
|
1020 |
"Modified: 5.4.1997 / 15:34:38 / cg" |
|
1021 |
! |
|
1022 |
||
1023 |
setupData_vids_RLE8 |
|
1024 |
"RLE8 specific setup" |
|
1025 |
||
1026 |
'setupData_vids_RLE8' infoPrint. |
|
1027 |
||
1028 |
depth ~~ 8 ifTrue:[ |
|
1029 |
"/ 'AVI [info]: RLE8 but depth ~~ 8 format not supported' errorPrintCR. |
|
1030 |
UnsupportedFormatErrorSignal raiseErrorString:'RLE8 but depth ~~ 8'. |
|
1031 |
^ self |
|
1032 |
]. |
|
1033 |
deltaMethod := #AVI_Decode_RLE8: |
|
1034 |
||
1035 |
"Created: 5.4.1997 / 15:29:54 / cg" |
|
1036 |
"Modified: 5.4.1997 / 15:43:22 / cg" |
|
1037 |
! |
|
1038 |
||
1039 |
setupData_vids_RT21 |
|
1040 |
"RT21 specific setup" |
|
1041 |
||
1042 |
'setupData_vids_RT21' infoPrint. |
|
1043 |
||
1044 |
"/ 'AVI [info]: AVI: Intel Indeo Video Codec Not Supported' errorPrintCR. |
|
1045 |
UnsupportedFormatErrorSignal raiseErrorString:'AVI: Intel Indeo Video Codec Not Supported'. |
|
1046 |
||
1047 |
"Created: 5.4.1997 / 15:56:37 / cg" |
|
1048 |
! |
|
1049 |
||
1050 |
setupData_vids_TRAN |
|
1051 |
"TRAN specific setup" |
|
1052 |
||
1053 |
'setupData_vids_TRAN' infoPrint. |
|
1054 |
||
1055 |
"Created: 5.4.1997 / 15:29:54 / cg" |
|
1056 |
"Modified: 5.4.1997 / 15:34:53 / cg" |
|
1057 |
! |
|
1058 |
||
1059 |
setupData_vids_ULTI |
|
1060 |
"ULTI specific setup" |
|
1061 |
||
1062 |
'setupData_vids_ULTI' infoPrint. |
|
1063 |
||
1064 |
depth == 16 ifTrue:[ |
|
1065 |
deltaMethod := #AVI_Decode_ULTI: |
|
1066 |
] ifFalse:[ |
|
1067 |
"/ 'AVI [info]: ULTI depth ~~ 16 format not supported' errorPrintCR. |
|
1068 |
UnsupportedFormatErrorSignal raiseErrorString:'ULTI depth ~~ 16'. |
|
1069 |
^ self. |
|
1070 |
]. |
|
1071 |
||
1072 |
"/ need to be multiple of 8 |
|
1073 |
self alignTo:8. |
|
1074 |
||
1075 |
self AVI_ULTI_Gen_YUV. |
|
1076 |
self AVI_Ulti_Gen_LTC. |
|
1077 |
||
1078 |
"Created: 5.4.1997 / 15:29:54 / cg" |
|
1079 |
"Modified: 5.4.1997 / 15:46:14 / cg" |
|
1080 |
! |
|
1081 |
||
1082 |
setupData_vids_Unknown |
|
1083 |
"ignore an unknown vids chunk" |
|
1084 |
||
1085 |
'setupData_vids_Unknown' infoPrint. |
|
1086 |
||
1087 |
"Created: 5.4.1997 / 15:29:54 / cg" |
|
1088 |
"Modified: 5.4.1997 / 15:32:52 / cg" |
|
1089 |
! |
|
1090 |
||
1091 |
setupData_vids_XMPG |
|
1092 |
"XMPG specific setup" |
|
1093 |
||
1094 |
'setupData_vids_XMPG' infoPrint. |
|
1095 |
||
1096 |
"/ need to be multiple of 4 |
|
1097 |
self alignTo:4. |
|
1098 |
||
1099 |
self QT_Gen_YUV_Tabs. |
|
1100 |
self jpg_alloc_MCU_bufs:width. |
|
1101 |
self jpg_setup_samp_limit_table. |
|
1102 |
self mpg_init_stuff. |
|
1103 |
||
1104 |
deltaMethod := #MPG_Decode_I: |
|
1105 |
||
1106 |
"Modified: 5.4.1997 / 15:49:53 / cg" |
|
1107 |
! |
|
1108 |
||
1109 |
setupData_vids_YUV9 |
|
1110 |
"YUV9 specific setup" |
|
1111 |
||
1112 |
'setupData_vids_YUV9' infoPrint. |
|
1113 |
||
1114 |
self QT_Gen_YUV_Tabs. |
|
1115 |
self jpg_setup_samp_limit_table. |
|
1116 |
||
1117 |
"/ need to be multiple of 4 |
|
1118 |
self alignTo:4. |
|
1119 |
||
1120 |
deltaMethod := #AVI_Decode_YUV9: |
|
1121 |
||
1122 |
"Created: 5.4.1997 / 15:29:54 / cg" |
|
1123 |
"Modified: 5.4.1997 / 15:49:19 / cg" |
|
1124 |
! |
|
1125 |
||
1126 |
setupData_vids_YVU9 |
|
1127 |
"YVU9 specific setup" |
|
1128 |
||
1129 |
'setupData_vids_YVU9' infoPrint. |
|
1130 |
||
1131 |
self QT_Gen_YUV_Tabs. |
|
1132 |
self jpg_setup_samp_limit_table. |
|
1133 |
||
1134 |
"/ need to be multiple of 4 |
|
1135 |
self alignTo:4. |
|
1136 |
||
1137 |
deltaMethod := #AVI_Decode_YUV9: |
|
1138 |
||
1139 |
"Modified: 5.4.1997 / 15:49:32 / cg" |
|
1140 |
! |
|
1141 |
||
1142 |
setupData_vids_cvid |
|
1143 |
"same as CVID" |
|
1144 |
||
1145 |
'setupData_vids_cvid' infoPrint. |
|
1146 |
compression := 'CVID'. |
|
1147 |
^ self setupData_vids_CVID. |
|
1148 |
||
1149 |
"Created: 5.4.1997 / 15:29:54 / cg" |
|
1150 |
"Modified: 5.4.1997 / 15:35:32 / cg" |
|
1151 |
! |
|
1152 |
||
1153 |
setupData_vids_iv31 |
|
1154 |
"same as IV31" |
|
1155 |
||
1156 |
'setupData_vids_iv31' infoPrint. |
|
1157 |
compression := 'IV31'. |
|
1158 |
^ self setupData_vids_IV31. |
|
1159 |
||
1160 |
"Created: 5.4.1997 / 15:29:54 / cg" |
|
1161 |
"Modified: 5.4.1997 / 15:35:39 / cg" |
|
1162 |
! |
|
1163 |
||
1164 |
setupData_vids_iv32 |
|
1165 |
"same as IV32" |
|
1166 |
||
1167 |
'setupData_vids_iv32' infoPrint. |
|
1168 |
compression := 'IV32'. |
|
1169 |
^ self setupData_vids_IV32. |
|
1170 |
||
1171 |
"Created: 5.4.1997 / 15:29:55 / cg" |
|
1172 |
"Modified: 5.4.1997 / 15:35:45 / cg" |
|
1173 |
! |
|
1174 |
||
1175 |
setupData_vids_jpeg |
|
1176 |
"same as JPEG" |
|
1177 |
||
1178 |
'setupData_vids_jpeg' infoPrint. |
|
1179 |
compression := 'JPEG'. |
|
1180 |
^ self setupData_vids_JPEG. |
|
1181 |
||
1182 |
"Created: 5.4.1997 / 15:29:55 / cg" |
|
1183 |
"Modified: 5.4.1997 / 15:35:53 / cg" |
|
1184 |
! |
|
1185 |
||
1186 |
setupData_vids_none |
|
1187 |
"same as NONE" |
|
1188 |
||
1189 |
'setupData_vids_none' infoPrint. |
|
1190 |
compression := 'NONE'. |
|
1191 |
^ self setupData_vids_NONE. |
|
1192 |
||
1193 |
"Created: 5.4.1997 / 15:29:55 / cg" |
|
1194 |
"Modified: 5.4.1997 / 15:36:02 / cg" |
|
1195 |
! |
|
1196 |
||
1197 |
setupData_vids_pack |
|
1198 |
"same as PACK" |
|
1199 |
||
1200 |
'setupData_vids_pack' infoPrint. |
|
1201 |
compression := 'PACK'. |
|
1202 |
^ self setupData_vids_PACK. |
|
1203 |
||
1204 |
"Created: 5.4.1997 / 15:29:55 / cg" |
|
1205 |
"Modified: 5.4.1997 / 15:36:08 / cg" |
|
1206 |
! |
|
1207 |
||
1208 |
setupData_vids_rle4 |
|
1209 |
"same as RLE4" |
|
1210 |
||
1211 |
'setupData_vids_rle4' infoPrint. |
|
1212 |
compression := 'RLE4'. |
|
1213 |
^ self setupData_vids_RLE4. |
|
1214 |
||
1215 |
"Created: 5.4.1997 / 15:29:55 / cg" |
|
1216 |
"Modified: 5.4.1997 / 15:36:14 / cg" |
|
1217 |
! |
|
1218 |
||
1219 |
setupData_vids_rle8 |
|
1220 |
"same as RLE8" |
|
1221 |
||
1222 |
'setupData_vids_rle8' infoPrint. |
|
1223 |
compression := 'RLE8'. |
|
1224 |
^ self setupData_vids_RLE8. |
|
1225 |
||
1226 |
"Created: 5.4.1997 / 15:29:55 / cg" |
|
1227 |
"Modified: 5.4.1997 / 15:36:21 / cg" |
|
1228 |
! |
|
1229 |
||
1230 |
setupData_vids_rt21 |
|
1231 |
"same as RT21" |
|
1232 |
||
1233 |
'setupData_vids_rt21' infoPrint. |
|
1234 |
compression := 'RT21'. |
|
1235 |
^ self setupData_vids_RT21. |
|
1236 |
||
1237 |
"Created: 5.4.1997 / 15:29:55 / cg" |
|
1238 |
"Modified: 5.4.1997 / 15:36:28 / cg" |
|
1239 |
! |
|
1240 |
||
1241 |
setupData_vids_tran |
|
1242 |
"same as TRAN" |
|
1243 |
||
1244 |
'setupData_vids_tran' infoPrint. |
|
1245 |
compression := 'TRAN'. |
|
1246 |
^ self setupData_vids_TRAN. |
|
1247 |
||
1248 |
"Created: 5.4.1997 / 15:29:55 / cg" |
|
1249 |
"Modified: 5.4.1997 / 15:36:35 / cg" |
|
1250 |
! |
|
1251 |
||
1252 |
setupData_vids_xmpg |
|
1253 |
"same as XMPG" |
|
1254 |
||
1255 |
'setupData_vids_xmpg' infoPrint. |
|
1256 |
compression := 'XMPG'. |
|
1257 |
^ self setupData_vids_XMPG. |
|
1258 |
||
1259 |
"Created: 5.4.1997 / 15:29:55 / cg" |
|
1260 |
"Modified: 5.4.1997 / 15:36:43 / cg" |
|
1261 |
! |
|
1262 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
1263 |
skipChunk:chunkSize |
525 | 1264 |
"skip a chunk" |
1265 |
||
1435
d7c6c5cf4d31
refactored RIFF- and AVIReader for general use
Claus Gittinger <cg@exept.de>
parents:
622
diff
changeset
|
1266 |
riffReader skipChunk:chunkSize |
525 | 1267 |
! ! |
1268 |
||
1848 | 1269 |
!AVIReader methodsFor:'reading'! |
1270 |
||
1271 |
fromStream:aStream |
|
1272 |
"read a AVI-movie from aStream. Return a frame sequence." |
|
1273 |
||
1274 |
inStream := aStream. |
|
1275 |
||
1276 |
riffReader := RIFFReader new. |
|
1277 |
riffReader client:self. |
|
1278 |
riffReader processStream:inStream. |
|
1279 |
||
1280 |
"/ return the first frame as image |
|
1281 |
||
1282 |
"/ ATTENTION: the following is not true: |
|
1283 |
||
1284 |
colorMap := MappedPalette |
|
1285 |
redVector:redPalette |
|
1286 |
greenVector:greenPalette |
|
1287 |
blueVector:bluePalette. |
|
1288 |
||
1289 |
photometric := #palette. |
|
1290 |
samplesPerPixel := 1. |
|
1291 |
bitsPerSample := #(8). |
|
1292 |
||
1293 |
" |
|
1294 |
AVIReader readFile:'/phys/exept/home/pd_stuff/movies/avi/drlair.avi'. |
|
1295 |
AVIReader readFile:'/phys/exept/home/pd_stuff/movies/avi/hangldm.avi'. |
|
1296 |
" |
|
1297 |
||
1298 |
"Created: 4.4.1997 / 22:35:53 / cg" |
|
1299 |
"Modified: 24.6.1997 / 15:58:29 / cg" |
|
1300 |
! ! |
|
1301 |
||
525 | 1302 |
!AVIReader class methodsFor:'documentation'! |
1303 |
||
1304 |
version |
|
1848 | 1305 |
^ '$Header: /cvs/stx/stx/libview2/AVIReader.st,v 1.14 2003-11-19 15:38:28 cg Exp $' |
525 | 1306 |
! ! |
1745
4fa0fad2a463
code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents:
1437
diff
changeset
|
1307 |
|
525 | 1308 |
AVIReader initialize! |