mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
Rot out all uses of time.milli*().
Also change command line options to use seconds for all times.
This commit is contained in:
parent
ca1c876d43
commit
605909dc9d
1 changed files with 17 additions and 16 deletions
|
|
@ -12,10 +12,10 @@ def help():
|
||||||
print '-M magnify : magnify the image by the given factor'
|
print '-M magnify : magnify the image by the given factor'
|
||||||
print '-d : write some debug stuff on stderr'
|
print '-d : write some debug stuff on stderr'
|
||||||
print '-l : loop, playing the movie over and over again'
|
print '-l : loop, playing the movie over and over again'
|
||||||
print '-m delta : drop frames closer than delta msec (default 0)'
|
print '-m delta : drop frames closer than delta seconds (default 0.)'
|
||||||
print '-n : don\'t wait after each file'
|
print '-n : don\'t wait after each file'
|
||||||
print '-q : quiet, no informative messages'
|
print '-q : quiet, no informative messages'
|
||||||
print '-r delta : regenerate input time base delta msec apart'
|
print '-r delta : regenerate input time base delta seconds apart'
|
||||||
print '-s speed : speed change factor (default 1.0)'
|
print '-s speed : speed change factor (default 1.0)'
|
||||||
print '-t : use a 2nd thread for read-ahead'
|
print '-t : use a 2nd thread for read-ahead'
|
||||||
print '-x left : window offset from left of screen'
|
print '-x left : window offset from left of screen'
|
||||||
|
|
@ -81,10 +81,10 @@ def main():
|
||||||
if opt == '-M': magnify = float(eval(arg))
|
if opt == '-M': magnify = float(eval(arg))
|
||||||
if opt == '-d': debug = debug + 1
|
if opt == '-d': debug = debug + 1
|
||||||
if opt == '-l': looping = 1
|
if opt == '-l': looping = 1
|
||||||
if opt == '-m': mindelta = string.atoi(arg)
|
if opt == '-m': mindelta = float(eval(arg))
|
||||||
if opt == '-n': nowait = 1
|
if opt == '-n': nowait = 1
|
||||||
if opt == '-q': quiet = 1
|
if opt == '-q': quiet = 1
|
||||||
if opt == '-r': regen = string.atoi(arg)
|
if opt == '-r': regen = float(eval(arg))
|
||||||
if opt == '-s':
|
if opt == '-s':
|
||||||
try:
|
try:
|
||||||
speed = float(eval(arg))
|
speed = float(eval(arg))
|
||||||
|
|
@ -238,7 +238,7 @@ def playonce(vin):
|
||||||
thread.start_new_thread(read_ahead, (vin, queue, stop))
|
thread.start_new_thread(read_ahead, (vin, queue, stop))
|
||||||
# Get the read-ahead thread going
|
# Get the read-ahead thread going
|
||||||
while queue.qsize() < MAXSIZE/2 and not stop:
|
while queue.qsize() < MAXSIZE/2 and not stop:
|
||||||
time.millisleep(100)
|
time.sleep(0.100)
|
||||||
|
|
||||||
tin = 0
|
tin = 0
|
||||||
toffset = 0
|
toffset = 0
|
||||||
|
|
@ -250,7 +250,7 @@ def playonce(vin):
|
||||||
nskipped = 0
|
nskipped = 0
|
||||||
data = None
|
data = None
|
||||||
|
|
||||||
tlast = t0 = time.millitimer()
|
tlast = t0 = time.time()
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
if gl.qtest():
|
if gl.qtest():
|
||||||
|
|
@ -278,6 +278,7 @@ def playonce(vin):
|
||||||
tin, size, csize = vin.getnextframeheader()
|
tin, size, csize = vin.getnextframeheader()
|
||||||
except EOFError:
|
except EOFError:
|
||||||
break
|
break
|
||||||
|
tin = tin*0.001
|
||||||
nin = nin+1
|
nin = nin+1
|
||||||
if tin+toffset < oldtin:
|
if tin+toffset < oldtin:
|
||||||
print 'Fix reversed time:', oldtin, 'to', tin
|
print 'Fix reversed time:', oldtin, 'to', tin
|
||||||
|
|
@ -286,7 +287,7 @@ def playonce(vin):
|
||||||
oldtin = tin
|
oldtin = tin
|
||||||
if regen: tout = nin * regen
|
if regen: tout = nin * regen
|
||||||
else: tout = tin
|
else: tout = tin
|
||||||
tout = int(tout / speed)
|
tout = tout / speed
|
||||||
if tout - told < mindelta:
|
if tout - told < mindelta:
|
||||||
nskipped = nskipped + 1
|
nskipped = nskipped + 1
|
||||||
if not threading:
|
if not threading:
|
||||||
|
|
@ -300,34 +301,34 @@ def playonce(vin):
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print '[incomplete last frame]'
|
print '[incomplete last frame]'
|
||||||
break
|
break
|
||||||
now = time.millitimer()
|
now = time.time()
|
||||||
dt = (tout-told) - (now-tlast)
|
dt = (tout-told) - (now-tlast)
|
||||||
told = tout
|
told = tout
|
||||||
if debug: sys.stderr.write(`dt/10` + ' ')
|
if debug: sys.stderr.write(`round(dt, 3)` + ' ')
|
||||||
if dt < 0: nlate = nlate + 1
|
if dt < 0: nlate = nlate + 1
|
||||||
if dt > 0:
|
if dt > 0:
|
||||||
time.millisleep(dt)
|
time.sleep(dt)
|
||||||
now = now + dt
|
now = time.time()
|
||||||
tlast = now
|
tlast = now
|
||||||
vin.showframe(data, cdata)
|
vin.showframe(data, cdata)
|
||||||
nout = nout + 1
|
nout = nout + 1
|
||||||
|
|
||||||
t1 = time.millitimer()
|
t1 = time.time()
|
||||||
|
|
||||||
if debug: sys.stderr.write('\n')
|
if debug: sys.stderr.write('\n')
|
||||||
|
|
||||||
if quiet: return 0
|
if quiet: return 0
|
||||||
|
|
||||||
print 'Recorded:', nin, 'frames in', tin*0.001, 'sec.',
|
print 'Recorded:', nin, 'frames in', round(tin, 3), 'sec.',
|
||||||
if tin: print '-- average', int(nin*10000.0/tin)*0.1, 'frames/sec',
|
if tin: print '-- average', round(nin/tin, 1), 'frames/sec',
|
||||||
print
|
print
|
||||||
|
|
||||||
if nskipped: print 'Skipped', nskipped, 'frames'
|
if nskipped: print 'Skipped', nskipped, 'frames'
|
||||||
|
|
||||||
tout = t1-t0
|
tout = t1-t0
|
||||||
print 'Played:', nout,
|
print 'Played:', nout,
|
||||||
print 'frames in', tout*0.001, 'sec.',
|
print 'frames in', round(tout, 3), 'sec.',
|
||||||
if tout: print '-- average', int(nout*10000.0/tout)*0.1, 'frames/sec',
|
if tout: print '-- average', round(nout/tout, 1), 'frames/sec',
|
||||||
print
|
print
|
||||||
|
|
||||||
if nlate: print 'There were', nlate, 'late frames'
|
if nlate: print 'There were', nlate, 'late frames'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue