Open Bug 2068332 Opened 2 months ago

Support odd-sized subsampled VideoFrames in allocationSize() and copyTo()

Categories

(Core :: Audio/Video: Web Codecs, defect, P2)

defect

Tracking

()

People

(Reporter: chunmin, Assigned: chunmin)

References

(Blocks 1 open bug)

Details

Firefox does not fully support odd coded or visible extents for subsampled VideoFrame formats.

VideoFrame::Format::IsValidSize() rejects odd I420 and NV12 coded sizes. In ComputeLayoutAndAllocationSize(), the source-height calculation divides and rounds down, and the source-row-width calculation also divides and rounds down. This can omit the final chroma column or row and understate the result of allocationSize().

The existing WPT has a 3×3 I420 construction case with 2×2 U and V data and an allocation and copy case expecting two-byte chroma strides and every input byte. Firefox marks the window cases and worker cases as expected failures.

Test dashboard

For an aligned I420 or NV12 visible rectangle {16,16,289,209}, endpoint transformation gives:

  • Luma X interval: [16,305)
  • Chroma X interval: [8,153), or 145 samples
  • Luma Y interval: [16,225)
  • Chroma Y interval: [8,113), or 105 samples
  • Packed allocation size: 289×209 + 2×145×105 = 90,851 bytes

The current extent-flooring calculation produces only 90,353 bytes.

The fix should:

  1. Permit odd coded sizes for supported subsampled formats.
  2. Derive plane rectangles from transformed start and end coordinates.
  3. Use checked arithmetic for plane dimensions, strides, offsets, and total allocation.
  4. Make allocationSize() and copyTo() cover every addressable sample.
  5. Enable the existing odd-size WPT.
  6. Add I420 and NV12 gtests covering odd width, odd height, both odd, nonzero aligned origins, exact layouts, and copied pixel values.
You need to log in before you can comment on or make changes to this bug.