diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 1993-01-27 11:38:03 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 1993-01-27 11:38:03 (GMT) |
commit | 2c49017279b89b9631a1cb6adc8fda72ff9c26c9 (patch) | |
tree | 65ede46a6a0867c332004e841e4d7d0a33ec097c /Demo | |
parent | 34679b7661873ec65e5157ddd1ea2be8269632d0 (diff) | |
download | cpython-2c49017279b89b9631a1cb6adc8fda72ff9c26c9.zip cpython-2c49017279b89b9631a1cb6adc8fda72ff9c26c9.tar.gz cpython-2c49017279b89b9631a1cb6adc8fda72ff9c26c9.tar.bz2 |
- Added LiveVideoOutSlow class (which only updates after full pkt)
- fixed bug in setmirror
- cleaned up some common code
Diffstat (limited to 'Demo')
-rwxr-xr-x | Demo/sgi/video/LiveVideoOut.py | 58 |
1 files changed, 44 insertions, 14 deletions
diff --git a/Demo/sgi/video/LiveVideoOut.py b/Demo/sgi/video/LiveVideoOut.py index 0ac64d2..d39d76e 100755 --- a/Demo/sgi/video/LiveVideoOut.py +++ b/Demo/sgi/video/LiveVideoOut.py @@ -51,6 +51,17 @@ class LiveVideoOut: self.disp.setsize(vw, vh) self.reshapewindow() + # Return the number of bytes in one video line + def linewidth(self): + if self.disp.format == 'mono': + return (self.vw+7)/8 + elif self.disp.format == 'grey2': + return (self.vw+3)/4 + elif self.disp.format == 'grey4': + return (self.vw+1)/2 + else: + return self.vw + # Call this to display the next video packet. Arguments: # pos: line number where the packet begins # data: image data of the packet @@ -58,19 +69,10 @@ class LiveVideoOut: # LiveVideoIn.getnextpacket()). def putnextpacket(self, pos, data): - if self.disp.format == 'mono': - # Unfortunately size-check is difficult for - # packed video - nline = (len(data)*8)/self.vw - elif self.disp.format == 'grey2': - nline = (len(data)*4)/self.vw - elif self.disp.format == 'grey4': - nline = (len(data)*2)/self.vw - else: - nline = len(data)/self.vw - if nline*self.vw <> len(data): - print 'Incorrect-sized video fragment ignored' - return + nline = len(data)/self.linewidth() + if nline*self.linewidth() <> len(data): + print 'Incorrect-sized video fragment ignored' + return oldwid = gl.winget() gl.winset(self.wid) self.disp.showpartframe(data, None, (0, pos, self.vw, nline)) @@ -92,4 +94,32 @@ class LiveVideoOut: if mirrored: xpf = -xpf info = (f, w, h, (xpf, ypf), c0, c1, c2, o, cp) - self.disp.setinfo(inf0) + self.disp.setinfo(info) + self.disp.initcolormap() + self.disp.clear() + +# +# This derived class has one difference with the base class: the video is +# not displayed until an entire image has been gotten +# +class LiveVideoOutSlow(LiveVideoOut): + + # Reshapewindow - Realloc buffer. + # (is also called by init() indirectly) + + def reshapewindow(self): + LiveVideoOut.reshapewindow(self) + self.buffer = '\0'*self.linewidth()*self.vh + self.isbuffered = [] + + # putnextpacket - buffer incoming data until a complete + # image has been received + + def putnextpacket(self, pos, data): + if pos in self.isbuffered or pos == 0: + LiveVideoOut.putnextpacket(self, 0, self.buffer) + self.isbuffered = [] + self.isbuffered.append(pos) + bpos = pos * self.linewidth() + epos = bpos + len(data) + self.buffer = self.buffer[:bpos] + data + self.buffer[epos:] |