mirror of
https://github.com/brues-code/TwitchEmotes.git
synced 2026-09-21 23:26:57 +00:00
Fix animated frame budget for non-square emote cells
main() capped resample() at the square-cell frame budget (128 across 4 columns) regardless of cell shape, but layout() forces a wide/tall cell to a single column, whose real budget is only 32. A long animation in a non-square cell would blow past MAX_TEXTURE and die instead of resampling down to a fitting framerate.
This commit is contained in:
+12
-1
@@ -126,6 +126,17 @@ def resample(durations, budget):
|
||||
return fps, indices
|
||||
|
||||
|
||||
def max_frames(cell):
|
||||
"""Most frames `layout` can pack for this cell shape within MAX_TEXTURE.
|
||||
|
||||
A non-square cell stays single-column (see `layout`), so its budget is
|
||||
shallower than a square cell's, which can spread across MAX_COLS.
|
||||
"""
|
||||
cw, ch = cell
|
||||
cols = MAX_COLS if cw == FRAME else 1
|
||||
return cols * (MAX_TEXTURE // ch)
|
||||
|
||||
|
||||
def layout(count, cell):
|
||||
"""Column count and texture size for `count` frames.
|
||||
|
||||
@@ -286,7 +297,7 @@ def main():
|
||||
info = None
|
||||
print('%s: static, %s in a %dx%d texture' % (args.name, shape, tw, th))
|
||||
else:
|
||||
fps, indices = resample(durations, MAX_COLS * (MAX_TEXTURE // FRAME))
|
||||
fps, indices = resample(durations, max_frames(cell))
|
||||
sheet, nframes, cols, tw, th = build_sheet(frames, indices, cell)
|
||||
info = (nframes, fps)
|
||||
print('%s: %d source frames (%.2fs) -> %d frames at %dfps (%.2fs, '
|
||||
|
||||
Reference in New Issue
Block a user