Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
a63f1979
Kaydet (Commit)
a63f1979
authored
Kas 22, 1991
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
New options: -m mag, and -F.
Also support for 'CMIF version 2.0' movies, with compressed color.
üst
7385d583
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
12 deletions
+73
-12
video.py
Demo/sgi/video/video.py
+73
-12
No files found.
Demo/sgi/video/video.py
Dosyayı görüntüle @
a63f1979
...
...
@@ -6,11 +6,13 @@ import time
import
sys
import
al
import
AL
import
colorsys
BUFFERSIZE
=
32000
class
Struct
():
pass
epoch
=
Struct
()
epoch
.
correcttiming
=
1
EndOfFile
=
'End of file'
bye
=
'bye'
...
...
@@ -29,13 +31,19 @@ def openvideo(name):
sys
.
exit
(
1
)
line
=
f
.
readline
()
if
not
line
:
raise
EndOfFile
if
line
[:
4
]
=
'CMIF'
:
line
=
f
.
readline
()
if
line
[:
4
]
=
'CMIF'
:
if
line
[:
14
]
=
'CMIF video 2.0'
:
line
=
f
.
readline
()
colorinfo
=
eval
(
line
[:
-
1
])
else
:
colorinfo
=
(
8
,
0
,
0
,
0
)
line
=
f
.
readline
()
x
=
eval
(
line
[:
-
1
])
if
len
(
x
)
=
3
:
w
,
h
,
pf
=
x
else
:
w
,
h
=
x
;
pf
=
2
return
f
,
w
,
h
,
pf
return
f
,
w
,
h
,
pf
,
colorinfo
def
loadframe
(
f
,
w
,
h
,
pf
,
af
,
spkr
):
def
loadframe
(
f
,
w
,
h
,
pf
,
af
,
spkr
,
(
ybits
,
ibits
,
qbits
,
chrompack
),
mf
):
line
=
f
.
readline
()
if
line
=
''
:
raise
EndOfFile
...
...
@@ -52,21 +60,54 @@ def loadframe(f,w,h,pf,af,spkr):
if
len
(
data
)
<>
size
:
raise
EndOfFile
if
pf
:
rectzoom
(
pf
,
pf
)
w
=
w
/
pf
h
=
h
/
pf
data
=
unpackrect
(
w
,
h
,
1
,
data
)
if
chrompack
:
cw
=
(
w
+
chrompack
-
1
)
/
chrompack
ch
=
(
h
+
chrompack
-
1
)
/
chrompack
chromdata
=
f
.
read
(
2
*
cw
*
ch
)
rectzoom
(
pf
*
chrompack
*
mf
,
pf
*
chrompack
*
mf
)
pixmode
(
5
,
16
)
writemask
(
0x7ff
-
((
1
<<
ybits
)
-
1
))
lrectwrite
(
0
,
0
,
cw
-
1
,
ch
-
1
,
chromdata
)
writemask
((
1
<<
ybits
)
-
1
)
pixmode
(
5
,
8
)
if
pf
:
rectzoom
(
pf
*
mf
,
pf
*
mf
)
elif
mf
<>
1
:
rectzoom
(
mf
,
mf
)
lrectwrite
(
0
,
0
,
w
-
1
,
h
-
1
,
data
)
# This is ugly here, but the only way to get the two
# channels started in sync
#if af <> None:
# playsound(af,spkr)
ct
=
time
.
millitimer
()
-
epoch
.
epoch
if
tijd
>
0
and
ct
<
tijd
:
if
epoch
.
correcttiming
and
tijd
>
0
and
ct
<
tijd
:
time
.
millisleep
(
tijd
-
ct
)
#swapbuffers()
return
tijd
def
initcmap
(
ybits
,
ibits
,
qbits
,
chrompack
):
if
ybits
+
ibits
+
qbits
>
11
:
raise
'Sorry, 11 bits max'
maxy
=
pow
(
2
,
ybits
)
maxi
=
pow
(
2
,
ibits
)
maxq
=
pow
(
2
,
qbits
)
for
i
in
range
(
2048
,
4096
-
256
):
mapcolor
(
i
,
0
,
255
,
0
)
for
y
in
range
(
maxy
):
yv
=
float
(
y
)
/
float
(
maxy
-
1
)
for
i
in
range
(
maxi
):
iv
=
(
float
(
i
)
/
float
(
maxi
-
1
))
-
0.5
for
q
in
range
(
maxq
):
qv
=
(
float
(
q
)
/
float
(
maxq
-
1
))
-
0.5
index
=
2048
+
y
+
(
i
<<
ybits
)
+
(
q
<<
(
ybits
+
ibits
))
rv
,
gv
,
bv
=
colorsys
.
yiq_to_rgb
(
yv
,
iv
,
qv
)
r
,
g
,
b
=
int
(
rv
*
255.0
),
int
(
gv
*
255.0
),
int
(
bv
*
255.0
)
if
index
<
4096
-
256
:
mapcolor
(
index
,
r
,
g
,
b
)
def
playsound
(
af
,
spkr
):
nsamp
=
spkr
.
getfillable
()
data
=
af
.
read
(
nsamp
*
2
)
...
...
@@ -75,17 +116,27 @@ def playsound(af, spkr):
def
main
():
looping
=
0
packfactor
=
0
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'p:l'
)
magfactor
=
1
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'm:p:lF'
)
except
getopt
.
error
:
sys
.
stderr
.
write
(
'usage: video '
+
\
'[-l] [-p pf] [-m mag] [-F] [moviefile [soundfile [skipbytes]]]
\n
'
)
sys
.
exit
(
2
)
for
opt
,
arg
in
opts
:
if
opt
=
'-p'
:
if
opt
=
'-m'
:
magfactor
=
int
(
eval
(
arg
))
elif
opt
=
'-p'
:
packfactor
=
int
(
eval
(
arg
))
elif
opt
=
'-l'
:
looping
=
1
elif
opt
=
'-F'
:
epoch
.
correcttiming
=
0
if
args
:
filename
=
args
[
0
]
else
:
filename
=
'film.video'
f
,
w
,
h
,
pf
=
openvideo
(
filename
)
f
,
w
,
h
,
pf
,
cinfo
=
openvideo
(
filename
)
if
0
<
packfactor
<>
pf
:
w
=
w
/
pf
*
packfactor
h
=
h
/
pf
*
packfactor
...
...
@@ -101,11 +152,21 @@ def main():
else
:
af
,
spkr
=
None
,
None
foreground
()
prefsize
(
w
,
h
)
prefsize
(
w
*
magfactor
,
h
*
magfactor
)
win
=
winopen
(
filename
)
RGBmode
()
if
pf
:
#doublebuffer()
cmode
()
else
:
RGBmode
()
#doublebuffer()
gconfig
()
if
pf
:
initcmap
(
cinfo
)
color
(
2048
)
clear
()
writemask
(
2047
)
pixmode
(
5
,
8
)
# 8 bit pixels
qdevice
(
ESCKEY
)
qdevice
(
WINSHUT
)
qdevice
(
WINQUIT
)
...
...
@@ -119,7 +180,7 @@ def main():
while
1
:
if
running
:
try
:
tijd
=
loadframe
(
f
,
w
,
h
,
pf
,
af
,
spkr
)
tijd
=
loadframe
(
f
,
w
,
h
,
pf
,
af
,
spkr
,
cinfo
,
magfactor
)
nframe
=
nframe
+
1
except
EndOfFile
:
running
=
0
...
...
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