Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

This module parses the H.264/AVC syntax needed by Vulkan Video applications:
NAL headers, sequence and picture parameter sets (SPS/PPS), video usability
information (VUI), and slice headers.
information (VUI) and slice headers.

It is **not** a video decoder: it does not perform entropy decoding, motion
compensation, inverse transforms, or produce pixels. The
It is **not** a video decoder: it does not perform entropy decoding, motion compensation or inverse transforms, and it does not produce pixels. The
[`v_vulkan_video`](https://github.com/antono2/v_vulkan_video) player uses these
parsed structures to prepare hardware decode operations.

Expand Down Expand Up @@ -39,7 +38,7 @@ assert header.type == .sps

`Bitstream.init()` expects raw RBSP/NAL bytes in memory. Container extraction,
length prefixes or Annex-B start codes, emulation-prevention removal, frame
reordering, and decoded-picture management remain the caller's responsibility.
reordering and decoded-picture management remain the caller's responsibility.

## Parsing order and caller responsibilities

Expand All @@ -64,7 +63,7 @@ bytes available and unchanged while parsing, and give concurrent parses
separate cursors and output structures. Parameter-set readers consume trailing
RBSP bits; the slice-header reader leaves the remaining coded slice data for
the decoder. Returned fields retain their H.264 syntax encodings rather than
being normalized into dimensions, frame rates, or decoder operations.
being normalized into dimensions, frame rates or decoder operations.

## Safety and supported scope

Expand All @@ -75,7 +74,7 @@ boundaries before parsing them.

The implementation covers the syntax exercised by the Vulkan Video H.264
player and is not yet a claim of complete support for every profile, extension,
bit depth, chroma format, or interlaced stream.
bit depth, chroma format or interlaced stream.

## Tests

Expand All @@ -91,9 +90,9 @@ v -cc msvc test .
```

They cover fixed-width and Exp-Golomb bit reading, truncated input behavior,
NAL headers, RBSP look-ahead, integer bit widths, and representative
NAL headers, RBSP look-ahead, integer bit widths and representative
High-profile SPS/PPS parsing used by the player. HRD buffering syntax tests cover
one, two, and the maximum 32 CPB entries, including alignment of the following
one, two and the maximum 32 CPB entries, including alignment of the following
delay fields. Counts beyond 32 entries are rejected by an assertion.

CI also runs strict V3 with TinyCC on Linux, using a pinned compiler snapshot.
Expand Down
4 changes: 2 additions & 2 deletions h264.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module h264

// Parses H.264 NAL headers, parameter sets, and slice metadata for decoder setup.
// Parses H.264 NAL headers, parameter sets and slice metadata for decoder setup.
// Callers supply bounded, unescaped NAL/RBSP bytes and manage decoded pictures;
// this module neither extracts container data nor decodes pixels.
// Syntax reference: Rec. ITU-T H.264 (08/2021).
Expand Down Expand Up @@ -440,7 +440,7 @@ pub fn (mut b Bitstream) read_rbsp_trailing_bits() {
}
}

// read_vui_parameters consumes optional display, timing, and buffering syntax.
// read_vui_parameters consumes optional display, timing and buffering syntax.
// Normally called by read_sps when the VUI presence flag is set.
pub fn (mut sps SequenceParameterSet) read_vui_parameters(mut b Bitstream) {
sps.vui.aspect_ratio_info_present_flag = b.u1()
Expand Down
2 changes: 1 addition & 1 deletion h264_test.v
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Exercises bit reads, NAL headers, and parameter-set parsing without a decoder or GPU.
// Exercises bit reads, NAL headers and parameter-set parsing without a decoder or GPU.
// Includes scaling-list regressions and checks for EOF and cursor-preserving look-ahead.
module h264

Expand Down
2 changes: 1 addition & 1 deletion hrd_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import encoding.hex

fn test_hrd_reads_all_cpb_entries() {
// H.264 E.1.2 encodes count minus one. Fixtures contain 1, 2 and 32 CPBs,
// distinct entry values, four delay widths, and an 0xa5 cursor sentinel.
// distinct entry values, four delay widths and an 0xa5 cursor sentinel.
for count, encoded in {
1: '9a30208a63a294'
2: '468c08220102531d14a0'
Expand Down