feat: choose how frames are resized with interpolation - #15
Merged
Merged
Conversation
read, read_batches, and FrameReader take interpolation: "nearest", "bilinear", "bicubic", "area", or "lanczos", which pick swscale's SWS_* flag. The default, None, stays bilinear on the CPU. NVIDIA's resizing method cannot be chosen, so naming an interpolation with device="cuda" turns off the resize of the *_cuvid decoders and lets the CPU resize the frames. It raises ValueError with on_device=True. SWS_FAST_BILINEAR is left out: on an Apple M2 it was no faster than bilinear at 960x540 or when enlarging, and it aliased heavily when shrinking. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Type checkers and editors now know the names that device and interpolation accept. iterframes.Device and iterframes.Interpolation are exported for annotating callers' own code. The extension still validates the names at runtime, and tests check that the Literal types match the names it accepts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Linux and Windows wheels know "cuda", but CI has no NVIDIA GPU, so opening it raises RuntimeError rather than ValueError. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Description
interpolation.read,read_batches, andFrameReadertakeinterpolation:"nearest","bilinear","bicubic","area", or"lanczos", each mapped to swscale'sSWS_*flag. The default,None, stays bilinear on the CPU. An unknown name raisesValueErrorand lists the accepted ones.device="cuda"turns off the resize of the*_cuviddecoders and lets the CPU resize the frames. Withon_device=Trueit raisesValueError.SWS_FAST_BILINEARis left out: on an Apple M2 it was no faster than bilinear at 960x540 or when enlarging, and it aliased heavily when shrinking.AGENTS.mddescribe the argument.deviceandinterpolationare typed asLiteral, exported asiterframes.Deviceanditerframes.Interpolationand documented under Types in the API page. The extension still validates at runtime; tests check that theLiteraltypes match the names it accepts.uv.lock(dev and docs dependencies only: filelock, identify, markdown, nodeenv, platformdirs, pymdown-extensions, virtualenv).The NVDEC tests were skipped locally, since the machine has no NVIDIA GPU, so the
device="cuda"path is untested here.Checklist
cargo fmtandcargo clippy --all-targets -- -D warningspassuv run --no-sync pre-commit run -apassesuv run --no-sync pytestpasses (103 passed, 3 skipped for NVDEC)CHANGELOG.mdupdated (the changelog is written by release-please);mkdocs build --strictpasses🤖 Generated with Claude Code