Support odd-sized subsampled VideoFrames in allocationSize() and copyTo()
Categories
(Core :: Audio/Video: Web Codecs, defect, P2)
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.
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,851bytes
The current extent-flooring calculation produces only 90,353 bytes.
The fix should:
- Permit odd coded sizes for supported subsampled formats.
- Derive plane rectangles from transformed start and end coordinates.
- Use checked arithmetic for plane dimensions, strides, offsets, and total allocation.
- Make
allocationSize()andcopyTo()cover every addressable sample. - Enable the existing odd-size WPT.
- Add I420 and NV12 gtests covering odd width, odd height, both odd, nonzero aligned origins, exact layouts, and copied pixel values.
Description
•