Open Bug 2057760 Opened 1 month ago Updated 9 hours ago

VideoEncoder converts RGB input with a BT601 matrix but emits decoderConfig.colorSpace claiming BT709

Categories

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

defect

Tracking

()

UNCONFIRMED

People

(Reporter: david.torcivia, Assigned: chunmin)

References

(Blocks 1 open bug)

Details

(Keywords: correctness)

When VideoEncoder is fed RGB input (canvas or ImageBitmap sources), the actual pixel conversion and the emitted metadata disagree:

  • The conversion to I420 goes through ImageConversion.cpp's ConvertToI420, which uses libyuv::ARGBToI420, a BT601 limited-range matrix.
  • The decoderConfig metadata emitted with the first chunk hardcodes a complete bt709 color space (VideoEncoder.cpp, "Colorspace is mandatory when outputing a decoder config": fullRange false, matrix bt709, primaries bt709, transfer bt709).

So the pixels are encoded with a 601 matrix while the metadata tells every consumer to decode them with 709. A player honoring the metadata (Chrome's WebCodecs pipeline, or anything consuming a recording made from this data) reconstructs slightly wrong colors: the classic 601/709 green-magenta skew.

Options, which need deciding together with bug 2057758 so the bitstream, the metadata, and the actual conversion all agree:

  1. Convert RGB input with a BT709 matrix and keep the bt709 metadata claim. libyuv has no direct ARGB-to-709-limited path (ARGBToI420 is 601), so this needs either a two-step conversion or gfx's own converters.
  2. Keep the 601 conversion and make the metadata (and, with encoder signaling, the bitstream) say smpte170m. Honest and cheap, but changes the emitted decoderConfig for existing consumers.

Either resolves the mismatch; what matters is that all three layers stop disagreeing.

Keywords: correctness
Flags: needinfo?(cchang)
Severity: -- → S3
Priority: -- → P3
Flags: needinfo?(cchang)
See Also: → 2056028, 2055639
Assignee: nobody → cchang
Blocks: 1869825
You need to log in before you can comment on or make changes to this bug.