Improve bundled Opus build and packet handling - #5
Merged
Merged
Conversation
Deniskore
force-pushed
the
new-version
branch
3 times, most recently
from
July 18, 2026 11:08
51a5755 to
1d6afd9
Compare
There was a problem hiding this comment.
Pull request overview
This PR improves the crate’s bundled/libopus build reliability and correctness around packet padding, extensions, and repacketizer emission, while tightening argument validation and expanding CI/test coverage for both bundled and system-lib configurations.
Changes:
- Add Rust implementations for packet padding/unpadding and repacketizer emission (with extension handling), conditionally enabled via build-time compatibility checks.
- Harden argument validation and documented safety contracts for external/allocation “*_Ref::from_raw” and size helper APIs; adjust thread-safety traits (drop
Sync) for codec state wrappers. - Expand CI scripts/workflows and add extensive tests to validate parity with libopus behavior and new edge cases (padding/extensions, CTLs, system-lib verification, Windows CRT mode, AVX presume behavior).
Reviewed changes
Copilot reviewed 30 out of 31 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/repacketizer.rs | Adds extensive repacketizer emission/range tests, including extension filtering/reindexing and raw-libopus parity checks under cfg. |
| tests/raw_alloc.rs | Adds negative tests for multistream size helpers rejecting invalid stream counts. |
| tests/projection.rs | Adds negative tests for projection size helpers rejecting invalid args. |
| tests/packet_padding.rs | New test suite validating packet_pad/unpad and multistream padding behavior, including randomized parity vs libopus. |
| tests/multistream.rs | Adds tests for scalar CTLs behavior and large-packet multistream padding/unpadding. |
| tests/multhithread.rs | Updates thread-safety assertions to match Send-only codec wrappers. |
| tests/encoder_decoder.rs | Adds test ensuring Decoder::packet_samples rejects empty packets. |
| tests/encoder_ctls.rs | Adds tests for lookahead scaling and DRED duration CTL behavior. |
| tests/ctl_compatibility.rs | New bundled-only test ensuring CTL surface compatibility with bundled libopus (plus DRED ABI checks when enabled). |
| src/types.rs | Adds Complexity::try_new and tests for checked construction. |
| src/repacketizer.rs | Improves push semantics, adds Rust-path repacketizer emission (cfg-gated), strengthens safety docs, and resets borrowed state on drop when owning packet buffers. |
| src/raw.rs | Introduces checked_non_null helper for consistent null/alignment assertions in unsafe constructors. |
| src/projection.rs | Adds robust argument validation, safer demixing matrix handling, PLC/FEC 2.5ms alignment checks, and updates safety docs; removes Sync. |
| src/packet/layout/extensions.rs | Adds Rust extension parsing/generation logic (frame-bounded and non-frame-bounded variants). |
| src/packet/layout.rs | Adds Rust packet layout parsing/writing and repacketizer frame (range) emission helpers, including extension handling. |
| src/packet.rs | Integrates Rust packet ops behind cfg, tightens argument validation for pad/unpad APIs, and uses shared MAX_FRAMES constant. |
| src/multistream.rs | Adds stream-count validation, fixes/extends scalar CTLs via underlying stream states, adds 2.5ms alignment checks, and removes Sync. |
| src/lib.rs | Re-exports checked_non_null internally. |
| src/encoder.rs | Improves docs, adds DRED duration CTLs (feature-gated), uses checked Complexity::try_new, updates unsafe wrapper construction; removes Sync. |
| src/dred.rs | Adds typed DNN blob ctl, safer size checks, overflow guards, 2.5ms alignment checks, and initializes malloc-like state; removes Sync. |
| src/decoder.rs | Adds PLC/FEC 2.5ms alignment checks, rejects empty packet in packet_samples, moves DRED duration CTLs out (keeps DNN blob ctl), updates unsafe wrapper construction; removes Sync. |
| src/constants.rs | Adds helpers for 2.5ms alignment checks used by decode/PLC/FEC/DRED paths. |
| scripts/verify_windows_static_crt.py | New CI verifier ensuring bundled Windows builds follow Cargo CRT mode and do not import dynamic CRT DLLs when crt-static is enabled. |
| scripts/verify_system_lib.py | Reworks system-lib verification to require >=1.5.2 and ensure Cargo selected system-lib build path (no bundled CMake artifacts). |
| scripts/verify_avx.py | Strengthens AVX gating verification with archive/object inspection and flag/define checks. |
| scripts/ci_utils.py | Adds Cargo JSON parsing helpers, improves output grouping/printing, and better error reporting. |
| README.md | Documents Windows MSVC CRT behavior for bundled vs system-lib builds. |
| Cargo.toml | Bumps version to 0.2.0, adds excludes for DRED assets, updates deps/dev-deps (pkg-config pin, sha2, rand, tempfile). |
| Cargo.lock | Updates lockfile for the dependency/version changes. |
| build.rs | Adds compatibility fingerprinting for enabling Rust packet ops, improves MSVC CRT selection, refactors DRED asset handling with checksum+safe extraction, and emits cfg/check-cfg directives. |
| .github/workflows/ci.yml | Updates CI matrix and adds jobs for Windows static CRT verification, system-lib verification, and ASan/leak testing; updates checkout action version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Deniskore
force-pushed
the
new-version
branch
2 times, most recently
from
July 18, 2026 13:17
3a3cf53 to
c8deb0e
Compare
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.
No description provided.