mirror of
https://github.com/python/cpython.git
synced 2025-07-31 23:23:11 +00:00
Vrec.py: sv now raises sv.error instead of RuntimeError.
VFile.py: support for showing partial frames.
This commit is contained in:
parent
66122d2dae
commit
42e07afe3d
2 changed files with 16 additions and 8 deletions
|
@ -273,7 +273,7 @@ class Displayer(VideoParams):
|
||||||
# setinfo() must reset some internal flags
|
# setinfo() must reset some internal flags
|
||||||
|
|
||||||
def setinfo(self, values):
|
def setinfo(self, values):
|
||||||
VideoParams.setinfo(values)
|
VideoParams.setinfo(self, values)
|
||||||
self.colormapinited = 0
|
self.colormapinited = 0
|
||||||
self.skipchrom = 0
|
self.skipchrom = 0
|
||||||
self.color0 = None
|
self.color0 = None
|
||||||
|
@ -282,33 +282,41 @@ class Displayer(VideoParams):
|
||||||
# Show one frame, initializing the window if necessary
|
# Show one frame, initializing the window if necessary
|
||||||
|
|
||||||
def showframe(self, data, chromdata):
|
def showframe(self, data, chromdata):
|
||||||
|
self.showpartframe(data, chromdata, \
|
||||||
|
(0,0,self.width,self.height))
|
||||||
|
|
||||||
|
def showpartframe(self, data, chromdata, (x,y,w,h)):
|
||||||
if not self.colormapinited:
|
if not self.colormapinited:
|
||||||
self.initcolormap()
|
self.initcolormap()
|
||||||
if self.fixcolor0:
|
if self.fixcolor0:
|
||||||
gl.mapcolor(self.color0)
|
gl.mapcolor(self.color0)
|
||||||
self.fixcolor0 = 0
|
self.fixcolor0 = 0
|
||||||
w, h, pf = self.width, self.height, self.packfactor
|
pf = self.packfactor
|
||||||
factor = self.magnify
|
factor = self.magnify
|
||||||
if pf: factor = factor * pf
|
if pf: factor = factor * pf
|
||||||
if chromdata and not self.skipchrom:
|
if chromdata and not self.skipchrom:
|
||||||
cp = self.chrompack
|
cp = self.chrompack
|
||||||
|
cx = int(x*factor*cp) + self.xorigin
|
||||||
|
cy = int(y*factor*cp) + self.yorigin
|
||||||
cw = (w+cp-1)/cp
|
cw = (w+cp-1)/cp
|
||||||
ch = (h+cp-1)/cp
|
ch = (h+cp-1)/cp
|
||||||
gl.rectzoom(factor*cp, factor*cp)
|
gl.rectzoom(factor*cp, factor*cp)
|
||||||
gl.pixmode(GL.PM_SIZE, 16)
|
gl.pixmode(GL.PM_SIZE, 16)
|
||||||
gl.writemask(self.mask - ((1 << self.c0bits) - 1))
|
gl.writemask(self.mask - ((1 << self.c0bits) - 1))
|
||||||
gl.lrectwrite(self.xorigin, self.yorigin, \
|
gl.lrectwrite(cx, cy, cx + cw - 1, cy + ch - 1, \
|
||||||
self.xorigin + cw - 1, self.yorigin + ch - 1, \
|
chromdata)
|
||||||
chromdata)
|
|
||||||
#
|
#
|
||||||
if pf:
|
if pf:
|
||||||
gl.writemask((1 << self.c0bits) - 1)
|
gl.writemask((1 << self.c0bits) - 1)
|
||||||
gl.pixmode(GL.PM_SIZE, 8)
|
gl.pixmode(GL.PM_SIZE, 8)
|
||||||
w = w/pf
|
w = w/pf
|
||||||
h = h/pf
|
h = h/pf
|
||||||
|
x = x/pf
|
||||||
|
y = y/pf
|
||||||
gl.rectzoom(factor, factor)
|
gl.rectzoom(factor, factor)
|
||||||
gl.lrectwrite(self.xorigin, self.yorigin, \
|
x = int(x*factor)+self.xorigin
|
||||||
self.xorigin + w - 1, self.yorigin + h - 1, data)
|
y = int(y*factor)+self.yorigin
|
||||||
|
gl.lrectwrite(x, y, x + w - 1, y + h - 1, data)
|
||||||
gl.gflush()
|
gl.gflush()
|
||||||
|
|
||||||
# Initialize the window: set RGB or colormap mode as required,
|
# Initialize the window: set RGB or colormap mode as required,
|
||||||
|
|
|
@ -183,7 +183,7 @@ def record(v, info, filename, audiofilename):
|
||||||
while not gl.qtest():
|
while not gl.qtest():
|
||||||
try:
|
try:
|
||||||
cd, id = v.GetCaptureData()
|
cd, id = v.GetCaptureData()
|
||||||
except RuntimeError:
|
except sv.error:
|
||||||
time.millisleep(10) # XXX is this necessary?
|
time.millisleep(10) # XXX is this necessary?
|
||||||
continue
|
continue
|
||||||
id = id + 2*rate
|
id = id + 2*rate
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue