541
|
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 |
|
|
13 |
ImageReader subclass:#RIFFReader
|
|
14 |
instanceVariableNames:'chunkSize streamTypes'
|
|
15 |
classVariableNames:'UnsupportedFormatErrorSignal'
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Graphics-Images-Support'
|
|
18 |
!
|
|
19 |
|
|
20 |
!RIFFReader class methodsFor:'documentation'!
|
|
21 |
|
526
|
22 |
copyright
|
|
23 |
"
|
|
24 |
COPYRIGHT (c) 1997 by eXept Software AG
|
|
25 |
All Rights Reserved
|
|
26 |
|
|
27 |
This software is furnished under a license and may be used
|
|
28 |
only in accordance with the terms of that license and with the
|
|
29 |
inclusion of the above copyright notice. This software may not
|
|
30 |
be provided or otherwise made available to, or used by, any
|
|
31 |
other person. No title to or ownership of the software is
|
|
32 |
hereby transferred.
|
|
33 |
"
|
|
34 |
!
|
|
35 |
|
525
|
36 |
documentation
|
|
37 |
"
|
541
|
38 |
Abstract helper class to read RIFF files. See concrete subclasses for details.
|
|
39 |
|
|
40 |
This is in an experimental state and not yet finished.
|
|
41 |
The protocol may change.
|
525
|
42 |
"
|
|
43 |
! !
|
|
44 |
|
|
45 |
!RIFFReader class methodsFor:'class initialization'!
|
|
46 |
|
|
47 |
initialize
|
|
48 |
UnsupportedFormatErrorSignal isNil ifTrue:[
|
|
49 |
UnsupportedFormatErrorSignal := ErrorSignal newSignalMayProceed:true.
|
|
50 |
UnsupportedFormatErrorSignal nameClass:self message:#unsupportedFormatErrorSignal.
|
|
51 |
].
|
|
52 |
|
|
53 |
"
|
|
54 |
RIFFReader initialize
|
|
55 |
"
|
|
56 |
|
|
57 |
"Created: 4.4.1997 / 22:35:52 / cg"
|
|
58 |
"Modified: 5.4.1997 / 16:12:16 / cg"
|
|
59 |
! !
|
|
60 |
|
|
61 |
!RIFFReader class methodsFor:'testing'!
|
|
62 |
|
|
63 |
isRIFFFile:aFileName
|
|
64 |
"return true, if aFileName contains RIFF-encoded data"
|
|
65 |
|
|
66 |
|data1 inStream|
|
|
67 |
|
|
68 |
inStream := self streamReadingFile:aFileName.
|
|
69 |
inStream isNil ifTrue:[^ false].
|
|
70 |
inStream binary.
|
|
71 |
|
|
72 |
data1 := String new:4.
|
|
73 |
inStream nextBytes:4 into:data1.
|
|
74 |
inStream close.
|
|
75 |
|
|
76 |
^ (data1 = 'RIFF')
|
|
77 |
|
|
78 |
"
|
|
79 |
RIFFReader isRIFFFile:'bitmaps/magtape.xpm'
|
|
80 |
RIFFReader isRIFFFile:'/home2/pd_stuff/movies/avi/drlair.avi'
|
|
81 |
"
|
|
82 |
|
|
83 |
"Created: 4.4.1997 / 22:35:52 / cg"
|
|
84 |
"Modified: 5.4.1997 / 16:12:16 / cg"
|
|
85 |
! !
|
|
86 |
|
|
87 |
!RIFFReader methodsFor:'reading from stream'!
|
|
88 |
|
541
|
89 |
fromStream:aStream
|
|
90 |
"read RIFF chunks from aStream. Process chunks in getChunkXXX methods
|
|
91 |
(usually redefined in concrete reader classes."
|
|
92 |
|
|
93 |
inStream := aStream.
|
|
94 |
inStream binary.
|
|
95 |
|
|
96 |
[inStream atEnd] whileFalse:[
|
|
97 |
self getChunk
|
|
98 |
].
|
|
99 |
^ nil
|
|
100 |
|
|
101 |
"
|
|
102 |
RIFFReader fromFile:'/home2/pd_stuff/movies/avi/hangldm.avi'
|
|
103 |
RIFFReader fromFile:'/home2/cg/AFsp-V2R0/test/audiofiles/jg00b1ss.wav'
|
|
104 |
"
|
|
105 |
|
|
106 |
"Modified: 17.4.1997 / 03:25:08 / cg"
|
|
107 |
!
|
|
108 |
|
525
|
109 |
getChunk
|
|
110 |
"get a single chunk"
|
|
111 |
|
|
112 |
|id s sel streamNr streamType|
|
|
113 |
|
|
114 |
'getChunk -> ' infoPrint.
|
|
115 |
|
|
116 |
id := ' '.
|
|
117 |
inStream nextBytes:4 into:id startingAt:1.
|
|
118 |
chunkSize := inStream nextLongMSB:false.
|
|
119 |
|
|
120 |
(id at:4) == Character space ifTrue:[
|
|
121 |
id := id copyTo:3
|
|
122 |
].
|
|
123 |
|
|
124 |
(id at:1) isDigit ifTrue:[
|
|
125 |
streamNr := Number readFrom:(id copyTo:2).
|
541
|
126 |
streamTypes notNil ifTrue:[
|
|
127 |
streamType := streamTypes at:(streamNr + 1).
|
|
128 |
s := 'getChunk_' , streamType , '_' , (id copyFrom:3).
|
|
129 |
] ifFalse:[
|
|
130 |
s := 'getChunk_' , id.
|
|
131 |
]
|
525
|
132 |
] ifFalse:[
|
|
133 |
s := 'getChunk_' , id.
|
|
134 |
].
|
|
135 |
sel := s asSymbolIfInterned.
|
|
136 |
(sel isNil or:[(self respondsTo:sel) not]) ifTrue:[
|
|
137 |
'[' infoPrint. s infoPrint. '] ' infoPrint.
|
|
138 |
sel := #'getChunk_Unknown'
|
|
139 |
].
|
|
140 |
|
|
141 |
self perform:sel.
|
|
142 |
|
|
143 |
'' infoPrintCR.
|
|
144 |
|
|
145 |
"Created: 5.4.1997 / 16:29:40 / cg"
|
541
|
146 |
"Modified: 17.4.1997 / 03:24:48 / cg"
|
525
|
147 |
!
|
|
148 |
|
|
149 |
getChunk_LIST
|
|
150 |
"process a LIST chunk"
|
|
151 |
|
|
152 |
'getChunk_LIST' infoPrint.
|
|
153 |
|
|
154 |
inStream skip:4.
|
|
155 |
|
|
156 |
"
|
|
157 |
AVIReader fromFile:'/home2/pd_stuff/movies/avi/hangldm.avi'
|
541
|
158 |
RIFFReader fromFile:'/home2/pd_stuff/movies/avi/hangldm.avi'
|
|
159 |
RIFFReader fromFile:'/home2/cg/AFsp-V2R0/test/audiofiles/jg00b1ss.wav'
|
525
|
160 |
"
|
|
161 |
|
|
162 |
"Created: 4.4.1997 / 23:18:33 / cg"
|
541
|
163 |
"Modified: 17.4.1997 / 03:22:15 / cg"
|
525
|
164 |
!
|
|
165 |
|
|
166 |
getChunk_RIFF
|
|
167 |
"process a RIFF chunk"
|
|
168 |
|
|
169 |
'getChunk_RIFF' infoPrint.
|
|
170 |
|
|
171 |
inStream skip:4.
|
|
172 |
|
|
173 |
"
|
|
174 |
AVIReader fromFile:'/home2/pd_stuff/movies/avi/hangldm.avi'
|
|
175 |
"
|
|
176 |
|
|
177 |
"Created: 4.4.1997 / 23:18:08 / cg"
|
|
178 |
"Modified: 5.4.1997 / 16:12:16 / cg"
|
|
179 |
!
|
|
180 |
|
|
181 |
getChunk_Unknown
|
|
182 |
"ignore any other chunk"
|
|
183 |
|
|
184 |
'getChunk_Unknown -> ' infoPrint.
|
|
185 |
|
|
186 |
self skipChunk
|
|
187 |
|
|
188 |
"
|
|
189 |
AVIReader fromFile:'/home2/pd_stuff/movies/avi/hangldm.avi'
|
|
190 |
"
|
|
191 |
|
|
192 |
"Created: 5.4.1997 / 00:03:43 / cg"
|
|
193 |
"Modified: 5.4.1997 / 16:12:16 / cg"
|
|
194 |
!
|
|
195 |
|
|
196 |
skipChunk
|
|
197 |
"skip a chunk"
|
|
198 |
|
|
199 |
|sz|
|
|
200 |
|
|
201 |
'skipChunk' infoPrint.
|
|
202 |
|
|
203 |
sz := chunkSize.
|
|
204 |
(sz bitTest:1) ifTrue:[
|
|
205 |
sz := sz + 1
|
|
206 |
].
|
|
207 |
|
|
208 |
inStream skip:sz.
|
|
209 |
|
|
210 |
"
|
|
211 |
AVIReader fromFile:'/home2/pd_stuff/movies/avi/hangldm.avi'
|
|
212 |
"
|
|
213 |
|
|
214 |
"Created: 5.4.1997 / 14:13:43 / cg"
|
|
215 |
"Modified: 5.4.1997 / 16:12:16 / cg"
|
|
216 |
! !
|
|
217 |
|
|
218 |
!RIFFReader class methodsFor:'documentation'!
|
|
219 |
|
|
220 |
version
|
541
|
221 |
^ '$Header: /cvs/stx/stx/libview2/RIFFReader.st,v 1.3 1997-04-17 01:32:11 cg Exp $'
|
525
|
222 |
! !
|
|
223 |
RIFFReader initialize!
|