Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 696f911

Browse files
committed
Fix division by zero in some cases.
1 parent 444339d commit 696f911

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Demo/sgi/video/video.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,12 @@ def initcmap(ybits,ibits,qbits,chrompack):
9898
for y in range(maxy):
9999
yv = float(y)/float(maxy-1)
100100
for i in range(maxi):
101-
iv = (float(i)/float(maxi-1))-0.5
101+
if maxi = 1: iv = 0
102+
else: iv = (float(i)/float(maxi-1))-0.5
102103
for q in range(maxq):
103-
qv = (float(q)/float(maxq-1))-0.5
104+
if maxq = 1: qv = 0
105+
else: qv = (float(q)/float(maxq-1))-0.5
104106
index = 2048 + y + (i << ybits) + (q << (ybits+ibits))
105-
106107
rv,gv,bv = colorsys.yiq_to_rgb(yv,iv,qv)
107108
r,g,b = int(rv*255.0), int(gv*255.0), int(bv*255.0)
108109
if index < 4096 - 256:

0 commit comments

Comments
 (0)