Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
d9ff06b1
Commit
d9ff06b1
authored
Nov 04, 1991
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial revision
parent
32e643a5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
108 additions
and
0 deletions
+108
-0
Demo/sgi/video/vcopy.py
Demo/sgi/video/vcopy.py
+108
-0
No files found.
Demo/sgi/video/vcopy.py
0 → 100755
View file @
d9ff06b1
# Copy a video file, interactively, frame-by-frame.
import
sys
import
getopt
from
gl
import
*
from
DEVICE
import
*
def
loadframe
(
f
,
w
,
h
,
pf
):
line
=
f
.
readline
()
if
not
line
or
line
=
'
\
n
'
:
raise
EOFError
x
=
eval
(
line
[:
-
1
])
if
type
(
x
)
=
type
(
0
):
if
pf
:
size
=
w
*
h
*
4
else
:
size
=
w
*
h
*
pf
else
:
time
,
size
=
x
data
=
f
.
read
(
size
)
if
len
(
data
)
<>
size
:
raise
EOFError
if
pf
:
windata
=
unpackrect
(
w
/
pf
,
h
/
pf
,
1
,
data
)
rectzoom
(
pf
,
pf
)
lrectwrite
(
0
,
0
,
w
/
pf
-
1
,
h
/
pf
-
1
,
windata
)
else
:
lrectwrite
(
0
,
0
,
w
-
1
,
h
-
1
,
data
)
return
time
,
data
def
report
(
time
,
iframe
):
print
'Frame'
,
iframe
,
': t ='
,
time
def
usage
():
sys
.
write
(
'usage: vcopy infile outfile
\
n
'
)
sys
.
exit
(
2
)
def
help
():
print
'Command summary:'
print
'n get next image from input'
print
'w write current image to output'
def
main
():
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
''
)
if
len
(
args
)
<>
2
:
usage
()
[
ifile
,
ofile
]
=
args
ifp
=
open
(
ifile
,
'r'
)
ofp
=
open
(
ofile
,
'w'
)
#
line
=
ifp
.
readline
()
if
line
[:
4
]
=
'CMIF'
:
line
=
ifp
.
readline
()
x
=
eval
(
line
[:
-
1
])
if
len
(
x
)
=
3
:
w
,
h
,
pf
=
x
else
:
w
,
h
=
x
pf
=
2
if
pf
:
w
=
(
w
/
pf
)
*
pf
h
=
(
h
/
pf
)
*
pf
#
ofp
.
write
(
'CMIF video 1.0
\
n
'
)
ofp
.
write
(
`w, h, pf`
+
'
\
n
'
)
#
foreground
()
prefsize
(
w
,
h
)
wid
=
winopen
(
ifile
+
' -> '
+
ofile
)
RGBmode
()
gconfig
()
qdevice
(
KEYBD
)
qdevice
(
ESCKEY
)
qdevice
(
WINQUIT
)
qdevice
(
WINSHUT
)
#
help
()
#
time
,
data
=
loadframe
(
ifp
,
w
,
h
,
pf
)
iframe
=
1
report
(
time
,
iframe
)
#
while
1
:
dev
,
val
=
qread
()
if
dev
in
(
ESCKEY
,
WINQUIT
,
WINSHUT
):
break
if
dev
=
REDRAW
:
reshapeviewport
()
elif
dev
=
KEYBD
:
c
=
chr
(
val
)
if
c
=
'n'
:
try
:
time
,
data
=
loadframe
(
ifp
,
w
,
h
,
pf
)
iframe
=
iframe
+
1
report
(
time
,
iframe
)
except
EOFError
:
print
'EOF'
ringbell
()
elif
c
=
'w'
:
ofp
.
write
(
`time, len(data)`
+
'
\
n
'
)
ofp
.
write
(
data
)
print
'Frame'
,
iframe
,
'written.'
else
:
print
'Character'
,
`c`
,
'ignored'
elif
dev
=
INPUTCHANGE
:
pass
else
:
print
'(dev, val) ='
,
(
dev
,
val
)
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment