summaryrefslogtreecommitdiffstats
path: root/Demo/sgi/video
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1993-02-17 15:54:06 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1993-02-17 15:54:06 (GMT)
commit7961ea78689a02c91df65b83b35df42ebf819966 (patch)
treeb2f36b5d2ef452c0b61784b3a67e892933e1353a /Demo/sgi/video
parenteeec33f820ce0903f45b64ea7512054ccde7f295 (diff)
downloadcpython-7961ea78689a02c91df65b83b35df42ebf819966.zip
cpython-7961ea78689a02c91df65b83b35df42ebf819966.tar.gz
cpython-7961ea78689a02c91df65b83b35df42ebf819966.tar.bz2
Moved line-size stuff to single routine
Diffstat (limited to 'Demo/sgi/video')
-rwxr-xr-xDemo/sgi/video/LiveVideoIn.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/Demo/sgi/video/LiveVideoIn.py b/Demo/sgi/video/LiveVideoIn.py
index 47fae67..4e000b1 100755
--- a/Demo/sgi/video/LiveVideoIn.py
+++ b/Demo/sgi/video/LiveVideoIn.py
@@ -54,7 +54,7 @@ class LiveVideoIn:
# Initialize capture
(mode, self.realwidth, self.realheight, qsize, rate) = \
v.InitContinuousCapture(SV.RGB8_FRAMES, \
- self.realwidth, self.realheight, 1, 5)
+ self.realwidth, self.realheight, 1, 2)
self.width = vw
self.height = vh
self.x0 = (self.realwidth-self.width)/2
@@ -62,8 +62,8 @@ class LiveVideoIn:
self.y0 = (self.realheight-self.height)/2
self.y1 = self.y0 + self.height - 1
# Compute # full lines per packet
- self.lpp = pktmax / self.width
- self.pktsize = self.lpp*self.width
+ self.lpp = pktmax / self.linewidth()
+ self.pktsize = self.lpp*self.linewidth()
self.data = None
self.dataoffset = 0
self.lpos = 0
@@ -86,6 +86,17 @@ class LiveVideoIn:
def close(self):
v.EndContinuousCapture()
+ # Get the length in bytes of a video line
+ def linewidth(self):
+ if self.type == 'mono':
+ return (self.width+7)/8
+ elif self.type == 'grey2':
+ return (self.width+3)/4
+ elif self.type == 'grey4':
+ return (self.width+1)/2
+ else:
+ return self.width
+
# Get the next video packet.
# This returns (lpos, data) where:
# - lpos is the line position
@@ -125,12 +136,5 @@ class LiveVideoIn:
data = self.data[self.dataoffset:self.dataoffset+self.pktsize]
lpos = self.lpos
self.dataoffset = self.dataoffset + self.pktsize
- if self.type == 'mono':
- self.lpos = self.lpos + self.lpp*8
- elif self.type == 'grey2':
- self.lpos = self.lpos + self.lpp*4
- elif self.type == 'grey4':
- self.lpos = self.lpos + self.lpp*2
- else:
- self.lpos = self.lpos + self.lpp
+ self.lpos = self.lpos + self.lpp
return lpos, data