From f27f9fe2590e4f3908bcf7500d09bf96a3bdc4bc Mon Sep 17 00:00:00 2001 From: Star Brilliant Date: Thu, 28 Nov 2013 00:15:50 +0800 Subject: [PATCH] Fix 71776ba Fix commit 71776bacccf51d0dc3abec48143f02c6452d3f8f --- danmaku2ass.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/danmaku2ass.py b/danmaku2ass.py index 647d176..cfec82a 100755 --- a/danmaku2ass.py +++ b/danmaku2ass.py @@ -353,29 +353,30 @@ def ProcessComments(comments, f, width, height, bottomReserved, fontface, fontsi def TestFreeRows(rows, c, row, width, height, bottomReserved, lifetime): res = 0 rowmax = height-bottomReserved-c[7] + targetRow = None if c[4] in (1, 2): while row < rowmax and res < c[7]: - targetRow = rows[c[4]][row] - if targetRow and targetRow[0]+lifetime > c[0]: - break - while rows[c[4]][row] == targetRow: - row += 1 - res += 1 + if targetRow != rows[c[4]][row]: + targetRow = rows[c[4]][row] + if targetRow and targetRow[0]+lifetime > c[0]: + break + row += 1 + res += 1 else: try: thresholdTime = c[0]-lifetime*(1-width/(c[8]+width)) except ZeroDivisionError: thresholdTime = c[0]-lifetime while row < rowmax and res < c[7]: - targetRow = rows[c[4]][row] - try: - if targetRow and (targetRow[0] > thresholdTime or targetRow[0]+targetRow[8]*lifetime/(targetRow[8]+width) > c[0]): - break - except ZeroDivisionError: - pass - while rows[c[4]][row] == targetRow: - row += 1 - res += 1 + if targetRow != rows[c[4]][row]: + targetRow = rows[c[4]][row] + try: + if targetRow and (targetRow[0] > thresholdTime or targetRow[0]+targetRow[8]*lifetime/(targetRow[8]+width) > c[0]): + break + except ZeroDivisionError: + pass + row += 1 + res += 1 return res