Skip to content

Conversation

@lennartkloock
Copy link
Member

@lennartkloock lennartkloock commented Apr 6, 2025

Reimplementation of H.265 SPS NALU parsing with scuffle-h265.

CLOUD-30

@lennartkloock lennartkloock changed the title h265: docs and tests h265: reimplementation Apr 12, 2025
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Apr 12, 2025

Deploying scuffle-docrs with  Cloudflare Pages  Cloudflare Pages

Latest commit: c729ec0
Status: ✅  Deploy successful!
Preview URL: https://3f57a53a.scuffle-docrs.pages.dev
Branch Preview URL: https://pr-425.scuffle-docrs.pages.dev

View logs

@codecov
Copy link

codecov bot commented Apr 12, 2025

Codecov Report

Attention: Patch coverage is 72.22583% with 428 lines in your changes missing coverage. Please review.

Project coverage is 83.32%. Comparing base (827bdd8) to head (c729ec0).
Report is 72 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/h265/src/sps/profile_tier_level.rs 65.34% 61 Missing ⚠️
crates/h265/src/sps/sps_range_extension.rs 0.00% 58 Missing ⚠️
crates/h265/src/sps/pcm.rs 0.00% 52 Missing ⚠️
crates/h265/src/sps/mod.rs 83.83% 48 Missing ⚠️
crates/h265/src/sps/sps_3d_extension.rs 0.00% 40 Missing ⚠️
crates/h265/src/sps/vui_parameters/mod.rs 87.23% 30 Missing ⚠️
crates/h265/src/sps/st_ref_pic_set.rs 81.29% 29 Missing ⚠️
crates/h265/src/nal_unit_header.rs 58.62% 24 Missing ⚠️
crates/h265/src/sps/sub_layer_ordering_info.rs 67.27% 18 Missing ⚠️
crates/h265/src/sps/long_term_ref_pics.rs 0.00% 17 Missing ⚠️
... and 8 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #425      +/-   ##
==========================================
- Coverage   84.15%   83.32%   -0.83%     
==========================================
  Files         225      240      +15     
  Lines       15915    17007    +1092     
==========================================
+ Hits        13393    14171     +778     
- Misses       2522     2836     +314     
Files with missing lines Coverage Δ
crates/bytes-util/src/nal_emulation_prevention.rs 100.00% <ø> (ø)
crates/h264/src/sps/mod.rs 100.00% <ø> (ø)
crates/h265/src/sps/conformance_window.rs 100.00% <100.00%> (ø)
crates/transmuxer/src/codecs/hevc.rs 98.00% <100.00%> (+0.17%) ⬆️
crates/transmuxer/src/lib.rs 94.75% <100.00%> (+0.25%) ⬆️
crates/h265/src/rbsp_trailing_bits.rs 90.00% <90.00%> (ø)
crates/h265/src/sps/scaling_list.rs 97.22% <97.22%> (ø)
crates/h265/src/enums/nal_unit_type.rs 0.00% <0.00%> (ø)
crates/h265/src/sps/sps_multilayer_extension.rs 0.00% <0.00%> (ø)
crates/mp4/src/codec.rs 31.57% <77.77%> (+5.71%) ⬆️
... and 13 more

... and 7 files with indirect coverage changes

Components Coverage Δ
scuffle-aac 89.65% <ø> (ø)
scuffle-amf0 90.61% <ø> (ø)
scuffle-av1 98.44% <ø> (ø)
scuffle-batching 100.00% <ø> (ø)
scuffle-bootstrap 83.46% <ø> (-0.60%) ⬇️
scuffle-bytes-util 97.04% <ø> (+0.26%) ⬆️
scuffle-context 100.00% <ø> (ø)
scuffle-expgolomb 100.00% <ø> (ø)
scuffle-ffmpeg 90.92% <ø> (-0.12%) ⬇️
scuffle-flv 95.90% <ø> (ø)
scuffle-future-ext 50.00% <ø> (ø)
nutype-enum 71.87% <ø> (ø)
scuffle-h264 100.00% <ø> (ø)
scuffle-http 86.21% <ø> (ø)
scuffle-metrics 87.29% <ø> (ø)
postcompile 78.81% <ø> (-0.58%) ⬇️
scuffle-pprof 100.00% <ø> (ø)
scuffle-rtmp 91.45% <ø> (-0.40%) ⬇️
scuffle-settings 92.85% <ø> (ø)
scuffle-signal 95.68% <ø> (+10.89%) ⬆️

@TroyKomodo
Copy link
Member

@lennartkloock rebase this pr

@github-actions
Copy link
Contributor

github-actions bot commented Apr 17, 2025

🛫 Startup details 🛫 Revision main not found locally. Fetching from origin...

Checking out commit 827bdd8 into "target/semver-baseline"

HEAD is now at 827bdd8 Auto merge of #433 - lennart/new-nightly-clippy, r=TroyKomodo

📦 Processing crates 📦
  • nutype-enum
  • postcompile
  • scuffle-aac
  • scuffle-amf0
  • scuffle-av1
  • scuffle-batching
  • scuffle-bootstrap
  • scuffle-bootstrap-telemetry
  • scuffle-bytes-util
  • scuffle-context
  • scuffle-expgolomb
  • scuffle-ffmpeg
  • scuffle-flv
  • scuffle-future-ext
  • scuffle-h264
  • scuffle-h265
  • scuffle-http
  • scuffle-metrics
  • scuffle-mp4
  • scuffle-pprof
  • scuffle-rtmp
  • scuffle-settings
  • scuffle-signal
  • scuffle-transmuxer
  • scuffle-workspace-hack

Semver-checks summary

🚩 2 ERRORS FOUND 🚩

🔖 Error #1

⚠️ major update required for scuffle-h264.
🛠️ Please update the version from v0.1.1 to v0.2.1.

📜 scuffle-h264 logs 📜

Description:
A publicly-visible struct cannot be imported by its prior path. A pub use may have been removed, or the struct itself may have been renamed or removed entirely.
ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/struct_missing.ron

🎈 Failed in the following locations 🎈
--- failure enum_missing: pub enum removed or renamed ---

Description:
A publicly-visible enum cannot be imported by its prior path. A pub use may have been removed, or the enum itself may have been renamed or removed entirely.
ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/enum_missing.ron

🎈 Failed in the following locations 🎈
--- failure struct_missing: pub struct removed or renamed ---

Description:
A publicly-visible struct cannot be imported by its prior path. A pub use may have been removed, or the struct itself may have been renamed or removed entirely.
ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/struct_missing.ron

🎈 Failed in the following locations 🎈
--- failure struct_pub_field_missing: pub struct's pub field removed or renamed ---

Description:
A publicly-visible struct has at least one public field that is no longer available under its prior name. It may have been renamed or removed entirely.
ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/struct_pub_field_missing.ron

🎈 Failed in the following locations 🎈

🔖 Error #2

⚠️ major update required for scuffle-h265.
🛠️ Please update the version from v0.1.1 to v0.2.1.

📜 scuffle-h265 logs 📜
🛬 Cleanup details 🛬 Cleaning up git worktree at "target/semver-baseline"

Successfully removed git worktree

@TroyKomodo TroyKomodo requested a review from Copilot April 17, 2025 19:47
Copy link
Contributor

Copilot AI left a comment

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 reimplements H.265 SPS parsing and updates related modules with improved error handling, enum-based type safety, and enhanced tests and documentation.

  • Introduces new modules for SPS profile tier level, PCM and conformance window parsing.
  • Updates configuration record parsing/muxing to leverage new enums and refactors module exports.
  • Adjusts tests (including FLV integration) and dependency metadata.

Reviewed Changes

Copilot reviewed 43 out of 45 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/h265/src/sps/profile_tier_level.rs Adds new parsing logic for ProfileTierLevel and sub-layer profiles/levels.
crates/h265/src/sps/pcm.rs Implements PCM parsing with range checking and exp-Golomb decoding.
crates/h265/src/sps/conformance_window.rs Introduces conformance window parsing and byte stream building.
crates/h265/src/sps.rs Removes the old SPS parsing implementation.
crates/h265/src/range_check.rs Adds a macro to validate numeric ranges in the bitstream.
crates/h265/src/nal_unit_header.rs Updates NAL unit header parsing with stricter temporal id and layer id checks.
crates/h265/src/lib.rs Updates module exports and documentation; revises comments and metadata.
crates/h265/src/enums/* Adds several enums (e.g., VideoFormat, ParallelismType, NumTemporalLayers, NALUnitType, ConstantFrameRate, AspectRatioIdc) to improve type safety.
crates/h265/src/config.rs Reimplements the HEVCDecoderConfigurationRecord demux/mux logic using new enum types and clearer error checks.
crates/flv/src/lib.rs Adjusts FLV integration tests to account for the updated HEVC configuration and SPS parsing.
crates/h265/Cargo.toml Updates crate metadata and dependencies for the new implementation.
changes.d/pr-425.toml Provides PR metadata summarizing the reimplementation of H.265 SPS parsing.
Files not reviewed (2)
  • crates/flv/src/snapshots/scuffle_flv__tests__demux_flv_hevc_aac.snap: Language not supported
  • crates/h265/src/snapshots/scuffle_h265__config__tests__config_demux.snap: Language not supported
Comments suppressed due to low confidence (1)

crates/h265/src/config.rs:51

  • [nitpick] The inline comment suggests that 'avg_frame_rate' might be better represented as a f64 rather than a u16; consider reviewing this type for consistency with expected frame rate precision.
pub avg_frame_rate: u16,

@lennartkloock lennartkloock requested a review from Copilot April 18, 2025 23:35
Copy link
Contributor

Copilot AI left a comment

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 reimplements the H.265 SPS parsing functionality while refactoring several related modules and updating documentation and tests.

  • Introduces a new range_check! macro for cleaner boundary checks.
  • Implements NAL unit header parsing using stronger type definitions and updated error handling.
  • Refactors configuration demux/mux logic and updates tests to align with the new design.

Reviewed Changes

Copilot reviewed 48 out of 50 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/h265/src/range_check.rs New macro for validating numeric ranges.
crates/h265/src/nal_unit_header.rs Implements NAL unit header parsing with improved error messages.
crates/h265/src/lib.rs Updates module organization and documentation for H.265 decoding.
crates/h265/src/config.rs Refactors configuration record demux/mux with new enums and checks.
crates/h265/src/enums/*.rs Introduces nutype_enum-based enums for various H.265 parameters.
crates/h264/src/* Updates related SPS parsing module imports.
crates/flv/src/lib.rs Adjusts tests to reflect changes in nal unit type naming and decoding.
crates/bytes-util/* Adds/export NAL emulation prevention handling.
changes.d/pr-425.toml Documents the refactor as a breaking change.
Files not reviewed (2)
  • crates/flv/src/snapshots/scuffle_flv__tests__demux_flv_hevc_aac.snap: Language not supported
  • crates/h265/src/snapshots/scuffle_h265__config__tests__config_demux.snap: Language not supported
Comments suppressed due to low confidence (1)

crates/h265/src/range_check.rs:3

  • [nitpick] Consider using a more descriptive variable name instead of 'n' in the macro to reduce the chance of name collisions or confusion in expanded contexts.
let n = $n;

@lennartkloock lennartkloock requested a review from Copilot April 19, 2025 10:57
Copy link
Contributor

Copilot AI left a comment

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 reimplements several aspects of H.265 header parsing and configuration handling while updating documentation, tests, and dependency management. Key changes include:

  • A reimplementation of H.265 SPS parsing and associated NAL unit handling.
  • Updates to the configuration record parsing/muxing with new enum types (e.g. ConstantFrameRate, NumTemporalLayers, ParallelismType) and conversion logic.
  • Adjustments in related crates (H264, FLV, bytes-util) to align with the new H265 implementation.

Reviewed Changes

Copilot reviewed 50 out of 51 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/h265/src/rbsp_trailing_bits.rs Added implementation for reading RBSP trailing bits.
crates/h265/src/range_check.rs Introduced a macro for range checking with associated test case.
crates/h265/src/nal_unit_header.rs Updated NAL unit header parsing with stricter error conditions.
crates/h265/src/lib.rs Reorganized modules, exports and updated mux/demux logic for config.
crates/h265/src/enums/* Added various enums (video format, nal unit type, parallelism, etc.).
crates/h265/src/config.rs Extended and refined HEVC decoder configuration record handling.
crates/h264/src/{sps/mod.rs,lib.rs} Adjusted imports in SPS parsing to account for refactoring in H265.
crates/flv/src/lib.rs Updated test expectations to reflect changes in H265 unit naming.
crates/bytes-util/src/{nal_emulation_prevention.rs, lib.rs} Added support for NAL emulation prevention I/O.
changes.d/pr-425.toml Documented PR changes in changelog format.
Files not reviewed (1)
  • crates/flv/src/snapshots/scuffle_flv__tests__demux_flv_hevc_aac.snap: Language not supported

@lennartkloock lennartkloock force-pushed the lennart/CLOUD-30 branch 2 times, most recently from 7a0ec37 to 241f3a0 Compare April 21, 2025 19:51
@lennartkloock lennartkloock marked this pull request as ready for review April 23, 2025 14:35
@lennartkloock lennartkloock requested review from a team as code owners April 23, 2025 14:35
}

impl VuiParameters {
// TODO: Find a solution for this
Copy link
Member

Choose a reason for hiding this comment

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

I think in h264 I never had to pass in values like this. It was either passing in the parsed object or the reader of the bitstream.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think h264 is less complex, so there are less values which other values might depend on.

Copy link
Member

Choose a reason for hiding this comment

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

Oh I see. I wonder if @TroyKomodo has any ideas for how to design/handle this?

@philipch07
Copy link
Member

Great work!! My suggestions are just nits.

@TroyKomodo
Copy link
Member

?brawl merge

@scuffle-brawl
Copy link
Contributor

scuffle-brawl bot commented Apr 27, 2025

📌 Commit c729ec0 has been approved and added to the merge queue.

Requested by: @TroyKomodo

Approved by: @TroyKomodo

@scuffle-brawl
Copy link
Contributor

scuffle-brawl bot commented Apr 27, 2025

⌛ Trying commit c729ec0 with merge 532be9e...

@scuffle-brawl
Copy link
Contributor

scuffle-brawl bot commented Apr 27, 2025

🎉 Build successful!
Completed in 12:38

Approved by: @TroyKomodo
Pushing 532be9e to main

@scuffle-brawl scuffle-brawl bot merged commit 532be9e into main Apr 27, 2025
16 checks passed
@scuffle-brawl scuffle-brawl bot deleted the lennart/CLOUD-30 branch April 27, 2025 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants