Skip to content

Improve bundled Opus build and packet handling - #5

Merged
Deniskore merged 1 commit into
mainfrom
new-version
Jul 24, 2026
Merged

Improve bundled Opus build and packet handling#5
Deniskore merged 1 commit into
mainfrom
new-version

Conversation

@Deniskore

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Deniskore force-pushed the new-version branch 2 times, most recently from 3a3cf53 to c8deb0e Compare July 18, 2026 13:17
@Deniskore
Deniskore requested a review from Copilot July 18, 2026 13:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 31 out of 32 changed files in this pull request and generated 1 comment.

Comment thread src/repacketizer.rs
@Deniskore
Deniskore merged commit bd64525 into main Jul 24, 2026
12 checks passed
@Deniskore
Deniskore deleted the new-version branch July 24, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants