fix(video): 首帧放大改用 NEAREST,不把 sprite 硬边糊掉 - #543
Open
johnnyzhang-eng wants to merge 1 commit into
Open
Conversation
放大是把源像素铺成块,插值会造出源图没有的中间色;缩小仍用 LANCZOS。 与交付侧 _fit_to 的同一条规则对齐。 Closes 1024XEngineer#542
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
Reviewed the complete fixed diff for the first-frame resize contract. The change applies NEAREST only when the fitted image is enlarged and preserves LANCZOS for reductions, matching the linked #542 requirement; the new regression test exercises the small-sprite hard-edge case. No actionable correctness, compatibility, or security findings remain.
Verification: git diff --check and Python compilation passed for both changed files. The focused pytest suite was not runnable in this workspace because uv, pytest, and Pillow are unavailable.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
xyh202131
approved these changes
Aug 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #542
问题
_fit_first_frame放大用 LANCZOS。放大是把一个源像素铺成一块,插值会在块边界造出源图里没有的中间色,把 sprite 的硬边糊成渐变 —— 而这张糊图正是喂给 i2v 的输入。倍率越大越严重。同一函数、同一张双色硬边图,测成品里那条边的过渡带宽度:
即小 sprite 受损最重,而 64×64 / 128×128 正是 #509 点名的场景。
交付侧的
_fit_to早就是这条规则,其 docstring 原文:「序列帧是像素画,必须 NEAREST(插值会把硬边糊成灰边)」。首帧这一侧与它不一致。方案
放大用 NEAREST,缩小仍用 LANCZOS(缩小反过来,NEAREST 会丢样出锯齿)。
不包含
验收
新增用例用 64×64 源(11.2× 放大),断言硬边过渡带 ≤8px。把滤波换回 LANCZOS 时该用例失败:
用例特意不拿色数当判据 —— 那个量在 JPEG 之后两种滤波分不开,拿它会得出「没区别」的错结论。
ruff check .、lint-imports(2 kept, 0 broken)、pytest -q(1318 passed, 14 skipped)。